vendor: 78 bytes, lines 1-3
1/******/ (() => { // webpackBootstrap 2/******/ var __webpack_modules__ = ({ 3
vendor: 342 bytes, lines 4-13
4/***/ "./node_modules/axios/index.js": 5/*!*************************************!*\ 6 !*** ./node_modules/axios/index.js ***! 7 \*************************************/ 8/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 9 10module.exports = __webpack_require__(/*! ./lib/axios */ "./node_modules/axios/lib/axios.js"); 11 12/***/ }), 13
vendor: 7,873 bytes, lines 14-236
14/***/ "./node_modules/axios/lib/adapters/xhr.js": 15/*!************************************************!*\ 16 !*** ./node_modules/axios/lib/adapters/xhr.js ***! 17 \************************************************/ 18/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 19 20"use strict"; 21 22 23var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 24var settle = __webpack_require__(/*! ./../core/settle */ "./node_modules/axios/lib/core/settle.js"); 25var cookies = __webpack_require__(/*! ./../helpers/cookies */ "./node_modules/axios/lib/helpers/cookies.js"); 26var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js"); 27var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./node_modules/axios/lib/core/buildFullPath.js"); 28var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./node_modules/axios/lib/helpers/parseHeaders.js"); 29var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./node_modules/axios/lib/helpers/isURLSameOrigin.js"); 30var createError = __webpack_require__(/*! ../core/createError */ "./node_modules/axios/lib/core/createError.js"); 31var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js"); 32var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 33 34module.exports = function xhrAdapter(config) { 35 return new Promise(function dispatchXhrRequest(resolve, reject) { 36 var requestData = config.data; 37 var requestHeaders = config.headers; 38 var responseType = config.responseType; 39 var onCanceled; 40 function done() { 41 if (config.cancelToken) { 42 config.cancelToken.unsubscribe(onCanceled); 43 } 44 45 if (config.signal) { 46 config.signal.removeEventListener('abort', onCanceled); 47 } 48 } 49 50 if (utils.isFormData(requestData)) { 51 delete requestHeaders['Content-Type']; // Let the browser set it 52 } 53 54 var request = new XMLHttpRequest(); 55 56 // HTTP basic authentication 57 if (config.auth) { 58 var username = config.auth.username || ''; 59 var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : ''; 60 requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password); 61 } 62 63 var fullPath = buildFullPath(config.baseURL, config.url); 64 request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true); 65 66 // Set the request timeout in MS 67 request.timeout = config.timeout; 68 69 function onloadend() { 70 if (!request) { 71 return; 72 } 73 // Prepare the response 74 var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null; 75 var responseData = !responseType || responseType === 'text' || responseType === 'json' ? 76 request.responseText : request.response; 77 var response = { 78 data: responseData, 79 status: request.status, 80 statusText: request.statusText, 81 headers: responseHeaders, 82 config: config, 83 request: request 84 }; 85 86 settle(function _resolve(value) { 87 resolve(value); 88 done(); 89 }, function _reject(err) { 90 reject(err); 91 done(); 92 }, response); 93 94 // Clean up request 95 request = null; 96 } 97 98 if ('onloadend' in request) { 99 // Use onloadend if available 100 request.onloadend = onloadend; 101 } else { 102 // Listen for ready state to emulate onloadend 103 request.onreadystatechange = function handleLoad() { 104 if (!request || request.readyState !== 4) { 105 return; 106 } 107 108 // The request errored out and we didn't get a response, this will be 109 // handled by onerror instead 110 // With one exception: request that using file: protocol, most browsers 111 // will return status as 0 even though it's a successful request 112 if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) { 113 return; 114 } 115 // readystate handler is calling before onerror or ontimeout handlers, 116 // so we should call onloadend on the next 'tick' 117 setTimeout(onloadend); 118 }; 119 } 120 121 // Handle browser request cancellation (as opposed to a manual cancellation) 122 request.onabort = function handleAbort() { 123 if (!request) { 124 return; 125 } 126 127 reject(createError('Request aborted', config, 'ECONNABORTED', request)); 128 129 // Clean up request 130 request = null; 131 }; 132 133 // Handle low level network errors 134 request.onerror = function handleError() { 135 // Real errors are hidden from us by the browser 136 // onerror should only fire if it's a network error 137 reject(createError('Network Error', config, null, request)); 138 139 // Clean up request 140 request = null; 141 }; 142 143 // Handle timeout 144 request.ontimeout = function handleTimeout() { 145 var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded'; 146 var transitional = config.transitional || defaults.transitional; 147 if (config.timeoutErrorMessage) { 148 timeoutErrorMessage = config.timeoutErrorMessage; 149 } 150 reject(createError( 151 timeoutErrorMessage, 152 config, 153 transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED', 154 request)); 155 156 // Clean up request 157 request = null; 158 }; 159 160 // Add xsrf header 161 // This is only done if running in a standard browser environment. 162 // Specifically not if we're in a web worker, or react-native. 163 if (utils.isStandardBrowserEnv()) { 164 // Add xsrf header 165 var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ? 166 cookies.read(config.xsrfCookieName) : 167 undefined; 168 169 if (xsrfValue) { 170 requestHeaders[config.xsrfHeaderName] = xsrfValue; 171 } 172 } 173 174 // Add headers to the request 175 if ('setRequestHeader' in request) { 176 utils.forEach(requestHeaders, function setRequestHeader(val, key) { 177 if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') { 178 // Remove Content-Type if data is undefined 179 delete requestHeaders[key]; 180 } else { 181 // Otherwise add header to the request 182 request.setRequestHeader(key, val); 183 } 184 }); 185 } 186 187 // Add withCredentials to request if needed 188 if (!utils.isUndefined(config.withCredentials)) { 189 request.withCredentials = !!config.withCredentials; 190 } 191 192 // Add responseType to request if needed 193 if (responseType && responseType !== 'json') { 194 request.responseType = config.responseType; 195 } 196 197 // Handle progress if needed 198 if (typeof config.onDownloadProgress === 'function') { 199 request.addEventListener('progress', config.onDownloadProgress); 200 } 201 202 // Not all browsers support upload events 203 if (typeof config.onUploadProgress === 'function' && request.upload) { 204 request.upload.addEventListener('progress', config.onUploadProgress); 205 } 206 207 if (config.cancelToken || config.signal) { 208 // Handle cancellation 209 // eslint-disable-next-line func-names 210 onCanceled = function(cancel) { 211 if (!request) { 212 return; 213 } 214 reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel); 215 request.abort(); 216 request = null; 217 }; 218 219 config.cancelToken && config.cancelToken.subscribe(onCanceled); 220 if (config.signal) { 221 config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled); 222 } 223 } 224 225 if (!requestData) { 226 requestData = null; 227 } 228 229 // Send the request 230 request.send(requestData); 231 }); 232}; 233 234 235/***/ }), 236
vendor: 2,498 bytes, lines 237-304
237/***/ "./node_modules/axios/lib/axios.js": 238/*!*****************************************!*\ 239 !*** ./node_modules/axios/lib/axios.js ***! 240 \*****************************************/ 241/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 242 243"use strict"; 244 245 246var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js"); 247var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js"); 248var Axios = __webpack_require__(/*! ./core/Axios */ "./node_modules/axios/lib/core/Axios.js"); 249var mergeConfig = __webpack_require__(/*! ./core/mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js"); 250var defaults = __webpack_require__(/*! ./defaults */ "./node_modules/axios/lib/defaults.js"); 251 252/** 253 * Create an instance of Axios 254 * 255 * @param {Object} defaultConfig The default config for the instance 256 * @return {Axios} A new instance of Axios 257 */ 258function createInstance(defaultConfig) { 259 var context = new Axios(defaultConfig); 260 var instance = bind(Axios.prototype.request, context); 261 262 // Copy axios.prototype to instance 263 utils.extend(instance, Axios.prototype, context); 264 265 // Copy context to instance 266 utils.extend(instance, context); 267 268 // Factory for creating new instances 269 instance.create = function create(instanceConfig) { 270 return createInstance(mergeConfig(defaultConfig, instanceConfig)); 271 }; 272 273 return instance; 274} 275 276// Create the default instance to be exported 277var axios = createInstance(defaults); 278 279// Expose Axios class to allow class inheritance 280axios.Axios = Axios; 281 282// Expose Cancel & CancelToken 283axios.Cancel = __webpack_require__(/*! ./cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 284axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./node_modules/axios/lib/cancel/CancelToken.js"); 285axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js"); 286axios.VERSION = (__webpack_require__(/*! ./env/data */ "./node_modules/axios/lib/env/data.js").version); 287 288// Expose all/spread 289axios.all = function all(promises) { 290 return Promise.all(promises); 291}; 292axios.spread = __webpack_require__(/*! ./helpers/spread */ "./node_modules/axios/lib/helpers/spread.js"); 293 294// Expose isAxiosError 295axios.isAxiosError = __webpack_require__(/*! ./helpers/isAxiosError */ "./node_modules/axios/lib/helpers/isAxiosError.js"); 296 297module.exports = axios; 298 299// Allow use of default import syntax in TypeScript 300module.exports["default"] = axios; 301 302 303/***/ }), 304
vendor: 636 bytes, lines 305-334
305/***/ "./node_modules/axios/lib/cancel/Cancel.js": 306/*!*************************************************!*\ 307 !*** ./node_modules/axios/lib/cancel/Cancel.js ***! 308 \*************************************************/ 309/***/ ((module) => { 310 311"use strict"; 312 313 314/** 315 * A `Cancel` is an object that is thrown when an operation is canceled. 316 * 317 * @class 318 * @param {string=} message The message. 319 */ 320function Cancel(message) { 321 this.message = message; 322} 323 324Cancel.prototype.toString = function toString() { 325 return 'Cancel' + (this.message ? ': ' + this.message : ''); 326}; 327 328Cancel.prototype.__CANCEL__ = true; 329 330module.exports = Cancel; 331 332 333/***/ }), 334
vendor: 2,848 bytes, lines 335-464
335/***/ "./node_modules/axios/lib/cancel/CancelToken.js": 336/*!******************************************************!*\ 337 !*** ./node_modules/axios/lib/cancel/CancelToken.js ***! 338 \******************************************************/ 339/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 340 341"use strict"; 342 343 344var Cancel = __webpack_require__(/*! ./Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 345 346/** 347 * A `CancelToken` is an object that can be used to request cancellation of an operation. 348 * 349 * @class 350 * @param {Function} executor The executor function. 351 */ 352function CancelToken(executor) { 353 if (typeof executor !== 'function') { 354 throw new TypeError('executor must be a function.'); 355 } 356 357 var resolvePromise; 358 359 this.promise = new Promise(function promiseExecutor(resolve) { 360 resolvePromise = resolve; 361 }); 362 363 var token = this; 364 365 // eslint-disable-next-line func-names 366 this.promise.then(function(cancel) { 367 if (!token._listeners) return; 368 369 var i; 370 var l = token._listeners.length; 371 372 for (i = 0; i < l; i++) { 373 token._listeners[i](cancel); 374 } 375 token._listeners = null; 376 }); 377 378 // eslint-disable-next-line func-names 379 this.promise.then = function(onfulfilled) { 380 var _resolve; 381 // eslint-disable-next-line func-names 382 var promise = new Promise(function(resolve) { 383 token.subscribe(resolve); 384 _resolve = resolve; 385 }).then(onfulfilled); 386 387 promise.cancel = function reject() { 388 token.unsubscribe(_resolve); 389 }; 390 391 return promise; 392 }; 393 394 executor(function cancel(message) { 395 if (token.reason) { 396 // Cancellation has already been requested 397 return; 398 } 399 400 token.reason = new Cancel(message); 401 resolvePromise(token.reason); 402 }); 403} 404 405/** 406 * Throws a `Cancel` if cancellation has been requested. 407 */ 408CancelToken.prototype.throwIfRequested = function throwIfRequested() { 409 if (this.reason) { 410 throw this.reason; 411 } 412}; 413 414/** 415 * Subscribe to the cancel signal 416 */ 417 418CancelToken.prototype.subscribe = function subscribe(listener) { 419 if (this.reason) { 420 listener(this.reason); 421 return; 422 } 423 424 if (this._listeners) { 425 this._listeners.push(listener); 426 } else { 427 this._listeners = [listener]; 428 } 429}; 430 431/** 432 * Unsubscribe from the cancel signal 433 */ 434 435CancelToken.prototype.unsubscribe = function unsubscribe(listener) { 436 if (!this._listeners) { 437 return; 438 } 439 var index = this._listeners.indexOf(listener); 440 if (index !== -1) { 441 this._listeners.splice(index, 1); 442 } 443}; 444 445/** 446 * Returns an object that contains a new `CancelToken` and a function that, when called, 447 * cancels the `CancelToken`. 448 */ 449CancelToken.source = function source() { 450 var cancel; 451 var token = new CancelToken(function executor(c) { 452 cancel = c; 453 }); 454 return { 455 token: token, 456 cancel: cancel 457 }; 458}; 459 460module.exports = CancelToken; 461 462 463/***/ }), 464
vendor: 361 bytes, lines 465-480
465/***/ "./node_modules/axios/lib/cancel/isCancel.js": 466/*!***************************************************!*\ 467 !*** ./node_modules/axios/lib/cancel/isCancel.js ***! 468 \***************************************************/ 469/***/ ((module) => { 470 471"use strict"; 472 473 474module.exports = function isCancel(value) { 475 return !!(value && value.__CANCEL__); 476}; 477 478 479/***/ }), 480
vendor: 4,892 bytes, lines 481-639
481/***/ "./node_modules/axios/lib/core/Axios.js": 482/*!**********************************************!*\ 483 !*** ./node_modules/axios/lib/core/Axios.js ***! 484 \**********************************************/ 485/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 486 487"use strict"; 488 489 490var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 491var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./node_modules/axios/lib/helpers/buildURL.js"); 492var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./node_modules/axios/lib/core/InterceptorManager.js"); 493var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./node_modules/axios/lib/core/dispatchRequest.js"); 494var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./node_modules/axios/lib/core/mergeConfig.js"); 495var validator = __webpack_require__(/*! ../helpers/validator */ "./node_modules/axios/lib/helpers/validator.js"); 496 497var validators = validator.validators; 498/** 499 * Create a new instance of Axios 500 * 501 * @param {Object} instanceConfig The default config for the instance 502 */ 503function Axios(instanceConfig) { 504 this.defaults = instanceConfig; 505 this.interceptors = { 506 request: new InterceptorManager(), 507 response: new InterceptorManager() 508 }; 509} 510 511/** 512 * Dispatch a request 513 * 514 * @param {Object} config The config specific for this request (merged with this.defaults) 515 */ 516Axios.prototype.request = function request(config) { 517 /*eslint no-param-reassign:0*/ 518 // Allow for axios('example/url'[, config]) a la fetch API 519 if (typeof config === 'string') { 520 config = arguments[1] || {}; 521 config.url = arguments[0]; 522 } else { 523 config = config || {}; 524 } 525 526 config = mergeConfig(this.defaults, config); 527 528 // Set config.method 529 if (config.method) { 530 config.method = config.method.toLowerCase(); 531 } else if (this.defaults.method) { 532 config.method = this.defaults.method.toLowerCase(); 533 } else { 534 config.method = 'get'; 535 } 536 537 var transitional = config.transitional; 538 539 if (transitional !== undefined) { 540 validator.assertOptions(transitional, { 541 silentJSONParsing: validators.transitional(validators.boolean), 542 forcedJSONParsing: validators.transitional(validators.boolean), 543 clarifyTimeoutError: validators.transitional(validators.boolean) 544 }, false); 545 } 546 547 // filter out skipped interceptors 548 var requestInterceptorChain = []; 549 var synchronousRequestInterceptors = true; 550 this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) { 551 if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) { 552 return; 553 } 554 555 synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous; 556 557 requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected); 558 }); 559 560 var responseInterceptorChain = []; 561 this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) { 562 responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected); 563 }); 564 565 var promise; 566 567 if (!synchronousRequestInterceptors) { 568 var chain = [dispatchRequest, undefined]; 569 570 Array.prototype.unshift.apply(chain, requestInterceptorChain); 571 chain = chain.concat(responseInterceptorChain); 572 573 promise = Promise.resolve(config); 574 while (chain.length) { 575 promise = promise.then(chain.shift(), chain.shift()); 576 } 577 578 return promise; 579 } 580 581 582 var newConfig = config; 583 while (requestInterceptorChain.length) { 584 var onFulfilled = requestInterceptorChain.shift(); 585 var onRejected = requestInterceptorChain.shift(); 586 try { 587 newConfig = onFulfilled(newConfig); 588 } catch (error) { 589 onRejected(error); 590 break; 591 } 592 } 593 594 try { 595 promise = dispatchRequest(newConfig); 596 } catch (error) { 597 return Promise.reject(error); 598 } 599 600 while (responseInterceptorChain.length) { 601 promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift()); 602 } 603 604 return promise; 605}; 606 607Axios.prototype.getUri = function getUri(config) { 608 config = mergeConfig(this.defaults, config); 609 return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, ''); 610}; 611 612// Provide aliases for supported request methods 613utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) { 614 /*eslint func-names:0*/ 615 Axios.prototype[method] = function(url, config) { 616 return this.request(mergeConfig(config || {}, { 617 method: method, 618 url: url, 619 data: (config || {}).data 620 })); 621 }; 622}); 623 624utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 625 /*eslint func-names:0*/ 626 Axios.prototype[method] = function(url, data, config) { 627 return this.request(mergeConfig(config || {}, { 628 method: method, 629 url: url, 630 data: data 631 })); 632 }; 633}); 634 635module.exports = Axios; 636 637 638/***/ }), 639
vendor: 1,754 bytes, lines 640-704
640/***/ "./node_modules/axios/lib/core/InterceptorManager.js": 641/*!***********************************************************!*\ 642 !*** ./node_modules/axios/lib/core/InterceptorManager.js ***! 643 \***********************************************************/ 644/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 645 646"use strict"; 647 648 649var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 650 651function InterceptorManager() { 652 this.handlers = []; 653} 654 655/** 656 * Add a new interceptor to the stack 657 * 658 * @param {Function} fulfilled The function to handle `then` for a `Promise` 659 * @param {Function} rejected The function to handle `reject` for a `Promise` 660 * 661 * @return {Number} An ID used to remove interceptor later 662 */ 663InterceptorManager.prototype.use = function use(fulfilled, rejected, options) { 664 this.handlers.push({ 665 fulfilled: fulfilled, 666 rejected: rejected, 667 synchronous: options ? options.synchronous : false, 668 runWhen: options ? options.runWhen : null 669 }); 670 return this.handlers.length - 1; 671}; 672 673/** 674 * Remove an interceptor from the stack 675 * 676 * @param {Number} id The ID that was returned by `use` 677 */ 678InterceptorManager.prototype.eject = function eject(id) { 679 if (this.handlers[id]) { 680 this.handlers[id] = null; 681 } 682}; 683 684/** 685 * Iterate over all the registered interceptors 686 * 687 * This method is particularly useful for skipping over any 688 * interceptors that may have become `null` calling `eject`. 689 * 690 * @param {Function} fn The function to call for each interceptor 691 */ 692InterceptorManager.prototype.forEach = function forEach(fn) { 693 utils.forEach(this.handlers, function forEachHandler(h) { 694 if (h !== null) { 695 fn(h); 696 } 697 }); 698}; 699 700module.exports = InterceptorManager; 701 702 703/***/ }), 704
vendor: 1,149 bytes, lines 705-735
705/***/ "./node_modules/axios/lib/core/buildFullPath.js": 706/*!******************************************************!*\ 707 !*** ./node_modules/axios/lib/core/buildFullPath.js ***! 708 \******************************************************/ 709/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 710 711"use strict"; 712 713 714var isAbsoluteURL = __webpack_require__(/*! ../helpers/isAbsoluteURL */ "./node_modules/axios/lib/helpers/isAbsoluteURL.js"); 715var combineURLs = __webpack_require__(/*! ../helpers/combineURLs */ "./node_modules/axios/lib/helpers/combineURLs.js"); 716 717/** 718 * Creates a new URL by combining the baseURL with the requestedURL, 719 * only when the requestedURL is not already an absolute URL. 720 * If the requestURL is absolute, this function returns the requestedURL untouched. 721 * 722 * @param {string} baseURL The base URL 723 * @param {string} requestedURL Absolute or relative URL to combine 724 * @returns {string} The combined full path 725 */ 726module.exports = function buildFullPath(baseURL, requestedURL) { 727 if (baseURL && !isAbsoluteURL(requestedURL)) { 728 return combineURLs(baseURL, requestedURL); 729 } 730 return requestedURL; 731}; 732 733 734/***/ }), 735
vendor: 1,000 bytes, lines 736-764
736/***/ "./node_modules/axios/lib/core/createError.js": 737/*!****************************************************!*\ 738 !*** ./node_modules/axios/lib/core/createError.js ***! 739 \****************************************************/ 740/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 741 742"use strict"; 743 744 745var enhanceError = __webpack_require__(/*! ./enhanceError */ "./node_modules/axios/lib/core/enhanceError.js"); 746 747/** 748 * Create an Error with the specified message, config, error code, request and response. 749 * 750 * @param {string} message The error message. 751 * @param {Object} config The config. 752 * @param {string} [code] The error code (for example, 'ECONNABORTED'). 753 * @param {Object} [request] The request. 754 * @param {Object} [response] The response. 755 * @returns {Error} The created error. 756 */ 757module.exports = function createError(message, config, code, request, response) { 758 var error = new Error(message); 759 return enhanceError(error, config, code, request, response); 760}; 761 762 763/***/ }), 764
vendor: 2,747 bytes, lines 765-862
765/***/ "./node_modules/axios/lib/core/dispatchRequest.js": 766/*!********************************************************!*\ 767 !*** ./node_modules/axios/lib/core/dispatchRequest.js ***! 768 \********************************************************/ 769/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 770 771"use strict"; 772 773 774var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 775var transformData = __webpack_require__(/*! ./transformData */ "./node_modules/axios/lib/core/transformData.js"); 776var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./node_modules/axios/lib/cancel/isCancel.js"); 777var defaults = __webpack_require__(/*! ../defaults */ "./node_modules/axios/lib/defaults.js"); 778var Cancel = __webpack_require__(/*! ../cancel/Cancel */ "./node_modules/axios/lib/cancel/Cancel.js"); 779 780/** 781 * Throws a `Cancel` if cancellation has been requested. 782 */ 783function throwIfCancellationRequested(config) { 784 if (config.cancelToken) { 785 config.cancelToken.throwIfRequested(); 786 } 787 788 if (config.signal && config.signal.aborted) { 789 throw new Cancel('canceled'); 790 } 791} 792 793/** 794 * Dispatch a request to the server using the configured adapter. 795 * 796 * @param {object} config The config that is to be used for the request 797 * @returns {Promise} The Promise to be fulfilled 798 */ 799module.exports = function dispatchRequest(config) { 800 throwIfCancellationRequested(config); 801 802 // Ensure headers exist 803 config.headers = config.headers || {}; 804 805 // Transform request data 806 config.data = transformData.call( 807 config, 808 config.data, 809 config.headers, 810 config.transformRequest 811 ); 812 813 // Flatten headers 814 config.headers = utils.merge( 815 config.headers.common || {}, 816 config.headers[config.method] || {}, 817 config.headers 818 ); 819 820 utils.forEach( 821 ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'], 822 function cleanHeaderConfig(method) { 823 delete config.headers[method]; 824 } 825 ); 826 827 var adapter = config.adapter || defaults.adapter; 828 829 return adapter(config).then(function onAdapterResolution(response) { 830 throwIfCancellationRequested(config); 831 832 // Transform response data 833 response.data = transformData.call( 834 config, 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.call( 848 config, 849 reason.response.data, 850 reason.response.headers, 851 config.transformResponse 852 ); 853 } 854 } 855 856 return Promise.reject(reason); 857 }); 858}; 859 860 861/***/ }), 862
vendor: 1,399 bytes, lines 863-916
863/***/ "./node_modules/axios/lib/core/enhanceError.js": 864/*!*****************************************************!*\ 865 !*** ./node_modules/axios/lib/core/enhanceError.js ***! 866 \*****************************************************/ 867/***/ ((module) => { 868 869"use strict"; 870 871 872/** 873 * Update an Error with the specified config, error code, and response. 874 * 875 * @param {Error} error The error to update. 876 * @param {Object} config The config. 877 * @param {string} [code] The error code (for example, 'ECONNABORTED'). 878 * @param {Object} [request] The request. 879 * @param {Object} [response] The response. 880 * @returns {Error} The error. 881 */ 882module.exports = function enhanceError(error, config, code, request, response) { 883 error.config = config; 884 if (code) { 885 error.code = code; 886 } 887 888 error.request = request; 889 error.response = response; 890 error.isAxiosError = true; 891 892 error.toJSON = function toJSON() { 893 return { 894 // Standard 895 message: this.message, 896 name: this.name, 897 // Microsoft 898 description: this.description, 899 number: this.number, 900 // Mozilla 901 fileName: this.fileName, 902 lineNumber: this.lineNumber, 903 columnNumber: this.columnNumber, 904 stack: this.stack, 905 // Axios 906 config: this.config, 907 code: this.code, 908 status: this.response && this.response.status ? this.response.status : null 909 }; 910 }; 911 return error; 912}; 913 914 915/***/ }), 916
vendor: 3,558 bytes, lines 917-1026
917/***/ "./node_modules/axios/lib/core/mergeConfig.js": 918/*!****************************************************!*\ 919 !*** ./node_modules/axios/lib/core/mergeConfig.js ***! 920 \****************************************************/ 921/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 922 923"use strict"; 924 925 926var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js"); 927 928/** 929 * Config-specific merge-function which creates a new config-object 930 * by merging two configuration objects together. 931 * 932 * @param {Object} config1 933 * @param {Object} config2 934 * @returns {Object} New object resulting from merging config2 to config1 935 */ 936module.exports = function mergeConfig(config1, config2) { 937 // eslint-disable-next-line no-param-reassign 938 config2 = config2 || {}; 939 var config = {}; 940 941 function getMergedValue(target, source) { 942 if (utils.isPlainObject(target) && utils.isPlainObject(source)) { 943 return utils.merge(target, source); 944 } else if (utils.isPlainObject(source)) { 945 return utils.merge({}, source); 946 } else if (utils.isArray(source)) { 947 return source.slice(); 948 } 949 return source; 950 } 951 952 // eslint-disable-next-line consistent-return 953 function mergeDeepProperties(prop) { 954 if (!utils.isUndefined(config2[prop])) { 955 return getMergedValue(config1[prop], config2[prop]); 956 } else if (!utils.isUndefined(config1[prop])) { 957 return getMergedValue(undefined, config1[prop]); 958 } 959 } 960 961 // eslint-disable-next-line consistent-return 962 function valueFromConfig2(prop) { 963 if (!utils.isUndefined(config2[prop])) { 964 return getMergedValue(undefined, config2[prop]); 965 } 966 } 967 968 // eslint-disable-next-line consistent-return 969 function defaultToConfig2(prop) { 970 if (!utils.isUndefined(config2[prop])) { 971 return getMergedValue(undefined, config2[prop]); 972 } else if (!utils.isUndefined(config1[prop])) { 973 return getMergedValue(undefined, config1[prop]); 974 } 975 } 976 977 // eslint-disable-next-line consistent-return 978 function mergeDirectKeys(prop) { 979 if (prop in config2) { 980 return getMergedValue(config1[prop], config2[prop]); 981 } else if (prop in config1) { 982 return getMergedValue(undefined, config1[prop]); 983 } 984 } 985 986 var mergeMap = { 987 'url': valueFromConfig2, 988 'method': valueFromConfig2, 989 'data': valueFromConfig2, 990 'baseURL': defaultToConfig2, 991 'transformRequest': defaultToConfig2, 992 'transformResponse': defaultToConfig2, 993 'paramsSerializer': defaultToConfig2, 994 'timeout': defaultToConfig2, 995 'timeoutMessage': defaultToConfig2, 996 'withCredentials': defaultToConfig2, 997 'adapter': defaultToConfig2, 998 'responseType': defaultToConfig2, 999 'xsrfCookieName': defaultToConfig2, 1000 'xsrfHeaderName': defaultToConfig2, 1001 'onUploadProgress': defaultToConfig2, 1002 'onDownloadProgress': defaultToConfig2, 1003 'decompress': defaultToConfig2, 1004 'maxContentLength': defaultToConfig2, 1005 'maxBodyLength': defaultToConfig2, 1006 'transport': defaultToConfig2, 1007 'httpAgent': defaultToConfig2, 1008 'httpsAgent': defaultToConfig2, 1009 'cancelToken': defaultToConfig2, 1010 'socketPath': defaultToConfig2, 1011 'responseEncoding': defaultToConfig2, 1012 'validateStatus': mergeDirectKeys 1013 }; 1014 1015 utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) { 1016 var merge = mergeMap[prop] || mergeDeepProperties; 1017 var configValue = merge(prop); 1018 (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue); 1019 }); 1020 1021 return config; 1022}; 1023 1024 1025/***/ }), 1026
vendor: 1,060 bytes, lines 1027-1062
1027/***/ "./node_modules/axios/lib/core/settle.js": 1028/*!***********************************************!*\ 1029 !*** ./node_modules/axios/lib/core/settle.js ***! 1030 \***********************************************/ 1031/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1032 1033"use strict"; 1034 1035 1036var createError = __webpack_require__(/*! ./createError */ "./node_modules/axios/lib/core/createError.js"); 1037 1038/** 1039 * Resolve or reject a Promise based on response status. 1040 * 1041 * @param {Function} resolve A function that resolves the promise. 1042 * @param {Function} reject A function that rejects the promise. 1043 * @param {object} response The response. 1044 */ 1045module.exports = function settle(resolve, reject, response) { 1046 var validateStatus = response.config.validateStatus; 1047 if (!response.status || !validateStatus || validateStatus(response.status)) { 1048 resolve(response); 1049 } else { 1050 reject(createError( 1051 'Request failed with status code ' + response.status, 1052 response.config, 1053 null, 1054 response.request, 1055 response 1056 )); 1057 } 1058}; 1059 1060 1061/***/ }), 1062
vendor: 1,066 bytes, lines 1063-1095
1063/***/ "./node_modules/axios/lib/core/transformData.js": 1064/*!******************************************************!*\ 1065 !*** ./node_modules/axios/lib/core/transformData.js ***! 1066 \******************************************************/ 1067/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1068 1069"use strict"; 1070 1071 1072var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1073var defaults = __webpack_require__(/*! ./../defaults */ "./node_modules/axios/lib/defaults.js"); 1074 1075/** 1076 * Transform the data for a request or a response 1077 * 1078 * @param {Object|String} data The data to be transformed 1079 * @param {Array} headers The headers for the request or response 1080 * @param {Array|Function} fns A single function or Array of functions 1081 * @returns {*} The resulting transformed data 1082 */ 1083module.exports = function transformData(data, headers, fns) { 1084 var context = this || defaults; 1085 /*eslint no-param-reassign:0*/ 1086 utils.forEach(fns, function transform(fn) { 1087 data = fn.call(context, data, headers); 1088 }); 1089 1090 return data; 1091}; 1092 1093 1094/***/ }), 1095
vendor: 4,297 bytes, lines 1096-1241
1096/***/ "./node_modules/axios/lib/defaults.js": 1097/*!********************************************!*\ 1098 !*** ./node_modules/axios/lib/defaults.js ***! 1099 \********************************************/ 1100/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1101 1102"use strict"; 1103/* provided dependency */ var process = __webpack_require__(/*! process/browser.js */ "./node_modules/process/browser.js"); 1104 1105 1106var utils = __webpack_require__(/*! ./utils */ "./node_modules/axios/lib/utils.js"); 1107var normalizeHeaderName = __webpack_require__(/*! ./helpers/normalizeHeaderName */ "./node_modules/axios/lib/helpers/normalizeHeaderName.js"); 1108var enhanceError = __webpack_require__(/*! ./core/enhanceError */ "./node_modules/axios/lib/core/enhanceError.js"); 1109 1110var DEFAULT_CONTENT_TYPE = { 1111 'Content-Type': 'application/x-www-form-urlencoded' 1112}; 1113 1114function setContentTypeIfUnset(headers, value) { 1115 if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) { 1116 headers['Content-Type'] = value; 1117 } 1118} 1119 1120function getDefaultAdapter() { 1121 var adapter; 1122 if (typeof XMLHttpRequest !== 'undefined') { 1123 // For browsers use XHR adapter 1124 adapter = __webpack_require__(/*! ./adapters/xhr */ "./node_modules/axios/lib/adapters/xhr.js"); 1125 } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') { 1126 // For node use HTTP adapter 1127 adapter = __webpack_require__(/*! ./adapters/http */ "./node_modules/axios/lib/adapters/xhr.js"); 1128 } 1129 return adapter; 1130} 1131 1132function stringifySafely(rawValue, parser, encoder) { 1133 if (utils.isString(rawValue)) { 1134 try { 1135 (parser || JSON.parse)(rawValue); 1136 return utils.trim(rawValue); 1137 } catch (e) { 1138 if (e.name !== 'SyntaxError') { 1139 throw e; 1140 } 1141 } 1142 } 1143 1144 return (encoder || JSON.stringify)(rawValue); 1145} 1146 1147var defaults = { 1148 1149 transitional: { 1150 silentJSONParsing: true, 1151 forcedJSONParsing: true, 1152 clarifyTimeoutError: false 1153 }, 1154 1155 adapter: getDefaultAdapter(), 1156 1157 transformRequest: [function transformRequest(data, headers) { 1158 normalizeHeaderName(headers, 'Accept'); 1159 normalizeHeaderName(headers, 'Content-Type'); 1160 1161 if (utils.isFormData(data) || 1162 utils.isArrayBuffer(data) || 1163 utils.isBuffer(data) || 1164 utils.isStream(data) || 1165 utils.isFile(data) || 1166 utils.isBlob(data) 1167 ) { 1168 return data; 1169 } 1170 if (utils.isArrayBufferView(data)) { 1171 return data.buffer; 1172 } 1173 if (utils.isURLSearchParams(data)) { 1174 setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8'); 1175 return data.toString(); 1176 } 1177 if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) { 1178 setContentTypeIfUnset(headers, 'application/json'); 1179 return stringifySafely(data); 1180 } 1181 return data; 1182 }], 1183 1184 transformResponse: [function transformResponse(data) { 1185 var transitional = this.transitional || defaults.transitional; 1186 var silentJSONParsing = transitional && transitional.silentJSONParsing; 1187 var forcedJSONParsing = transitional && transitional.forcedJSONParsing; 1188 var strictJSONParsing = !silentJSONParsing && this.responseType === 'json'; 1189 1190 if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) { 1191 try { 1192 return JSON.parse(data); 1193 } catch (e) { 1194 if (strictJSONParsing) { 1195 if (e.name === 'SyntaxError') { 1196 throw enhanceError(e, this, 'E_JSON_PARSE'); 1197 } 1198 throw e; 1199 } 1200 } 1201 } 1202 1203 return data; 1204 }], 1205 1206 /** 1207 * A timeout in milliseconds to abort a request. If set to 0 (default) a 1208 * timeout is not created. 1209 */ 1210 timeout: 0, 1211 1212 xsrfCookieName: 'XSRF-TOKEN', 1213 xsrfHeaderName: 'X-XSRF-TOKEN', 1214 1215 maxContentLength: -1, 1216 maxBodyLength: -1, 1217 1218 validateStatus: function validateStatus(status) { 1219 return status >= 200 && status < 300; 1220 }, 1221 1222 headers: { 1223 common: { 1224 'Accept': 'application/json, text/plain, */*' 1225 } 1226 } 1227}; 1228 1229utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) { 1230 defaults.headers[method] = {}; 1231}); 1232 1233utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) { 1234 defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE); 1235}); 1236 1237module.exports = defaults; 1238 1239 1240/***/ }), 1241
vendor: 273 bytes, lines 1242-1253
1242/***/ "./node_modules/axios/lib/env/data.js": 1243/*!********************************************!*\ 1244 !*** ./node_modules/axios/lib/env/data.js ***! 1245 \********************************************/ 1246/***/ ((module) => { 1247 1248module.exports = { 1249 "version": "0.23.0" 1250}; 1251 1252/***/ }), 1253
vendor: 503 bytes, lines 1254-1275
1254/***/ "./node_modules/axios/lib/helpers/bind.js": 1255/*!************************************************!*\ 1256 !*** ./node_modules/axios/lib/helpers/bind.js ***! 1257 \************************************************/ 1258/***/ ((module) => { 1259 1260"use strict"; 1261 1262 1263module.exports = function bind(fn, thisArg) { 1264 return function wrap() { 1265 var args = new Array(arguments.length); 1266 for (var i = 0; i < args.length; i++) { 1267 args[i] = arguments[i]; 1268 } 1269 return fn.apply(thisArg, args); 1270 }; 1271}; 1272 1273 1274/***/ }), 1275
vendor: 2,007 bytes, lines 1276-1356
1276/***/ "./node_modules/axios/lib/helpers/buildURL.js": 1277/*!****************************************************!*\ 1278 !*** ./node_modules/axios/lib/helpers/buildURL.js ***! 1279 \****************************************************/ 1280/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1281 1282"use strict"; 1283 1284 1285var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1286 1287function encode(val) { 1288 return encodeURIComponent(val). 1289 replace(/%3A/gi, ':'). 1290 replace(/%24/g, '$'). 1291 replace(/%2C/gi, ','). 1292 replace(/%20/g, '+'). 1293 replace(/%5B/gi, '['). 1294 replace(/%5D/gi, ']'); 1295} 1296 1297/** 1298 * Build a URL by appending params to the end 1299 * 1300 * @param {string} url The base of the url (e.g., http://www.google.com) 1301 * @param {object} [params] The params to be appended 1302 * @returns {string} The formatted url 1303 */ 1304module.exports = function buildURL(url, params, paramsSerializer) { 1305 /*eslint no-param-reassign:0*/ 1306 if (!params) { 1307 return url; 1308 } 1309 1310 var serializedParams; 1311 if (paramsSerializer) { 1312 serializedParams = paramsSerializer(params); 1313 } else if (utils.isURLSearchParams(params)) { 1314 serializedParams = params.toString(); 1315 } else { 1316 var parts = []; 1317 1318 utils.forEach(params, function serialize(val, key) { 1319 if (val === null || typeof val === 'undefined') { 1320 return; 1321 } 1322 1323 if (utils.isArray(val)) { 1324 key = key + '[]'; 1325 } else { 1326 val = [val]; 1327 } 1328 1329 utils.forEach(val, function parseValue(v) { 1330 if (utils.isDate(v)) { 1331 v = v.toISOString(); 1332 } else if (utils.isObject(v)) { 1333 v = JSON.stringify(v); 1334 } 1335 parts.push(encode(key) + '=' + encode(v)); 1336 }); 1337 }); 1338 1339 serializedParams = parts.join('&'); 1340 } 1341 1342 if (serializedParams) { 1343 var hashmarkIndex = url.indexOf('#'); 1344 if (hashmarkIndex !== -1) { 1345 url = url.slice(0, hashmarkIndex); 1346 } 1347 1348 url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams; 1349 } 1350 1351 return url; 1352}; 1353 1354 1355/***/ }), 1356
vendor: 655 bytes, lines 1357-1381
1357/***/ "./node_modules/axios/lib/helpers/combineURLs.js": 1358/*!*******************************************************!*\ 1359 !*** ./node_modules/axios/lib/helpers/combineURLs.js ***! 1360 \*******************************************************/ 1361/***/ ((module) => { 1362 1363"use strict"; 1364 1365 1366/** 1367 * Creates a new URL by combining the specified URLs 1368 * 1369 * @param {string} baseURL The base URL 1370 * @param {string} relativeURL The relative URL 1371 * @returns {string} The combined URL 1372 */ 1373module.exports = function combineURLs(baseURL, relativeURL) { 1374 return relativeURL 1375 ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '') 1376 : baseURL; 1377}; 1378 1379 1380/***/ }), 1381
vendor: 1,794 bytes, lines 1382-1445
1382/***/ "./node_modules/axios/lib/helpers/cookies.js": 1383/*!***************************************************!*\ 1384 !*** ./node_modules/axios/lib/helpers/cookies.js ***! 1385 \***************************************************/ 1386/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1387 1388"use strict"; 1389 1390 1391var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1392 1393module.exports = ( 1394 utils.isStandardBrowserEnv() ? 1395 1396 // Standard browser envs support document.cookie 1397 (function standardBrowserEnv() { 1398 return { 1399 write: function write(name, value, expires, path, domain, secure) { 1400 var cookie = []; 1401 cookie.push(name + '=' + encodeURIComponent(value)); 1402 1403 if (utils.isNumber(expires)) { 1404 cookie.push('expires=' + new Date(expires).toGMTString()); 1405 } 1406 1407 if (utils.isString(path)) { 1408 cookie.push('path=' + path); 1409 } 1410 1411 if (utils.isString(domain)) { 1412 cookie.push('domain=' + domain); 1413 } 1414 1415 if (secure === true) { 1416 cookie.push('secure'); 1417 } 1418 1419 document.cookie = cookie.join('; '); 1420 }, 1421 1422 read: function read(name) { 1423 var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); 1424 return (match ? decodeURIComponent(match[3]) : null); 1425 }, 1426 1427 remove: function remove(name) { 1428 this.write(name, '', Date.now() - 86400000); 1429 } 1430 }; 1431 })() : 1432 1433 // Non standard browser env (web workers, react-native) lack needed support. 1434 (function nonStandardBrowserEnv() { 1435 return { 1436 write: function write() {}, 1437 read: function read() { return null; }, 1438 remove: function remove() {} 1439 }; 1440 })() 1441); 1442 1443 1444/***/ }), 1445
vendor: 846 bytes, lines 1446-1470
1446/***/ "./node_modules/axios/lib/helpers/isAbsoluteURL.js": 1447/*!*********************************************************!*\ 1448 !*** ./node_modules/axios/lib/helpers/isAbsoluteURL.js ***! 1449 \*********************************************************/ 1450/***/ ((module) => { 1451 1452"use strict"; 1453 1454 1455/** 1456 * Determines whether the specified URL is absolute 1457 * 1458 * @param {string} url The URL to test 1459 * @returns {boolean} True if the specified URL is absolute, otherwise false 1460 */ 1461module.exports = function isAbsoluteURL(url) { 1462 // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL). 1463 // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed 1464 // by any combination of letters, digits, plus, period, or hyphen. 1465 return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url); 1466}; 1467 1468 1469/***/ }), 1470
vendor: 622 bytes, lines 1471-1492
1471/***/ "./node_modules/axios/lib/helpers/isAxiosError.js": 1472/*!********************************************************!*\ 1473 !*** ./node_modules/axios/lib/helpers/isAxiosError.js ***! 1474 \********************************************************/ 1475/***/ ((module) => { 1476 1477"use strict"; 1478 1479 1480/** 1481 * Determines whether the payload is an error thrown by Axios 1482 * 1483 * @param {*} payload The value to test 1484 * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false 1485 */ 1486module.exports = function isAxiosError(payload) { 1487 return (typeof payload === 'object') && (payload.isAxiosError === true); 1488}; 1489 1490 1491/***/ }), 1492
vendor: 2,696 bytes, lines 1493-1571
1493/***/ "./node_modules/axios/lib/helpers/isURLSameOrigin.js": 1494/*!***********************************************************!*\ 1495 !*** ./node_modules/axios/lib/helpers/isURLSameOrigin.js ***! 1496 \***********************************************************/ 1497/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1498 1499"use strict"; 1500 1501 1502var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1503 1504module.exports = ( 1505 utils.isStandardBrowserEnv() ? 1506 1507 // Standard browser envs have full support of the APIs needed to test 1508 // whether the request URL is of the same origin as current location. 1509 (function standardBrowserEnv() { 1510 var msie = /(msie|trident)/i.test(navigator.userAgent); 1511 var urlParsingNode = document.createElement('a'); 1512 var originURL; 1513 1514 /** 1515 * Parse a URL to discover it's components 1516 * 1517 * @param {String} url The URL to be parsed 1518 * @returns {Object} 1519 */ 1520 function resolveURL(url) { 1521 var href = url; 1522 1523 if (msie) { 1524 // IE needs attribute set twice to normalize properties 1525 urlParsingNode.setAttribute('href', href); 1526 href = urlParsingNode.href; 1527 } 1528 1529 urlParsingNode.setAttribute('href', href); 1530 1531 // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils 1532 return { 1533 href: urlParsingNode.href, 1534 protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '', 1535 host: urlParsingNode.host, 1536 search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '', 1537 hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '', 1538 hostname: urlParsingNode.hostname, 1539 port: urlParsingNode.port, 1540 pathname: (urlParsingNode.pathname.charAt(0) === '/') ? 1541 urlParsingNode.pathname : 1542 '/' + urlParsingNode.pathname 1543 }; 1544 } 1545 1546 originURL = resolveURL(window.location.href); 1547 1548 /** 1549 * Determine if a URL shares the same origin as the current location 1550 * 1551 * @param {String} requestURL The URL to test 1552 * @returns {boolean} True if URL shares the same origin, otherwise false 1553 */ 1554 return function isURLSameOrigin(requestURL) { 1555 var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL; 1556 return (parsed.protocol === originURL.protocol && 1557 parsed.host === originURL.host); 1558 }; 1559 })() : 1560 1561 // Non standard browser envs (web workers, react-native) lack needed support. 1562 (function nonStandardBrowserEnv() { 1563 return function isURLSameOrigin() { 1564 return true; 1565 }; 1566 })() 1567); 1568 1569 1570/***/ }), 1571
vendor: 764 bytes, lines 1572-1594
1572/***/ "./node_modules/axios/lib/helpers/normalizeHeaderName.js": 1573/*!***************************************************************!*\ 1574 !*** ./node_modules/axios/lib/helpers/normalizeHeaderName.js ***! 1575 \***************************************************************/ 1576/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1577 1578"use strict"; 1579 1580 1581var utils = __webpack_require__(/*! ../utils */ "./node_modules/axios/lib/utils.js"); 1582 1583module.exports = function normalizeHeaderName(headers, normalizedName) { 1584 utils.forEach(headers, function processHeader(value, name) { 1585 if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) { 1586 headers[normalizedName] = value; 1587 delete headers[name]; 1588 } 1589 }); 1590}; 1591 1592 1593/***/ }), 1594
vendor: 1,772 bytes, lines 1595-1658
1595/***/ "./node_modules/axios/lib/helpers/parseHeaders.js": 1596/*!********************************************************!*\ 1597 !*** ./node_modules/axios/lib/helpers/parseHeaders.js ***! 1598 \********************************************************/ 1599/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1600 1601"use strict"; 1602 1603 1604var utils = __webpack_require__(/*! ./../utils */ "./node_modules/axios/lib/utils.js"); 1605 1606// Headers whose duplicates are ignored by node 1607// c.f. https://nodejs.org/api/http.html#http_message_headers 1608var ignoreDuplicateOf = [ 1609 'age', 'authorization', 'content-length', 'content-type', 'etag', 1610 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since', 1611 'last-modified', 'location', 'max-forwards', 'proxy-authorization', 1612 'referer', 'retry-after', 'user-agent' 1613]; 1614 1615/** 1616 * Parse headers into an object 1617 * 1618 * ``` 1619 * Date: Wed, 27 Aug 2014 08:58:49 GMT 1620 * Content-Type: application/json 1621 * Connection: keep-alive 1622 * Transfer-Encoding: chunked 1623 * ``` 1624 * 1625 * @param {String} headers Headers needing to be parsed 1626 * @returns {Object} Headers parsed into an object 1627 */ 1628module.exports = function parseHeaders(headers) { 1629 var parsed = {}; 1630 var key; 1631 var val; 1632 var i; 1633 1634 if (!headers) { return parsed; } 1635 1636 utils.forEach(headers.split('\n'), function parser(line) { 1637 i = line.indexOf(':'); 1638 key = utils.trim(line.substr(0, i)).toLowerCase(); 1639 val = utils.trim(line.substr(i + 1)); 1640 1641 if (key) { 1642 if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) { 1643 return; 1644 } 1645 if (key === 'set-cookie') { 1646 parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]); 1647 } else { 1648 parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; 1649 } 1650 } 1651 }); 1652 1653 return parsed; 1654}; 1655 1656 1657/***/ }), 1658
vendor: 819 bytes, lines 1659-1696
1659/***/ "./node_modules/axios/lib/helpers/spread.js": 1660/*!**************************************************!*\ 1661 !*** ./node_modules/axios/lib/helpers/spread.js ***! 1662 \**************************************************/ 1663/***/ ((module) => { 1664 1665"use strict"; 1666 1667 1668/** 1669 * Syntactic sugar for invoking a function and expanding an array for arguments. 1670 * 1671 * Common use case would be to use `Function.prototype.apply`. 1672 * 1673 * ```js 1674 * function f(x, y, z) {} 1675 * var args = [1, 2, 3]; 1676 * f.apply(null, args); 1677 * ``` 1678 * 1679 * With `spread` this example can be re-written. 1680 * 1681 * ```js 1682 * spread(function(x, y, z) {})([1, 2, 3]); 1683 * ``` 1684 * 1685 * @param {Function} callback 1686 * @returns {Function} 1687 */ 1688module.exports = function spread(callback) { 1689 return function wrap(arr) { 1690 return callback.apply(null, arr); 1691 }; 1692}; 1693 1694 1695/***/ }), 1696
vendor: 2,719 bytes, lines 1697-1789
1697/***/ "./node_modules/axios/lib/helpers/validator.js": 1698/*!*****************************************************!*\ 1699 !*** ./node_modules/axios/lib/helpers/validator.js ***! 1700 \*****************************************************/ 1701/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1702 1703"use strict"; 1704 1705 1706var VERSION = (__webpack_require__(/*! ../env/data */ "./node_modules/axios/lib/env/data.js").version); 1707 1708var validators = {}; 1709 1710// eslint-disable-next-line func-names 1711['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) { 1712 validators[type] = function validator(thing) { 1713 return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type; 1714 }; 1715}); 1716 1717var deprecatedWarnings = {}; 1718 1719/** 1720 * Transitional option validator 1721 * @param {function|boolean?} validator - set to false if the transitional option has been removed 1722 * @param {string?} version - deprecated version / removed since version 1723 * @param {string?} message - some message with additional info 1724 * @returns {function} 1725 */ 1726validators.transitional = function transitional(validator, version, message) { 1727 function formatMessage(opt, desc) { 1728 return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : ''); 1729 } 1730 1731 // eslint-disable-next-line func-names 1732 return function(value, opt, opts) { 1733 if (validator === false) { 1734 throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : ''))); 1735 } 1736 1737 if (version && !deprecatedWarnings[opt]) { 1738 deprecatedWarnings[opt] = true; 1739 // eslint-disable-next-line no-console 1740 console.warn( 1741 formatMessage( 1742 opt, 1743 ' has been deprecated since v' + version + ' and will be removed in the near future' 1744 ) 1745 ); 1746 } 1747 1748 return validator ? validator(value, opt, opts) : true; 1749 }; 1750}; 1751 1752/** 1753 * Assert object's properties type 1754 * @param {object} options 1755 * @param {object} schema 1756 * @param {boolean?} allowUnknown 1757 */ 1758 1759function assertOptions(options, schema, allowUnknown) { 1760 if (typeof options !== 'object') { 1761 throw new TypeError('options must be an object'); 1762 } 1763 var keys = Object.keys(options); 1764 var i = keys.length; 1765 while (i-- > 0) { 1766 var opt = keys[i]; 1767 var validator = schema[opt]; 1768 if (validator) { 1769 var value = options[opt]; 1770 var result = value === undefined || validator(value, opt, options); 1771 if (result !== true) { 1772 throw new TypeError('option ' + opt + ' must be ' + result); 1773 } 1774 continue; 1775 } 1776 if (allowUnknown !== true) { 1777 throw Error('Unknown option ' + opt); 1778 } 1779 } 1780} 1781 1782module.exports = { 1783 assertOptions: assertOptions, 1784 validators: validators 1785}; 1786 1787 1788/***/ }), 1789
vendor: 9,257 bytes, lines 1790-2149
1790/***/ "./node_modules/axios/lib/utils.js": 1791/*!*****************************************!*\ 1792 !*** ./node_modules/axios/lib/utils.js ***! 1793 \*****************************************/ 1794/***/ ((module, __unused_webpack_exports, __webpack_require__) => { 1795 1796"use strict"; 1797 1798 1799var bind = __webpack_require__(/*! ./helpers/bind */ "./node_modules/axios/lib/helpers/bind.js"); 1800 1801// utils is a library of generic helper functions non-specific to axios 1802 1803var toString = Object.prototype.toString; 1804 1805/** 1806 * Determine if a value is an Array 1807 * 1808 * @param {Object} val The value to test 1809 * @returns {boolean} True if value is an Array, otherwise false 1810 */ 1811function isArray(val) { 1812 return toString.call(val) === '[object Array]'; 1813} 1814 1815/** 1816 * Determine if a value is undefined 1817 * 1818 * @param {Object} val The value to test 1819 * @returns {boolean} True if the value is undefined, otherwise false 1820 */ 1821function isUndefined(val) { 1822 return typeof val === 'undefined'; 1823} 1824 1825/** 1826 * Determine if a value is a Buffer 1827 * 1828 * @param {Object} val The value to test 1829 * @returns {boolean} True if value is a Buffer, otherwise false 1830 */ 1831function isBuffer(val) { 1832 return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) 1833 && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val); 1834} 1835 1836/** 1837 * Determine if a value is an ArrayBuffer 1838 * 1839 * @param {Object} val The value to test 1840 * @returns {boolean} True if value is an ArrayBuffer, otherwise false 1841 */ 1842function isArrayBuffer(val) { 1843 return toString.call(val) === '[object ArrayBuffer]'; 1844} 1845 1846/** 1847 * Determine if a value is a FormData 1848 * 1849 * @param {Object} val The value to test 1850 * @returns {boolean} True if value is an FormData, otherwise false 1851 */ 1852function isFormData(val) { 1853 return (typeof FormData !== 'undefined') && (val instanceof FormData); 1854} 1855 1856/** 1857 * Determine if a value is a view on an ArrayBuffer 1858 * 1859 * @param {Object} val The value to test 1860 * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false 1861 */ 1862function isArrayBufferView(val) { 1863 var result; 1864 if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) { 1865 result = ArrayBuffer.isView(val); 1866 } else { 1867 result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer); 1868 } 1869 return result; 1870} 1871 1872/** 1873 * Determine if a value is a String 1874 * 1875 * @param {Object} val The value to test 1876 * @returns {boolean} True if value is a String, otherwise false 1877 */ 1878function isString(val) { 1879 return typeof val === 'string'; 1880} 1881 1882/** 1883 * Determine if a value is a Number 1884 * 1885 * @param {Object} val The value to test 1886 * @returns {boolean} True if value is a Number, otherwise false 1887 */ 1888function isNumber(val) { 1889 return typeof val === 'number'; 1890} 1891 1892/** 1893 * Determine if a value is an Object 1894 * 1895 * @param {Object} val The value to test 1896 * @returns {boolean} True if value is an Object, otherwise false 1897 */ 1898function isObject(val) { 1899 return val !== null && typeof val === 'object'; 1900} 1901 1902/** 1903 * Determine if a value is a plain Object 1904 * 1905 * @param {Object} val The value to test 1906 * @return {boolean} True if value is a plain Object, otherwise false 1907 */ 1908function isPlainObject(val) { 1909 if (toString.call(val) !== '[object Object]') { 1910 return false; 1911 } 1912 1913 var prototype = Object.getPrototypeOf(val); 1914 return prototype === null || prototype === Object.prototype; 1915} 1916 1917/** 1918 * Determine if a value is a Date 1919 * 1920 * @param {Object} val The value to test 1921 * @returns {boolean} True if value is a Date, otherwise false 1922 */ 1923function isDate(val) { 1924 return toString.call(val) === '[object Date]'; 1925} 1926 1927/** 1928 * Determine if a value is a File 1929 * 1930 * @param {Object} val The value to test 1931 * @returns {boolean} True if value is a File, otherwise false 1932 */ 1933function isFile(val) { 1934 return toString.call(val) === '[object File]'; 1935} 1936 1937/** 1938 * Determine if a value is a Blob 1939 * 1940 * @param {Object} val The value to test 1941 * @returns {boolean} True if value is a Blob, otherwise false 1942 */ 1943function isBlob(val) { 1944 return toString.call(val) === '[object Blob]'; 1945} 1946 1947/** 1948 * Determine if a value is a Function 1949 * 1950 * @param {Object} val The value to test 1951 * @returns {boolean} True if value is a Function, otherwise false 1952 */ 1953function isFunction(val) { 1954 return toString.call(val) === '[object Function]'; 1955} 1956 1957/** 1958 * Determine if a value is a Stream 1959 * 1960 * @param {Object} val The value to test 1961 * @returns {boolean} True if value is a Stream, otherwise false 1962 */ 1963function isStream(val) { 1964 return isObject(val) && isFunction(val.pipe); 1965} 1966 1967/** 1968 * Determine if a value is a URLSearchParams object 1969 * 1970 * @param {Object} val The value to test 1971 * @returns {boolean} True if value is a URLSearchParams object, otherwise false 1972 */ 1973function isURLSearchParams(val) { 1974 return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; 1975} 1976 1977/** 1978 * Trim excess whitespace off the beginning and end of a string 1979 * 1980 * @param {String} str The String to trim 1981 * @returns {String} The String freed of excess whitespace 1982 */ 1983function trim(str) { 1984 return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, ''); 1985} 1986 1987/** 1988 * Determine if we're running in a standard browser environment 1989 * 1990 * This allows axios to run in a web worker, and react-native. 1991 * Both environments support XMLHttpRequest, but not fully standard globals. 1992 * 1993 * web workers: 1994 * typeof window -> undefined 1995 * typeof document -> undefined 1996 * 1997 * react-native: 1998 * navigator.product -> 'ReactNative' 1999 * nativescript 2000 * navigator.product -> 'NativeScript' or 'NS' 2001 */ 2002function isStandardBrowserEnv() { 2003 if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' || 2004 navigator.product === 'NativeScript' || 2005 navigator.product === 'NS')) { 2006 return false; 2007 } 2008 return ( 2009 typeof window !== 'undefined' && 2010 typeof document !== 'undefined' 2011 ); 2012} 2013 2014/** 2015 * Iterate over an Array or an Object invoking a function for each item. 2016 * 2017 * If `obj` is an Array callback will be called passing 2018 * the value, index, and complete array for each item. 2019 * 2020 * If 'obj' is an Object callback will be called passing 2021 * the value, key, and complete object for each property. 2022 * 2023 * @param {Object|Array} obj The object to iterate 2024 * @param {Function} fn The callback to invoke for each item 2025 */ 2026function forEach(obj, fn) { 2027 // Don't bother if no value provided 2028 if (obj === null || typeof obj === 'undefined') { 2029 return; 2030 } 2031 2032 // Force an array if not already something iterable 2033 if (typeof obj !== 'object') { 2034 /*eslint no-param-reassign:0*/ 2035 obj = [obj]; 2036 } 2037 2038 if (isArray(obj)) { 2039 // Iterate over array values 2040 for (var i = 0, l = obj.length; i < l; i++) { 2041 fn.call(null, obj[i], i, obj); 2042 } 2043 } else { 2044 // Iterate over object keys 2045 for (var key in obj) { 2046 if (Object.prototype.hasOwnProperty.call(obj, key)) { 2047 fn.call(null, obj[key], key, obj); 2048 } 2049 } 2050 } 2051} 2052 2053/** 2054 * Accepts varargs expecting each argument to be an object, then 2055 * immutably merges the properties of each object and returns result. 2056 * 2057 * When multiple objects contain the same key the later object in 2058 * the arguments list will take precedence. 2059 * 2060 * Example: 2061 * 2062 * ```js 2063 * var result = merge({foo: 123}, {foo: 456}); 2064 * console.log(result.foo); // outputs 456 2065 * ``` 2066 * 2067 * @param {Object} obj1 Object to merge 2068 * @returns {Object} Result of all merge properties 2069 */ 2070function merge(/* obj1, obj2, obj3, ... */) { 2071 var result = {}; 2072 function assignValue(val, key) { 2073 if (isPlainObject(result[key]) && isPlainObject(val)) { 2074 result[key] = merge(result[key], val); 2075 } else if (isPlainObject(val)) { 2076 result[key] = merge({}, val); 2077 } else if (isArray(val)) { 2078 result[key] = val.slice(); 2079 } else { 2080 result[key] = val; 2081 } 2082 } 2083 2084 for (var i = 0, l = arguments.length; i < l; i++) { 2085 forEach(arguments[i], assignValue); 2086 } 2087 return result; 2088} 2089 2090/** 2091 * Extends object a by mutably adding to it the properties of object b. 2092 * 2093 * @param {Object} a The object to be extended 2094 * @param {Object} b The object to copy properties from 2095 * @param {Object} thisArg The object to bind function to 2096 * @return {Object} The resulting value of object a 2097 */ 2098function extend(a, b, thisArg) { 2099 forEach(b, function assignValue(val, key) { 2100 if (thisArg && typeof val === 'function') { 2101 a[key] = bind(val, thisArg); 2102 } else { 2103 a[key] = val; 2104 } 2105 }); 2106 return a; 2107} 2108 2109/** 2110 * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM) 2111 * 2112 * @param {string} content with BOM 2113 * @return {string} content value without BOM 2114 */ 2115function stripBOM(content) { 2116 if (content.charCodeAt(0) === 0xFEFF) { 2117 content = content.slice(1); 2118 } 2119 return content; 2120} 2121 2122module.exports = { 2123 isArray: isArray, 2124 isArrayBuffer: isArrayBuffer, 2125 isBuffer: isBuffer, 2126 isFormData: isFormData, 2127 isArrayBufferView: isArrayBufferView, 2128 isString: isString, 2129 isNumber: isNumber, 2130 isObject: isObject, 2131 isPlainObject: isPlainObject, 2132 isUndefined: isUndefined, 2133 isDate: isDate, 2134 isFile: isFile, 2135 isBlob: isBlob, 2136 isFunction: isFunction, 2137 isStream: isStream, 2138 isURLSearchParams: isURLSearchParams, 2139 isStandardBrowserEnv: isStandardBrowserEnv, 2140 forEach: forEach, 2141 merge: merge, 2142 extend: extend, 2143 trim: trim, 2144 stripBOM: stripBOM 2145}; 2146 2147 2148/***/ }), 2149
2150/***/ "./resources/js/app.js": 2151/*!*****************************!*\ 2152 !*** ./resources/js/app.js ***! 2153 \*****************************/ 2154/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { 2155 2156__webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js"); 2157 2158/***/ }), 2159
2160/***/ "./resources/js/bootstrap.js": 2161/*!***********************************!*\ 2162 !*** ./resources/js/bootstrap.js ***! 2163 \***********************************/ 2164/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { 2165 2166window._ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"); 2167 2168/** 2169 * We'll load the axios HTTP library which allows us to easily issue requests 2170 * to our Laravel back-end. This library automatically handles sending the 2171 * CSRF token as a header based on the value of the "XSRF" token cookie. 2172 */ 2173 2174window.axios = __webpack_require__(/*! axios */ "./node_modules/axios/index.js"); 2175window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 2176 2177/** 2178 * Echo exposes an expressive API for subscribing to channels and listening 2179 * for events that are broadcast by Laravel. Echo and event broadcasting 2180 * allows your team to easily build robust real-time web applications. 2181 */ 2182 2183// import Echo from 'laravel-echo'; 2184 2185// window.Pusher = require('pusher-js'); 2186 2187// window.Echo = new Echo({ 2188// broadcaster: 'pusher', 2189// key: process.env.MIX_PUSHER_APP_KEY, 2190// cluster: process.env.MIX_PUSHER_APP_CLUSTER, 2191// forceTLS: true 2192// }); 2193 2194/***/ }), 2195
vendor: 544,380 bytes, lines 2196-19407
2196/***/ "./node_modules/lodash/lodash.js": 2197/*!***************************************!*\ 2198 !*** ./node_modules/lodash/lodash.js ***! 2199 \***************************************/ 2200/***/ (function(module, exports, __webpack_require__) { 2201 2202/* module decorator */ module = __webpack_require__.nmd(module); 2203var __WEBPACK_AMD_DEFINE_RESULT__;/** 2204 * @license 2205 * Lodash <https://lodash.com/> 2206 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> 2207 * Released under MIT license <https://lodash.com/license> 2208 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> 2209 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 2210 */ 2211;(function() { 2212 2213 /** Used as a safe reference for `undefined` in pre-ES5 environments. */ 2214 var undefined; 2215 2216 /** Used as the semantic version number. */ 2217 var VERSION = '4.17.21'; 2218 2219 /** Used as the size to enable large array optimizations. */ 2220 var LARGE_ARRAY_SIZE = 200; 2221 2222 /** Error message constants. */ 2223 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', 2224 FUNC_ERROR_TEXT = 'Expected a function', 2225 INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`'; 2226 2227 /** Used to stand-in for `undefined` hash values. */ 2228 var HASH_UNDEFINED = '__lodash_hash_undefined__'; 2229 2230 /** Used as the maximum memoize cache size. */ 2231 var MAX_MEMOIZE_SIZE = 500; 2232 2233 /** Used as the internal argument placeholder. */ 2234 var PLACEHOLDER = '__lodash_placeholder__'; 2235 2236 /** Used to compose bitmasks for cloning. */ 2237 var CLONE_DEEP_FLAG = 1, 2238 CLONE_FLAT_FLAG = 2, 2239 CLONE_SYMBOLS_FLAG = 4; 2240 2241 /** Used to compose bitmasks for value comparisons. */ 2242 var COMPARE_PARTIAL_FLAG = 1, 2243 COMPARE_UNORDERED_FLAG = 2; 2244 2245 /** Used to compose bitmasks for function metadata. */ 2246 var WRAP_BIND_FLAG = 1, 2247 WRAP_BIND_KEY_FLAG = 2, 2248 WRAP_CURRY_BOUND_FLAG = 4, 2249 WRAP_CURRY_FLAG = 8, 2250 WRAP_CURRY_RIGHT_FLAG = 16, 2251 WRAP_PARTIAL_FLAG = 32, 2252 WRAP_PARTIAL_RIGHT_FLAG = 64, 2253 WRAP_ARY_FLAG = 128, 2254 WRAP_REARG_FLAG = 256, 2255 WRAP_FLIP_FLAG = 512; 2256 2257 /** Used as default options for `_.truncate`. */ 2258 var DEFAULT_TRUNC_LENGTH = 30, 2259 DEFAULT_TRUNC_OMISSION = '...'; 2260 2261 /** Used to detect hot functions by number of calls within a span of milliseconds. */ 2262 var HOT_COUNT = 800, 2263 HOT_SPAN = 16; 2264 2265 /** Used to indicate the type of lazy iteratees. */ 2266 var LAZY_FILTER_FLAG = 1, 2267 LAZY_MAP_FLAG = 2, 2268 LAZY_WHILE_FLAG = 3; 2269 2270 /** Used as references for various `Number` constants. */ 2271 var INFINITY = 1 / 0, 2272 MAX_SAFE_INTEGER = 9007199254740991, 2273 MAX_INTEGER = 1.7976931348623157e+308, 2274 NAN = 0 / 0; 2275 2276 /** Used as references for the maximum length and index of an array. */ 2277 var MAX_ARRAY_LENGTH = 4294967295, 2278 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, 2279 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; 2280 2281 /** Used to associate wrap methods with their bit flags. */ 2282 var wrapFlags = [ 2283 ['ary', WRAP_ARY_FLAG], 2284 ['bind', WRAP_BIND_FLAG], 2285 ['bindKey', WRAP_BIND_KEY_FLAG], 2286 ['curry', WRAP_CURRY_FLAG], 2287 ['curryRight', WRAP_CURRY_RIGHT_FLAG], 2288 ['flip', WRAP_FLIP_FLAG], 2289 ['partial', WRAP_PARTIAL_FLAG], 2290 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], 2291 ['rearg', WRAP_REARG_FLAG] 2292 ]; 2293 2294 /** `Object#toString` result references. */ 2295 var argsTag = '[object Arguments]', 2296 arrayTag = '[object Array]', 2297 asyncTag = '[object AsyncFunction]', 2298 boolTag = '[object Boolean]', 2299 dateTag = '[object Date]', 2300 domExcTag = '[object DOMException]', 2301 errorTag = '[object Error]', 2302 funcTag = '[object Function]', 2303 genTag = '[object GeneratorFunction]', 2304 mapTag = '[object Map]', 2305 numberTag = '[object Number]', 2306 nullTag = '[object Null]', 2307 objectTag = '[object Object]', 2308 promiseTag = '[object Promise]', 2309 proxyTag = '[object Proxy]', 2310 regexpTag = '[object RegExp]', 2311 setTag = '[object Set]', 2312 stringTag = '[object String]', 2313 symbolTag = '[object Symbol]', 2314 undefinedTag = '[object Undefined]', 2315 weakMapTag = '[object WeakMap]', 2316 weakSetTag = '[object WeakSet]'; 2317 2318 var arrayBufferTag = '[object ArrayBuffer]', 2319 dataViewTag = '[object DataView]', 2320 float32Tag = '[object Float32Array]', 2321 float64Tag = '[object Float64Array]', 2322 int8Tag = '[object Int8Array]', 2323 int16Tag = '[object Int16Array]', 2324 int32Tag = '[object Int32Array]', 2325 uint8Tag = '[object Uint8Array]', 2326 uint8ClampedTag = '[object Uint8ClampedArray]', 2327 uint16Tag = '[object Uint16Array]', 2328 uint32Tag = '[object Uint32Array]'; 2329 2330 /** Used to match empty string literals in compiled template source. */ 2331 var reEmptyStringLeading = /\b__p \+= '';/g, 2332 reEmptyStringMiddle = /\b(__p \+=) '' \+/g, 2333 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; 2334 2335 /** Used to match HTML entities and HTML characters. */ 2336 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, 2337 reUnescapedHtml = /[&<>"']/g, 2338 reHasEscapedHtml = RegExp(reEscapedHtml.source), 2339 reHasUnescapedHtml = RegExp(reUnescapedHtml.source); 2340 2341 /** Used to match template delimiters. */ 2342 var reEscape = /<%-([\s\S]+?)%>/g, 2343 reEvaluate = /<%([\s\S]+?)%>/g, 2344 reInterpolate = /<%=([\s\S]+?)%>/g; 2345 2346 /** Used to match property names within property paths. */ 2347 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, 2348 reIsPlainProp = /^\w*$/, 2349 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; 2350 2351 /** 2352 * Used to match `RegExp` 2353 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). 2354 */ 2355 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, 2356 reHasRegExpChar = RegExp(reRegExpChar.source); 2357 2358 /** Used to match leading whitespace. */ 2359 var reTrimStart = /^\s+/; 2360 2361 /** Used to match a single whitespace character. */ 2362 var reWhitespace = /\s/; 2363 2364 /** Used to match wrap detail comments. */ 2365 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, 2366 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, 2367 reSplitDetails = /,? & /; 2368 2369 /** Used to match words composed of alphanumeric characters. */ 2370 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; 2371 2372 /** 2373 * Used to validate the `validate` option in `_.template` variable. 2374 * 2375 * Forbids characters which could potentially change the meaning of the function argument definition: 2376 * - "()," (modification of function parameters) 2377 * - "=" (default value) 2378 * - "[]{}" (destructuring of function parameters) 2379 * - "/" (beginning of a comment) 2380 * - whitespace 2381 */ 2382 var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/; 2383 2384 /** Used to match backslashes in property paths. */ 2385 var reEscapeChar = /\\(\\)?/g; 2386 2387 /** 2388 * Used to match 2389 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). 2390 */ 2391 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; 2392 2393 /** Used to match `RegExp` flags from their coerced string values. */ 2394 var reFlags = /\w*$/; 2395 2396 /** Used to detect bad signed hexadecimal string values. */ 2397 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 2398 2399 /** Used to detect binary string values. */ 2400 var reIsBinary = /^0b[01]+$/i; 2401 2402 /** Used to detect host constructors (Safari). */ 2403 var reIsHostCtor = /^\[object .+?Constructor\]$/; 2404 2405 /** Used to detect octal string values. */ 2406 var reIsOctal = /^0o[0-7]+$/i; 2407 2408 /** Used to detect unsigned integer values. */ 2409 var reIsUint = /^(?:0|[1-9]\d*)$/; 2410 2411 /** Used to match Latin Unicode letters (excluding mathematical operators). */ 2412 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; 2413 2414 /** Used to ensure capturing order of template delimiters. */ 2415 var reNoMatch = /($^)/; 2416 2417 /** Used to match unescaped characters in compiled string literals. */ 2418 var reUnescapedString = /['\n\r\u2028\u2029\\]/g; 2419 2420 /** Used to compose unicode character classes. */ 2421 var rsAstralRange = '\\ud800-\\udfff', 2422 rsComboMarksRange = '\\u0300-\\u036f', 2423 reComboHalfMarksRange = '\\ufe20-\\ufe2f', 2424 rsComboSymbolsRange = '\\u20d0-\\u20ff', 2425 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, 2426 rsDingbatRange = '\\u2700-\\u27bf', 2427 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', 2428 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', 2429 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', 2430 rsPunctuationRange = '\\u2000-\\u206f', 2431 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', 2432 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', 2433 rsVarRange = '\\ufe0e\\ufe0f', 2434 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; 2435 2436 /** Used to compose unicode capture groups. */ 2437 var rsApos = "['\u2019]", 2438 rsAstral = '[' + rsAstralRange + ']', 2439 rsBreak = '[' + rsBreakRange + ']', 2440 rsCombo = '[' + rsComboRange + ']', 2441 rsDigits = '\\d+', 2442 rsDingbat = '[' + rsDingbatRange + ']', 2443 rsLower = '[' + rsLowerRange + ']', 2444 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', 2445 rsFitz = '\\ud83c[\\udffb-\\udfff]', 2446 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', 2447 rsNonAstral = '[^' + rsAstralRange + ']', 2448 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', 2449 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', 2450 rsUpper = '[' + rsUpperRange + ']', 2451 rsZWJ = '\\u200d'; 2452 2453 /** Used to compose unicode regexes. */ 2454 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', 2455 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', 2456 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', 2457 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', 2458 reOptMod = rsModifier + '?', 2459 rsOptVar = '[' + rsVarRange + ']?', 2460 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', 2461 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', 2462 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', 2463 rsSeq = rsOptVar + reOptMod + rsOptJoin, 2464 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, 2465 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; 2466 2467 /** Used to match apostrophes. */ 2468 var reApos = RegExp(rsApos, 'g'); 2469 2470 /** 2471 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and 2472 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). 2473 */ 2474 var reComboMark = RegExp(rsCombo, 'g'); 2475 2476 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ 2477 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); 2478 2479 /** Used to match complex or compound words. */ 2480 var reUnicodeWord = RegExp([ 2481 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', 2482 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', 2483 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, 2484 rsUpper + '+' + rsOptContrUpper, 2485 rsOrdUpper, 2486 rsOrdLower, 2487 rsDigits, 2488 rsEmoji 2489 ].join('|'), 'g'); 2490 2491 /** 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/). */ 2492 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); 2493 2494 /** Used to detect strings that need a more robust regexp to match words. */ 2495 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 ]/; 2496 2497 /** Used to assign default `context` object properties. */ 2498 var contextProps = [ 2499 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 2500 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', 2501 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', 2502 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 2503 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' 2504 ]; 2505 2506 /** Used to make template sourceURLs easier to identify. */ 2507 var templateCounter = -1; 2508 2509 /** Used to identify `toStringTag` values of typed arrays. */ 2510 var typedArrayTags = {}; 2511 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = 2512 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = 2513 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = 2514 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = 2515 typedArrayTags[uint32Tag] = true; 2516 typedArrayTags[argsTag] = typedArrayTags[arrayTag] = 2517 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = 2518 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = 2519 typedArrayTags[errorTag] = typedArrayTags[funcTag] = 2520 typedArrayTags[mapTag] = typedArrayTags[numberTag] = 2521 typedArrayTags[objectTag] = typedArrayTags[regexpTag] = 2522 typedArrayTags[setTag] = typedArrayTags[stringTag] = 2523 typedArrayTags[weakMapTag] = false; 2524 2525 /** Used to identify `toStringTag` values supported by `_.clone`. */ 2526 var cloneableTags = {}; 2527 cloneableTags[argsTag] = cloneableTags[arrayTag] = 2528 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = 2529 cloneableTags[boolTag] = cloneableTags[dateTag] = 2530 cloneableTags[float32Tag] = cloneableTags[float64Tag] = 2531 cloneableTags[int8Tag] = cloneableTags[int16Tag] = 2532 cloneableTags[int32Tag] = cloneableTags[mapTag] = 2533 cloneableTags[numberTag] = cloneableTags[objectTag] = 2534 cloneableTags[regexpTag] = cloneableTags[setTag] = 2535 cloneableTags[stringTag] = cloneableTags[symbolTag] = 2536 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = 2537 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; 2538 cloneableTags[errorTag] = cloneableTags[funcTag] = 2539 cloneableTags[weakMapTag] = false; 2540 2541 /** Used to map Latin Unicode letters to basic Latin letters. */ 2542 var deburredLetters = { 2543 // Latin-1 Supplement block. 2544 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', 2545 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', 2546 '\xc7': 'C', '\xe7': 'c', 2547 '\xd0': 'D', '\xf0': 'd', 2548 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', 2549 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', 2550 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', 2551 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', 2552 '\xd1': 'N', '\xf1': 'n', 2553 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', 2554 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', 2555 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', 2556 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', 2557 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', 2558 '\xc6': 'Ae', '\xe6': 'ae', 2559 '\xde': 'Th', '\xfe': 'th', 2560 '\xdf': 'ss', 2561 // Latin Extended-A block. 2562 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', 2563 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', 2564 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', 2565 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', 2566 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', 2567 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', 2568 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', 2569 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', 2570 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', 2571 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', 2572 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', 2573 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', 2574 '\u0134': 'J', '\u0135': 'j', 2575 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', 2576 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', 2577 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', 2578 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', 2579 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', 2580 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', 2581 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', 2582 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', 2583 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', 2584 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', 2585 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', 2586 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', 2587 '\u0163': 't', '\u0165': 't', '\u0167': 't', 2588 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', 2589 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', 2590 '\u0174': 'W', '\u0175': 'w', 2591 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', 2592 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', 2593 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', 2594 '\u0132': 'IJ', '\u0133': 'ij', 2595 '\u0152': 'Oe', '\u0153': 'oe', 2596 '\u0149': "'n", '\u017f': 's' 2597 }; 2598 2599 /** Used to map characters to HTML entities. */ 2600 var htmlEscapes = { 2601 '&': '&', 2602 '<': '<', 2603 '>': '>', 2604 '"': '"', 2605 "'": ''' 2606 }; 2607 2608 /** Used to map HTML entities to characters. */ 2609 var htmlUnescapes = { 2610 '&': '&', 2611 '<': '<', 2612 '>': '>', 2613 '"': '"', 2614 ''': "'" 2615 }; 2616 2617 /** Used to escape characters for inclusion in compiled string literals. */ 2618 var stringEscapes = { 2619 '\\': '\\', 2620 "'": "'", 2621 '\n': 'n', 2622 '\r': 'r', 2623 '\u2028': 'u2028', 2624 '\u2029': 'u2029' 2625 }; 2626 2627 /** Built-in method references without a dependency on `root`. */ 2628 var freeParseFloat = parseFloat, 2629 freeParseInt = parseInt; 2630 2631 /** Detect free variable `global` from Node.js. */ 2632 var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g; 2633 2634 /** Detect free variable `self`. */ 2635 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 2636 2637 /** Used as a reference to the global object. */ 2638 var root = freeGlobal || freeSelf || Function('return this')(); 2639 2640 /** Detect free variable `exports`. */ 2641 var freeExports = true && exports && !exports.nodeType && exports; 2642 2643 /** Detect free variable `module`. */ 2644 var freeModule = freeExports && "object" == 'object' && module && !module.nodeType && module; 2645 2646 /** Detect the popular CommonJS extension `module.exports`. */ 2647 var moduleExports = freeModule && freeModule.exports === freeExports; 2648 2649 /** Detect free variable `process` from Node.js. */ 2650 var freeProcess = moduleExports && freeGlobal.process; 2651 2652 /** Used to access faster Node.js helpers. */ 2653 var nodeUtil = (function() { 2654 try { 2655 // Use `util.types` for Node.js 10+. 2656 var types = freeModule && freeModule.require && freeModule.require('util').types; 2657 2658 if (types) { 2659 return types; 2660 } 2661 2662 // Legacy `process.binding('util')` for Node.js < 10. 2663 return freeProcess && freeProcess.binding && freeProcess.binding('util'); 2664 } catch (e) {} 2665 }()); 2666 2667 /* Node.js helper references. */ 2668 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, 2669 nodeIsDate = nodeUtil && nodeUtil.isDate, 2670 nodeIsMap = nodeUtil && nodeUtil.isMap, 2671 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, 2672 nodeIsSet = nodeUtil && nodeUtil.isSet, 2673 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; 2674 2675 /*--------------------------------------------------------------------------*/ 2676 2677 /** 2678 * A faster alternative to `Function#apply`, this function invokes `func` 2679 * with the `this` binding of `thisArg` and the arguments of `args`. 2680 * 2681 * @private 2682 * @param {Function} func The function to invoke. 2683 * @param {*} thisArg The `this` binding of `func`. 2684 * @param {Array} args The arguments to invoke `func` with. 2685 * @returns {*} Returns the result of `func`. 2686 */ 2687 function apply(func, thisArg, args) { 2688 switch (args.length) { 2689 case 0: return func.call(thisArg); 2690 case 1: return func.call(thisArg, args[0]); 2691 case 2: return func.call(thisArg, args[0], args[1]); 2692 case 3: return func.call(thisArg, args[0], args[1], args[2]); 2693 } 2694 return func.apply(thisArg, args); 2695 } 2696 2697 /** 2698 * A specialized version of `baseAggregator` for arrays. 2699 * 2700 * @private 2701 * @param {Array} [array] The array to iterate over. 2702 * @param {Function} setter The function to set `accumulator` values. 2703 * @param {Function} iteratee The iteratee to transform keys. 2704 * @param {Object} accumulator The initial aggregated object. 2705 * @returns {Function} Returns `accumulator`. 2706 */ 2707 function arrayAggregator(array, setter, iteratee, accumulator) { 2708 var index = -1, 2709 length = array == null ? 0 : array.length; 2710 2711 while (++index < length) { 2712 var value = array[index]; 2713 setter(accumulator, value, iteratee(value), array); 2714 } 2715 return accumulator; 2716 } 2717 2718 /** 2719 * A specialized version of `_.forEach` for arrays without support for 2720 * iteratee shorthands. 2721 * 2722 * @private 2723 * @param {Array} [array] The array to iterate over. 2724 * @param {Function} iteratee The function invoked per iteration. 2725 * @returns {Array} Returns `array`. 2726 */ 2727 function arrayEach(array, iteratee) { 2728 var index = -1, 2729 length = array == null ? 0 : array.length; 2730 2731 while (++index < length) { 2732 if (iteratee(array[index], index, array) === false) { 2733 break; 2734 } 2735 } 2736 return array; 2737 } 2738 2739 /** 2740 * A specialized version of `_.forEachRight` for arrays without support for 2741 * iteratee shorthands. 2742 * 2743 * @private 2744 * @param {Array} [array] The array to iterate over. 2745 * @param {Function} iteratee The function invoked per iteration. 2746 * @returns {Array} Returns `array`. 2747 */ 2748 function arrayEachRight(array, iteratee) { 2749 var length = array == null ? 0 : array.length; 2750 2751 while (length--) { 2752 if (iteratee(array[length], length, array) === false) { 2753 break; 2754 } 2755 } 2756 return array; 2757 } 2758 2759 /** 2760 * A specialized version of `_.every` for arrays without support for 2761 * iteratee shorthands. 2762 * 2763 * @private 2764 * @param {Array} [array] The array to iterate over. 2765 * @param {Function} predicate The function invoked per iteration. 2766 * @returns {boolean} Returns `true` if all elements pass the predicate check, 2767 * else `false`. 2768 */ 2769 function arrayEvery(array, predicate) { 2770 var index = -1, 2771 length = array == null ? 0 : array.length; 2772 2773 while (++index < length) { 2774 if (!predicate(array[index], index, array)) { 2775 return false; 2776 } 2777 } 2778 return true; 2779 } 2780 2781 /** 2782 * A specialized version of `_.filter` for arrays without support for 2783 * iteratee shorthands. 2784 * 2785 * @private 2786 * @param {Array} [array] The array to iterate over. 2787 * @param {Function} predicate The function invoked per iteration. 2788 * @returns {Array} Returns the new filtered array. 2789 */ 2790 function arrayFilter(array, predicate) { 2791 var index = -1, 2792 length = array == null ? 0 : array.length, 2793 resIndex = 0, 2794 result = []; 2795 2796 while (++index < length) { 2797 var value = array[index]; 2798 if (predicate(value, index, array)) { 2799 result[resIndex++] = value; 2800 } 2801 } 2802 return result; 2803 } 2804 2805 /** 2806 * A specialized version of `_.includes` for arrays without support for 2807 * specifying an index to search from. 2808 * 2809 * @private 2810 * @param {Array} [array] The array to inspect. 2811 * @param {*} target The value to search for. 2812 * @returns {boolean} Returns `true` if `target` is found, else `false`. 2813 */ 2814 function arrayIncludes(array, value) { 2815 var length = array == null ? 0 : array.length; 2816 return !!length && baseIndexOf(array, value, 0) > -1; 2817 } 2818 2819 /** 2820 * This function is like `arrayIncludes` except that it accepts a comparator. 2821 * 2822 * @private 2823 * @param {Array} [array] The array to inspect. 2824 * @param {*} target The value to search for. 2825 * @param {Function} comparator The comparator invoked per element. 2826 * @returns {boolean} Returns `true` if `target` is found, else `false`. 2827 */ 2828 function arrayIncludesWith(array, value, comparator) { 2829 var index = -1, 2830 length = array == null ? 0 : array.length; 2831 2832 while (++index < length) { 2833 if (comparator(value, array[index])) { 2834 return true; 2835 } 2836 } 2837 return false; 2838 } 2839 2840 /** 2841 * A specialized version of `_.map` for arrays without support for iteratee 2842 * shorthands. 2843 * 2844 * @private 2845 * @param {Array} [array] The array to iterate over. 2846 * @param {Function} iteratee The function invoked per iteration. 2847 * @returns {Array} Returns the new mapped array. 2848 */ 2849 function arrayMap(array, iteratee) { 2850 var index = -1, 2851 length = array == null ? 0 : array.length, 2852 result = Array(length); 2853 2854 while (++index < length) { 2855 result[index] = iteratee(array[index], index, array); 2856 } 2857 return result; 2858 } 2859 2860 /** 2861 * Appends the elements of `values` to `array`. 2862 * 2863 * @private 2864 * @param {Array} array The array to modify. 2865 * @param {Array} values The values to append. 2866 * @returns {Array} Returns `array`. 2867 */ 2868 function arrayPush(array, values) { 2869 var index = -1, 2870 length = values.length, 2871 offset = array.length; 2872 2873 while (++index < length) { 2874 array[offset + index] = values[index]; 2875 } 2876 return array; 2877 } 2878 2879 /** 2880 * A specialized version of `_.reduce` for arrays without support for 2881 * iteratee shorthands. 2882 * 2883 * @private 2884 * @param {Array} [array] The array to iterate over. 2885 * @param {Function} iteratee The function invoked per iteration. 2886 * @param {*} [accumulator] The initial value. 2887 * @param {boolean} [initAccum] Specify using the first element of `array` as 2888 * the initial value. 2889 * @returns {*} Returns the accumulated value. 2890 */ 2891 function arrayReduce(array, iteratee, accumulator, initAccum) { 2892 var index = -1, 2893 length = array == null ? 0 : array.length; 2894 2895 if (initAccum && length) { 2896 accumulator = array[++index]; 2897 } 2898 while (++index < length) { 2899 accumulator = iteratee(accumulator, array[index], index, array); 2900 } 2901 return accumulator; 2902 } 2903 2904 /** 2905 * A specialized version of `_.reduceRight` 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 * @param {*} [accumulator] The initial value. 2912 * @param {boolean} [initAccum] Specify using the last element of `array` as 2913 * the initial value. 2914 * @returns {*} Returns the accumulated value. 2915 */ 2916 function arrayReduceRight(array, iteratee, accumulator, initAccum) { 2917 var length = array == null ? 0 : array.length; 2918 if (initAccum && length) { 2919 accumulator = array[--length]; 2920 } 2921 while (length--) { 2922 accumulator = iteratee(accumulator, array[length], length, array); 2923 } 2924 return accumulator; 2925 } 2926 2927 /** 2928 * A specialized version of `_.some` for arrays without support for iteratee 2929 * shorthands. 2930 * 2931 * @private 2932 * @param {Array} [array] The array to iterate over. 2933 * @param {Function} predicate The function invoked per iteration. 2934 * @returns {boolean} Returns `true` if any element passes the predicate check, 2935 * else `false`. 2936 */ 2937 function arraySome(array, predicate) { 2938 var index = -1, 2939 length = array == null ? 0 : array.length; 2940 2941 while (++index < length) { 2942 if (predicate(array[index], index, array)) { 2943 return true; 2944 } 2945 } 2946 return false; 2947 } 2948 2949 /** 2950 * Gets the size of an ASCII `string`. 2951 * 2952 * @private 2953 * @param {string} string The string inspect. 2954 * @returns {number} Returns the string size. 2955 */ 2956 var asciiSize = baseProperty('length'); 2957 2958 /** 2959 * Converts an ASCII `string` to an array. 2960 * 2961 * @private 2962 * @param {string} string The string to convert. 2963 * @returns {Array} Returns the converted array. 2964 */ 2965 function asciiToArray(string) { 2966 return string.split(''); 2967 } 2968 2969 /** 2970 * Splits an ASCII `string` into an array of its words. 2971 * 2972 * @private 2973 * @param {string} The string to inspect. 2974 * @returns {Array} Returns the words of `string`. 2975 */ 2976 function asciiWords(string) { 2977 return string.match(reAsciiWord) || []; 2978 } 2979 2980 /** 2981 * The base implementation of methods like `_.findKey` and `_.findLastKey`, 2982 * without support for iteratee shorthands, which iterates over `collection` 2983 * using `eachFunc`. 2984 * 2985 * @private 2986 * @param {Array|Object} collection The collection to inspect. 2987 * @param {Function} predicate The function invoked per iteration. 2988 * @param {Function} eachFunc The function to iterate over `collection`. 2989 * @returns {*} Returns the found element or its key, else `undefined`. 2990 */ 2991 function baseFindKey(collection, predicate, eachFunc) { 2992 var result; 2993 eachFunc(collection, function(value, key, collection) { 2994 if (predicate(value, key, collection)) { 2995 result = key; 2996 return false; 2997 } 2998 }); 2999 return result; 3000 } 3001 3002 /** 3003 * The base implementation of `_.findIndex` and `_.findLastIndex` without 3004 * support for iteratee shorthands. 3005 * 3006 * @private 3007 * @param {Array} array The array to inspect. 3008 * @param {Function} predicate The function invoked per iteration. 3009 * @param {number} fromIndex The index to search from. 3010 * @param {boolean} [fromRight] Specify iterating from right to left. 3011 * @returns {number} Returns the index of the matched value, else `-1`. 3012 */ 3013 function baseFindIndex(array, predicate, fromIndex, fromRight) { 3014 var length = array.length, 3015 index = fromIndex + (fromRight ? 1 : -1); 3016 3017 while ((fromRight ? index-- : ++index < length)) { 3018 if (predicate(array[index], index, array)) { 3019 return index; 3020 } 3021 } 3022 return -1; 3023 } 3024 3025 /** 3026 * The base implementation of `_.indexOf` without `fromIndex` bounds checks. 3027 * 3028 * @private 3029 * @param {Array} array The array to inspect. 3030 * @param {*} value The value to search for. 3031 * @param {number} fromIndex The index to search from. 3032 * @returns {number} Returns the index of the matched value, else `-1`. 3033 */ 3034 function baseIndexOf(array, value, fromIndex) { 3035 return value === value 3036 ? strictIndexOf(array, value, fromIndex) 3037 : baseFindIndex(array, baseIsNaN, fromIndex); 3038 } 3039 3040 /** 3041 * This function is like `baseIndexOf` except that it accepts a comparator. 3042 * 3043 * @private 3044 * @param {Array} array The array to inspect. 3045 * @param {*} value The value to search for. 3046 * @param {number} fromIndex The index to search from. 3047 * @param {Function} comparator The comparator invoked per element. 3048 * @returns {number} Returns the index of the matched value, else `-1`. 3049 */ 3050 function baseIndexOfWith(array, value, fromIndex, comparator) { 3051 var index = fromIndex - 1, 3052 length = array.length; 3053 3054 while (++index < length) { 3055 if (comparator(array[index], value)) { 3056 return index; 3057 } 3058 } 3059 return -1; 3060 } 3061 3062 /** 3063 * The base implementation of `_.isNaN` without support for number objects. 3064 * 3065 * @private 3066 * @param {*} value The value to check. 3067 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 3068 */ 3069 function baseIsNaN(value) { 3070 return value !== value; 3071 } 3072 3073 /** 3074 * The base implementation of `_.mean` and `_.meanBy` without support for 3075 * iteratee shorthands. 3076 * 3077 * @private 3078 * @param {Array} array The array to iterate over. 3079 * @param {Function} iteratee The function invoked per iteration. 3080 * @returns {number} Returns the mean. 3081 */ 3082 function baseMean(array, iteratee) { 3083 var length = array == null ? 0 : array.length; 3084 return length ? (baseSum(array, iteratee) / length) : NAN; 3085 } 3086 3087 /** 3088 * The base implementation of `_.property` without support for deep paths. 3089 * 3090 * @private 3091 * @param {string} key The key of the property to get. 3092 * @returns {Function} Returns the new accessor function. 3093 */ 3094 function baseProperty(key) { 3095 return function(object) { 3096 return object == null ? undefined : object[key]; 3097 }; 3098 } 3099 3100 /** 3101 * The base implementation of `_.propertyOf` without support for deep paths. 3102 * 3103 * @private 3104 * @param {Object} object The object to query. 3105 * @returns {Function} Returns the new accessor function. 3106 */ 3107 function basePropertyOf(object) { 3108 return function(key) { 3109 return object == null ? undefined : object[key]; 3110 }; 3111 } 3112 3113 /** 3114 * The base implementation of `_.reduce` and `_.reduceRight`, without support 3115 * for iteratee shorthands, which iterates over `collection` using `eachFunc`. 3116 * 3117 * @private 3118 * @param {Array|Object} collection The collection to iterate over. 3119 * @param {Function} iteratee The function invoked per iteration. 3120 * @param {*} accumulator The initial value. 3121 * @param {boolean} initAccum Specify using the first or last element of 3122 * `collection` as the initial value. 3123 * @param {Function} eachFunc The function to iterate over `collection`. 3124 * @returns {*} Returns the accumulated value. 3125 */ 3126 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { 3127 eachFunc(collection, function(value, index, collection) { 3128 accumulator = initAccum 3129 ? (initAccum = false, value) 3130 : iteratee(accumulator, value, index, collection); 3131 }); 3132 return accumulator; 3133 } 3134 3135 /** 3136 * The base implementation of `_.sortBy` which uses `comparer` to define the 3137 * sort order of `array` and replaces criteria objects with their corresponding 3138 * values. 3139 * 3140 * @private 3141 * @param {Array} array The array to sort. 3142 * @param {Function} comparer The function to define sort order. 3143 * @returns {Array} Returns `array`. 3144 */ 3145 function baseSortBy(array, comparer) { 3146 var length = array.length; 3147 3148 array.sort(comparer); 3149 while (length--) { 3150 array[length] = array[length].value; 3151 } 3152 return array; 3153 } 3154 3155 /** 3156 * The base implementation of `_.sum` and `_.sumBy` without support for 3157 * iteratee shorthands. 3158 * 3159 * @private 3160 * @param {Array} array The array to iterate over. 3161 * @param {Function} iteratee The function invoked per iteration. 3162 * @returns {number} Returns the sum. 3163 */ 3164 function baseSum(array, iteratee) { 3165 var result, 3166 index = -1, 3167 length = array.length; 3168 3169 while (++index < length) { 3170 var current = iteratee(array[index]); 3171 if (current !== undefined) { 3172 result = result === undefined ? current : (result + current); 3173 } 3174 } 3175 return result; 3176 } 3177 3178 /** 3179 * The base implementation of `_.times` without support for iteratee shorthands 3180 * or max array length checks. 3181 * 3182 * @private 3183 * @param {number} n The number of times to invoke `iteratee`. 3184 * @param {Function} iteratee The function invoked per iteration. 3185 * @returns {Array} Returns the array of results. 3186 */ 3187 function baseTimes(n, iteratee) { 3188 var index = -1, 3189 result = Array(n); 3190 3191 while (++index < n) { 3192 result[index] = iteratee(index); 3193 } 3194 return result; 3195 } 3196 3197 /** 3198 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array 3199 * of key-value pairs for `object` corresponding to the property names of `props`. 3200 * 3201 * @private 3202 * @param {Object} object The object to query. 3203 * @param {Array} props The property names to get values for. 3204 * @returns {Object} Returns the key-value pairs. 3205 */ 3206 function baseToPairs(object, props) { 3207 return arrayMap(props, function(key) { 3208 return [key, object[key]]; 3209 }); 3210 } 3211 3212 /** 3213 * The base implementation of `_.trim`. 3214 * 3215 * @private 3216 * @param {string} string The string to trim. 3217 * @returns {string} Returns the trimmed string. 3218 */ 3219 function baseTrim(string) { 3220 return string 3221 ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') 3222 : string; 3223 } 3224 3225 /** 3226 * The base implementation of `_.unary` without support for storing metadata. 3227 * 3228 * @private 3229 * @param {Function} func The function to cap arguments for. 3230 * @returns {Function} Returns the new capped function. 3231 */ 3232 function baseUnary(func) { 3233 return function(value) { 3234 return func(value); 3235 }; 3236 } 3237 3238 /** 3239 * The base implementation of `_.values` and `_.valuesIn` which creates an 3240 * array of `object` property values corresponding to the property names 3241 * of `props`. 3242 * 3243 * @private 3244 * @param {Object} object The object to query. 3245 * @param {Array} props The property names to get values for. 3246 * @returns {Object} Returns the array of property values. 3247 */ 3248 function baseValues(object, props) { 3249 return arrayMap(props, function(key) { 3250 return object[key]; 3251 }); 3252 } 3253 3254 /** 3255 * Checks if a `cache` value for `key` exists. 3256 * 3257 * @private 3258 * @param {Object} cache The cache to query. 3259 * @param {string} key The key of the entry to check. 3260 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 3261 */ 3262 function cacheHas(cache, key) { 3263 return cache.has(key); 3264 } 3265 3266 /** 3267 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol 3268 * that is not found in the character symbols. 3269 * 3270 * @private 3271 * @param {Array} strSymbols The string symbols to inspect. 3272 * @param {Array} chrSymbols The character symbols to find. 3273 * @returns {number} Returns the index of the first unmatched string symbol. 3274 */ 3275 function charsStartIndex(strSymbols, chrSymbols) { 3276 var index = -1, 3277 length = strSymbols.length; 3278 3279 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 3280 return index; 3281 } 3282 3283 /** 3284 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol 3285 * that is not found in the character symbols. 3286 * 3287 * @private 3288 * @param {Array} strSymbols The string symbols to inspect. 3289 * @param {Array} chrSymbols The character symbols to find. 3290 * @returns {number} Returns the index of the last unmatched string symbol. 3291 */ 3292 function charsEndIndex(strSymbols, chrSymbols) { 3293 var index = strSymbols.length; 3294 3295 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 3296 return index; 3297 } 3298 3299 /** 3300 * Gets the number of `placeholder` occurrences in `array`. 3301 * 3302 * @private 3303 * @param {Array} array The array to inspect. 3304 * @param {*} placeholder The placeholder to search for. 3305 * @returns {number} Returns the placeholder count. 3306 */ 3307 function countHolders(array, placeholder) { 3308 var length = array.length, 3309 result = 0; 3310 3311 while (length--) { 3312 if (array[length] === placeholder) { 3313 ++result; 3314 } 3315 } 3316 return result; 3317 } 3318 3319 /** 3320 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A 3321 * letters to basic Latin letters. 3322 * 3323 * @private 3324 * @param {string} letter The matched letter to deburr. 3325 * @returns {string} Returns the deburred letter. 3326 */ 3327 var deburrLetter = basePropertyOf(deburredLetters); 3328 3329 /** 3330 * Used by `_.escape` to convert characters to HTML entities. 3331 * 3332 * @private 3333 * @param {string} chr The matched character to escape. 3334 * @returns {string} Returns the escaped character. 3335 */ 3336 var escapeHtmlChar = basePropertyOf(htmlEscapes); 3337 3338 /** 3339 * Used by `_.template` to escape characters for inclusion in compiled string literals. 3340 * 3341 * @private 3342 * @param {string} chr The matched character to escape. 3343 * @returns {string} Returns the escaped character. 3344 */ 3345 function escapeStringChar(chr) { 3346 return '\\' + stringEscapes[chr]; 3347 } 3348 3349 /** 3350 * Gets the value at `key` of `object`. 3351 * 3352 * @private 3353 * @param {Object} [object] The object to query. 3354 * @param {string} key The key of the property to get. 3355 * @returns {*} Returns the property value. 3356 */ 3357 function getValue(object, key) { 3358 return object == null ? undefined : object[key]; 3359 } 3360 3361 /** 3362 * Checks if `string` contains Unicode symbols. 3363 * 3364 * @private 3365 * @param {string} string The string to inspect. 3366 * @returns {boolean} Returns `true` if a symbol is found, else `false`. 3367 */ 3368 function hasUnicode(string) { 3369 return reHasUnicode.test(string); 3370 } 3371 3372 /** 3373 * Checks if `string` contains a word composed of Unicode symbols. 3374 * 3375 * @private 3376 * @param {string} string The string to inspect. 3377 * @returns {boolean} Returns `true` if a word is found, else `false`. 3378 */ 3379 function hasUnicodeWord(string) { 3380 return reHasUnicodeWord.test(string); 3381 } 3382 3383 /** 3384 * Converts `iterator` to an array. 3385 * 3386 * @private 3387 * @param {Object} iterator The iterator to convert. 3388 * @returns {Array} Returns the converted array. 3389 */ 3390 function iteratorToArray(iterator) { 3391 var data, 3392 result = []; 3393 3394 while (!(data = iterator.next()).done) { 3395 result.push(data.value); 3396 } 3397 return result; 3398 } 3399 3400 /** 3401 * Converts `map` to its key-value pairs. 3402 * 3403 * @private 3404 * @param {Object} map The map to convert. 3405 * @returns {Array} Returns the key-value pairs. 3406 */ 3407 function mapToArray(map) { 3408 var index = -1, 3409 result = Array(map.size); 3410 3411 map.forEach(function(value, key) { 3412 result[++index] = [key, value]; 3413 }); 3414 return result; 3415 } 3416 3417 /** 3418 * Creates a unary function that invokes `func` with its argument transformed. 3419 * 3420 * @private 3421 * @param {Function} func The function to wrap. 3422 * @param {Function} transform The argument transform. 3423 * @returns {Function} Returns the new function. 3424 */ 3425 function overArg(func, transform) { 3426 return function(arg) { 3427 return func(transform(arg)); 3428 }; 3429 } 3430 3431 /** 3432 * Replaces all `placeholder` elements in `array` with an internal placeholder 3433 * and returns an array of their indexes. 3434 * 3435 * @private 3436 * @param {Array} array The array to modify. 3437 * @param {*} placeholder The placeholder to replace. 3438 * @returns {Array} Returns the new array of placeholder indexes. 3439 */ 3440 function replaceHolders(array, placeholder) { 3441 var index = -1, 3442 length = array.length, 3443 resIndex = 0, 3444 result = []; 3445 3446 while (++index < length) { 3447 var value = array[index]; 3448 if (value === placeholder || value === PLACEHOLDER) { 3449 array[index] = PLACEHOLDER; 3450 result[resIndex++] = index; 3451 } 3452 } 3453 return result; 3454 } 3455 3456 /** 3457 * Converts `set` to an array of its values. 3458 * 3459 * @private 3460 * @param {Object} set The set to convert. 3461 * @returns {Array} Returns the values. 3462 */ 3463 function setToArray(set) { 3464 var index = -1, 3465 result = Array(set.size); 3466 3467 set.forEach(function(value) { 3468 result[++index] = value; 3469 }); 3470 return result; 3471 } 3472 3473 /** 3474 * Converts `set` to its value-value pairs. 3475 * 3476 * @private 3477 * @param {Object} set The set to convert. 3478 * @returns {Array} Returns the value-value pairs. 3479 */ 3480 function setToPairs(set) { 3481 var index = -1, 3482 result = Array(set.size); 3483 3484 set.forEach(function(value) { 3485 result[++index] = [value, value]; 3486 }); 3487 return result; 3488 } 3489 3490 /** 3491 * A specialized version of `_.indexOf` which performs strict equality 3492 * comparisons of values, i.e. `===`. 3493 * 3494 * @private 3495 * @param {Array} array The array to inspect. 3496 * @param {*} value The value to search for. 3497 * @param {number} fromIndex The index to search from. 3498 * @returns {number} Returns the index of the matched value, else `-1`. 3499 */ 3500 function strictIndexOf(array, value, fromIndex) { 3501 var index = fromIndex - 1, 3502 length = array.length; 3503 3504 while (++index < length) { 3505 if (array[index] === value) { 3506 return index; 3507 } 3508 } 3509 return -1; 3510 } 3511 3512 /** 3513 * A specialized version of `_.lastIndexOf` which performs strict equality 3514 * comparisons of values, i.e. `===`. 3515 * 3516 * @private 3517 * @param {Array} array The array to inspect. 3518 * @param {*} value The value to search for. 3519 * @param {number} fromIndex The index to search from. 3520 * @returns {number} Returns the index of the matched value, else `-1`. 3521 */ 3522 function strictLastIndexOf(array, value, fromIndex) { 3523 var index = fromIndex + 1; 3524 while (index--) { 3525 if (array[index] === value) { 3526 return index; 3527 } 3528 } 3529 return index; 3530 } 3531 3532 /** 3533 * Gets the number of symbols in `string`. 3534 * 3535 * @private 3536 * @param {string} string The string to inspect. 3537 * @returns {number} Returns the string size. 3538 */ 3539 function stringSize(string) { 3540 return hasUnicode(string) 3541 ? unicodeSize(string) 3542 : asciiSize(string); 3543 } 3544 3545 /** 3546 * Converts `string` to an array. 3547 * 3548 * @private 3549 * @param {string} string The string to convert. 3550 * @returns {Array} Returns the converted array. 3551 */ 3552 function stringToArray(string) { 3553 return hasUnicode(string) 3554 ? unicodeToArray(string) 3555 : asciiToArray(string); 3556 } 3557 3558 /** 3559 * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace 3560 * character of `string`. 3561 * 3562 * @private 3563 * @param {string} string The string to inspect. 3564 * @returns {number} Returns the index of the last non-whitespace character. 3565 */ 3566 function trimmedEndIndex(string) { 3567 var index = string.length; 3568 3569 while (index-- && reWhitespace.test(string.charAt(index))) {} 3570 return index; 3571 } 3572 3573 /** 3574 * Used by `_.unescape` to convert HTML entities to characters. 3575 * 3576 * @private 3577 * @param {string} chr The matched character to unescape. 3578 * @returns {string} Returns the unescaped character. 3579 */ 3580 var unescapeHtmlChar = basePropertyOf(htmlUnescapes); 3581 3582 /** 3583 * Gets the size of a Unicode `string`. 3584 * 3585 * @private 3586 * @param {string} string The string inspect. 3587 * @returns {number} Returns the string size. 3588 */ 3589 function unicodeSize(string) { 3590 var result = reUnicode.lastIndex = 0; 3591 while (reUnicode.test(string)) { 3592 ++result; 3593 } 3594 return result; 3595 } 3596 3597 /** 3598 * Converts a Unicode `string` to an array. 3599 * 3600 * @private 3601 * @param {string} string The string to convert. 3602 * @returns {Array} Returns the converted array. 3603 */ 3604 function unicodeToArray(string) { 3605 return string.match(reUnicode) || []; 3606 } 3607 3608 /** 3609 * Splits a Unicode `string` into an array of its words. 3610 * 3611 * @private 3612 * @param {string} The string to inspect. 3613 * @returns {Array} Returns the words of `string`. 3614 */ 3615 function unicodeWords(string) { 3616 return string.match(reUnicodeWord) || []; 3617 } 3618 3619 /*--------------------------------------------------------------------------*/ 3620 3621 /** 3622 * Create a new pristine `lodash` function using the `context` object. 3623 * 3624 * @static 3625 * @memberOf _ 3626 * @since 1.1.0 3627 * @category Util 3628 * @param {Object} [context=root] The context object. 3629 * @returns {Function} Returns a new `lodash` function. 3630 * @example 3631 * 3632 * _.mixin({ 'foo': _.constant('foo') }); 3633 * 3634 * var lodash = _.runInContext(); 3635 * lodash.mixin({ 'bar': lodash.constant('bar') }); 3636 * 3637 * _.isFunction(_.foo); 3638 * // => true 3639 * _.isFunction(_.bar); 3640 * // => false 3641 * 3642 * lodash.isFunction(lodash.foo); 3643 * // => false 3644 * lodash.isFunction(lodash.bar); 3645 * // => true 3646 * 3647 * // Create a suped-up `defer` in Node.js. 3648 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; 3649 */ 3650 var runInContext = (function runInContext(context) { 3651 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); 3652 3653 /** Built-in constructor references. */ 3654 var Array = context.Array, 3655 Date = context.Date, 3656 Error = context.Error, 3657 Function = context.Function, 3658 Math = context.Math, 3659 Object = context.Object, 3660 RegExp = context.RegExp, 3661 String = context.String, 3662 TypeError = context.TypeError; 3663 3664 /** Used for built-in method references. */ 3665 var arrayProto = Array.prototype, 3666 funcProto = Function.prototype, 3667 objectProto = Object.prototype; 3668 3669 /** Used to detect overreaching core-js shims. */ 3670 var coreJsData = context['__core-js_shared__']; 3671 3672 /** Used to resolve the decompiled source of functions. */ 3673 var funcToString = funcProto.toString; 3674 3675 /** Used to check objects for own properties. */ 3676 var hasOwnProperty = objectProto.hasOwnProperty; 3677 3678 /** Used to generate unique IDs. */ 3679 var idCounter = 0; 3680 3681 /** Used to detect methods masquerading as native. */ 3682 var maskSrcKey = (function() { 3683 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); 3684 return uid ? ('Symbol(src)_1.' + uid) : ''; 3685 }()); 3686 3687 /** 3688 * Used to resolve the 3689 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 3690 * of values. 3691 */ 3692 var nativeObjectToString = objectProto.toString; 3693 3694 /** Used to infer the `Object` constructor. */ 3695 var objectCtorString = funcToString.call(Object); 3696 3697 /** Used to restore the original `_` reference in `_.noConflict`. */ 3698 var oldDash = root._; 3699 3700 /** Used to detect if a method is native. */ 3701 var reIsNative = RegExp('^' + 3702 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') 3703 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 3704 ); 3705 3706 /** Built-in value references. */ 3707 var Buffer = moduleExports ? context.Buffer : undefined, 3708 Symbol = context.Symbol, 3709 Uint8Array = context.Uint8Array, 3710 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, 3711 getPrototype = overArg(Object.getPrototypeOf, Object), 3712 objectCreate = Object.create, 3713 propertyIsEnumerable = objectProto.propertyIsEnumerable, 3714 splice = arrayProto.splice, 3715 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, 3716 symIterator = Symbol ? Symbol.iterator : undefined, 3717 symToStringTag = Symbol ? Symbol.toStringTag : undefined; 3718 3719 var defineProperty = (function() { 3720 try { 3721 var func = getNative(Object, 'defineProperty'); 3722 func({}, '', {}); 3723 return func; 3724 } catch (e) {} 3725 }()); 3726 3727 /** Mocked built-ins. */ 3728 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, 3729 ctxNow = Date && Date.now !== root.Date.now && Date.now, 3730 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; 3731 3732 /* Built-in method references for those with the same name as other `lodash` methods. */ 3733 var nativeCeil = Math.ceil, 3734 nativeFloor = Math.floor, 3735 nativeGetSymbols = Object.getOwnPropertySymbols, 3736 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, 3737 nativeIsFinite = context.isFinite, 3738 nativeJoin = arrayProto.join, 3739 nativeKeys = overArg(Object.keys, Object), 3740 nativeMax = Math.max, 3741 nativeMin = Math.min, 3742 nativeNow = Date.now, 3743 nativeParseInt = context.parseInt, 3744 nativeRandom = Math.random, 3745 nativeReverse = arrayProto.reverse; 3746 3747 /* Built-in method references that are verified to be native. */ 3748 var DataView = getNative(context, 'DataView'), 3749 Map = getNative(context, 'Map'), 3750 Promise = getNative(context, 'Promise'), 3751 Set = getNative(context, 'Set'), 3752 WeakMap = getNative(context, 'WeakMap'), 3753 nativeCreate = getNative(Object, 'create'); 3754 3755 /** Used to store function metadata. */ 3756 var metaMap = WeakMap && new WeakMap; 3757 3758 /** Used to lookup unminified function names. */ 3759 var realNames = {}; 3760 3761 /** Used to detect maps, sets, and weakmaps. */ 3762 var dataViewCtorString = toSource(DataView), 3763 mapCtorString = toSource(Map), 3764 promiseCtorString = toSource(Promise), 3765 setCtorString = toSource(Set), 3766 weakMapCtorString = toSource(WeakMap); 3767 3768 /** Used to convert symbols to primitives and strings. */ 3769 var symbolProto = Symbol ? Symbol.prototype : undefined, 3770 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, 3771 symbolToString = symbolProto ? symbolProto.toString : undefined; 3772 3773 /*------------------------------------------------------------------------*/ 3774 3775 /** 3776 * Creates a `lodash` object which wraps `value` to enable implicit method 3777 * chain sequences. Methods that operate on and return arrays, collections, 3778 * and functions can be chained together. Methods that retrieve a single value 3779 * or may return a primitive value will automatically end the chain sequence 3780 * and return the unwrapped value. Otherwise, the value must be unwrapped 3781 * with `_#value`. 3782 * 3783 * Explicit chain sequences, which must be unwrapped with `_#value`, may be 3784 * enabled using `_.chain`. 3785 * 3786 * The execution of chained methods is lazy, that is, it's deferred until 3787 * `_#value` is implicitly or explicitly called. 3788 * 3789 * Lazy evaluation allows several methods to support shortcut fusion. 3790 * Shortcut fusion is an optimization to merge iteratee calls; this avoids 3791 * the creation of intermediate arrays and can greatly reduce the number of 3792 * iteratee executions. Sections of a chain sequence qualify for shortcut 3793 * fusion if the section is applied to an array and iteratees accept only 3794 * one argument. The heuristic for whether a section qualifies for shortcut 3795 * fusion is subject to change. 3796 * 3797 * Chaining is supported in custom builds as long as the `_#value` method is 3798 * directly or indirectly included in the build. 3799 * 3800 * In addition to lodash methods, wrappers have `Array` and `String` methods. 3801 * 3802 * The wrapper `Array` methods are: 3803 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` 3804 * 3805 * The wrapper `String` methods are: 3806 * `replace` and `split` 3807 * 3808 * The wrapper methods that support shortcut fusion are: 3809 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, 3810 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, 3811 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` 3812 * 3813 * The chainable wrapper methods are: 3814 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, 3815 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, 3816 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, 3817 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, 3818 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, 3819 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, 3820 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, 3821 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, 3822 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, 3823 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, 3824 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, 3825 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, 3826 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, 3827 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, 3828 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, 3829 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, 3830 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, 3831 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, 3832 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, 3833 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, 3834 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, 3835 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, 3836 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, 3837 * `zipObject`, `zipObjectDeep`, and `zipWith` 3838 * 3839 * The wrapper methods that are **not** chainable by default are: 3840 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, 3841 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, 3842 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, 3843 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, 3844 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, 3845 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, 3846 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, 3847 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, 3848 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, 3849 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, 3850 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, 3851 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, 3852 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, 3853 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, 3854 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, 3855 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, 3856 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, 3857 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, 3858 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, 3859 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, 3860 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, 3861 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, 3862 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, 3863 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, 3864 * `upperFirst`, `value`, and `words` 3865 * 3866 * @name _ 3867 * @constructor 3868 * @category Seq 3869 * @param {*} value The value to wrap in a `lodash` instance. 3870 * @returns {Object} Returns the new `lodash` wrapper instance. 3871 * @example 3872 * 3873 * function square(n) { 3874 * return n * n; 3875 * } 3876 * 3877 * var wrapped = _([1, 2, 3]); 3878 * 3879 * // Returns an unwrapped value. 3880 * wrapped.reduce(_.add); 3881 * // => 6 3882 * 3883 * // Returns a wrapped value. 3884 * var squares = wrapped.map(square); 3885 * 3886 * _.isArray(squares); 3887 * // => false 3888 * 3889 * _.isArray(squares.value()); 3890 * // => true 3891 */ 3892 function lodash(value) { 3893 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { 3894 if (value instanceof LodashWrapper) { 3895 return value; 3896 } 3897 if (hasOwnProperty.call(value, '__wrapped__')) { 3898 return wrapperClone(value); 3899 } 3900 } 3901 return new LodashWrapper(value); 3902 } 3903 3904 /** 3905 * The base implementation of `_.create` without support for assigning 3906 * properties to the created object. 3907 * 3908 * @private 3909 * @param {Object} proto The object to inherit from. 3910 * @returns {Object} Returns the new object. 3911 */ 3912 var baseCreate = (function() { 3913 function object() {} 3914 return function(proto) { 3915 if (!isObject(proto)) { 3916 return {}; 3917 } 3918 if (objectCreate) { 3919 return objectCreate(proto); 3920 } 3921 object.prototype = proto; 3922 var result = new object; 3923 object.prototype = undefined; 3924 return result; 3925 }; 3926 }()); 3927 3928 /** 3929 * The function whose prototype chain sequence wrappers inherit from. 3930 * 3931 * @private 3932 */ 3933 function baseLodash() { 3934 // No operation performed. 3935 } 3936 3937 /** 3938 * The base constructor for creating `lodash` wrapper objects. 3939 * 3940 * @private 3941 * @param {*} value The value to wrap. 3942 * @param {boolean} [chainAll] Enable explicit method chain sequences. 3943 */ 3944 function LodashWrapper(value, chainAll) { 3945 this.__wrapped__ = value; 3946 this.__actions__ = []; 3947 this.__chain__ = !!chainAll; 3948 this.__index__ = 0; 3949 this.__values__ = undefined; 3950 } 3951 3952 /** 3953 * By default, the template delimiters used by lodash are like those in 3954 * embedded Ruby (ERB) as well as ES2015 template strings. Change the 3955 * following template settings to use alternative delimiters. 3956 * 3957 * @static 3958 * @memberOf _ 3959 * @type {Object} 3960 */ 3961 lodash.templateSettings = { 3962 3963 /** 3964 * Used to detect `data` property values to be HTML-escaped. 3965 * 3966 * @memberOf _.templateSettings 3967 * @type {RegExp} 3968 */ 3969 'escape': reEscape, 3970 3971 /** 3972 * Used to detect code to be evaluated. 3973 * 3974 * @memberOf _.templateSettings 3975 * @type {RegExp} 3976 */ 3977 'evaluate': reEvaluate, 3978 3979 /** 3980 * Used to detect `data` property values to inject. 3981 * 3982 * @memberOf _.templateSettings 3983 * @type {RegExp} 3984 */ 3985 'interpolate': reInterpolate, 3986 3987 /** 3988 * Used to reference the data object in the template text. 3989 * 3990 * @memberOf _.templateSettings 3991 * @type {string} 3992 */ 3993 'variable': '', 3994 3995 /** 3996 * Used to import variables into the compiled template. 3997 * 3998 * @memberOf _.templateSettings 3999 * @type {Object} 4000 */ 4001 'imports': { 4002 4003 /** 4004 * A reference to the `lodash` function. 4005 * 4006 * @memberOf _.templateSettings.imports 4007 * @type {Function} 4008 */ 4009 '_': lodash 4010 } 4011 }; 4012 4013 // Ensure wrappers are instances of `baseLodash`. 4014 lodash.prototype = baseLodash.prototype; 4015 lodash.prototype.constructor = lodash; 4016 4017 LodashWrapper.prototype = baseCreate(baseLodash.prototype); 4018 LodashWrapper.prototype.constructor = LodashWrapper; 4019 4020 /*------------------------------------------------------------------------*/ 4021 4022 /** 4023 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. 4024 * 4025 * @private 4026 * @constructor 4027 * @param {*} value The value to wrap. 4028 */ 4029 function LazyWrapper(value) { 4030 this.__wrapped__ = value; 4031 this.__actions__ = []; 4032 this.__dir__ = 1; 4033 this.__filtered__ = false; 4034 this.__iteratees__ = []; 4035 this.__takeCount__ = MAX_ARRAY_LENGTH; 4036 this.__views__ = []; 4037 } 4038 4039 /** 4040 * Creates a clone of the lazy wrapper object. 4041 * 4042 * @private 4043 * @name clone 4044 * @memberOf LazyWrapper 4045 * @returns {Object} Returns the cloned `LazyWrapper` object. 4046 */ 4047 function lazyClone() { 4048 var result = new LazyWrapper(this.__wrapped__); 4049 result.__actions__ = copyArray(this.__actions__); 4050 result.__dir__ = this.__dir__; 4051 result.__filtered__ = this.__filtered__; 4052 result.__iteratees__ = copyArray(this.__iteratees__); 4053 result.__takeCount__ = this.__takeCount__; 4054 result.__views__ = copyArray(this.__views__); 4055 return result; 4056 } 4057 4058 /** 4059 * Reverses the direction of lazy iteration. 4060 * 4061 * @private 4062 * @name reverse 4063 * @memberOf LazyWrapper 4064 * @returns {Object} Returns the new reversed `LazyWrapper` object. 4065 */ 4066 function lazyReverse() { 4067 if (this.__filtered__) { 4068 var result = new LazyWrapper(this); 4069 result.__dir__ = -1; 4070 result.__filtered__ = true; 4071 } else { 4072 result = this.clone(); 4073 result.__dir__ *= -1; 4074 } 4075 return result; 4076 } 4077 4078 /** 4079 * Extracts the unwrapped value from its lazy wrapper. 4080 * 4081 * @private 4082 * @name value 4083 * @memberOf LazyWrapper 4084 * @returns {*} Returns the unwrapped value. 4085 */ 4086 function lazyValue() { 4087 var array = this.__wrapped__.value(), 4088 dir = this.__dir__, 4089 isArr = isArray(array), 4090 isRight = dir < 0, 4091 arrLength = isArr ? array.length : 0, 4092 view = getView(0, arrLength, this.__views__), 4093 start = view.start, 4094 end = view.end, 4095 length = end - start, 4096 index = isRight ? end : (start - 1), 4097 iteratees = this.__iteratees__, 4098 iterLength = iteratees.length, 4099 resIndex = 0, 4100 takeCount = nativeMin(length, this.__takeCount__); 4101 4102 if (!isArr || (!isRight && arrLength == length && takeCount == length)) { 4103 return baseWrapperValue(array, this.__actions__); 4104 } 4105 var result = []; 4106 4107 outer: 4108 while (length-- && resIndex < takeCount) { 4109 index += dir; 4110 4111 var iterIndex = -1, 4112 value = array[index]; 4113 4114 while (++iterIndex < iterLength) { 4115 var data = iteratees[iterIndex], 4116 iteratee = data.iteratee, 4117 type = data.type, 4118 computed = iteratee(value); 4119 4120 if (type == LAZY_MAP_FLAG) { 4121 value = computed; 4122 } else if (!computed) { 4123 if (type == LAZY_FILTER_FLAG) { 4124 continue outer; 4125 } else { 4126 break outer; 4127 } 4128 } 4129 } 4130 result[resIndex++] = value; 4131 } 4132 return result; 4133 } 4134 4135 // Ensure `LazyWrapper` is an instance of `baseLodash`. 4136 LazyWrapper.prototype = baseCreate(baseLodash.prototype); 4137 LazyWrapper.prototype.constructor = LazyWrapper; 4138 4139 /*------------------------------------------------------------------------*/ 4140 4141 /** 4142 * Creates a hash object. 4143 * 4144 * @private 4145 * @constructor 4146 * @param {Array} [entries] The key-value pairs to cache. 4147 */ 4148 function Hash(entries) { 4149 var index = -1, 4150 length = entries == null ? 0 : entries.length; 4151 4152 this.clear(); 4153 while (++index < length) { 4154 var entry = entries[index]; 4155 this.set(entry[0], entry[1]); 4156 } 4157 } 4158 4159 /** 4160 * Removes all key-value entries from the hash. 4161 * 4162 * @private 4163 * @name clear 4164 * @memberOf Hash 4165 */ 4166 function hashClear() { 4167 this.__data__ = nativeCreate ? nativeCreate(null) : {}; 4168 this.size = 0; 4169 } 4170 4171 /** 4172 * Removes `key` and its value from the hash. 4173 * 4174 * @private 4175 * @name delete 4176 * @memberOf Hash 4177 * @param {Object} hash The hash to modify. 4178 * @param {string} key The key of the value to remove. 4179 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 4180 */ 4181 function hashDelete(key) { 4182 var result = this.has(key) && delete this.__data__[key]; 4183 this.size -= result ? 1 : 0; 4184 return result; 4185 } 4186 4187 /** 4188 * Gets the hash value for `key`. 4189 * 4190 * @private 4191 * @name get 4192 * @memberOf Hash 4193 * @param {string} key The key of the value to get. 4194 * @returns {*} Returns the entry value. 4195 */ 4196 function hashGet(key) { 4197 var data = this.__data__; 4198 if (nativeCreate) { 4199 var result = data[key]; 4200 return result === HASH_UNDEFINED ? undefined : result; 4201 } 4202 return hasOwnProperty.call(data, key) ? data[key] : undefined; 4203 } 4204 4205 /** 4206 * Checks if a hash value for `key` exists. 4207 * 4208 * @private 4209 * @name has 4210 * @memberOf Hash 4211 * @param {string} key The key of the entry to check. 4212 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 4213 */ 4214 function hashHas(key) { 4215 var data = this.__data__; 4216 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); 4217 } 4218 4219 /** 4220 * Sets the hash `key` to `value`. 4221 * 4222 * @private 4223 * @name set 4224 * @memberOf Hash 4225 * @param {string} key The key of the value to set. 4226 * @param {*} value The value to set. 4227 * @returns {Object} Returns the hash instance. 4228 */ 4229 function hashSet(key, value) { 4230 var data = this.__data__; 4231 this.size += this.has(key) ? 0 : 1; 4232 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; 4233 return this; 4234 } 4235 4236 // Add methods to `Hash`. 4237 Hash.prototype.clear = hashClear; 4238 Hash.prototype['delete'] = hashDelete; 4239 Hash.prototype.get = hashGet; 4240 Hash.prototype.has = hashHas; 4241 Hash.prototype.set = hashSet; 4242 4243 /*------------------------------------------------------------------------*/ 4244 4245 /** 4246 * Creates an list cache object. 4247 * 4248 * @private 4249 * @constructor 4250 * @param {Array} [entries] The key-value pairs to cache. 4251 */ 4252 function ListCache(entries) { 4253 var index = -1, 4254 length = entries == null ? 0 : entries.length; 4255 4256 this.clear(); 4257 while (++index < length) { 4258 var entry = entries[index]; 4259 this.set(entry[0], entry[1]); 4260 } 4261 } 4262 4263 /** 4264 * Removes all key-value entries from the list cache. 4265 * 4266 * @private 4267 * @name clear 4268 * @memberOf ListCache 4269 */ 4270 function listCacheClear() { 4271 this.__data__ = []; 4272 this.size = 0; 4273 } 4274 4275 /** 4276 * Removes `key` and its value from the list cache. 4277 * 4278 * @private 4279 * @name delete 4280 * @memberOf ListCache 4281 * @param {string} key The key of the value to remove. 4282 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 4283 */ 4284 function listCacheDelete(key) { 4285 var data = this.__data__, 4286 index = assocIndexOf(data, key); 4287 4288 if (index < 0) { 4289 return false; 4290 } 4291 var lastIndex = data.length - 1; 4292 if (index == lastIndex) { 4293 data.pop(); 4294 } else { 4295 splice.call(data, index, 1); 4296 } 4297 --this.size; 4298 return true; 4299 } 4300 4301 /** 4302 * Gets the list cache value for `key`. 4303 * 4304 * @private 4305 * @name get 4306 * @memberOf ListCache 4307 * @param {string} key The key of the value to get. 4308 * @returns {*} Returns the entry value. 4309 */ 4310 function listCacheGet(key) { 4311 var data = this.__data__, 4312 index = assocIndexOf(data, key); 4313 4314 return index < 0 ? undefined : data[index][1]; 4315 } 4316 4317 /** 4318 * Checks if a list cache value for `key` exists. 4319 * 4320 * @private 4321 * @name has 4322 * @memberOf ListCache 4323 * @param {string} key The key of the entry to check. 4324 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 4325 */ 4326 function listCacheHas(key) { 4327 return assocIndexOf(this.__data__, key) > -1; 4328 } 4329 4330 /** 4331 * Sets the list cache `key` to `value`. 4332 * 4333 * @private 4334 * @name set 4335 * @memberOf ListCache 4336 * @param {string} key The key of the value to set. 4337 * @param {*} value The value to set. 4338 * @returns {Object} Returns the list cache instance. 4339 */ 4340 function listCacheSet(key, value) { 4341 var data = this.__data__, 4342 index = assocIndexOf(data, key); 4343 4344 if (index < 0) { 4345 ++this.size; 4346 data.push([key, value]); 4347 } else { 4348 data[index][1] = value; 4349 } 4350 return this; 4351 } 4352 4353 // Add methods to `ListCache`. 4354 ListCache.prototype.clear = listCacheClear; 4355 ListCache.prototype['delete'] = listCacheDelete; 4356 ListCache.prototype.get = listCacheGet; 4357 ListCache.prototype.has = listCacheHas; 4358 ListCache.prototype.set = listCacheSet; 4359 4360 /*------------------------------------------------------------------------*/ 4361 4362 /** 4363 * Creates a map cache object to store key-value pairs. 4364 * 4365 * @private 4366 * @constructor 4367 * @param {Array} [entries] The key-value pairs to cache. 4368 */ 4369 function MapCache(entries) { 4370 var index = -1, 4371 length = entries == null ? 0 : entries.length; 4372 4373 this.clear(); 4374 while (++index < length) { 4375 var entry = entries[index]; 4376 this.set(entry[0], entry[1]); 4377 } 4378 } 4379 4380 /** 4381 * Removes all key-value entries from the map. 4382 * 4383 * @private 4384 * @name clear 4385 * @memberOf MapCache 4386 */ 4387 function mapCacheClear() { 4388 this.size = 0; 4389 this.__data__ = { 4390 'hash': new Hash, 4391 'map': new (Map || ListCache), 4392 'string': new Hash 4393 }; 4394 } 4395 4396 /** 4397 * Removes `key` and its value from the map. 4398 * 4399 * @private 4400 * @name delete 4401 * @memberOf MapCache 4402 * @param {string} key The key of the value to remove. 4403 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 4404 */ 4405 function mapCacheDelete(key) { 4406 var result = getMapData(this, key)['delete'](key); 4407 this.size -= result ? 1 : 0; 4408 return result; 4409 } 4410 4411 /** 4412 * Gets the map value for `key`. 4413 * 4414 * @private 4415 * @name get 4416 * @memberOf MapCache 4417 * @param {string} key The key of the value to get. 4418 * @returns {*} Returns the entry value. 4419 */ 4420 function mapCacheGet(key) { 4421 return getMapData(this, key).get(key); 4422 } 4423 4424 /** 4425 * Checks if a map value for `key` exists. 4426 * 4427 * @private 4428 * @name has 4429 * @memberOf MapCache 4430 * @param {string} key The key of the entry to check. 4431 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 4432 */ 4433 function mapCacheHas(key) { 4434 return getMapData(this, key).has(key); 4435 } 4436 4437 /** 4438 * Sets the map `key` to `value`. 4439 * 4440 * @private 4441 * @name set 4442 * @memberOf MapCache 4443 * @param {string} key The key of the value to set. 4444 * @param {*} value The value to set. 4445 * @returns {Object} Returns the map cache instance. 4446 */ 4447 function mapCacheSet(key, value) { 4448 var data = getMapData(this, key), 4449 size = data.size; 4450 4451 data.set(key, value); 4452 this.size += data.size == size ? 0 : 1; 4453 return this; 4454 } 4455 4456 // Add methods to `MapCache`. 4457 MapCache.prototype.clear = mapCacheClear; 4458 MapCache.prototype['delete'] = mapCacheDelete; 4459 MapCache.prototype.get = mapCacheGet; 4460 MapCache.prototype.has = mapCacheHas; 4461 MapCache.prototype.set = mapCacheSet; 4462 4463 /*------------------------------------------------------------------------*/ 4464 4465 /** 4466 * 4467 * Creates an array cache object to store unique values. 4468 * 4469 * @private 4470 * @constructor 4471 * @param {Array} [values] The values to cache. 4472 */ 4473 function SetCache(values) { 4474 var index = -1, 4475 length = values == null ? 0 : values.length; 4476 4477 this.__data__ = new MapCache; 4478 while (++index < length) { 4479 this.add(values[index]); 4480 } 4481 } 4482 4483 /** 4484 * Adds `value` to the array cache. 4485 * 4486 * @private 4487 * @name add 4488 * @memberOf SetCache 4489 * @alias push 4490 * @param {*} value The value to cache. 4491 * @returns {Object} Returns the cache instance. 4492 */ 4493 function setCacheAdd(value) { 4494 this.__data__.set(value, HASH_UNDEFINED); 4495 return this; 4496 } 4497 4498 /** 4499 * Checks if `value` is in the array cache. 4500 * 4501 * @private 4502 * @name has 4503 * @memberOf SetCache 4504 * @param {*} value The value to search for. 4505 * @returns {number} Returns `true` if `value` is found, else `false`. 4506 */ 4507 function setCacheHas(value) { 4508 return this.__data__.has(value); 4509 } 4510 4511 // Add methods to `SetCache`. 4512 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; 4513 SetCache.prototype.has = setCacheHas; 4514 4515 /*------------------------------------------------------------------------*/ 4516 4517 /** 4518 * Creates a stack cache object to store key-value pairs. 4519 * 4520 * @private 4521 * @constructor 4522 * @param {Array} [entries] The key-value pairs to cache. 4523 */ 4524 function Stack(entries) { 4525 var data = this.__data__ = new ListCache(entries); 4526 this.size = data.size; 4527 } 4528 4529 /** 4530 * Removes all key-value entries from the stack. 4531 * 4532 * @private 4533 * @name clear 4534 * @memberOf Stack 4535 */ 4536 function stackClear() { 4537 this.__data__ = new ListCache; 4538 this.size = 0; 4539 } 4540 4541 /** 4542 * Removes `key` and its value from the stack. 4543 * 4544 * @private 4545 * @name delete 4546 * @memberOf Stack 4547 * @param {string} key The key of the value to remove. 4548 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 4549 */ 4550 function stackDelete(key) { 4551 var data = this.__data__, 4552 result = data['delete'](key); 4553 4554 this.size = data.size; 4555 return result; 4556 } 4557 4558 /** 4559 * Gets the stack value for `key`. 4560 * 4561 * @private 4562 * @name get 4563 * @memberOf Stack 4564 * @param {string} key The key of the value to get. 4565 * @returns {*} Returns the entry value. 4566 */ 4567 function stackGet(key) { 4568 return this.__data__.get(key); 4569 } 4570 4571 /** 4572 * Checks if a stack value for `key` exists. 4573 * 4574 * @private 4575 * @name has 4576 * @memberOf Stack 4577 * @param {string} key The key of the entry to check. 4578 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 4579 */ 4580 function stackHas(key) { 4581 return this.__data__.has(key); 4582 } 4583 4584 /** 4585 * Sets the stack `key` to `value`. 4586 * 4587 * @private 4588 * @name set 4589 * @memberOf Stack 4590 * @param {string} key The key of the value to set. 4591 * @param {*} value The value to set. 4592 * @returns {Object} Returns the stack cache instance. 4593 */ 4594 function stackSet(key, value) { 4595 var data = this.__data__; 4596 if (data instanceof ListCache) { 4597 var pairs = data.__data__; 4598 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { 4599 pairs.push([key, value]); 4600 this.size = ++data.size; 4601 return this; 4602 } 4603 data = this.__data__ = new MapCache(pairs); 4604 } 4605 data.set(key, value); 4606 this.size = data.size; 4607 return this; 4608 } 4609 4610 // Add methods to `Stack`. 4611 Stack.prototype.clear = stackClear; 4612 Stack.prototype['delete'] = stackDelete; 4613 Stack.prototype.get = stackGet; 4614 Stack.prototype.has = stackHas; 4615 Stack.prototype.set = stackSet; 4616 4617 /*------------------------------------------------------------------------*/ 4618 4619 /** 4620 * Creates an array of the enumerable property names of the array-like `value`. 4621 * 4622 * @private 4623 * @param {*} value The value to query. 4624 * @param {boolean} inherited Specify returning inherited property names. 4625 * @returns {Array} Returns the array of property names. 4626 */ 4627 function arrayLikeKeys(value, inherited) { 4628 var isArr = isArray(value), 4629 isArg = !isArr && isArguments(value), 4630 isBuff = !isArr && !isArg && isBuffer(value), 4631 isType = !isArr && !isArg && !isBuff && isTypedArray(value), 4632 skipIndexes = isArr || isArg || isBuff || isType, 4633 result = skipIndexes ? baseTimes(value.length, String) : [], 4634 length = result.length; 4635 4636 for (var key in value) { 4637 if ((inherited || hasOwnProperty.call(value, key)) && 4638 !(skipIndexes && ( 4639 // Safari 9 has enumerable `arguments.length` in strict mode. 4640 key == 'length' || 4641 // Node.js 0.10 has enumerable non-index properties on buffers. 4642 (isBuff && (key == 'offset' || key == 'parent')) || 4643 // PhantomJS 2 has enumerable non-index properties on typed arrays. 4644 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || 4645 // Skip index properties. 4646 isIndex(key, length) 4647 ))) { 4648 result.push(key); 4649 } 4650 } 4651 return result; 4652 } 4653 4654 /** 4655 * A specialized version of `_.sample` for arrays. 4656 * 4657 * @private 4658 * @param {Array} array The array to sample. 4659 * @returns {*} Returns the random element. 4660 */ 4661 function arraySample(array) { 4662 var length = array.length; 4663 return length ? array[baseRandom(0, length - 1)] : undefined; 4664 } 4665 4666 /** 4667 * A specialized version of `_.sampleSize` for arrays. 4668 * 4669 * @private 4670 * @param {Array} array The array to sample. 4671 * @param {number} n The number of elements to sample. 4672 * @returns {Array} Returns the random elements. 4673 */ 4674 function arraySampleSize(array, n) { 4675 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); 4676 } 4677 4678 /** 4679 * A specialized version of `_.shuffle` for arrays. 4680 * 4681 * @private 4682 * @param {Array} array The array to shuffle. 4683 * @returns {Array} Returns the new shuffled array. 4684 */ 4685 function arrayShuffle(array) { 4686 return shuffleSelf(copyArray(array)); 4687 } 4688 4689 /** 4690 * This function is like `assignValue` except that it doesn't assign 4691 * `undefined` values. 4692 * 4693 * @private 4694 * @param {Object} object The object to modify. 4695 * @param {string} key The key of the property to assign. 4696 * @param {*} value The value to assign. 4697 */ 4698 function assignMergeValue(object, key, value) { 4699 if ((value !== undefined && !eq(object[key], value)) || 4700 (value === undefined && !(key in object))) { 4701 baseAssignValue(object, key, value); 4702 } 4703 } 4704 4705 /** 4706 * Assigns `value` to `key` of `object` if the existing value is not equivalent 4707 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 4708 * for equality comparisons. 4709 * 4710 * @private 4711 * @param {Object} object The object to modify. 4712 * @param {string} key The key of the property to assign. 4713 * @param {*} value The value to assign. 4714 */ 4715 function assignValue(object, key, value) { 4716 var objValue = object[key]; 4717 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || 4718 (value === undefined && !(key in object))) { 4719 baseAssignValue(object, key, value); 4720 } 4721 } 4722 4723 /** 4724 * Gets the index at which the `key` is found in `array` of key-value pairs. 4725 * 4726 * @private 4727 * @param {Array} array The array to inspect. 4728 * @param {*} key The key to search for. 4729 * @returns {number} Returns the index of the matched value, else `-1`. 4730 */ 4731 function assocIndexOf(array, key) { 4732 var length = array.length; 4733 while (length--) { 4734 if (eq(array[length][0], key)) { 4735 return length; 4736 } 4737 } 4738 return -1; 4739 } 4740 4741 /** 4742 * Aggregates elements of `collection` on `accumulator` with keys transformed 4743 * by `iteratee` and values set by `setter`. 4744 * 4745 * @private 4746 * @param {Array|Object} collection The collection to iterate over. 4747 * @param {Function} setter The function to set `accumulator` values. 4748 * @param {Function} iteratee The iteratee to transform keys. 4749 * @param {Object} accumulator The initial aggregated object. 4750 * @returns {Function} Returns `accumulator`. 4751 */ 4752 function baseAggregator(collection, setter, iteratee, accumulator) { 4753 baseEach(collection, function(value, key, collection) { 4754 setter(accumulator, value, iteratee(value), collection); 4755 }); 4756 return accumulator; 4757 } 4758 4759 /** 4760 * The base implementation of `_.assign` without support for multiple sources 4761 * or `customizer` functions. 4762 * 4763 * @private 4764 * @param {Object} object The destination object. 4765 * @param {Object} source The source object. 4766 * @returns {Object} Returns `object`. 4767 */ 4768 function baseAssign(object, source) { 4769 return object && copyObject(source, keys(source), object); 4770 } 4771 4772 /** 4773 * The base implementation of `_.assignIn` without support for multiple sources 4774 * or `customizer` functions. 4775 * 4776 * @private 4777 * @param {Object} object The destination object. 4778 * @param {Object} source The source object. 4779 * @returns {Object} Returns `object`. 4780 */ 4781 function baseAssignIn(object, source) { 4782 return object && copyObject(source, keysIn(source), object); 4783 } 4784 4785 /** 4786 * The base implementation of `assignValue` and `assignMergeValue` without 4787 * value checks. 4788 * 4789 * @private 4790 * @param {Object} object The object to modify. 4791 * @param {string} key The key of the property to assign. 4792 * @param {*} value The value to assign. 4793 */ 4794 function baseAssignValue(object, key, value) { 4795 if (key == '__proto__' && defineProperty) { 4796 defineProperty(object, key, { 4797 'configurable': true, 4798 'enumerable': true, 4799 'value': value, 4800 'writable': true 4801 }); 4802 } else { 4803 object[key] = value; 4804 } 4805 } 4806 4807 /** 4808 * The base implementation of `_.at` without support for individual paths. 4809 * 4810 * @private 4811 * @param {Object} object The object to iterate over. 4812 * @param {string[]} paths The property paths to pick. 4813 * @returns {Array} Returns the picked elements. 4814 */ 4815 function baseAt(object, paths) { 4816 var index = -1, 4817 length = paths.length, 4818 result = Array(length), 4819 skip = object == null; 4820 4821 while (++index < length) { 4822 result[index] = skip ? undefined : get(object, paths[index]); 4823 } 4824 return result; 4825 } 4826 4827 /** 4828 * The base implementation of `_.clamp` which doesn't coerce arguments. 4829 * 4830 * @private 4831 * @param {number} number The number to clamp. 4832 * @param {number} [lower] The lower bound. 4833 * @param {number} upper The upper bound. 4834 * @returns {number} Returns the clamped number. 4835 */ 4836 function baseClamp(number, lower, upper) { 4837 if (number === number) { 4838 if (upper !== undefined) { 4839 number = number <= upper ? number : upper; 4840 } 4841 if (lower !== undefined) { 4842 number = number >= lower ? number : lower; 4843 } 4844 } 4845 return number; 4846 } 4847 4848 /** 4849 * The base implementation of `_.clone` and `_.cloneDeep` which tracks 4850 * traversed objects. 4851 * 4852 * @private 4853 * @param {*} value The value to clone. 4854 * @param {boolean} bitmask The bitmask flags. 4855 * 1 - Deep clone 4856 * 2 - Flatten inherited properties 4857 * 4 - Clone symbols 4858 * @param {Function} [customizer] The function to customize cloning. 4859 * @param {string} [key] The key of `value`. 4860 * @param {Object} [object] The parent object of `value`. 4861 * @param {Object} [stack] Tracks traversed objects and their clone counterparts. 4862 * @returns {*} Returns the cloned value. 4863 */ 4864 function baseClone(value, bitmask, customizer, key, object, stack) { 4865 var result, 4866 isDeep = bitmask & CLONE_DEEP_FLAG, 4867 isFlat = bitmask & CLONE_FLAT_FLAG, 4868 isFull = bitmask & CLONE_SYMBOLS_FLAG; 4869 4870 if (customizer) { 4871 result = object ? customizer(value, key, object, stack) : customizer(value); 4872 } 4873 if (result !== undefined) { 4874 return result; 4875 } 4876 if (!isObject(value)) { 4877 return value; 4878 } 4879 var isArr = isArray(value); 4880 if (isArr) { 4881 result = initCloneArray(value); 4882 if (!isDeep) { 4883 return copyArray(value, result); 4884 } 4885 } else { 4886 var tag = getTag(value), 4887 isFunc = tag == funcTag || tag == genTag; 4888 4889 if (isBuffer(value)) { 4890 return cloneBuffer(value, isDeep); 4891 } 4892 if (tag == objectTag || tag == argsTag || (isFunc && !object)) { 4893 result = (isFlat || isFunc) ? {} : initCloneObject(value); 4894 if (!isDeep) { 4895 return isFlat 4896 ? copySymbolsIn(value, baseAssignIn(result, value)) 4897 : copySymbols(value, baseAssign(result, value)); 4898 } 4899 } else { 4900 if (!cloneableTags[tag]) { 4901 return object ? value : {}; 4902 } 4903 result = initCloneByTag(value, tag, isDeep); 4904 } 4905 } 4906 // Check for circular references and return its corresponding clone. 4907 stack || (stack = new Stack); 4908 var stacked = stack.get(value); 4909 if (stacked) { 4910 return stacked; 4911 } 4912 stack.set(value, result); 4913 4914 if (isSet(value)) { 4915 value.forEach(function(subValue) { 4916 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); 4917 }); 4918 } else if (isMap(value)) { 4919 value.forEach(function(subValue, key) { 4920 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); 4921 }); 4922 } 4923 4924 var keysFunc = isFull 4925 ? (isFlat ? getAllKeysIn : getAllKeys) 4926 : (isFlat ? keysIn : keys); 4927 4928 var props = isArr ? undefined : keysFunc(value); 4929 arrayEach(props || value, function(subValue, key) { 4930 if (props) { 4931 key = subValue; 4932 subValue = value[key]; 4933 } 4934 // Recursively populate clone (susceptible to call stack limits). 4935 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); 4936 }); 4937 return result; 4938 } 4939 4940 /** 4941 * The base implementation of `_.conforms` which doesn't clone `source`. 4942 * 4943 * @private 4944 * @param {Object} source The object of property predicates to conform to. 4945 * @returns {Function} Returns the new spec function. 4946 */ 4947 function baseConforms(source) { 4948 var props = keys(source); 4949 return function(object) { 4950 return baseConformsTo(object, source, props); 4951 }; 4952 } 4953 4954 /** 4955 * The base implementation of `_.conformsTo` which accepts `props` to check. 4956 * 4957 * @private 4958 * @param {Object} object The object to inspect. 4959 * @param {Object} source The object of property predicates to conform to. 4960 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 4961 */ 4962 function baseConformsTo(object, source, props) { 4963 var length = props.length; 4964 if (object == null) { 4965 return !length; 4966 } 4967 object = Object(object); 4968 while (length--) { 4969 var key = props[length], 4970 predicate = source[key], 4971 value = object[key]; 4972 4973 if ((value === undefined && !(key in object)) || !predicate(value)) { 4974 return false; 4975 } 4976 } 4977 return true; 4978 } 4979 4980 /** 4981 * The base implementation of `_.delay` and `_.defer` which accepts `args` 4982 * to provide to `func`. 4983 * 4984 * @private 4985 * @param {Function} func The function to delay. 4986 * @param {number} wait The number of milliseconds to delay invocation. 4987 * @param {Array} args The arguments to provide to `func`. 4988 * @returns {number|Object} Returns the timer id or timeout object. 4989 */ 4990 function baseDelay(func, wait, args) { 4991 if (typeof func != 'function') { 4992 throw new TypeError(FUNC_ERROR_TEXT); 4993 } 4994 return setTimeout(function() { func.apply(undefined, args); }, wait); 4995 } 4996 4997 /** 4998 * The base implementation of methods like `_.difference` without support 4999 * for excluding multiple arrays or iteratee shorthands. 5000 * 5001 * @private 5002 * @param {Array} array The array to inspect. 5003 * @param {Array} values The values to exclude. 5004 * @param {Function} [iteratee] The iteratee invoked per element. 5005 * @param {Function} [comparator] The comparator invoked per element. 5006 * @returns {Array} Returns the new array of filtered values. 5007 */ 5008 function baseDifference(array, values, iteratee, comparator) { 5009 var index = -1, 5010 includes = arrayIncludes, 5011 isCommon = true, 5012 length = array.length, 5013 result = [], 5014 valuesLength = values.length; 5015 5016 if (!length) { 5017 return result; 5018 } 5019 if (iteratee) { 5020 values = arrayMap(values, baseUnary(iteratee)); 5021 } 5022 if (comparator) { 5023 includes = arrayIncludesWith; 5024 isCommon = false; 5025 } 5026 else if (values.length >= LARGE_ARRAY_SIZE) { 5027 includes = cacheHas; 5028 isCommon = false; 5029 values = new SetCache(values); 5030 } 5031 outer: 5032 while (++index < length) { 5033 var value = array[index], 5034 computed = iteratee == null ? value : iteratee(value); 5035 5036 value = (comparator || value !== 0) ? value : 0; 5037 if (isCommon && computed === computed) { 5038 var valuesIndex = valuesLength; 5039 while (valuesIndex--) { 5040 if (values[valuesIndex] === computed) { 5041 continue outer; 5042 } 5043 } 5044 result.push(value); 5045 } 5046 else if (!includes(values, computed, comparator)) { 5047 result.push(value); 5048 } 5049 } 5050 return result; 5051 } 5052 5053 /** 5054 * The base implementation of `_.forEach` without support for iteratee shorthands. 5055 * 5056 * @private 5057 * @param {Array|Object} collection The collection to iterate over. 5058 * @param {Function} iteratee The function invoked per iteration. 5059 * @returns {Array|Object} Returns `collection`. 5060 */ 5061 var baseEach = createBaseEach(baseForOwn); 5062 5063 /** 5064 * The base implementation of `_.forEachRight` without support for iteratee shorthands. 5065 * 5066 * @private 5067 * @param {Array|Object} collection The collection to iterate over. 5068 * @param {Function} iteratee The function invoked per iteration. 5069 * @returns {Array|Object} Returns `collection`. 5070 */ 5071 var baseEachRight = createBaseEach(baseForOwnRight, true); 5072 5073 /** 5074 * The base implementation of `_.every` without support for iteratee shorthands. 5075 * 5076 * @private 5077 * @param {Array|Object} collection The collection to iterate over. 5078 * @param {Function} predicate The function invoked per iteration. 5079 * @returns {boolean} Returns `true` if all elements pass the predicate check, 5080 * else `false` 5081 */ 5082 function baseEvery(collection, predicate) { 5083 var result = true; 5084 baseEach(collection, function(value, index, collection) { 5085 result = !!predicate(value, index, collection); 5086 return result; 5087 }); 5088 return result; 5089 } 5090 5091 /** 5092 * The base implementation of methods like `_.max` and `_.min` which accepts a 5093 * `comparator` to determine the extremum value. 5094 * 5095 * @private 5096 * @param {Array} array The array to iterate over. 5097 * @param {Function} iteratee The iteratee invoked per iteration. 5098 * @param {Function} comparator The comparator used to compare values. 5099 * @returns {*} Returns the extremum value. 5100 */ 5101 function baseExtremum(array, iteratee, comparator) { 5102 var index = -1, 5103 length = array.length; 5104 5105 while (++index < length) { 5106 var value = array[index], 5107 current = iteratee(value); 5108 5109 if (current != null && (computed === undefined 5110 ? (current === current && !isSymbol(current)) 5111 : comparator(current, computed) 5112 )) { 5113 var computed = current, 5114 result = value; 5115 } 5116 } 5117 return result; 5118 } 5119 5120 /** 5121 * The base implementation of `_.fill` without an iteratee call guard. 5122 * 5123 * @private 5124 * @param {Array} array The array to fill. 5125 * @param {*} value The value to fill `array` with. 5126 * @param {number} [start=0] The start position. 5127 * @param {number} [end=array.length] The end position. 5128 * @returns {Array} Returns `array`. 5129 */ 5130 function baseFill(array, value, start, end) { 5131 var length = array.length; 5132 5133 start = toInteger(start); 5134 if (start < 0) { 5135 start = -start > length ? 0 : (length + start); 5136 } 5137 end = (end === undefined || end > length) ? length : toInteger(end); 5138 if (end < 0) { 5139 end += length; 5140 } 5141 end = start > end ? 0 : toLength(end); 5142 while (start < end) { 5143 array[start++] = value; 5144 } 5145 return array; 5146 } 5147 5148 /** 5149 * The base implementation of `_.filter` without support for iteratee shorthands. 5150 * 5151 * @private 5152 * @param {Array|Object} collection The collection to iterate over. 5153 * @param {Function} predicate The function invoked per iteration. 5154 * @returns {Array} Returns the new filtered array. 5155 */ 5156 function baseFilter(collection, predicate) { 5157 var result = []; 5158 baseEach(collection, function(value, index, collection) { 5159 if (predicate(value, index, collection)) { 5160 result.push(value); 5161 } 5162 }); 5163 return result; 5164 } 5165 5166 /** 5167 * The base implementation of `_.flatten` with support for restricting flattening. 5168 * 5169 * @private 5170 * @param {Array} array The array to flatten. 5171 * @param {number} depth The maximum recursion depth. 5172 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. 5173 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. 5174 * @param {Array} [result=[]] The initial result value. 5175 * @returns {Array} Returns the new flattened array. 5176 */ 5177 function baseFlatten(array, depth, predicate, isStrict, result) { 5178 var index = -1, 5179 length = array.length; 5180 5181 predicate || (predicate = isFlattenable); 5182 result || (result = []); 5183 5184 while (++index < length) { 5185 var value = array[index]; 5186 if (depth > 0 && predicate(value)) { 5187 if (depth > 1) { 5188 // Recursively flatten arrays (susceptible to call stack limits). 5189 baseFlatten(value, depth - 1, predicate, isStrict, result); 5190 } else { 5191 arrayPush(result, value); 5192 } 5193 } else if (!isStrict) { 5194 result[result.length] = value; 5195 } 5196 } 5197 return result; 5198 } 5199 5200 /** 5201 * The base implementation of `baseForOwn` which iterates over `object` 5202 * properties returned by `keysFunc` and invokes `iteratee` for each property. 5203 * Iteratee functions may exit iteration early by explicitly returning `false`. 5204 * 5205 * @private 5206 * @param {Object} object The object to iterate over. 5207 * @param {Function} iteratee The function invoked per iteration. 5208 * @param {Function} keysFunc The function to get the keys of `object`. 5209 * @returns {Object} Returns `object`. 5210 */ 5211 var baseFor = createBaseFor(); 5212 5213 /** 5214 * This function is like `baseFor` except that it iterates over properties 5215 * in the opposite order. 5216 * 5217 * @private 5218 * @param {Object} object The object to iterate over. 5219 * @param {Function} iteratee The function invoked per iteration. 5220 * @param {Function} keysFunc The function to get the keys of `object`. 5221 * @returns {Object} Returns `object`. 5222 */ 5223 var baseForRight = createBaseFor(true); 5224 5225 /** 5226 * The base implementation of `_.forOwn` without support for iteratee shorthands. 5227 * 5228 * @private 5229 * @param {Object} object The object to iterate over. 5230 * @param {Function} iteratee The function invoked per iteration. 5231 * @returns {Object} Returns `object`. 5232 */ 5233 function baseForOwn(object, iteratee) { 5234 return object && baseFor(object, iteratee, keys); 5235 } 5236 5237 /** 5238 * The base implementation of `_.forOwnRight` without support for iteratee shorthands. 5239 * 5240 * @private 5241 * @param {Object} object The object to iterate over. 5242 * @param {Function} iteratee The function invoked per iteration. 5243 * @returns {Object} Returns `object`. 5244 */ 5245 function baseForOwnRight(object, iteratee) { 5246 return object && baseForRight(object, iteratee, keys); 5247 } 5248 5249 /** 5250 * The base implementation of `_.functions` which creates an array of 5251 * `object` function property names filtered from `props`. 5252 * 5253 * @private 5254 * @param {Object} object The object to inspect. 5255 * @param {Array} props The property names to filter. 5256 * @returns {Array} Returns the function names. 5257 */ 5258 function baseFunctions(object, props) { 5259 return arrayFilter(props, function(key) { 5260 return isFunction(object[key]); 5261 }); 5262 } 5263 5264 /** 5265 * The base implementation of `_.get` without support for default values. 5266 * 5267 * @private 5268 * @param {Object} object The object to query. 5269 * @param {Array|string} path The path of the property to get. 5270 * @returns {*} Returns the resolved value. 5271 */ 5272 function baseGet(object, path) { 5273 path = castPath(path, object); 5274 5275 var index = 0, 5276 length = path.length; 5277 5278 while (object != null && index < length) { 5279 object = object[toKey(path[index++])]; 5280 } 5281 return (index && index == length) ? object : undefined; 5282 } 5283 5284 /** 5285 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses 5286 * `keysFunc` and `symbolsFunc` to get the enumerable property names and 5287 * symbols of `object`. 5288 * 5289 * @private 5290 * @param {Object} object The object to query. 5291 * @param {Function} keysFunc The function to get the keys of `object`. 5292 * @param {Function} symbolsFunc The function to get the symbols of `object`. 5293 * @returns {Array} Returns the array of property names and symbols. 5294 */ 5295 function baseGetAllKeys(object, keysFunc, symbolsFunc) { 5296 var result = keysFunc(object); 5297 return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); 5298 } 5299 5300 /** 5301 * The base implementation of `getTag` without fallbacks for buggy environments. 5302 * 5303 * @private 5304 * @param {*} value The value to query. 5305 * @returns {string} Returns the `toStringTag`. 5306 */ 5307 function baseGetTag(value) { 5308 if (value == null) { 5309 return value === undefined ? undefinedTag : nullTag; 5310 } 5311 return (symToStringTag && symToStringTag in Object(value)) 5312 ? getRawTag(value) 5313 : objectToString(value); 5314 } 5315 5316 /** 5317 * The base implementation of `_.gt` which doesn't coerce arguments. 5318 * 5319 * @private 5320 * @param {*} value The value to compare. 5321 * @param {*} other The other value to compare. 5322 * @returns {boolean} Returns `true` if `value` is greater than `other`, 5323 * else `false`. 5324 */ 5325 function baseGt(value, other) { 5326 return value > other; 5327 } 5328 5329 /** 5330 * The base implementation of `_.has` without support for deep paths. 5331 * 5332 * @private 5333 * @param {Object} [object] The object to query. 5334 * @param {Array|string} key The key to check. 5335 * @returns {boolean} Returns `true` if `key` exists, else `false`. 5336 */ 5337 function baseHas(object, key) { 5338 return object != null && hasOwnProperty.call(object, key); 5339 } 5340 5341 /** 5342 * The base implementation of `_.hasIn` without support for deep paths. 5343 * 5344 * @private 5345 * @param {Object} [object] The object to query. 5346 * @param {Array|string} key The key to check. 5347 * @returns {boolean} Returns `true` if `key` exists, else `false`. 5348 */ 5349 function baseHasIn(object, key) { 5350 return object != null && key in Object(object); 5351 } 5352 5353 /** 5354 * The base implementation of `_.inRange` which doesn't coerce arguments. 5355 * 5356 * @private 5357 * @param {number} number The number to check. 5358 * @param {number} start The start of the range. 5359 * @param {number} end The end of the range. 5360 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 5361 */ 5362 function baseInRange(number, start, end) { 5363 return number >= nativeMin(start, end) && number < nativeMax(start, end); 5364 } 5365 5366 /** 5367 * The base implementation of methods like `_.intersection`, without support 5368 * for iteratee shorthands, that accepts an array of arrays to inspect. 5369 * 5370 * @private 5371 * @param {Array} arrays The arrays to inspect. 5372 * @param {Function} [iteratee] The iteratee invoked per element. 5373 * @param {Function} [comparator] The comparator invoked per element. 5374 * @returns {Array} Returns the new array of shared values. 5375 */ 5376 function baseIntersection(arrays, iteratee, comparator) { 5377 var includes = comparator ? arrayIncludesWith : arrayIncludes, 5378 length = arrays[0].length, 5379 othLength = arrays.length, 5380 othIndex = othLength, 5381 caches = Array(othLength), 5382 maxLength = Infinity, 5383 result = []; 5384 5385 while (othIndex--) { 5386 var array = arrays[othIndex]; 5387 if (othIndex && iteratee) { 5388 array = arrayMap(array, baseUnary(iteratee)); 5389 } 5390 maxLength = nativeMin(array.length, maxLength); 5391 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) 5392 ? new SetCache(othIndex && array) 5393 : undefined; 5394 } 5395 array = arrays[0]; 5396 5397 var index = -1, 5398 seen = caches[0]; 5399 5400 outer: 5401 while (++index < length && result.length < maxLength) { 5402 var value = array[index], 5403 computed = iteratee ? iteratee(value) : value; 5404 5405 value = (comparator || value !== 0) ? value : 0; 5406 if (!(seen 5407 ? cacheHas(seen, computed) 5408 : includes(result, computed, comparator) 5409 )) { 5410 othIndex = othLength; 5411 while (--othIndex) { 5412 var cache = caches[othIndex]; 5413 if (!(cache 5414 ? cacheHas(cache, computed) 5415 : includes(arrays[othIndex], computed, comparator)) 5416 ) { 5417 continue outer; 5418 } 5419 } 5420 if (seen) { 5421 seen.push(computed); 5422 } 5423 result.push(value); 5424 } 5425 } 5426 return result; 5427 } 5428 5429 /** 5430 * The base implementation of `_.invert` and `_.invertBy` which inverts 5431 * `object` with values transformed by `iteratee` and set by `setter`. 5432 * 5433 * @private 5434 * @param {Object} object The object to iterate over. 5435 * @param {Function} setter The function to set `accumulator` values. 5436 * @param {Function} iteratee The iteratee to transform values. 5437 * @param {Object} accumulator The initial inverted object. 5438 * @returns {Function} Returns `accumulator`. 5439 */ 5440 function baseInverter(object, setter, iteratee, accumulator) { 5441 baseForOwn(object, function(value, key, object) { 5442 setter(accumulator, iteratee(value), key, object); 5443 }); 5444 return accumulator; 5445 } 5446 5447 /** 5448 * The base implementation of `_.invoke` without support for individual 5449 * method arguments. 5450 * 5451 * @private 5452 * @param {Object} object The object to query. 5453 * @param {Array|string} path The path of the method to invoke. 5454 * @param {Array} args The arguments to invoke the method with. 5455 * @returns {*} Returns the result of the invoked method. 5456 */ 5457 function baseInvoke(object, path, args) { 5458 path = castPath(path, object); 5459 object = parent(object, path); 5460 var func = object == null ? object : object[toKey(last(path))]; 5461 return func == null ? undefined : apply(func, object, args); 5462 } 5463 5464 /** 5465 * The base implementation of `_.isArguments`. 5466 * 5467 * @private 5468 * @param {*} value The value to check. 5469 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 5470 */ 5471 function baseIsArguments(value) { 5472 return isObjectLike(value) && baseGetTag(value) == argsTag; 5473 } 5474 5475 /** 5476 * The base implementation of `_.isArrayBuffer` without Node.js optimizations. 5477 * 5478 * @private 5479 * @param {*} value The value to check. 5480 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 5481 */ 5482 function baseIsArrayBuffer(value) { 5483 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; 5484 } 5485 5486 /** 5487 * The base implementation of `_.isDate` without Node.js optimizations. 5488 * 5489 * @private 5490 * @param {*} value The value to check. 5491 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 5492 */ 5493 function baseIsDate(value) { 5494 return isObjectLike(value) && baseGetTag(value) == dateTag; 5495 } 5496 5497 /** 5498 * The base implementation of `_.isEqual` which supports partial comparisons 5499 * and tracks traversed objects. 5500 * 5501 * @private 5502 * @param {*} value The value to compare. 5503 * @param {*} other The other value to compare. 5504 * @param {boolean} bitmask The bitmask flags. 5505 * 1 - Unordered comparison 5506 * 2 - Partial comparison 5507 * @param {Function} [customizer] The function to customize comparisons. 5508 * @param {Object} [stack] Tracks traversed `value` and `other` objects. 5509 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 5510 */ 5511 function baseIsEqual(value, other, bitmask, customizer, stack) { 5512 if (value === other) { 5513 return true; 5514 } 5515 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { 5516 return value !== value && other !== other; 5517 } 5518 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); 5519 } 5520 5521 /** 5522 * A specialized version of `baseIsEqual` for arrays and objects which performs 5523 * deep comparisons and tracks traversed objects enabling objects with circular 5524 * references to be compared. 5525 * 5526 * @private 5527 * @param {Object} object The object to compare. 5528 * @param {Object} other The other object to compare. 5529 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 5530 * @param {Function} customizer The function to customize comparisons. 5531 * @param {Function} equalFunc The function to determine equivalents of values. 5532 * @param {Object} [stack] Tracks traversed `object` and `other` objects. 5533 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 5534 */ 5535 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { 5536 var objIsArr = isArray(object), 5537 othIsArr = isArray(other), 5538 objTag = objIsArr ? arrayTag : getTag(object), 5539 othTag = othIsArr ? arrayTag : getTag(other); 5540 5541 objTag = objTag == argsTag ? objectTag : objTag; 5542 othTag = othTag == argsTag ? objectTag : othTag; 5543 5544 var objIsObj = objTag == objectTag, 5545 othIsObj = othTag == objectTag, 5546 isSameTag = objTag == othTag; 5547 5548 if (isSameTag && isBuffer(object)) { 5549 if (!isBuffer(other)) { 5550 return false; 5551 } 5552 objIsArr = true; 5553 objIsObj = false; 5554 } 5555 if (isSameTag && !objIsObj) { 5556 stack || (stack = new Stack); 5557 return (objIsArr || isTypedArray(object)) 5558 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) 5559 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); 5560 } 5561 if (!(bitmask & COMPARE_PARTIAL_FLAG)) { 5562 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), 5563 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); 5564 5565 if (objIsWrapped || othIsWrapped) { 5566 var objUnwrapped = objIsWrapped ? object.value() : object, 5567 othUnwrapped = othIsWrapped ? other.value() : other; 5568 5569 stack || (stack = new Stack); 5570 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); 5571 } 5572 } 5573 if (!isSameTag) { 5574 return false; 5575 } 5576 stack || (stack = new Stack); 5577 return equalObjects(object, other, bitmask, customizer, equalFunc, stack); 5578 } 5579 5580 /** 5581 * The base implementation of `_.isMap` without Node.js optimizations. 5582 * 5583 * @private 5584 * @param {*} value The value to check. 5585 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 5586 */ 5587 function baseIsMap(value) { 5588 return isObjectLike(value) && getTag(value) == mapTag; 5589 } 5590 5591 /** 5592 * The base implementation of `_.isMatch` without support for iteratee shorthands. 5593 * 5594 * @private 5595 * @param {Object} object The object to inspect. 5596 * @param {Object} source The object of property values to match. 5597 * @param {Array} matchData The property names, values, and compare flags to match. 5598 * @param {Function} [customizer] The function to customize comparisons. 5599 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 5600 */ 5601 function baseIsMatch(object, source, matchData, customizer) { 5602 var index = matchData.length, 5603 length = index, 5604 noCustomizer = !customizer; 5605 5606 if (object == null) { 5607 return !length; 5608 } 5609 object = Object(object); 5610 while (index--) { 5611 var data = matchData[index]; 5612 if ((noCustomizer && data[2]) 5613 ? data[1] !== object[data[0]] 5614 : !(data[0] in object) 5615 ) { 5616 return false; 5617 } 5618 } 5619 while (++index < length) { 5620 data = matchData[index]; 5621 var key = data[0], 5622 objValue = object[key], 5623 srcValue = data[1]; 5624 5625 if (noCustomizer && data[2]) { 5626 if (objValue === undefined && !(key in object)) { 5627 return false; 5628 } 5629 } else { 5630 var stack = new Stack; 5631 if (customizer) { 5632 var result = customizer(objValue, srcValue, key, object, source, stack); 5633 } 5634 if (!(result === undefined 5635 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) 5636 : result 5637 )) { 5638 return false; 5639 } 5640 } 5641 } 5642 return true; 5643 } 5644 5645 /** 5646 * The base implementation of `_.isNative` without bad shim checks. 5647 * 5648 * @private 5649 * @param {*} value The value to check. 5650 * @returns {boolean} Returns `true` if `value` is a native function, 5651 * else `false`. 5652 */ 5653 function baseIsNative(value) { 5654 if (!isObject(value) || isMasked(value)) { 5655 return false; 5656 } 5657 var pattern = isFunction(value) ? reIsNative : reIsHostCtor; 5658 return pattern.test(toSource(value)); 5659 } 5660 5661 /** 5662 * The base implementation of `_.isRegExp` without Node.js optimizations. 5663 * 5664 * @private 5665 * @param {*} value The value to check. 5666 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 5667 */ 5668 function baseIsRegExp(value) { 5669 return isObjectLike(value) && baseGetTag(value) == regexpTag; 5670 } 5671 5672 /** 5673 * The base implementation of `_.isSet` without Node.js optimizations. 5674 * 5675 * @private 5676 * @param {*} value The value to check. 5677 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 5678 */ 5679 function baseIsSet(value) { 5680 return isObjectLike(value) && getTag(value) == setTag; 5681 } 5682 5683 /** 5684 * The base implementation of `_.isTypedArray` without Node.js optimizations. 5685 * 5686 * @private 5687 * @param {*} value The value to check. 5688 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 5689 */ 5690 function baseIsTypedArray(value) { 5691 return isObjectLike(value) && 5692 isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; 5693 } 5694 5695 /** 5696 * The base implementation of `_.iteratee`. 5697 * 5698 * @private 5699 * @param {*} [value=_.identity] The value to convert to an iteratee. 5700 * @returns {Function} Returns the iteratee. 5701 */ 5702 function baseIteratee(value) { 5703 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. 5704 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. 5705 if (typeof value == 'function') { 5706 return value; 5707 } 5708 if (value == null) { 5709 return identity; 5710 } 5711 if (typeof value == 'object') { 5712 return isArray(value) 5713 ? baseMatchesProperty(value[0], value[1]) 5714 : baseMatches(value); 5715 } 5716 return property(value); 5717 } 5718 5719 /** 5720 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. 5721 * 5722 * @private 5723 * @param {Object} object The object to query. 5724 * @returns {Array} Returns the array of property names. 5725 */ 5726 function baseKeys(object) { 5727 if (!isPrototype(object)) { 5728 return nativeKeys(object); 5729 } 5730 var result = []; 5731 for (var key in Object(object)) { 5732 if (hasOwnProperty.call(object, key) && key != 'constructor') { 5733 result.push(key); 5734 } 5735 } 5736 return result; 5737 } 5738 5739 /** 5740 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. 5741 * 5742 * @private 5743 * @param {Object} object The object to query. 5744 * @returns {Array} Returns the array of property names. 5745 */ 5746 function baseKeysIn(object) { 5747 if (!isObject(object)) { 5748 return nativeKeysIn(object); 5749 } 5750 var isProto = isPrototype(object), 5751 result = []; 5752 5753 for (var key in object) { 5754 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { 5755 result.push(key); 5756 } 5757 } 5758 return result; 5759 } 5760 5761 /** 5762 * The base implementation of `_.lt` which doesn't coerce arguments. 5763 * 5764 * @private 5765 * @param {*} value The value to compare. 5766 * @param {*} other The other value to compare. 5767 * @returns {boolean} Returns `true` if `value` is less than `other`, 5768 * else `false`. 5769 */ 5770 function baseLt(value, other) { 5771 return value < other; 5772 } 5773 5774 /** 5775 * The base implementation of `_.map` without support for iteratee shorthands. 5776 * 5777 * @private 5778 * @param {Array|Object} collection The collection to iterate over. 5779 * @param {Function} iteratee The function invoked per iteration. 5780 * @returns {Array} Returns the new mapped array. 5781 */ 5782 function baseMap(collection, iteratee) { 5783 var index = -1, 5784 result = isArrayLike(collection) ? Array(collection.length) : []; 5785 5786 baseEach(collection, function(value, key, collection) { 5787 result[++index] = iteratee(value, key, collection); 5788 }); 5789 return result; 5790 } 5791 5792 /** 5793 * The base implementation of `_.matches` which doesn't clone `source`. 5794 * 5795 * @private 5796 * @param {Object} source The object of property values to match. 5797 * @returns {Function} Returns the new spec function. 5798 */ 5799 function baseMatches(source) { 5800 var matchData = getMatchData(source); 5801 if (matchData.length == 1 && matchData[0][2]) { 5802 return matchesStrictComparable(matchData[0][0], matchData[0][1]); 5803 } 5804 return function(object) { 5805 return object === source || baseIsMatch(object, source, matchData); 5806 }; 5807 } 5808 5809 /** 5810 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. 5811 * 5812 * @private 5813 * @param {string} path The path of the property to get. 5814 * @param {*} srcValue The value to match. 5815 * @returns {Function} Returns the new spec function. 5816 */ 5817 function baseMatchesProperty(path, srcValue) { 5818 if (isKey(path) && isStrictComparable(srcValue)) { 5819 return matchesStrictComparable(toKey(path), srcValue); 5820 } 5821 return function(object) { 5822 var objValue = get(object, path); 5823 return (objValue === undefined && objValue === srcValue) 5824 ? hasIn(object, path) 5825 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); 5826 }; 5827 } 5828 5829 /** 5830 * The base implementation of `_.merge` without support for multiple sources. 5831 * 5832 * @private 5833 * @param {Object} object The destination object. 5834 * @param {Object} source The source object. 5835 * @param {number} srcIndex The index of `source`. 5836 * @param {Function} [customizer] The function to customize merged values. 5837 * @param {Object} [stack] Tracks traversed source values and their merged 5838 * counterparts. 5839 */ 5840 function baseMerge(object, source, srcIndex, customizer, stack) { 5841 if (object === source) { 5842 return; 5843 } 5844 baseFor(source, function(srcValue, key) { 5845 stack || (stack = new Stack); 5846 if (isObject(srcValue)) { 5847 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); 5848 } 5849 else { 5850 var newValue = customizer 5851 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) 5852 : undefined; 5853 5854 if (newValue === undefined) { 5855 newValue = srcValue; 5856 } 5857 assignMergeValue(object, key, newValue); 5858 } 5859 }, keysIn); 5860 } 5861 5862 /** 5863 * A specialized version of `baseMerge` for arrays and objects which performs 5864 * deep merges and tracks traversed objects enabling objects with circular 5865 * references to be merged. 5866 * 5867 * @private 5868 * @param {Object} object The destination object. 5869 * @param {Object} source The source object. 5870 * @param {string} key The key of the value to merge. 5871 * @param {number} srcIndex The index of `source`. 5872 * @param {Function} mergeFunc The function to merge values. 5873 * @param {Function} [customizer] The function to customize assigned values. 5874 * @param {Object} [stack] Tracks traversed source values and their merged 5875 * counterparts. 5876 */ 5877 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { 5878 var objValue = safeGet(object, key), 5879 srcValue = safeGet(source, key), 5880 stacked = stack.get(srcValue); 5881 5882 if (stacked) { 5883 assignMergeValue(object, key, stacked); 5884 return; 5885 } 5886 var newValue = customizer 5887 ? customizer(objValue, srcValue, (key + ''), object, source, stack) 5888 : undefined; 5889 5890 var isCommon = newValue === undefined; 5891 5892 if (isCommon) { 5893 var isArr = isArray(srcValue), 5894 isBuff = !isArr && isBuffer(srcValue), 5895 isTyped = !isArr && !isBuff && isTypedArray(srcValue); 5896 5897 newValue = srcValue; 5898 if (isArr || isBuff || isTyped) { 5899 if (isArray(objValue)) { 5900 newValue = objValue; 5901 } 5902 else if (isArrayLikeObject(objValue)) { 5903 newValue = copyArray(objValue); 5904 } 5905 else if (isBuff) { 5906 isCommon = false; 5907 newValue = cloneBuffer(srcValue, true); 5908 } 5909 else if (isTyped) { 5910 isCommon = false; 5911 newValue = cloneTypedArray(srcValue, true); 5912 } 5913 else { 5914 newValue = []; 5915 } 5916 } 5917 else if (isPlainObject(srcValue) || isArguments(srcValue)) { 5918 newValue = objValue; 5919 if (isArguments(objValue)) { 5920 newValue = toPlainObject(objValue); 5921 } 5922 else if (!isObject(objValue) || isFunction(objValue)) { 5923 newValue = initCloneObject(srcValue); 5924 } 5925 } 5926 else { 5927 isCommon = false; 5928 } 5929 } 5930 if (isCommon) { 5931 // Recursively merge objects and arrays (susceptible to call stack limits). 5932 stack.set(srcValue, newValue); 5933 mergeFunc(newValue, srcValue, srcIndex, customizer, stack); 5934 stack['delete'](srcValue); 5935 } 5936 assignMergeValue(object, key, newValue); 5937 } 5938 5939 /** 5940 * The base implementation of `_.nth` which doesn't coerce arguments. 5941 * 5942 * @private 5943 * @param {Array} array The array to query. 5944 * @param {number} n The index of the element to return. 5945 * @returns {*} Returns the nth element of `array`. 5946 */ 5947 function baseNth(array, n) { 5948 var length = array.length; 5949 if (!length) { 5950 return; 5951 } 5952 n += n < 0 ? length : 0; 5953 return isIndex(n, length) ? array[n] : undefined; 5954 } 5955 5956 /** 5957 * The base implementation of `_.orderBy` without param guards. 5958 * 5959 * @private 5960 * @param {Array|Object} collection The collection to iterate over. 5961 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. 5962 * @param {string[]} orders The sort orders of `iteratees`. 5963 * @returns {Array} Returns the new sorted array. 5964 */ 5965 function baseOrderBy(collection, iteratees, orders) { 5966 if (iteratees.length) { 5967 iteratees = arrayMap(iteratees, function(iteratee) { 5968 if (isArray(iteratee)) { 5969 return function(value) { 5970 return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); 5971 } 5972 } 5973 return iteratee; 5974 }); 5975 } else { 5976 iteratees = [identity]; 5977 } 5978 5979 var index = -1; 5980 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 5981 5982 var result = baseMap(collection, function(value, key, collection) { 5983 var criteria = arrayMap(iteratees, function(iteratee) { 5984 return iteratee(value); 5985 }); 5986 return { 'criteria': criteria, 'index': ++index, 'value': value }; 5987 }); 5988 5989 return baseSortBy(result, function(object, other) { 5990 return compareMultiple(object, other, orders); 5991 }); 5992 } 5993 5994 /** 5995 * The base implementation of `_.pick` without support for individual 5996 * property identifiers. 5997 * 5998 * @private 5999 * @param {Object} object The source object. 6000 * @param {string[]} paths The property paths to pick. 6001 * @returns {Object} Returns the new object. 6002 */ 6003 function basePick(object, paths) { 6004 return basePickBy(object, paths, function(value, path) { 6005 return hasIn(object, path); 6006 }); 6007 } 6008 6009 /** 6010 * The base implementation of `_.pickBy` without support for iteratee shorthands. 6011 * 6012 * @private 6013 * @param {Object} object The source object. 6014 * @param {string[]} paths The property paths to pick. 6015 * @param {Function} predicate The function invoked per property. 6016 * @returns {Object} Returns the new object. 6017 */ 6018 function basePickBy(object, paths, predicate) { 6019 var index = -1, 6020 length = paths.length, 6021 result = {}; 6022 6023 while (++index < length) { 6024 var path = paths[index], 6025 value = baseGet(object, path); 6026 6027 if (predicate(value, path)) { 6028 baseSet(result, castPath(path, object), value); 6029 } 6030 } 6031 return result; 6032 } 6033 6034 /** 6035 * A specialized version of `baseProperty` which supports deep paths. 6036 * 6037 * @private 6038 * @param {Array|string} path The path of the property to get. 6039 * @returns {Function} Returns the new accessor function. 6040 */ 6041 function basePropertyDeep(path) { 6042 return function(object) { 6043 return baseGet(object, path); 6044 }; 6045 } 6046 6047 /** 6048 * The base implementation of `_.pullAllBy` without support for iteratee 6049 * shorthands. 6050 * 6051 * @private 6052 * @param {Array} array The array to modify. 6053 * @param {Array} values The values to remove. 6054 * @param {Function} [iteratee] The iteratee invoked per element. 6055 * @param {Function} [comparator] The comparator invoked per element. 6056 * @returns {Array} Returns `array`. 6057 */ 6058 function basePullAll(array, values, iteratee, comparator) { 6059 var indexOf = comparator ? baseIndexOfWith : baseIndexOf, 6060 index = -1, 6061 length = values.length, 6062 seen = array; 6063 6064 if (array === values) { 6065 values = copyArray(values); 6066 } 6067 if (iteratee) { 6068 seen = arrayMap(array, baseUnary(iteratee)); 6069 } 6070 while (++index < length) { 6071 var fromIndex = 0, 6072 value = values[index], 6073 computed = iteratee ? iteratee(value) : value; 6074 6075 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { 6076 if (seen !== array) { 6077 splice.call(seen, fromIndex, 1); 6078 } 6079 splice.call(array, fromIndex, 1); 6080 } 6081 } 6082 return array; 6083 } 6084 6085 /** 6086 * The base implementation of `_.pullAt` without support for individual 6087 * indexes or capturing the removed elements. 6088 * 6089 * @private 6090 * @param {Array} array The array to modify. 6091 * @param {number[]} indexes The indexes of elements to remove. 6092 * @returns {Array} Returns `array`. 6093 */ 6094 function basePullAt(array, indexes) { 6095 var length = array ? indexes.length : 0, 6096 lastIndex = length - 1; 6097 6098 while (length--) { 6099 var index = indexes[length]; 6100 if (length == lastIndex || index !== previous) { 6101 var previous = index; 6102 if (isIndex(index)) { 6103 splice.call(array, index, 1); 6104 } else { 6105 baseUnset(array, index); 6106 } 6107 } 6108 } 6109 return array; 6110 } 6111 6112 /** 6113 * The base implementation of `_.random` without support for returning 6114 * floating-point numbers. 6115 * 6116 * @private 6117 * @param {number} lower The lower bound. 6118 * @param {number} upper The upper bound. 6119 * @returns {number} Returns the random number. 6120 */ 6121 function baseRandom(lower, upper) { 6122 return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); 6123 } 6124 6125 /** 6126 * The base implementation of `_.range` and `_.rangeRight` which doesn't 6127 * coerce arguments. 6128 * 6129 * @private 6130 * @param {number} start The start of the range. 6131 * @param {number} end The end of the range. 6132 * @param {number} step The value to increment or decrement by. 6133 * @param {boolean} [fromRight] Specify iterating from right to left. 6134 * @returns {Array} Returns the range of numbers. 6135 */ 6136 function baseRange(start, end, step, fromRight) { 6137 var index = -1, 6138 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), 6139 result = Array(length); 6140 6141 while (length--) { 6142 result[fromRight ? length : ++index] = start; 6143 start += step; 6144 } 6145 return result; 6146 } 6147 6148 /** 6149 * The base implementation of `_.repeat` which doesn't coerce arguments. 6150 * 6151 * @private 6152 * @param {string} string The string to repeat. 6153 * @param {number} n The number of times to repeat the string. 6154 * @returns {string} Returns the repeated string. 6155 */ 6156 function baseRepeat(string, n) { 6157 var result = ''; 6158 if (!string || n < 1 || n > MAX_SAFE_INTEGER) { 6159 return result; 6160 } 6161 // Leverage the exponentiation by squaring algorithm for a faster repeat. 6162 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. 6163 do { 6164 if (n % 2) { 6165 result += string; 6166 } 6167 n = nativeFloor(n / 2); 6168 if (n) { 6169 string += string; 6170 } 6171 } while (n); 6172 6173 return result; 6174 } 6175 6176 /** 6177 * The base implementation of `_.rest` which doesn't validate or coerce arguments. 6178 * 6179 * @private 6180 * @param {Function} func The function to apply a rest parameter to. 6181 * @param {number} [start=func.length-1] The start position of the rest parameter. 6182 * @returns {Function} Returns the new function. 6183 */ 6184 function baseRest(func, start) { 6185 return setToString(overRest(func, start, identity), func + ''); 6186 } 6187 6188 /** 6189 * The base implementation of `_.sample`. 6190 * 6191 * @private 6192 * @param {Array|Object} collection The collection to sample. 6193 * @returns {*} Returns the random element. 6194 */ 6195 function baseSample(collection) { 6196 return arraySample(values(collection)); 6197 } 6198 6199 /** 6200 * The base implementation of `_.sampleSize` without param guards. 6201 * 6202 * @private 6203 * @param {Array|Object} collection The collection to sample. 6204 * @param {number} n The number of elements to sample. 6205 * @returns {Array} Returns the random elements. 6206 */ 6207 function baseSampleSize(collection, n) { 6208 var array = values(collection); 6209 return shuffleSelf(array, baseClamp(n, 0, array.length)); 6210 } 6211 6212 /** 6213 * The base implementation of `_.set`. 6214 * 6215 * @private 6216 * @param {Object} object The object to modify. 6217 * @param {Array|string} path The path of the property to set. 6218 * @param {*} value The value to set. 6219 * @param {Function} [customizer] The function to customize path creation. 6220 * @returns {Object} Returns `object`. 6221 */ 6222 function baseSet(object, path, value, customizer) { 6223 if (!isObject(object)) { 6224 return object; 6225 } 6226 path = castPath(path, object); 6227 6228 var index = -1, 6229 length = path.length, 6230 lastIndex = length - 1, 6231 nested = object; 6232 6233 while (nested != null && ++index < length) { 6234 var key = toKey(path[index]), 6235 newValue = value; 6236 6237 if (key === '__proto__' || key === 'constructor' || key === 'prototype') { 6238 return object; 6239 } 6240 6241 if (index != lastIndex) { 6242 var objValue = nested[key]; 6243 newValue = customizer ? customizer(objValue, key, nested) : undefined; 6244 if (newValue === undefined) { 6245 newValue = isObject(objValue) 6246 ? objValue 6247 : (isIndex(path[index + 1]) ? [] : {}); 6248 } 6249 } 6250 assignValue(nested, key, newValue); 6251 nested = nested[key]; 6252 } 6253 return object; 6254 } 6255 6256 /** 6257 * The base implementation of `setData` without support for hot loop shorting. 6258 * 6259 * @private 6260 * @param {Function} func The function to associate metadata with. 6261 * @param {*} data The metadata. 6262 * @returns {Function} Returns `func`. 6263 */ 6264 var baseSetData = !metaMap ? identity : function(func, data) { 6265 metaMap.set(func, data); 6266 return func; 6267 }; 6268 6269 /** 6270 * The base implementation of `setToString` without support for hot loop shorting. 6271 * 6272 * @private 6273 * @param {Function} func The function to modify. 6274 * @param {Function} string The `toString` result. 6275 * @returns {Function} Returns `func`. 6276 */ 6277 var baseSetToString = !defineProperty ? identity : function(func, string) { 6278 return defineProperty(func, 'toString', { 6279 'configurable': true, 6280 'enumerable': false, 6281 'value': constant(string), 6282 'writable': true 6283 }); 6284 }; 6285 6286 /** 6287 * The base implementation of `_.shuffle`. 6288 * 6289 * @private 6290 * @param {Array|Object} collection The collection to shuffle. 6291 * @returns {Array} Returns the new shuffled array. 6292 */ 6293 function baseShuffle(collection) { 6294 return shuffleSelf(values(collection)); 6295 } 6296 6297 /** 6298 * The base implementation of `_.slice` without an iteratee call guard. 6299 * 6300 * @private 6301 * @param {Array} array The array to slice. 6302 * @param {number} [start=0] The start position. 6303 * @param {number} [end=array.length] The end position. 6304 * @returns {Array} Returns the slice of `array`. 6305 */ 6306 function baseSlice(array, start, end) { 6307 var index = -1, 6308 length = array.length; 6309 6310 if (start < 0) { 6311 start = -start > length ? 0 : (length + start); 6312 } 6313 end = end > length ? length : end; 6314 if (end < 0) { 6315 end += length; 6316 } 6317 length = start > end ? 0 : ((end - start) >>> 0); 6318 start >>>= 0; 6319 6320 var result = Array(length); 6321 while (++index < length) { 6322 result[index] = array[index + start]; 6323 } 6324 return result; 6325 } 6326 6327 /** 6328 * The base implementation of `_.some` without support for iteratee shorthands. 6329 * 6330 * @private 6331 * @param {Array|Object} collection The collection to iterate over. 6332 * @param {Function} predicate The function invoked per iteration. 6333 * @returns {boolean} Returns `true` if any element passes the predicate check, 6334 * else `false`. 6335 */ 6336 function baseSome(collection, predicate) { 6337 var result; 6338 6339 baseEach(collection, function(value, index, collection) { 6340 result = predicate(value, index, collection); 6341 return !result; 6342 }); 6343 return !!result; 6344 } 6345 6346 /** 6347 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which 6348 * performs a binary search of `array` to determine the index at which `value` 6349 * should be inserted into `array` in order to maintain its sort order. 6350 * 6351 * @private 6352 * @param {Array} array The sorted array to inspect. 6353 * @param {*} value The value to evaluate. 6354 * @param {boolean} [retHighest] Specify returning the highest qualified index. 6355 * @returns {number} Returns the index at which `value` should be inserted 6356 * into `array`. 6357 */ 6358 function baseSortedIndex(array, value, retHighest) { 6359 var low = 0, 6360 high = array == null ? low : array.length; 6361 6362 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { 6363 while (low < high) { 6364 var mid = (low + high) >>> 1, 6365 computed = array[mid]; 6366 6367 if (computed !== null && !isSymbol(computed) && 6368 (retHighest ? (computed <= value) : (computed < value))) { 6369 low = mid + 1; 6370 } else { 6371 high = mid; 6372 } 6373 } 6374 return high; 6375 } 6376 return baseSortedIndexBy(array, value, identity, retHighest); 6377 } 6378 6379 /** 6380 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` 6381 * which invokes `iteratee` for `value` and each element of `array` to compute 6382 * their sort ranking. The iteratee is invoked with one argument; (value). 6383 * 6384 * @private 6385 * @param {Array} array The sorted array to inspect. 6386 * @param {*} value The value to evaluate. 6387 * @param {Function} iteratee The iteratee invoked per element. 6388 * @param {boolean} [retHighest] Specify returning the highest qualified index. 6389 * @returns {number} Returns the index at which `value` should be inserted 6390 * into `array`. 6391 */ 6392 function baseSortedIndexBy(array, value, iteratee, retHighest) { 6393 var low = 0, 6394 high = array == null ? 0 : array.length; 6395 if (high === 0) { 6396 return 0; 6397 } 6398 6399 value = iteratee(value); 6400 var valIsNaN = value !== value, 6401 valIsNull = value === null, 6402 valIsSymbol = isSymbol(value), 6403 valIsUndefined = value === undefined; 6404 6405 while (low < high) { 6406 var mid = nativeFloor((low + high) / 2), 6407 computed = iteratee(array[mid]), 6408 othIsDefined = computed !== undefined, 6409 othIsNull = computed === null, 6410 othIsReflexive = computed === computed, 6411 othIsSymbol = isSymbol(computed); 6412 6413 if (valIsNaN) { 6414 var setLow = retHighest || othIsReflexive; 6415 } else if (valIsUndefined) { 6416 setLow = othIsReflexive && (retHighest || othIsDefined); 6417 } else if (valIsNull) { 6418 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); 6419 } else if (valIsSymbol) { 6420 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); 6421 } else if (othIsNull || othIsSymbol) { 6422 setLow = false; 6423 } else { 6424 setLow = retHighest ? (computed <= value) : (computed < value); 6425 } 6426 if (setLow) { 6427 low = mid + 1; 6428 } else { 6429 high = mid; 6430 } 6431 } 6432 return nativeMin(high, MAX_ARRAY_INDEX); 6433 } 6434 6435 /** 6436 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without 6437 * support for iteratee shorthands. 6438 * 6439 * @private 6440 * @param {Array} array The array to inspect. 6441 * @param {Function} [iteratee] The iteratee invoked per element. 6442 * @returns {Array} Returns the new duplicate free array. 6443 */ 6444 function baseSortedUniq(array, iteratee) { 6445 var index = -1, 6446 length = array.length, 6447 resIndex = 0, 6448 result = []; 6449 6450 while (++index < length) { 6451 var value = array[index], 6452 computed = iteratee ? iteratee(value) : value; 6453 6454 if (!index || !eq(computed, seen)) { 6455 var seen = computed; 6456 result[resIndex++] = value === 0 ? 0 : value; 6457 } 6458 } 6459 return result; 6460 } 6461 6462 /** 6463 * The base implementation of `_.toNumber` which doesn't ensure correct 6464 * conversions of binary, hexadecimal, or octal string values. 6465 * 6466 * @private 6467 * @param {*} value The value to process. 6468 * @returns {number} Returns the number. 6469 */ 6470 function baseToNumber(value) { 6471 if (typeof value == 'number') { 6472 return value; 6473 } 6474 if (isSymbol(value)) { 6475 return NAN; 6476 } 6477 return +value; 6478 } 6479 6480 /** 6481 * The base implementation of `_.toString` which doesn't convert nullish 6482 * values to empty strings. 6483 * 6484 * @private 6485 * @param {*} value The value to process. 6486 * @returns {string} Returns the string. 6487 */ 6488 function baseToString(value) { 6489 // Exit early for strings to avoid a performance hit in some environments. 6490 if (typeof value == 'string') { 6491 return value; 6492 } 6493 if (isArray(value)) { 6494 // Recursively convert values (susceptible to call stack limits). 6495 return arrayMap(value, baseToString) + ''; 6496 } 6497 if (isSymbol(value)) { 6498 return symbolToString ? symbolToString.call(value) : ''; 6499 } 6500 var result = (value + ''); 6501 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 6502 } 6503 6504 /** 6505 * The base implementation of `_.uniqBy` without support for iteratee shorthands. 6506 * 6507 * @private 6508 * @param {Array} array The array to inspect. 6509 * @param {Function} [iteratee] The iteratee invoked per element. 6510 * @param {Function} [comparator] The comparator invoked per element. 6511 * @returns {Array} Returns the new duplicate free array. 6512 */ 6513 function baseUniq(array, iteratee, comparator) { 6514 var index = -1, 6515 includes = arrayIncludes, 6516 length = array.length, 6517 isCommon = true, 6518 result = [], 6519 seen = result; 6520 6521 if (comparator) { 6522 isCommon = false; 6523 includes = arrayIncludesWith; 6524 } 6525 else if (length >= LARGE_ARRAY_SIZE) { 6526 var set = iteratee ? null : createSet(array); 6527 if (set) { 6528 return setToArray(set); 6529 } 6530 isCommon = false; 6531 includes = cacheHas; 6532 seen = new SetCache; 6533 } 6534 else { 6535 seen = iteratee ? [] : result; 6536 } 6537 outer: 6538 while (++index < length) { 6539 var value = array[index], 6540 computed = iteratee ? iteratee(value) : value; 6541 6542 value = (comparator || value !== 0) ? value : 0; 6543 if (isCommon && computed === computed) { 6544 var seenIndex = seen.length; 6545 while (seenIndex--) { 6546 if (seen[seenIndex] === computed) { 6547 continue outer; 6548 } 6549 } 6550 if (iteratee) { 6551 seen.push(computed); 6552 } 6553 result.push(value); 6554 } 6555 else if (!includes(seen, computed, comparator)) { 6556 if (seen !== result) { 6557 seen.push(computed); 6558 } 6559 result.push(value); 6560 } 6561 } 6562 return result; 6563 } 6564 6565 /** 6566 * The base implementation of `_.unset`. 6567 * 6568 * @private 6569 * @param {Object} object The object to modify. 6570 * @param {Array|string} path The property path to unset. 6571 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 6572 */ 6573 function baseUnset(object, path) { 6574 path = castPath(path, object); 6575 object = parent(object, path); 6576 return object == null || delete object[toKey(last(path))]; 6577 } 6578 6579 /** 6580 * The base implementation of `_.update`. 6581 * 6582 * @private 6583 * @param {Object} object The object to modify. 6584 * @param {Array|string} path The path of the property to update. 6585 * @param {Function} updater The function to produce the updated value. 6586 * @param {Function} [customizer] The function to customize path creation. 6587 * @returns {Object} Returns `object`. 6588 */ 6589 function baseUpdate(object, path, updater, customizer) { 6590 return baseSet(object, path, updater(baseGet(object, path)), customizer); 6591 } 6592 6593 /** 6594 * The base implementation of methods like `_.dropWhile` and `_.takeWhile` 6595 * without support for iteratee shorthands. 6596 * 6597 * @private 6598 * @param {Array} array The array to query. 6599 * @param {Function} predicate The function invoked per iteration. 6600 * @param {boolean} [isDrop] Specify dropping elements instead of taking them. 6601 * @param {boolean} [fromRight] Specify iterating from right to left. 6602 * @returns {Array} Returns the slice of `array`. 6603 */ 6604 function baseWhile(array, predicate, isDrop, fromRight) { 6605 var length = array.length, 6606 index = fromRight ? length : -1; 6607 6608 while ((fromRight ? index-- : ++index < length) && 6609 predicate(array[index], index, array)) {} 6610 6611 return isDrop 6612 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) 6613 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); 6614 } 6615 6616 /** 6617 * The base implementation of `wrapperValue` which returns the result of 6618 * performing a sequence of actions on the unwrapped `value`, where each 6619 * successive action is supplied the return value of the previous. 6620 * 6621 * @private 6622 * @param {*} value The unwrapped value. 6623 * @param {Array} actions Actions to perform to resolve the unwrapped value. 6624 * @returns {*} Returns the resolved value. 6625 */ 6626 function baseWrapperValue(value, actions) { 6627 var result = value; 6628 if (result instanceof LazyWrapper) { 6629 result = result.value(); 6630 } 6631 return arrayReduce(actions, function(result, action) { 6632 return action.func.apply(action.thisArg, arrayPush([result], action.args)); 6633 }, result); 6634 } 6635 6636 /** 6637 * The base implementation of methods like `_.xor`, without support for 6638 * iteratee shorthands, that accepts an array of arrays to inspect. 6639 * 6640 * @private 6641 * @param {Array} arrays The arrays to inspect. 6642 * @param {Function} [iteratee] The iteratee invoked per element. 6643 * @param {Function} [comparator] The comparator invoked per element. 6644 * @returns {Array} Returns the new array of values. 6645 */ 6646 function baseXor(arrays, iteratee, comparator) { 6647 var length = arrays.length; 6648 if (length < 2) { 6649 return length ? baseUniq(arrays[0]) : []; 6650 } 6651 var index = -1, 6652 result = Array(length); 6653 6654 while (++index < length) { 6655 var array = arrays[index], 6656 othIndex = -1; 6657 6658 while (++othIndex < length) { 6659 if (othIndex != index) { 6660 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); 6661 } 6662 } 6663 } 6664 return baseUniq(baseFlatten(result, 1), iteratee, comparator); 6665 } 6666 6667 /** 6668 * This base implementation of `_.zipObject` which assigns values using `assignFunc`. 6669 * 6670 * @private 6671 * @param {Array} props The property identifiers. 6672 * @param {Array} values The property values. 6673 * @param {Function} assignFunc The function to assign values. 6674 * @returns {Object} Returns the new object. 6675 */ 6676 function baseZipObject(props, values, assignFunc) { 6677 var index = -1, 6678 length = props.length, 6679 valsLength = values.length, 6680 result = {}; 6681 6682 while (++index < length) { 6683 var value = index < valsLength ? values[index] : undefined; 6684 assignFunc(result, props[index], value); 6685 } 6686 return result; 6687 } 6688 6689 /** 6690 * Casts `value` to an empty array if it's not an array like object. 6691 * 6692 * @private 6693 * @param {*} value The value to inspect. 6694 * @returns {Array|Object} Returns the cast array-like object. 6695 */ 6696 function castArrayLikeObject(value) { 6697 return isArrayLikeObject(value) ? value : []; 6698 } 6699 6700 /** 6701 * Casts `value` to `identity` if it's not a function. 6702 * 6703 * @private 6704 * @param {*} value The value to inspect. 6705 * @returns {Function} Returns cast function. 6706 */ 6707 function castFunction(value) { 6708 return typeof value == 'function' ? value : identity; 6709 } 6710 6711 /** 6712 * Casts `value` to a path array if it's not one. 6713 * 6714 * @private 6715 * @param {*} value The value to inspect. 6716 * @param {Object} [object] The object to query keys on. 6717 * @returns {Array} Returns the cast property path array. 6718 */ 6719 function castPath(value, object) { 6720 if (isArray(value)) { 6721 return value; 6722 } 6723 return isKey(value, object) ? [value] : stringToPath(toString(value)); 6724 } 6725 6726 /** 6727 * A `baseRest` alias which can be replaced with `identity` by module 6728 * replacement plugins. 6729 * 6730 * @private 6731 * @type {Function} 6732 * @param {Function} func The function to apply a rest parameter to. 6733 * @returns {Function} Returns the new function. 6734 */ 6735 var castRest = baseRest; 6736 6737 /** 6738 * Casts `array` to a slice if it's needed. 6739 * 6740 * @private 6741 * @param {Array} array The array to inspect. 6742 * @param {number} start The start position. 6743 * @param {number} [end=array.length] The end position. 6744 * @returns {Array} Returns the cast slice. 6745 */ 6746 function castSlice(array, start, end) { 6747 var length = array.length; 6748 end = end === undefined ? length : end; 6749 return (!start && end >= length) ? array : baseSlice(array, start, end); 6750 } 6751 6752 /** 6753 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). 6754 * 6755 * @private 6756 * @param {number|Object} id The timer id or timeout object of the timer to clear. 6757 */ 6758 var clearTimeout = ctxClearTimeout || function(id) { 6759 return root.clearTimeout(id); 6760 }; 6761 6762 /** 6763 * Creates a clone of `buffer`. 6764 * 6765 * @private 6766 * @param {Buffer} buffer The buffer to clone. 6767 * @param {boolean} [isDeep] Specify a deep clone. 6768 * @returns {Buffer} Returns the cloned buffer. 6769 */ 6770 function cloneBuffer(buffer, isDeep) { 6771 if (isDeep) { 6772 return buffer.slice(); 6773 } 6774 var length = buffer.length, 6775 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); 6776 6777 buffer.copy(result); 6778 return result; 6779 } 6780 6781 /** 6782 * Creates a clone of `arrayBuffer`. 6783 * 6784 * @private 6785 * @param {ArrayBuffer} arrayBuffer The array buffer to clone. 6786 * @returns {ArrayBuffer} Returns the cloned array buffer. 6787 */ 6788 function cloneArrayBuffer(arrayBuffer) { 6789 var result = new arrayBuffer.constructor(arrayBuffer.byteLength); 6790 new Uint8Array(result).set(new Uint8Array(arrayBuffer)); 6791 return result; 6792 } 6793 6794 /** 6795 * Creates a clone of `dataView`. 6796 * 6797 * @private 6798 * @param {Object} dataView The data view to clone. 6799 * @param {boolean} [isDeep] Specify a deep clone. 6800 * @returns {Object} Returns the cloned data view. 6801 */ 6802 function cloneDataView(dataView, isDeep) { 6803 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; 6804 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); 6805 } 6806 6807 /** 6808 * Creates a clone of `regexp`. 6809 * 6810 * @private 6811 * @param {Object} regexp The regexp to clone. 6812 * @returns {Object} Returns the cloned regexp. 6813 */ 6814 function cloneRegExp(regexp) { 6815 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); 6816 result.lastIndex = regexp.lastIndex; 6817 return result; 6818 } 6819 6820 /** 6821 * Creates a clone of the `symbol` object. 6822 * 6823 * @private 6824 * @param {Object} symbol The symbol object to clone. 6825 * @returns {Object} Returns the cloned symbol object. 6826 */ 6827 function cloneSymbol(symbol) { 6828 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; 6829 } 6830 6831 /** 6832 * Creates a clone of `typedArray`. 6833 * 6834 * @private 6835 * @param {Object} typedArray The typed array to clone. 6836 * @param {boolean} [isDeep] Specify a deep clone. 6837 * @returns {Object} Returns the cloned typed array. 6838 */ 6839 function cloneTypedArray(typedArray, isDeep) { 6840 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; 6841 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); 6842 } 6843 6844 /** 6845 * Compares values to sort them in ascending order. 6846 * 6847 * @private 6848 * @param {*} value The value to compare. 6849 * @param {*} other The other value to compare. 6850 * @returns {number} Returns the sort order indicator for `value`. 6851 */ 6852 function compareAscending(value, other) { 6853 if (value !== other) { 6854 var valIsDefined = value !== undefined, 6855 valIsNull = value === null, 6856 valIsReflexive = value === value, 6857 valIsSymbol = isSymbol(value); 6858 6859 var othIsDefined = other !== undefined, 6860 othIsNull = other === null, 6861 othIsReflexive = other === other, 6862 othIsSymbol = isSymbol(other); 6863 6864 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || 6865 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || 6866 (valIsNull && othIsDefined && othIsReflexive) || 6867 (!valIsDefined && othIsReflexive) || 6868 !valIsReflexive) { 6869 return 1; 6870 } 6871 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || 6872 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || 6873 (othIsNull && valIsDefined && valIsReflexive) || 6874 (!othIsDefined && valIsReflexive) || 6875 !othIsReflexive) { 6876 return -1; 6877 } 6878 } 6879 return 0; 6880 } 6881 6882 /** 6883 * Used by `_.orderBy` to compare multiple properties of a value to another 6884 * and stable sort them. 6885 * 6886 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, 6887 * specify an order of "desc" for descending or "asc" for ascending sort order 6888 * of corresponding values. 6889 * 6890 * @private 6891 * @param {Object} object The object to compare. 6892 * @param {Object} other The other object to compare. 6893 * @param {boolean[]|string[]} orders The order to sort by for each property. 6894 * @returns {number} Returns the sort order indicator for `object`. 6895 */ 6896 function compareMultiple(object, other, orders) { 6897 var index = -1, 6898 objCriteria = object.criteria, 6899 othCriteria = other.criteria, 6900 length = objCriteria.length, 6901 ordersLength = orders.length; 6902 6903 while (++index < length) { 6904 var result = compareAscending(objCriteria[index], othCriteria[index]); 6905 if (result) { 6906 if (index >= ordersLength) { 6907 return result; 6908 } 6909 var order = orders[index]; 6910 return result * (order == 'desc' ? -1 : 1); 6911 } 6912 } 6913 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications 6914 // that causes it, under certain circumstances, to provide the same value for 6915 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 6916 // for more details. 6917 // 6918 // This also ensures a stable sort in V8 and other engines. 6919 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. 6920 return object.index - other.index; 6921 } 6922 6923 /** 6924 * Creates an array that is the composition of partially applied arguments, 6925 * placeholders, and provided arguments into a single array of arguments. 6926 * 6927 * @private 6928 * @param {Array} args The provided arguments. 6929 * @param {Array} partials The arguments to prepend to those provided. 6930 * @param {Array} holders The `partials` placeholder indexes. 6931 * @params {boolean} [isCurried] Specify composing for a curried function. 6932 * @returns {Array} Returns the new array of composed arguments. 6933 */ 6934 function composeArgs(args, partials, holders, isCurried) { 6935 var argsIndex = -1, 6936 argsLength = args.length, 6937 holdersLength = holders.length, 6938 leftIndex = -1, 6939 leftLength = partials.length, 6940 rangeLength = nativeMax(argsLength - holdersLength, 0), 6941 result = Array(leftLength + rangeLength), 6942 isUncurried = !isCurried; 6943 6944 while (++leftIndex < leftLength) { 6945 result[leftIndex] = partials[leftIndex]; 6946 } 6947 while (++argsIndex < holdersLength) { 6948 if (isUncurried || argsIndex < argsLength) { 6949 result[holders[argsIndex]] = args[argsIndex]; 6950 } 6951 } 6952 while (rangeLength--) { 6953 result[leftIndex++] = args[argsIndex++]; 6954 } 6955 return result; 6956 } 6957 6958 /** 6959 * This function is like `composeArgs` except that the arguments composition 6960 * is tailored for `_.partialRight`. 6961 * 6962 * @private 6963 * @param {Array} args The provided arguments. 6964 * @param {Array} partials The arguments to append to those provided. 6965 * @param {Array} holders The `partials` placeholder indexes. 6966 * @params {boolean} [isCurried] Specify composing for a curried function. 6967 * @returns {Array} Returns the new array of composed arguments. 6968 */ 6969 function composeArgsRight(args, partials, holders, isCurried) { 6970 var argsIndex = -1, 6971 argsLength = args.length, 6972 holdersIndex = -1, 6973 holdersLength = holders.length, 6974 rightIndex = -1, 6975 rightLength = partials.length, 6976 rangeLength = nativeMax(argsLength - holdersLength, 0), 6977 result = Array(rangeLength + rightLength), 6978 isUncurried = !isCurried; 6979 6980 while (++argsIndex < rangeLength) { 6981 result[argsIndex] = args[argsIndex]; 6982 } 6983 var offset = argsIndex; 6984 while (++rightIndex < rightLength) { 6985 result[offset + rightIndex] = partials[rightIndex]; 6986 } 6987 while (++holdersIndex < holdersLength) { 6988 if (isUncurried || argsIndex < argsLength) { 6989 result[offset + holders[holdersIndex]] = args[argsIndex++]; 6990 } 6991 } 6992 return result; 6993 } 6994 6995 /** 6996 * Copies the values of `source` to `array`. 6997 * 6998 * @private 6999 * @param {Array} source The array to copy values from. 7000 * @param {Array} [array=[]] The array to copy values to. 7001 * @returns {Array} Returns `array`. 7002 */ 7003 function copyArray(source, array) { 7004 var index = -1, 7005 length = source.length; 7006 7007 array || (array = Array(length)); 7008 while (++index < length) { 7009 array[index] = source[index]; 7010 } 7011 return array; 7012 } 7013 7014 /** 7015 * Copies properties of `source` to `object`. 7016 * 7017 * @private 7018 * @param {Object} source The object to copy properties from. 7019 * @param {Array} props The property identifiers to copy. 7020 * @param {Object} [object={}] The object to copy properties to. 7021 * @param {Function} [customizer] The function to customize copied values. 7022 * @returns {Object} Returns `object`. 7023 */ 7024 function copyObject(source, props, object, customizer) { 7025 var isNew = !object; 7026 object || (object = {}); 7027 7028 var index = -1, 7029 length = props.length; 7030 7031 while (++index < length) { 7032 var key = props[index]; 7033 7034 var newValue = customizer 7035 ? customizer(object[key], source[key], key, object, source) 7036 : undefined; 7037 7038 if (newValue === undefined) { 7039 newValue = source[key]; 7040 } 7041 if (isNew) { 7042 baseAssignValue(object, key, newValue); 7043 } else { 7044 assignValue(object, key, newValue); 7045 } 7046 } 7047 return object; 7048 } 7049 7050 /** 7051 * Copies own symbols of `source` to `object`. 7052 * 7053 * @private 7054 * @param {Object} source The object to copy symbols from. 7055 * @param {Object} [object={}] The object to copy symbols to. 7056 * @returns {Object} Returns `object`. 7057 */ 7058 function copySymbols(source, object) { 7059 return copyObject(source, getSymbols(source), object); 7060 } 7061 7062 /** 7063 * Copies own and inherited symbols of `source` to `object`. 7064 * 7065 * @private 7066 * @param {Object} source The object to copy symbols from. 7067 * @param {Object} [object={}] The object to copy symbols to. 7068 * @returns {Object} Returns `object`. 7069 */ 7070 function copySymbolsIn(source, object) { 7071 return copyObject(source, getSymbolsIn(source), object); 7072 } 7073 7074 /** 7075 * Creates a function like `_.groupBy`. 7076 * 7077 * @private 7078 * @param {Function} setter The function to set accumulator values. 7079 * @param {Function} [initializer] The accumulator object initializer. 7080 * @returns {Function} Returns the new aggregator function. 7081 */ 7082 function createAggregator(setter, initializer) { 7083 return function(collection, iteratee) { 7084 var func = isArray(collection) ? arrayAggregator : baseAggregator, 7085 accumulator = initializer ? initializer() : {}; 7086 7087 return func(collection, setter, getIteratee(iteratee, 2), accumulator); 7088 }; 7089 } 7090 7091 /** 7092 * Creates a function like `_.assign`. 7093 * 7094 * @private 7095 * @param {Function} assigner The function to assign values. 7096 * @returns {Function} Returns the new assigner function. 7097 */ 7098 function createAssigner(assigner) { 7099 return baseRest(function(object, sources) { 7100 var index = -1, 7101 length = sources.length, 7102 customizer = length > 1 ? sources[length - 1] : undefined, 7103 guard = length > 2 ? sources[2] : undefined; 7104 7105 customizer = (assigner.length > 3 && typeof customizer == 'function') 7106 ? (length--, customizer) 7107 : undefined; 7108 7109 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 7110 customizer = length < 3 ? undefined : customizer; 7111 length = 1; 7112 } 7113 object = Object(object); 7114 while (++index < length) { 7115 var source = sources[index]; 7116 if (source) { 7117 assigner(object, source, index, customizer); 7118 } 7119 } 7120 return object; 7121 }); 7122 } 7123 7124 /** 7125 * Creates a `baseEach` or `baseEachRight` function. 7126 * 7127 * @private 7128 * @param {Function} eachFunc The function to iterate over a collection. 7129 * @param {boolean} [fromRight] Specify iterating from right to left. 7130 * @returns {Function} Returns the new base function. 7131 */ 7132 function createBaseEach(eachFunc, fromRight) { 7133 return function(collection, iteratee) { 7134 if (collection == null) { 7135 return collection; 7136 } 7137 if (!isArrayLike(collection)) { 7138 return eachFunc(collection, iteratee); 7139 } 7140 var length = collection.length, 7141 index = fromRight ? length : -1, 7142 iterable = Object(collection); 7143 7144 while ((fromRight ? index-- : ++index < length)) { 7145 if (iteratee(iterable[index], index, iterable) === false) { 7146 break; 7147 } 7148 } 7149 return collection; 7150 }; 7151 } 7152 7153 /** 7154 * Creates a base function for methods like `_.forIn` and `_.forOwn`. 7155 * 7156 * @private 7157 * @param {boolean} [fromRight] Specify iterating from right to left. 7158 * @returns {Function} Returns the new base function. 7159 */ 7160 function createBaseFor(fromRight) { 7161 return function(object, iteratee, keysFunc) { 7162 var index = -1, 7163 iterable = Object(object), 7164 props = keysFunc(object), 7165 length = props.length; 7166 7167 while (length--) { 7168 var key = props[fromRight ? length : ++index]; 7169 if (iteratee(iterable[key], key, iterable) === false) { 7170 break; 7171 } 7172 } 7173 return object; 7174 }; 7175 } 7176 7177 /** 7178 * Creates a function that wraps `func` to invoke it with the optional `this` 7179 * binding of `thisArg`. 7180 * 7181 * @private 7182 * @param {Function} func The function to wrap. 7183 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7184 * @param {*} [thisArg] The `this` binding of `func`. 7185 * @returns {Function} Returns the new wrapped function. 7186 */ 7187 function createBind(func, bitmask, thisArg) { 7188 var isBind = bitmask & WRAP_BIND_FLAG, 7189 Ctor = createCtor(func); 7190 7191 function wrapper() { 7192 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 7193 return fn.apply(isBind ? thisArg : this, arguments); 7194 } 7195 return wrapper; 7196 } 7197 7198 /** 7199 * Creates a function like `_.lowerFirst`. 7200 * 7201 * @private 7202 * @param {string} methodName The name of the `String` case method to use. 7203 * @returns {Function} Returns the new case function. 7204 */ 7205 function createCaseFirst(methodName) { 7206 return function(string) { 7207 string = toString(string); 7208 7209 var strSymbols = hasUnicode(string) 7210 ? stringToArray(string) 7211 : undefined; 7212 7213 var chr = strSymbols 7214 ? strSymbols[0] 7215 : string.charAt(0); 7216 7217 var trailing = strSymbols 7218 ? castSlice(strSymbols, 1).join('') 7219 : string.slice(1); 7220 7221 return chr[methodName]() + trailing; 7222 }; 7223 } 7224 7225 /** 7226 * Creates a function like `_.camelCase`. 7227 * 7228 * @private 7229 * @param {Function} callback The function to combine each word. 7230 * @returns {Function} Returns the new compounder function. 7231 */ 7232 function createCompounder(callback) { 7233 return function(string) { 7234 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); 7235 }; 7236 } 7237 7238 /** 7239 * Creates a function that produces an instance of `Ctor` regardless of 7240 * whether it was invoked as part of a `new` expression or by `call` or `apply`. 7241 * 7242 * @private 7243 * @param {Function} Ctor The constructor to wrap. 7244 * @returns {Function} Returns the new wrapped function. 7245 */ 7246 function createCtor(Ctor) { 7247 return function() { 7248 // Use a `switch` statement to work with class constructors. See 7249 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist 7250 // for more details. 7251 var args = arguments; 7252 switch (args.length) { 7253 case 0: return new Ctor; 7254 case 1: return new Ctor(args[0]); 7255 case 2: return new Ctor(args[0], args[1]); 7256 case 3: return new Ctor(args[0], args[1], args[2]); 7257 case 4: return new Ctor(args[0], args[1], args[2], args[3]); 7258 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); 7259 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); 7260 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); 7261 } 7262 var thisBinding = baseCreate(Ctor.prototype), 7263 result = Ctor.apply(thisBinding, args); 7264 7265 // Mimic the constructor's `return` behavior. 7266 // See https://es5.github.io/#x13.2.2 for more details. 7267 return isObject(result) ? result : thisBinding; 7268 }; 7269 } 7270 7271 /** 7272 * Creates a function that wraps `func` to enable currying. 7273 * 7274 * @private 7275 * @param {Function} func The function to wrap. 7276 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7277 * @param {number} arity The arity of `func`. 7278 * @returns {Function} Returns the new wrapped function. 7279 */ 7280 function createCurry(func, bitmask, arity) { 7281 var Ctor = createCtor(func); 7282 7283 function wrapper() { 7284 var length = arguments.length, 7285 args = Array(length), 7286 index = length, 7287 placeholder = getHolder(wrapper); 7288 7289 while (index--) { 7290 args[index] = arguments[index]; 7291 } 7292 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) 7293 ? [] 7294 : replaceHolders(args, placeholder); 7295 7296 length -= holders.length; 7297 if (length < arity) { 7298 return createRecurry( 7299 func, bitmask, createHybrid, wrapper.placeholder, undefined, 7300 args, holders, undefined, undefined, arity - length); 7301 } 7302 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 7303 return apply(fn, this, args); 7304 } 7305 return wrapper; 7306 } 7307 7308 /** 7309 * Creates a `_.find` or `_.findLast` function. 7310 * 7311 * @private 7312 * @param {Function} findIndexFunc The function to find the collection index. 7313 * @returns {Function} Returns the new find function. 7314 */ 7315 function createFind(findIndexFunc) { 7316 return function(collection, predicate, fromIndex) { 7317 var iterable = Object(collection); 7318 if (!isArrayLike(collection)) { 7319 var iteratee = getIteratee(predicate, 3); 7320 collection = keys(collection); 7321 predicate = function(key) { return iteratee(iterable[key], key, iterable); }; 7322 } 7323 var index = findIndexFunc(collection, predicate, fromIndex); 7324 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; 7325 }; 7326 } 7327 7328 /** 7329 * Creates a `_.flow` or `_.flowRight` function. 7330 * 7331 * @private 7332 * @param {boolean} [fromRight] Specify iterating from right to left. 7333 * @returns {Function} Returns the new flow function. 7334 */ 7335 function createFlow(fromRight) { 7336 return flatRest(function(funcs) { 7337 var length = funcs.length, 7338 index = length, 7339 prereq = LodashWrapper.prototype.thru; 7340 7341 if (fromRight) { 7342 funcs.reverse(); 7343 } 7344 while (index--) { 7345 var func = funcs[index]; 7346 if (typeof func != 'function') { 7347 throw new TypeError(FUNC_ERROR_TEXT); 7348 } 7349 if (prereq && !wrapper && getFuncName(func) == 'wrapper') { 7350 var wrapper = new LodashWrapper([], true); 7351 } 7352 } 7353 index = wrapper ? index : length; 7354 while (++index < length) { 7355 func = funcs[index]; 7356 7357 var funcName = getFuncName(func), 7358 data = funcName == 'wrapper' ? getData(func) : undefined; 7359 7360 if (data && isLaziable(data[0]) && 7361 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && 7362 !data[4].length && data[9] == 1 7363 ) { 7364 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); 7365 } else { 7366 wrapper = (func.length == 1 && isLaziable(func)) 7367 ? wrapper[funcName]() 7368 : wrapper.thru(func); 7369 } 7370 } 7371 return function() { 7372 var args = arguments, 7373 value = args[0]; 7374 7375 if (wrapper && args.length == 1 && isArray(value)) { 7376 return wrapper.plant(value).value(); 7377 } 7378 var index = 0, 7379 result = length ? funcs[index].apply(this, args) : value; 7380 7381 while (++index < length) { 7382 result = funcs[index].call(this, result); 7383 } 7384 return result; 7385 }; 7386 }); 7387 } 7388 7389 /** 7390 * Creates a function that wraps `func` to invoke it with optional `this` 7391 * binding of `thisArg`, partial application, and currying. 7392 * 7393 * @private 7394 * @param {Function|string} func The function or method name to wrap. 7395 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7396 * @param {*} [thisArg] The `this` binding of `func`. 7397 * @param {Array} [partials] The arguments to prepend to those provided to 7398 * the new function. 7399 * @param {Array} [holders] The `partials` placeholder indexes. 7400 * @param {Array} [partialsRight] The arguments to append to those provided 7401 * to the new function. 7402 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. 7403 * @param {Array} [argPos] The argument positions of the new function. 7404 * @param {number} [ary] The arity cap of `func`. 7405 * @param {number} [arity] The arity of `func`. 7406 * @returns {Function} Returns the new wrapped function. 7407 */ 7408 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { 7409 var isAry = bitmask & WRAP_ARY_FLAG, 7410 isBind = bitmask & WRAP_BIND_FLAG, 7411 isBindKey = bitmask & WRAP_BIND_KEY_FLAG, 7412 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), 7413 isFlip = bitmask & WRAP_FLIP_FLAG, 7414 Ctor = isBindKey ? undefined : createCtor(func); 7415 7416 function wrapper() { 7417 var length = arguments.length, 7418 args = Array(length), 7419 index = length; 7420 7421 while (index--) { 7422 args[index] = arguments[index]; 7423 } 7424 if (isCurried) { 7425 var placeholder = getHolder(wrapper), 7426 holdersCount = countHolders(args, placeholder); 7427 } 7428 if (partials) { 7429 args = composeArgs(args, partials, holders, isCurried); 7430 } 7431 if (partialsRight) { 7432 args = composeArgsRight(args, partialsRight, holdersRight, isCurried); 7433 } 7434 length -= holdersCount; 7435 if (isCurried && length < arity) { 7436 var newHolders = replaceHolders(args, placeholder); 7437 return createRecurry( 7438 func, bitmask, createHybrid, wrapper.placeholder, thisArg, 7439 args, newHolders, argPos, ary, arity - length 7440 ); 7441 } 7442 var thisBinding = isBind ? thisArg : this, 7443 fn = isBindKey ? thisBinding[func] : func; 7444 7445 length = args.length; 7446 if (argPos) { 7447 args = reorder(args, argPos); 7448 } else if (isFlip && length > 1) { 7449 args.reverse(); 7450 } 7451 if (isAry && ary < length) { 7452 args.length = ary; 7453 } 7454 if (this && this !== root && this instanceof wrapper) { 7455 fn = Ctor || createCtor(fn); 7456 } 7457 return fn.apply(thisBinding, args); 7458 } 7459 return wrapper; 7460 } 7461 7462 /** 7463 * Creates a function like `_.invertBy`. 7464 * 7465 * @private 7466 * @param {Function} setter The function to set accumulator values. 7467 * @param {Function} toIteratee The function to resolve iteratees. 7468 * @returns {Function} Returns the new inverter function. 7469 */ 7470 function createInverter(setter, toIteratee) { 7471 return function(object, iteratee) { 7472 return baseInverter(object, setter, toIteratee(iteratee), {}); 7473 }; 7474 } 7475 7476 /** 7477 * Creates a function that performs a mathematical operation on two values. 7478 * 7479 * @private 7480 * @param {Function} operator The function to perform the operation. 7481 * @param {number} [defaultValue] The value used for `undefined` arguments. 7482 * @returns {Function} Returns the new mathematical operation function. 7483 */ 7484 function createMathOperation(operator, defaultValue) { 7485 return function(value, other) { 7486 var result; 7487 if (value === undefined && other === undefined) { 7488 return defaultValue; 7489 } 7490 if (value !== undefined) { 7491 result = value; 7492 } 7493 if (other !== undefined) { 7494 if (result === undefined) { 7495 return other; 7496 } 7497 if (typeof value == 'string' || typeof other == 'string') { 7498 value = baseToString(value); 7499 other = baseToString(other); 7500 } else { 7501 value = baseToNumber(value); 7502 other = baseToNumber(other); 7503 } 7504 result = operator(value, other); 7505 } 7506 return result; 7507 }; 7508 } 7509 7510 /** 7511 * Creates a function like `_.over`. 7512 * 7513 * @private 7514 * @param {Function} arrayFunc The function to iterate over iteratees. 7515 * @returns {Function} Returns the new over function. 7516 */ 7517 function createOver(arrayFunc) { 7518 return flatRest(function(iteratees) { 7519 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 7520 return baseRest(function(args) { 7521 var thisArg = this; 7522 return arrayFunc(iteratees, function(iteratee) { 7523 return apply(iteratee, thisArg, args); 7524 }); 7525 }); 7526 }); 7527 } 7528 7529 /** 7530 * Creates the padding for `string` based on `length`. The `chars` string 7531 * is truncated if the number of characters exceeds `length`. 7532 * 7533 * @private 7534 * @param {number} length The padding length. 7535 * @param {string} [chars=' '] The string used as padding. 7536 * @returns {string} Returns the padding for `string`. 7537 */ 7538 function createPadding(length, chars) { 7539 chars = chars === undefined ? ' ' : baseToString(chars); 7540 7541 var charsLength = chars.length; 7542 if (charsLength < 2) { 7543 return charsLength ? baseRepeat(chars, length) : chars; 7544 } 7545 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); 7546 return hasUnicode(chars) 7547 ? castSlice(stringToArray(result), 0, length).join('') 7548 : result.slice(0, length); 7549 } 7550 7551 /** 7552 * Creates a function that wraps `func` to invoke it with the `this` binding 7553 * of `thisArg` and `partials` prepended to the arguments it receives. 7554 * 7555 * @private 7556 * @param {Function} func The function to wrap. 7557 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7558 * @param {*} thisArg The `this` binding of `func`. 7559 * @param {Array} partials The arguments to prepend to those provided to 7560 * the new function. 7561 * @returns {Function} Returns the new wrapped function. 7562 */ 7563 function createPartial(func, bitmask, thisArg, partials) { 7564 var isBind = bitmask & WRAP_BIND_FLAG, 7565 Ctor = createCtor(func); 7566 7567 function wrapper() { 7568 var argsIndex = -1, 7569 argsLength = arguments.length, 7570 leftIndex = -1, 7571 leftLength = partials.length, 7572 args = Array(leftLength + argsLength), 7573 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 7574 7575 while (++leftIndex < leftLength) { 7576 args[leftIndex] = partials[leftIndex]; 7577 } 7578 while (argsLength--) { 7579 args[leftIndex++] = arguments[++argsIndex]; 7580 } 7581 return apply(fn, isBind ? thisArg : this, args); 7582 } 7583 return wrapper; 7584 } 7585 7586 /** 7587 * Creates a `_.range` or `_.rangeRight` function. 7588 * 7589 * @private 7590 * @param {boolean} [fromRight] Specify iterating from right to left. 7591 * @returns {Function} Returns the new range function. 7592 */ 7593 function createRange(fromRight) { 7594 return function(start, end, step) { 7595 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { 7596 end = step = undefined; 7597 } 7598 // Ensure the sign of `-0` is preserved. 7599 start = toFinite(start); 7600 if (end === undefined) { 7601 end = start; 7602 start = 0; 7603 } else { 7604 end = toFinite(end); 7605 } 7606 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); 7607 return baseRange(start, end, step, fromRight); 7608 }; 7609 } 7610 7611 /** 7612 * Creates a function that performs a relational operation on two values. 7613 * 7614 * @private 7615 * @param {Function} operator The function to perform the operation. 7616 * @returns {Function} Returns the new relational operation function. 7617 */ 7618 function createRelationalOperation(operator) { 7619 return function(value, other) { 7620 if (!(typeof value == 'string' && typeof other == 'string')) { 7621 value = toNumber(value); 7622 other = toNumber(other); 7623 } 7624 return operator(value, other); 7625 }; 7626 } 7627 7628 /** 7629 * Creates a function that wraps `func` to continue currying. 7630 * 7631 * @private 7632 * @param {Function} func The function to wrap. 7633 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7634 * @param {Function} wrapFunc The function to create the `func` wrapper. 7635 * @param {*} placeholder The placeholder value. 7636 * @param {*} [thisArg] The `this` binding of `func`. 7637 * @param {Array} [partials] The arguments to prepend to those provided to 7638 * the new function. 7639 * @param {Array} [holders] The `partials` placeholder indexes. 7640 * @param {Array} [argPos] The argument positions of the new function. 7641 * @param {number} [ary] The arity cap of `func`. 7642 * @param {number} [arity] The arity of `func`. 7643 * @returns {Function} Returns the new wrapped function. 7644 */ 7645 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { 7646 var isCurry = bitmask & WRAP_CURRY_FLAG, 7647 newHolders = isCurry ? holders : undefined, 7648 newHoldersRight = isCurry ? undefined : holders, 7649 newPartials = isCurry ? partials : undefined, 7650 newPartialsRight = isCurry ? undefined : partials; 7651 7652 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); 7653 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); 7654 7655 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { 7656 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); 7657 } 7658 var newData = [ 7659 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, 7660 newHoldersRight, argPos, ary, arity 7661 ]; 7662 7663 var result = wrapFunc.apply(undefined, newData); 7664 if (isLaziable(func)) { 7665 setData(result, newData); 7666 } 7667 result.placeholder = placeholder; 7668 return setWrapToString(result, func, bitmask); 7669 } 7670 7671 /** 7672 * Creates a function like `_.round`. 7673 * 7674 * @private 7675 * @param {string} methodName The name of the `Math` method to use when rounding. 7676 * @returns {Function} Returns the new round function. 7677 */ 7678 function createRound(methodName) { 7679 var func = Math[methodName]; 7680 return function(number, precision) { 7681 number = toNumber(number); 7682 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); 7683 if (precision && nativeIsFinite(number)) { 7684 // Shift with exponential notation to avoid floating-point issues. 7685 // See [MDN](https://mdn.io/round#Examples) for more details. 7686 var pair = (toString(number) + 'e').split('e'), 7687 value = func(pair[0] + 'e' + (+pair[1] + precision)); 7688 7689 pair = (toString(value) + 'e').split('e'); 7690 return +(pair[0] + 'e' + (+pair[1] - precision)); 7691 } 7692 return func(number); 7693 }; 7694 } 7695 7696 /** 7697 * Creates a set object of `values`. 7698 * 7699 * @private 7700 * @param {Array} values The values to add to the set. 7701 * @returns {Object} Returns the new set. 7702 */ 7703 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { 7704 return new Set(values); 7705 }; 7706 7707 /** 7708 * Creates a `_.toPairs` or `_.toPairsIn` function. 7709 * 7710 * @private 7711 * @param {Function} keysFunc The function to get the keys of a given object. 7712 * @returns {Function} Returns the new pairs function. 7713 */ 7714 function createToPairs(keysFunc) { 7715 return function(object) { 7716 var tag = getTag(object); 7717 if (tag == mapTag) { 7718 return mapToArray(object); 7719 } 7720 if (tag == setTag) { 7721 return setToPairs(object); 7722 } 7723 return baseToPairs(object, keysFunc(object)); 7724 }; 7725 } 7726 7727 /** 7728 * Creates a function that either curries or invokes `func` with optional 7729 * `this` binding and partially applied arguments. 7730 * 7731 * @private 7732 * @param {Function|string} func The function or method name to wrap. 7733 * @param {number} bitmask The bitmask flags. 7734 * 1 - `_.bind` 7735 * 2 - `_.bindKey` 7736 * 4 - `_.curry` or `_.curryRight` of a bound function 7737 * 8 - `_.curry` 7738 * 16 - `_.curryRight` 7739 * 32 - `_.partial` 7740 * 64 - `_.partialRight` 7741 * 128 - `_.rearg` 7742 * 256 - `_.ary` 7743 * 512 - `_.flip` 7744 * @param {*} [thisArg] The `this` binding of `func`. 7745 * @param {Array} [partials] The arguments to be partially applied. 7746 * @param {Array} [holders] The `partials` placeholder indexes. 7747 * @param {Array} [argPos] The argument positions of the new function. 7748 * @param {number} [ary] The arity cap of `func`. 7749 * @param {number} [arity] The arity of `func`. 7750 * @returns {Function} Returns the new wrapped function. 7751 */ 7752 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { 7753 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; 7754 if (!isBindKey && typeof func != 'function') { 7755 throw new TypeError(FUNC_ERROR_TEXT); 7756 } 7757 var length = partials ? partials.length : 0; 7758 if (!length) { 7759 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); 7760 partials = holders = undefined; 7761 } 7762 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); 7763 arity = arity === undefined ? arity : toInteger(arity); 7764 length -= holders ? holders.length : 0; 7765 7766 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { 7767 var partialsRight = partials, 7768 holdersRight = holders; 7769 7770 partials = holders = undefined; 7771 } 7772 var data = isBindKey ? undefined : getData(func); 7773 7774 var newData = [ 7775 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, 7776 argPos, ary, arity 7777 ]; 7778 7779 if (data) { 7780 mergeData(newData, data); 7781 } 7782 func = newData[0]; 7783 bitmask = newData[1]; 7784 thisArg = newData[2]; 7785 partials = newData[3]; 7786 holders = newData[4]; 7787 arity = newData[9] = newData[9] === undefined 7788 ? (isBindKey ? 0 : func.length) 7789 : nativeMax(newData[9] - length, 0); 7790 7791 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { 7792 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); 7793 } 7794 if (!bitmask || bitmask == WRAP_BIND_FLAG) { 7795 var result = createBind(func, bitmask, thisArg); 7796 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { 7797 result = createCurry(func, bitmask, arity); 7798 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { 7799 result = createPartial(func, bitmask, thisArg, partials); 7800 } else { 7801 result = createHybrid.apply(undefined, newData); 7802 } 7803 var setter = data ? baseSetData : setData; 7804 return setWrapToString(setter(result, newData), func, bitmask); 7805 } 7806 7807 /** 7808 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties 7809 * of source objects to the destination object for all destination properties 7810 * that resolve to `undefined`. 7811 * 7812 * @private 7813 * @param {*} objValue The destination value. 7814 * @param {*} srcValue The source value. 7815 * @param {string} key The key of the property to assign. 7816 * @param {Object} object The parent object of `objValue`. 7817 * @returns {*} Returns the value to assign. 7818 */ 7819 function customDefaultsAssignIn(objValue, srcValue, key, object) { 7820 if (objValue === undefined || 7821 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { 7822 return srcValue; 7823 } 7824 return objValue; 7825 } 7826 7827 /** 7828 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source 7829 * objects into destination objects that are passed thru. 7830 * 7831 * @private 7832 * @param {*} objValue The destination value. 7833 * @param {*} srcValue The source value. 7834 * @param {string} key The key of the property to merge. 7835 * @param {Object} object The parent object of `objValue`. 7836 * @param {Object} source The parent object of `srcValue`. 7837 * @param {Object} [stack] Tracks traversed source values and their merged 7838 * counterparts. 7839 * @returns {*} Returns the value to assign. 7840 */ 7841 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { 7842 if (isObject(objValue) && isObject(srcValue)) { 7843 // Recursively merge objects and arrays (susceptible to call stack limits). 7844 stack.set(srcValue, objValue); 7845 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); 7846 stack['delete'](srcValue); 7847 } 7848 return objValue; 7849 } 7850 7851 /** 7852 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain 7853 * objects. 7854 * 7855 * @private 7856 * @param {*} value The value to inspect. 7857 * @param {string} key The key of the property to inspect. 7858 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. 7859 */ 7860 function customOmitClone(value) { 7861 return isPlainObject(value) ? undefined : value; 7862 } 7863 7864 /** 7865 * A specialized version of `baseIsEqualDeep` for arrays with support for 7866 * partial deep comparisons. 7867 * 7868 * @private 7869 * @param {Array} array The array to compare. 7870 * @param {Array} other The other array to compare. 7871 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 7872 * @param {Function} customizer The function to customize comparisons. 7873 * @param {Function} equalFunc The function to determine equivalents of values. 7874 * @param {Object} stack Tracks traversed `array` and `other` objects. 7875 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 7876 */ 7877 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { 7878 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 7879 arrLength = array.length, 7880 othLength = other.length; 7881 7882 if (arrLength != othLength && !(isPartial && othLength > arrLength)) { 7883 return false; 7884 } 7885 // Check that cyclic values are equal. 7886 var arrStacked = stack.get(array); 7887 var othStacked = stack.get(other); 7888 if (arrStacked && othStacked) { 7889 return arrStacked == other && othStacked == array; 7890 } 7891 var index = -1, 7892 result = true, 7893 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; 7894 7895 stack.set(array, other); 7896 stack.set(other, array); 7897 7898 // Ignore non-index properties. 7899 while (++index < arrLength) { 7900 var arrValue = array[index], 7901 othValue = other[index]; 7902 7903 if (customizer) { 7904 var compared = isPartial 7905 ? customizer(othValue, arrValue, index, other, array, stack) 7906 : customizer(arrValue, othValue, index, array, other, stack); 7907 } 7908 if (compared !== undefined) { 7909 if (compared) { 7910 continue; 7911 } 7912 result = false; 7913 break; 7914 } 7915 // Recursively compare arrays (susceptible to call stack limits). 7916 if (seen) { 7917 if (!arraySome(other, function(othValue, othIndex) { 7918 if (!cacheHas(seen, othIndex) && 7919 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { 7920 return seen.push(othIndex); 7921 } 7922 })) { 7923 result = false; 7924 break; 7925 } 7926 } else if (!( 7927 arrValue === othValue || 7928 equalFunc(arrValue, othValue, bitmask, customizer, stack) 7929 )) { 7930 result = false; 7931 break; 7932 } 7933 } 7934 stack['delete'](array); 7935 stack['delete'](other); 7936 return result; 7937 } 7938 7939 /** 7940 * A specialized version of `baseIsEqualDeep` for comparing objects of 7941 * the same `toStringTag`. 7942 * 7943 * **Note:** This function only supports comparing values with tags of 7944 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 7945 * 7946 * @private 7947 * @param {Object} object The object to compare. 7948 * @param {Object} other The other object to compare. 7949 * @param {string} tag The `toStringTag` of the objects to compare. 7950 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 7951 * @param {Function} customizer The function to customize comparisons. 7952 * @param {Function} equalFunc The function to determine equivalents of values. 7953 * @param {Object} stack Tracks traversed `object` and `other` objects. 7954 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 7955 */ 7956 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { 7957 switch (tag) { 7958 case dataViewTag: 7959 if ((object.byteLength != other.byteLength) || 7960 (object.byteOffset != other.byteOffset)) { 7961 return false; 7962 } 7963 object = object.buffer; 7964 other = other.buffer; 7965 7966 case arrayBufferTag: 7967 if ((object.byteLength != other.byteLength) || 7968 !equalFunc(new Uint8Array(object), new Uint8Array(other))) { 7969 return false; 7970 } 7971 return true; 7972 7973 case boolTag: 7974 case dateTag: 7975 case numberTag: 7976 // Coerce booleans to `1` or `0` and dates to milliseconds. 7977 // Invalid dates are coerced to `NaN`. 7978 return eq(+object, +other); 7979 7980 case errorTag: 7981 return object.name == other.name && object.message == other.message; 7982 7983 case regexpTag: 7984 case stringTag: 7985 // Coerce regexes to strings and treat strings, primitives and objects, 7986 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring 7987 // for more details. 7988 return object == (other + ''); 7989 7990 case mapTag: 7991 var convert = mapToArray; 7992 7993 case setTag: 7994 var isPartial = bitmask & COMPARE_PARTIAL_FLAG; 7995 convert || (convert = setToArray); 7996 7997 if (object.size != other.size && !isPartial) { 7998 return false; 7999 } 8000 // Assume cyclic values are equal. 8001 var stacked = stack.get(object); 8002 if (stacked) { 8003 return stacked == other; 8004 } 8005 bitmask |= COMPARE_UNORDERED_FLAG; 8006 8007 // Recursively compare objects (susceptible to call stack limits). 8008 stack.set(object, other); 8009 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); 8010 stack['delete'](object); 8011 return result; 8012 8013 case symbolTag: 8014 if (symbolValueOf) { 8015 return symbolValueOf.call(object) == symbolValueOf.call(other); 8016 } 8017 } 8018 return false; 8019 } 8020 8021 /** 8022 * A specialized version of `baseIsEqualDeep` for objects with support for 8023 * partial deep comparisons. 8024 * 8025 * @private 8026 * @param {Object} object The object to compare. 8027 * @param {Object} other The other object to compare. 8028 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 8029 * @param {Function} customizer The function to customize comparisons. 8030 * @param {Function} equalFunc The function to determine equivalents of values. 8031 * @param {Object} stack Tracks traversed `object` and `other` objects. 8032 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 8033 */ 8034 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { 8035 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 8036 objProps = getAllKeys(object), 8037 objLength = objProps.length, 8038 othProps = getAllKeys(other), 8039 othLength = othProps.length; 8040 8041 if (objLength != othLength && !isPartial) { 8042 return false; 8043 } 8044 var index = objLength; 8045 while (index--) { 8046 var key = objProps[index]; 8047 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { 8048 return false; 8049 } 8050 } 8051 // Check that cyclic values are equal. 8052 var objStacked = stack.get(object); 8053 var othStacked = stack.get(other); 8054 if (objStacked && othStacked) { 8055 return objStacked == other && othStacked == object; 8056 } 8057 var result = true; 8058 stack.set(object, other); 8059 stack.set(other, object); 8060 8061 var skipCtor = isPartial; 8062 while (++index < objLength) { 8063 key = objProps[index]; 8064 var objValue = object[key], 8065 othValue = other[key]; 8066 8067 if (customizer) { 8068 var compared = isPartial 8069 ? customizer(othValue, objValue, key, other, object, stack) 8070 : customizer(objValue, othValue, key, object, other, stack); 8071 } 8072 // Recursively compare objects (susceptible to call stack limits). 8073 if (!(compared === undefined 8074 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) 8075 : compared 8076 )) { 8077 result = false; 8078 break; 8079 } 8080 skipCtor || (skipCtor = key == 'constructor'); 8081 } 8082 if (result && !skipCtor) { 8083 var objCtor = object.constructor, 8084 othCtor = other.constructor; 8085 8086 // Non `Object` object instances with different constructors are not equal. 8087 if (objCtor != othCtor && 8088 ('constructor' in object && 'constructor' in other) && 8089 !(typeof objCtor == 'function' && objCtor instanceof objCtor && 8090 typeof othCtor == 'function' && othCtor instanceof othCtor)) { 8091 result = false; 8092 } 8093 } 8094 stack['delete'](object); 8095 stack['delete'](other); 8096 return result; 8097 } 8098 8099 /** 8100 * A specialized version of `baseRest` which flattens the rest array. 8101 * 8102 * @private 8103 * @param {Function} func The function to apply a rest parameter to. 8104 * @returns {Function} Returns the new function. 8105 */ 8106 function flatRest(func) { 8107 return setToString(overRest(func, undefined, flatten), func + ''); 8108 } 8109 8110 /** 8111 * Creates an array of own enumerable property names and symbols of `object`. 8112 * 8113 * @private 8114 * @param {Object} object The object to query. 8115 * @returns {Array} Returns the array of property names and symbols. 8116 */ 8117 function getAllKeys(object) { 8118 return baseGetAllKeys(object, keys, getSymbols); 8119 } 8120 8121 /** 8122 * Creates an array of own and inherited enumerable property names and 8123 * symbols of `object`. 8124 * 8125 * @private 8126 * @param {Object} object The object to query. 8127 * @returns {Array} Returns the array of property names and symbols. 8128 */ 8129 function getAllKeysIn(object) { 8130 return baseGetAllKeys(object, keysIn, getSymbolsIn); 8131 } 8132 8133 /** 8134 * Gets metadata for `func`. 8135 * 8136 * @private 8137 * @param {Function} func The function to query. 8138 * @returns {*} Returns the metadata for `func`. 8139 */ 8140 var getData = !metaMap ? noop : function(func) { 8141 return metaMap.get(func); 8142 }; 8143 8144 /** 8145 * Gets the name of `func`. 8146 * 8147 * @private 8148 * @param {Function} func The function to query. 8149 * @returns {string} Returns the function name. 8150 */ 8151 function getFuncName(func) { 8152 var result = (func.name + ''), 8153 array = realNames[result], 8154 length = hasOwnProperty.call(realNames, result) ? array.length : 0; 8155 8156 while (length--) { 8157 var data = array[length], 8158 otherFunc = data.func; 8159 if (otherFunc == null || otherFunc == func) { 8160 return data.name; 8161 } 8162 } 8163 return result; 8164 } 8165 8166 /** 8167 * Gets the argument placeholder value for `func`. 8168 * 8169 * @private 8170 * @param {Function} func The function to inspect. 8171 * @returns {*} Returns the placeholder value. 8172 */ 8173 function getHolder(func) { 8174 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; 8175 return object.placeholder; 8176 } 8177 8178 /** 8179 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, 8180 * this function returns the custom method, otherwise it returns `baseIteratee`. 8181 * If arguments are provided, the chosen function is invoked with them and 8182 * its result is returned. 8183 * 8184 * @private 8185 * @param {*} [value] The value to convert to an iteratee. 8186 * @param {number} [arity] The arity of the created iteratee. 8187 * @returns {Function} Returns the chosen function or its result. 8188 */ 8189 function getIteratee() { 8190 var result = lodash.iteratee || iteratee; 8191 result = result === iteratee ? baseIteratee : result; 8192 return arguments.length ? result(arguments[0], arguments[1]) : result; 8193 } 8194 8195 /** 8196 * Gets the data for `map`. 8197 * 8198 * @private 8199 * @param {Object} map The map to query. 8200 * @param {string} key The reference key. 8201 * @returns {*} Returns the map data. 8202 */ 8203 function getMapData(map, key) { 8204 var data = map.__data__; 8205 return isKeyable(key) 8206 ? data[typeof key == 'string' ? 'string' : 'hash'] 8207 : data.map; 8208 } 8209 8210 /** 8211 * Gets the property names, values, and compare flags of `object`. 8212 * 8213 * @private 8214 * @param {Object} object The object to query. 8215 * @returns {Array} Returns the match data of `object`. 8216 */ 8217 function getMatchData(object) { 8218 var result = keys(object), 8219 length = result.length; 8220 8221 while (length--) { 8222 var key = result[length], 8223 value = object[key]; 8224 8225 result[length] = [key, value, isStrictComparable(value)]; 8226 } 8227 return result; 8228 } 8229 8230 /** 8231 * Gets the native function at `key` of `object`. 8232 * 8233 * @private 8234 * @param {Object} object The object to query. 8235 * @param {string} key The key of the method to get. 8236 * @returns {*} Returns the function if it's native, else `undefined`. 8237 */ 8238 function getNative(object, key) { 8239 var value = getValue(object, key); 8240 return baseIsNative(value) ? value : undefined; 8241 } 8242 8243 /** 8244 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 8245 * 8246 * @private 8247 * @param {*} value The value to query. 8248 * @returns {string} Returns the raw `toStringTag`. 8249 */ 8250 function getRawTag(value) { 8251 var isOwn = hasOwnProperty.call(value, symToStringTag), 8252 tag = value[symToStringTag]; 8253 8254 try { 8255 value[symToStringTag] = undefined; 8256 var unmasked = true; 8257 } catch (e) {} 8258 8259 var result = nativeObjectToString.call(value); 8260 if (unmasked) { 8261 if (isOwn) { 8262 value[symToStringTag] = tag; 8263 } else { 8264 delete value[symToStringTag]; 8265 } 8266 } 8267 return result; 8268 } 8269 8270 /** 8271 * Creates an array of the own enumerable symbols of `object`. 8272 * 8273 * @private 8274 * @param {Object} object The object to query. 8275 * @returns {Array} Returns the array of symbols. 8276 */ 8277 var getSymbols = !nativeGetSymbols ? stubArray : function(object) { 8278 if (object == null) { 8279 return []; 8280 } 8281 object = Object(object); 8282 return arrayFilter(nativeGetSymbols(object), function(symbol) { 8283 return propertyIsEnumerable.call(object, symbol); 8284 }); 8285 }; 8286 8287 /** 8288 * Creates an array of the own and inherited enumerable symbols of `object`. 8289 * 8290 * @private 8291 * @param {Object} object The object to query. 8292 * @returns {Array} Returns the array of symbols. 8293 */ 8294 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { 8295 var result = []; 8296 while (object) { 8297 arrayPush(result, getSymbols(object)); 8298 object = getPrototype(object); 8299 } 8300 return result; 8301 }; 8302 8303 /** 8304 * Gets the `toStringTag` of `value`. 8305 * 8306 * @private 8307 * @param {*} value The value to query. 8308 * @returns {string} Returns the `toStringTag`. 8309 */ 8310 var getTag = baseGetTag; 8311 8312 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. 8313 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || 8314 (Map && getTag(new Map) != mapTag) || 8315 (Promise && getTag(Promise.resolve()) != promiseTag) || 8316 (Set && getTag(new Set) != setTag) || 8317 (WeakMap && getTag(new WeakMap) != weakMapTag)) { 8318 getTag = function(value) { 8319 var result = baseGetTag(value), 8320 Ctor = result == objectTag ? value.constructor : undefined, 8321 ctorString = Ctor ? toSource(Ctor) : ''; 8322 8323 if (ctorString) { 8324 switch (ctorString) { 8325 case dataViewCtorString: return dataViewTag; 8326 case mapCtorString: return mapTag; 8327 case promiseCtorString: return promiseTag; 8328 case setCtorString: return setTag; 8329 case weakMapCtorString: return weakMapTag; 8330 } 8331 } 8332 return result; 8333 }; 8334 } 8335 8336 /** 8337 * Gets the view, applying any `transforms` to the `start` and `end` positions. 8338 * 8339 * @private 8340 * @param {number} start The start of the view. 8341 * @param {number} end The end of the view. 8342 * @param {Array} transforms The transformations to apply to the view. 8343 * @returns {Object} Returns an object containing the `start` and `end` 8344 * positions of the view. 8345 */ 8346 function getView(start, end, transforms) { 8347 var index = -1, 8348 length = transforms.length; 8349 8350 while (++index < length) { 8351 var data = transforms[index], 8352 size = data.size; 8353 8354 switch (data.type) { 8355 case 'drop': start += size; break; 8356 case 'dropRight': end -= size; break; 8357 case 'take': end = nativeMin(end, start + size); break; 8358 case 'takeRight': start = nativeMax(start, end - size); break; 8359 } 8360 } 8361 return { 'start': start, 'end': end }; 8362 } 8363 8364 /** 8365 * Extracts wrapper details from the `source` body comment. 8366 * 8367 * @private 8368 * @param {string} source The source to inspect. 8369 * @returns {Array} Returns the wrapper details. 8370 */ 8371 function getWrapDetails(source) { 8372 var match = source.match(reWrapDetails); 8373 return match ? match[1].split(reSplitDetails) : []; 8374 } 8375 8376 /** 8377 * Checks if `path` exists on `object`. 8378 * 8379 * @private 8380 * @param {Object} object The object to query. 8381 * @param {Array|string} path The path to check. 8382 * @param {Function} hasFunc The function to check properties. 8383 * @returns {boolean} Returns `true` if `path` exists, else `false`. 8384 */ 8385 function hasPath(object, path, hasFunc) { 8386 path = castPath(path, object); 8387 8388 var index = -1, 8389 length = path.length, 8390 result = false; 8391 8392 while (++index < length) { 8393 var key = toKey(path[index]); 8394 if (!(result = object != null && hasFunc(object, key))) { 8395 break; 8396 } 8397 object = object[key]; 8398 } 8399 if (result || ++index != length) { 8400 return result; 8401 } 8402 length = object == null ? 0 : object.length; 8403 return !!length && isLength(length) && isIndex(key, length) && 8404 (isArray(object) || isArguments(object)); 8405 } 8406 8407 /** 8408 * Initializes an array clone. 8409 * 8410 * @private 8411 * @param {Array} array The array to clone. 8412 * @returns {Array} Returns the initialized clone. 8413 */ 8414 function initCloneArray(array) { 8415 var length = array.length, 8416 result = new array.constructor(length); 8417 8418 // Add properties assigned by `RegExp#exec`. 8419 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { 8420 result.index = array.index; 8421 result.input = array.input; 8422 } 8423 return result; 8424 } 8425 8426 /** 8427 * Initializes an object clone. 8428 * 8429 * @private 8430 * @param {Object} object The object to clone. 8431 * @returns {Object} Returns the initialized clone. 8432 */ 8433 function initCloneObject(object) { 8434 return (typeof object.constructor == 'function' && !isPrototype(object)) 8435 ? baseCreate(getPrototype(object)) 8436 : {}; 8437 } 8438 8439 /** 8440 * Initializes an object clone based on its `toStringTag`. 8441 * 8442 * **Note:** This function only supports cloning values with tags of 8443 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. 8444 * 8445 * @private 8446 * @param {Object} object The object to clone. 8447 * @param {string} tag The `toStringTag` of the object to clone. 8448 * @param {boolean} [isDeep] Specify a deep clone. 8449 * @returns {Object} Returns the initialized clone. 8450 */ 8451 function initCloneByTag(object, tag, isDeep) { 8452 var Ctor = object.constructor; 8453 switch (tag) { 8454 case arrayBufferTag: 8455 return cloneArrayBuffer(object); 8456 8457 case boolTag: 8458 case dateTag: 8459 return new Ctor(+object); 8460 8461 case dataViewTag: 8462 return cloneDataView(object, isDeep); 8463 8464 case float32Tag: case float64Tag: 8465 case int8Tag: case int16Tag: case int32Tag: 8466 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: 8467 return cloneTypedArray(object, isDeep); 8468 8469 case mapTag: 8470 return new Ctor; 8471 8472 case numberTag: 8473 case stringTag: 8474 return new Ctor(object); 8475 8476 case regexpTag: 8477 return cloneRegExp(object); 8478 8479 case setTag: 8480 return new Ctor; 8481 8482 case symbolTag: 8483 return cloneSymbol(object); 8484 } 8485 } 8486 8487 /** 8488 * Inserts wrapper `details` in a comment at the top of the `source` body. 8489 * 8490 * @private 8491 * @param {string} source The source to modify. 8492 * @returns {Array} details The details to insert. 8493 * @returns {string} Returns the modified source. 8494 */ 8495 function insertWrapDetails(source, details) { 8496 var length = details.length; 8497 if (!length) { 8498 return source; 8499 } 8500 var lastIndex = length - 1; 8501 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; 8502 details = details.join(length > 2 ? ', ' : ' '); 8503 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); 8504 } 8505 8506 /** 8507 * Checks if `value` is a flattenable `arguments` object or array. 8508 * 8509 * @private 8510 * @param {*} value The value to check. 8511 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. 8512 */ 8513 function isFlattenable(value) { 8514 return isArray(value) || isArguments(value) || 8515 !!(spreadableSymbol && value && value[spreadableSymbol]); 8516 } 8517 8518 /** 8519 * Checks if `value` is a valid array-like index. 8520 * 8521 * @private 8522 * @param {*} value The value to check. 8523 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 8524 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 8525 */ 8526 function isIndex(value, length) { 8527 var type = typeof value; 8528 length = length == null ? MAX_SAFE_INTEGER : length; 8529 8530 return !!length && 8531 (type == 'number' || 8532 (type != 'symbol' && reIsUint.test(value))) && 8533 (value > -1 && value % 1 == 0 && value < length); 8534 } 8535 8536 /** 8537 * Checks if the given arguments are from an iteratee call. 8538 * 8539 * @private 8540 * @param {*} value The potential iteratee value argument. 8541 * @param {*} index The potential iteratee index or key argument. 8542 * @param {*} object The potential iteratee object argument. 8543 * @returns {boolean} Returns `true` if the arguments are from an iteratee call, 8544 * else `false`. 8545 */ 8546 function isIterateeCall(value, index, object) { 8547 if (!isObject(object)) { 8548 return false; 8549 } 8550 var type = typeof index; 8551 if (type == 'number' 8552 ? (isArrayLike(object) && isIndex(index, object.length)) 8553 : (type == 'string' && index in object) 8554 ) { 8555 return eq(object[index], value); 8556 } 8557 return false; 8558 } 8559 8560 /** 8561 * Checks if `value` is a property name and not a property path. 8562 * 8563 * @private 8564 * @param {*} value The value to check. 8565 * @param {Object} [object] The object to query keys on. 8566 * @returns {boolean} Returns `true` if `value` is a property name, else `false`. 8567 */ 8568 function isKey(value, object) { 8569 if (isArray(value)) { 8570 return false; 8571 } 8572 var type = typeof value; 8573 if (type == 'number' || type == 'symbol' || type == 'boolean' || 8574 value == null || isSymbol(value)) { 8575 return true; 8576 } 8577 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || 8578 (object != null && value in Object(object)); 8579 } 8580 8581 /** 8582 * Checks if `value` is suitable for use as unique object key. 8583 * 8584 * @private 8585 * @param {*} value The value to check. 8586 * @returns {boolean} Returns `true` if `value` is suitable, else `false`. 8587 */ 8588 function isKeyable(value) { 8589 var type = typeof value; 8590 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 8591 ? (value !== '__proto__') 8592 : (value === null); 8593 } 8594 8595 /** 8596 * Checks if `func` has a lazy counterpart. 8597 * 8598 * @private 8599 * @param {Function} func The function to check. 8600 * @returns {boolean} Returns `true` if `func` has a lazy counterpart, 8601 * else `false`. 8602 */ 8603 function isLaziable(func) { 8604 var funcName = getFuncName(func), 8605 other = lodash[funcName]; 8606 8607 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { 8608 return false; 8609 } 8610 if (func === other) { 8611 return true; 8612 } 8613 var data = getData(other); 8614 return !!data && func === data[0]; 8615 } 8616 8617 /** 8618 * Checks if `func` has its source masked. 8619 * 8620 * @private 8621 * @param {Function} func The function to check. 8622 * @returns {boolean} Returns `true` if `func` is masked, else `false`. 8623 */ 8624 function isMasked(func) { 8625 return !!maskSrcKey && (maskSrcKey in func); 8626 } 8627 8628 /** 8629 * Checks if `func` is capable of being masked. 8630 * 8631 * @private 8632 * @param {*} value The value to check. 8633 * @returns {boolean} Returns `true` if `func` is maskable, else `false`. 8634 */ 8635 var isMaskable = coreJsData ? isFunction : stubFalse; 8636 8637 /** 8638 * Checks if `value` is likely a prototype object. 8639 * 8640 * @private 8641 * @param {*} value The value to check. 8642 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. 8643 */ 8644 function isPrototype(value) { 8645 var Ctor = value && value.constructor, 8646 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; 8647 8648 return value === proto; 8649 } 8650 8651 /** 8652 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. 8653 * 8654 * @private 8655 * @param {*} value The value to check. 8656 * @returns {boolean} Returns `true` if `value` if suitable for strict 8657 * equality comparisons, else `false`. 8658 */ 8659 function isStrictComparable(value) { 8660 return value === value && !isObject(value); 8661 } 8662 8663 /** 8664 * A specialized version of `matchesProperty` for source values suitable 8665 * for strict equality comparisons, i.e. `===`. 8666 * 8667 * @private 8668 * @param {string} key The key of the property to get. 8669 * @param {*} srcValue The value to match. 8670 * @returns {Function} Returns the new spec function. 8671 */ 8672 function matchesStrictComparable(key, srcValue) { 8673 return function(object) { 8674 if (object == null) { 8675 return false; 8676 } 8677 return object[key] === srcValue && 8678 (srcValue !== undefined || (key in Object(object))); 8679 }; 8680 } 8681 8682 /** 8683 * A specialized version of `_.memoize` which clears the memoized function's 8684 * cache when it exceeds `MAX_MEMOIZE_SIZE`. 8685 * 8686 * @private 8687 * @param {Function} func The function to have its output memoized. 8688 * @returns {Function} Returns the new memoized function. 8689 */ 8690 function memoizeCapped(func) { 8691 var result = memoize(func, function(key) { 8692 if (cache.size === MAX_MEMOIZE_SIZE) { 8693 cache.clear(); 8694 } 8695 return key; 8696 }); 8697 8698 var cache = result.cache; 8699 return result; 8700 } 8701 8702 /** 8703 * Merges the function metadata of `source` into `data`. 8704 * 8705 * Merging metadata reduces the number of wrappers used to invoke a function. 8706 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` 8707 * may be applied regardless of execution order. Methods like `_.ary` and 8708 * `_.rearg` modify function arguments, making the order in which they are 8709 * executed important, preventing the merging of metadata. However, we make 8710 * an exception for a safe combined case where curried functions have `_.ary` 8711 * and or `_.rearg` applied. 8712 * 8713 * @private 8714 * @param {Array} data The destination metadata. 8715 * @param {Array} source The source metadata. 8716 * @returns {Array} Returns `data`. 8717 */ 8718 function mergeData(data, source) { 8719 var bitmask = data[1], 8720 srcBitmask = source[1], 8721 newBitmask = bitmask | srcBitmask, 8722 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); 8723 8724 var isCombo = 8725 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || 8726 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || 8727 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); 8728 8729 // Exit early if metadata can't be merged. 8730 if (!(isCommon || isCombo)) { 8731 return data; 8732 } 8733 // Use source `thisArg` if available. 8734 if (srcBitmask & WRAP_BIND_FLAG) { 8735 data[2] = source[2]; 8736 // Set when currying a bound function. 8737 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; 8738 } 8739 // Compose partial arguments. 8740 var value = source[3]; 8741 if (value) { 8742 var partials = data[3]; 8743 data[3] = partials ? composeArgs(partials, value, source[4]) : value; 8744 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; 8745 } 8746 // Compose partial right arguments. 8747 value = source[5]; 8748 if (value) { 8749 partials = data[5]; 8750 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; 8751 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; 8752 } 8753 // Use source `argPos` if available. 8754 value = source[7]; 8755 if (value) { 8756 data[7] = value; 8757 } 8758 // Use source `ary` if it's smaller. 8759 if (srcBitmask & WRAP_ARY_FLAG) { 8760 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); 8761 } 8762 // Use source `arity` if one is not provided. 8763 if (data[9] == null) { 8764 data[9] = source[9]; 8765 } 8766 // Use source `func` and merge bitmasks. 8767 data[0] = source[0]; 8768 data[1] = newBitmask; 8769 8770 return data; 8771 } 8772 8773 /** 8774 * This function is like 8775 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 8776 * except that it includes inherited enumerable properties. 8777 * 8778 * @private 8779 * @param {Object} object The object to query. 8780 * @returns {Array} Returns the array of property names. 8781 */ 8782 function nativeKeysIn(object) { 8783 var result = []; 8784 if (object != null) { 8785 for (var key in Object(object)) { 8786 result.push(key); 8787 } 8788 } 8789 return result; 8790 } 8791 8792 /** 8793 * Converts `value` to a string using `Object.prototype.toString`. 8794 * 8795 * @private 8796 * @param {*} value The value to convert. 8797 * @returns {string} Returns the converted string. 8798 */ 8799 function objectToString(value) { 8800 return nativeObjectToString.call(value); 8801 } 8802 8803 /** 8804 * A specialized version of `baseRest` which transforms the rest array. 8805 * 8806 * @private 8807 * @param {Function} func The function to apply a rest parameter to. 8808 * @param {number} [start=func.length-1] The start position of the rest parameter. 8809 * @param {Function} transform The rest array transform. 8810 * @returns {Function} Returns the new function. 8811 */ 8812 function overRest(func, start, transform) { 8813 start = nativeMax(start === undefined ? (func.length - 1) : start, 0); 8814 return function() { 8815 var args = arguments, 8816 index = -1, 8817 length = nativeMax(args.length - start, 0), 8818 array = Array(length); 8819 8820 while (++index < length) { 8821 array[index] = args[start + index]; 8822 } 8823 index = -1; 8824 var otherArgs = Array(start + 1); 8825 while (++index < start) { 8826 otherArgs[index] = args[index]; 8827 } 8828 otherArgs[start] = transform(array); 8829 return apply(func, this, otherArgs); 8830 }; 8831 } 8832 8833 /** 8834 * Gets the parent value at `path` of `object`. 8835 * 8836 * @private 8837 * @param {Object} object The object to query. 8838 * @param {Array} path The path to get the parent value of. 8839 * @returns {*} Returns the parent value. 8840 */ 8841 function parent(object, path) { 8842 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); 8843 } 8844 8845 /** 8846 * Reorder `array` according to the specified indexes where the element at 8847 * the first index is assigned as the first element, the element at 8848 * the second index is assigned as the second element, and so on. 8849 * 8850 * @private 8851 * @param {Array} array The array to reorder. 8852 * @param {Array} indexes The arranged array indexes. 8853 * @returns {Array} Returns `array`. 8854 */ 8855 function reorder(array, indexes) { 8856 var arrLength = array.length, 8857 length = nativeMin(indexes.length, arrLength), 8858 oldArray = copyArray(array); 8859 8860 while (length--) { 8861 var index = indexes[length]; 8862 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; 8863 } 8864 return array; 8865 } 8866 8867 /** 8868 * Gets the value at `key`, unless `key` is "__proto__" or "constructor". 8869 * 8870 * @private 8871 * @param {Object} object The object to query. 8872 * @param {string} key The key of the property to get. 8873 * @returns {*} Returns the property value. 8874 */ 8875 function safeGet(object, key) { 8876 if (key === 'constructor' && typeof object[key] === 'function') { 8877 return; 8878 } 8879 8880 if (key == '__proto__') { 8881 return; 8882 } 8883 8884 return object[key]; 8885 } 8886 8887 /** 8888 * Sets metadata for `func`. 8889 * 8890 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short 8891 * period of time, it will trip its breaker and transition to an identity 8892 * function to avoid garbage collection pauses in V8. See 8893 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) 8894 * for more details. 8895 * 8896 * @private 8897 * @param {Function} func The function to associate metadata with. 8898 * @param {*} data The metadata. 8899 * @returns {Function} Returns `func`. 8900 */ 8901 var setData = shortOut(baseSetData); 8902 8903 /** 8904 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). 8905 * 8906 * @private 8907 * @param {Function} func The function to delay. 8908 * @param {number} wait The number of milliseconds to delay invocation. 8909 * @returns {number|Object} Returns the timer id or timeout object. 8910 */ 8911 var setTimeout = ctxSetTimeout || function(func, wait) { 8912 return root.setTimeout(func, wait); 8913 }; 8914 8915 /** 8916 * Sets the `toString` method of `func` to return `string`. 8917 * 8918 * @private 8919 * @param {Function} func The function to modify. 8920 * @param {Function} string The `toString` result. 8921 * @returns {Function} Returns `func`. 8922 */ 8923 var setToString = shortOut(baseSetToString); 8924 8925 /** 8926 * Sets the `toString` method of `wrapper` to mimic the source of `reference` 8927 * with wrapper details in a comment at the top of the source body. 8928 * 8929 * @private 8930 * @param {Function} wrapper The function to modify. 8931 * @param {Function} reference The reference function. 8932 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 8933 * @returns {Function} Returns `wrapper`. 8934 */ 8935 function setWrapToString(wrapper, reference, bitmask) { 8936 var source = (reference + ''); 8937 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); 8938 } 8939 8940 /** 8941 * Creates a function that'll short out and invoke `identity` instead 8942 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` 8943 * milliseconds. 8944 * 8945 * @private 8946 * @param {Function} func The function to restrict. 8947 * @returns {Function} Returns the new shortable function. 8948 */ 8949 function shortOut(func) { 8950 var count = 0, 8951 lastCalled = 0; 8952 8953 return function() { 8954 var stamp = nativeNow(), 8955 remaining = HOT_SPAN - (stamp - lastCalled); 8956 8957 lastCalled = stamp; 8958 if (remaining > 0) { 8959 if (++count >= HOT_COUNT) { 8960 return arguments[0]; 8961 } 8962 } else { 8963 count = 0; 8964 } 8965 return func.apply(undefined, arguments); 8966 }; 8967 } 8968 8969 /** 8970 * A specialized version of `_.shuffle` which mutates and sets the size of `array`. 8971 * 8972 * @private 8973 * @param {Array} array The array to shuffle. 8974 * @param {number} [size=array.length] The size of `array`. 8975 * @returns {Array} Returns `array`. 8976 */ 8977 function shuffleSelf(array, size) { 8978 var index = -1, 8979 length = array.length, 8980 lastIndex = length - 1; 8981 8982 size = size === undefined ? length : size; 8983 while (++index < size) { 8984 var rand = baseRandom(index, lastIndex), 8985 value = array[rand]; 8986 8987 array[rand] = array[index]; 8988 array[index] = value; 8989 } 8990 array.length = size; 8991 return array; 8992 } 8993 8994 /** 8995 * Converts `string` to a property path array. 8996 * 8997 * @private 8998 * @param {string} string The string to convert. 8999 * @returns {Array} Returns the property path array. 9000 */ 9001 var stringToPath = memoizeCapped(function(string) { 9002 var result = []; 9003 if (string.charCodeAt(0) === 46 /* . */) { 9004 result.push(''); 9005 } 9006 string.replace(rePropName, function(match, number, quote, subString) { 9007 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); 9008 }); 9009 return result; 9010 }); 9011 9012 /** 9013 * Converts `value` to a string key if it's not a string or symbol. 9014 * 9015 * @private 9016 * @param {*} value The value to inspect. 9017 * @returns {string|symbol} Returns the key. 9018 */ 9019 function toKey(value) { 9020 if (typeof value == 'string' || isSymbol(value)) { 9021 return value; 9022 } 9023 var result = (value + ''); 9024 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 9025 } 9026 9027 /** 9028 * Converts `func` to its source code. 9029 * 9030 * @private 9031 * @param {Function} func The function to convert. 9032 * @returns {string} Returns the source code. 9033 */ 9034 function toSource(func) { 9035 if (func != null) { 9036 try { 9037 return funcToString.call(func); 9038 } catch (e) {} 9039 try { 9040 return (func + ''); 9041 } catch (e) {} 9042 } 9043 return ''; 9044 } 9045 9046 /** 9047 * Updates wrapper `details` based on `bitmask` flags. 9048 * 9049 * @private 9050 * @returns {Array} details The details to modify. 9051 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 9052 * @returns {Array} Returns `details`. 9053 */ 9054 function updateWrapDetails(details, bitmask) { 9055 arrayEach(wrapFlags, function(pair) { 9056 var value = '_.' + pair[0]; 9057 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { 9058 details.push(value); 9059 } 9060 }); 9061 return details.sort(); 9062 } 9063 9064 /** 9065 * Creates a clone of `wrapper`. 9066 * 9067 * @private 9068 * @param {Object} wrapper The wrapper to clone. 9069 * @returns {Object} Returns the cloned wrapper. 9070 */ 9071 function wrapperClone(wrapper) { 9072 if (wrapper instanceof LazyWrapper) { 9073 return wrapper.clone(); 9074 } 9075 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); 9076 result.__actions__ = copyArray(wrapper.__actions__); 9077 result.__index__ = wrapper.__index__; 9078 result.__values__ = wrapper.__values__; 9079 return result; 9080 } 9081 9082 /*------------------------------------------------------------------------*/ 9083 9084 /** 9085 * Creates an array of elements split into groups the length of `size`. 9086 * If `array` can't be split evenly, the final chunk will be the remaining 9087 * elements. 9088 * 9089 * @static 9090 * @memberOf _ 9091 * @since 3.0.0 9092 * @category Array 9093 * @param {Array} array The array to process. 9094 * @param {number} [size=1] The length of each chunk 9095 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9096 * @returns {Array} Returns the new array of chunks. 9097 * @example 9098 * 9099 * _.chunk(['a', 'b', 'c', 'd'], 2); 9100 * // => [['a', 'b'], ['c', 'd']] 9101 * 9102 * _.chunk(['a', 'b', 'c', 'd'], 3); 9103 * // => [['a', 'b', 'c'], ['d']] 9104 */ 9105 function chunk(array, size, guard) { 9106 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { 9107 size = 1; 9108 } else { 9109 size = nativeMax(toInteger(size), 0); 9110 } 9111 var length = array == null ? 0 : array.length; 9112 if (!length || size < 1) { 9113 return []; 9114 } 9115 var index = 0, 9116 resIndex = 0, 9117 result = Array(nativeCeil(length / size)); 9118 9119 while (index < length) { 9120 result[resIndex++] = baseSlice(array, index, (index += size)); 9121 } 9122 return result; 9123 } 9124 9125 /** 9126 * Creates an array with all falsey values removed. The values `false`, `null`, 9127 * `0`, `""`, `undefined`, and `NaN` are falsey. 9128 * 9129 * @static 9130 * @memberOf _ 9131 * @since 0.1.0 9132 * @category Array 9133 * @param {Array} array The array to compact. 9134 * @returns {Array} Returns the new array of filtered values. 9135 * @example 9136 * 9137 * _.compact([0, 1, false, 2, '', 3]); 9138 * // => [1, 2, 3] 9139 */ 9140 function compact(array) { 9141 var index = -1, 9142 length = array == null ? 0 : array.length, 9143 resIndex = 0, 9144 result = []; 9145 9146 while (++index < length) { 9147 var value = array[index]; 9148 if (value) { 9149 result[resIndex++] = value; 9150 } 9151 } 9152 return result; 9153 } 9154 9155 /** 9156 * Creates a new array concatenating `array` with any additional arrays 9157 * and/or values. 9158 * 9159 * @static 9160 * @memberOf _ 9161 * @since 4.0.0 9162 * @category Array 9163 * @param {Array} array The array to concatenate. 9164 * @param {...*} [values] The values to concatenate. 9165 * @returns {Array} Returns the new concatenated array. 9166 * @example 9167 * 9168 * var array = [1]; 9169 * var other = _.concat(array, 2, [3], [[4]]); 9170 * 9171 * console.log(other); 9172 * // => [1, 2, 3, [4]] 9173 * 9174 * console.log(array); 9175 * // => [1] 9176 */ 9177 function concat() { 9178 var length = arguments.length; 9179 if (!length) { 9180 return []; 9181 } 9182 var args = Array(length - 1), 9183 array = arguments[0], 9184 index = length; 9185 9186 while (index--) { 9187 args[index - 1] = arguments[index]; 9188 } 9189 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); 9190 } 9191 9192 /** 9193 * Creates an array of `array` values not included in the other given arrays 9194 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9195 * for equality comparisons. The order and references of result values are 9196 * determined by the first array. 9197 * 9198 * **Note:** Unlike `_.pullAll`, this method returns a new array. 9199 * 9200 * @static 9201 * @memberOf _ 9202 * @since 0.1.0 9203 * @category Array 9204 * @param {Array} array The array to inspect. 9205 * @param {...Array} [values] The values to exclude. 9206 * @returns {Array} Returns the new array of filtered values. 9207 * @see _.without, _.xor 9208 * @example 9209 * 9210 * _.difference([2, 1], [2, 3]); 9211 * // => [1] 9212 */ 9213 var difference = baseRest(function(array, values) { 9214 return isArrayLikeObject(array) 9215 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) 9216 : []; 9217 }); 9218 9219 /** 9220 * This method is like `_.difference` except that it accepts `iteratee` which 9221 * is invoked for each element of `array` and `values` to generate the criterion 9222 * by which they're compared. The order and references of result values are 9223 * determined by the first array. The iteratee is invoked with one argument: 9224 * (value). 9225 * 9226 * **Note:** Unlike `_.pullAllBy`, this method returns a new array. 9227 * 9228 * @static 9229 * @memberOf _ 9230 * @since 4.0.0 9231 * @category Array 9232 * @param {Array} array The array to inspect. 9233 * @param {...Array} [values] The values to exclude. 9234 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 9235 * @returns {Array} Returns the new array of filtered values. 9236 * @example 9237 * 9238 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); 9239 * // => [1.2] 9240 * 9241 * // The `_.property` iteratee shorthand. 9242 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); 9243 * // => [{ 'x': 2 }] 9244 */ 9245 var differenceBy = baseRest(function(array, values) { 9246 var iteratee = last(values); 9247 if (isArrayLikeObject(iteratee)) { 9248 iteratee = undefined; 9249 } 9250 return isArrayLikeObject(array) 9251 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) 9252 : []; 9253 }); 9254 9255 /** 9256 * This method is like `_.difference` except that it accepts `comparator` 9257 * which is invoked to compare elements of `array` to `values`. The order and 9258 * references of result values are determined by the first array. The comparator 9259 * is invoked with two arguments: (arrVal, othVal). 9260 * 9261 * **Note:** Unlike `_.pullAllWith`, this method returns a new array. 9262 * 9263 * @static 9264 * @memberOf _ 9265 * @since 4.0.0 9266 * @category Array 9267 * @param {Array} array The array to inspect. 9268 * @param {...Array} [values] The values to exclude. 9269 * @param {Function} [comparator] The comparator invoked per element. 9270 * @returns {Array} Returns the new array of filtered values. 9271 * @example 9272 * 9273 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 9274 * 9275 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); 9276 * // => [{ 'x': 2, 'y': 1 }] 9277 */ 9278 var differenceWith = baseRest(function(array, values) { 9279 var comparator = last(values); 9280 if (isArrayLikeObject(comparator)) { 9281 comparator = undefined; 9282 } 9283 return isArrayLikeObject(array) 9284 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) 9285 : []; 9286 }); 9287 9288 /** 9289 * Creates a slice of `array` with `n` elements dropped from the beginning. 9290 * 9291 * @static 9292 * @memberOf _ 9293 * @since 0.5.0 9294 * @category Array 9295 * @param {Array} array The array to query. 9296 * @param {number} [n=1] The number of elements to drop. 9297 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9298 * @returns {Array} Returns the slice of `array`. 9299 * @example 9300 * 9301 * _.drop([1, 2, 3]); 9302 * // => [2, 3] 9303 * 9304 * _.drop([1, 2, 3], 2); 9305 * // => [3] 9306 * 9307 * _.drop([1, 2, 3], 5); 9308 * // => [] 9309 * 9310 * _.drop([1, 2, 3], 0); 9311 * // => [1, 2, 3] 9312 */ 9313 function drop(array, n, guard) { 9314 var length = array == null ? 0 : array.length; 9315 if (!length) { 9316 return []; 9317 } 9318 n = (guard || n === undefined) ? 1 : toInteger(n); 9319 return baseSlice(array, n < 0 ? 0 : n, length); 9320 } 9321 9322 /** 9323 * Creates a slice of `array` with `n` elements dropped from the end. 9324 * 9325 * @static 9326 * @memberOf _ 9327 * @since 3.0.0 9328 * @category Array 9329 * @param {Array} array The array to query. 9330 * @param {number} [n=1] The number of elements to drop. 9331 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9332 * @returns {Array} Returns the slice of `array`. 9333 * @example 9334 * 9335 * _.dropRight([1, 2, 3]); 9336 * // => [1, 2] 9337 * 9338 * _.dropRight([1, 2, 3], 2); 9339 * // => [1] 9340 * 9341 * _.dropRight([1, 2, 3], 5); 9342 * // => [] 9343 * 9344 * _.dropRight([1, 2, 3], 0); 9345 * // => [1, 2, 3] 9346 */ 9347 function dropRight(array, n, guard) { 9348 var length = array == null ? 0 : array.length; 9349 if (!length) { 9350 return []; 9351 } 9352 n = (guard || n === undefined) ? 1 : toInteger(n); 9353 n = length - n; 9354 return baseSlice(array, 0, n < 0 ? 0 : n); 9355 } 9356 9357 /** 9358 * Creates a slice of `array` excluding elements dropped from the end. 9359 * Elements are dropped until `predicate` returns falsey. The predicate is 9360 * invoked with three arguments: (value, index, array). 9361 * 9362 * @static 9363 * @memberOf _ 9364 * @since 3.0.0 9365 * @category Array 9366 * @param {Array} array The array to query. 9367 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9368 * @returns {Array} Returns the slice of `array`. 9369 * @example 9370 * 9371 * var users = [ 9372 * { 'user': 'barney', 'active': true }, 9373 * { 'user': 'fred', 'active': false }, 9374 * { 'user': 'pebbles', 'active': false } 9375 * ]; 9376 * 9377 * _.dropRightWhile(users, function(o) { return !o.active; }); 9378 * // => objects for ['barney'] 9379 * 9380 * // The `_.matches` iteratee shorthand. 9381 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); 9382 * // => objects for ['barney', 'fred'] 9383 * 9384 * // The `_.matchesProperty` iteratee shorthand. 9385 * _.dropRightWhile(users, ['active', false]); 9386 * // => objects for ['barney'] 9387 * 9388 * // The `_.property` iteratee shorthand. 9389 * _.dropRightWhile(users, 'active'); 9390 * // => objects for ['barney', 'fred', 'pebbles'] 9391 */ 9392 function dropRightWhile(array, predicate) { 9393 return (array && array.length) 9394 ? baseWhile(array, getIteratee(predicate, 3), true, true) 9395 : []; 9396 } 9397 9398 /** 9399 * Creates a slice of `array` excluding elements dropped from the beginning. 9400 * Elements are dropped until `predicate` returns falsey. The predicate is 9401 * invoked with three arguments: (value, index, array). 9402 * 9403 * @static 9404 * @memberOf _ 9405 * @since 3.0.0 9406 * @category Array 9407 * @param {Array} array The array to query. 9408 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9409 * @returns {Array} Returns the slice of `array`. 9410 * @example 9411 * 9412 * var users = [ 9413 * { 'user': 'barney', 'active': false }, 9414 * { 'user': 'fred', 'active': false }, 9415 * { 'user': 'pebbles', 'active': true } 9416 * ]; 9417 * 9418 * _.dropWhile(users, function(o) { return !o.active; }); 9419 * // => objects for ['pebbles'] 9420 * 9421 * // The `_.matches` iteratee shorthand. 9422 * _.dropWhile(users, { 'user': 'barney', 'active': false }); 9423 * // => objects for ['fred', 'pebbles'] 9424 * 9425 * // The `_.matchesProperty` iteratee shorthand. 9426 * _.dropWhile(users, ['active', false]); 9427 * // => objects for ['pebbles'] 9428 * 9429 * // The `_.property` iteratee shorthand. 9430 * _.dropWhile(users, 'active'); 9431 * // => objects for ['barney', 'fred', 'pebbles'] 9432 */ 9433 function dropWhile(array, predicate) { 9434 return (array && array.length) 9435 ? baseWhile(array, getIteratee(predicate, 3), true) 9436 : []; 9437 } 9438 9439 /** 9440 * Fills elements of `array` with `value` from `start` up to, but not 9441 * including, `end`. 9442 * 9443 * **Note:** This method mutates `array`. 9444 * 9445 * @static 9446 * @memberOf _ 9447 * @since 3.2.0 9448 * @category Array 9449 * @param {Array} array The array to fill. 9450 * @param {*} value The value to fill `array` with. 9451 * @param {number} [start=0] The start position. 9452 * @param {number} [end=array.length] The end position. 9453 * @returns {Array} Returns `array`. 9454 * @example 9455 * 9456 * var array = [1, 2, 3]; 9457 * 9458 * _.fill(array, 'a'); 9459 * console.log(array); 9460 * // => ['a', 'a', 'a'] 9461 * 9462 * _.fill(Array(3), 2); 9463 * // => [2, 2, 2] 9464 * 9465 * _.fill([4, 6, 8, 10], '*', 1, 3); 9466 * // => [4, '*', '*', 10] 9467 */ 9468 function fill(array, value, start, end) { 9469 var length = array == null ? 0 : array.length; 9470 if (!length) { 9471 return []; 9472 } 9473 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { 9474 start = 0; 9475 end = length; 9476 } 9477 return baseFill(array, value, start, end); 9478 } 9479 9480 /** 9481 * This method is like `_.find` except that it returns the index of the first 9482 * element `predicate` returns truthy for instead of the element itself. 9483 * 9484 * @static 9485 * @memberOf _ 9486 * @since 1.1.0 9487 * @category Array 9488 * @param {Array} array The array to inspect. 9489 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9490 * @param {number} [fromIndex=0] The index to search from. 9491 * @returns {number} Returns the index of the found element, else `-1`. 9492 * @example 9493 * 9494 * var users = [ 9495 * { 'user': 'barney', 'active': false }, 9496 * { 'user': 'fred', 'active': false }, 9497 * { 'user': 'pebbles', 'active': true } 9498 * ]; 9499 * 9500 * _.findIndex(users, function(o) { return o.user == 'barney'; }); 9501 * // => 0 9502 * 9503 * // The `_.matches` iteratee shorthand. 9504 * _.findIndex(users, { 'user': 'fred', 'active': false }); 9505 * // => 1 9506 * 9507 * // The `_.matchesProperty` iteratee shorthand. 9508 * _.findIndex(users, ['active', false]); 9509 * // => 0 9510 * 9511 * // The `_.property` iteratee shorthand. 9512 * _.findIndex(users, 'active'); 9513 * // => 2 9514 */ 9515 function findIndex(array, predicate, fromIndex) { 9516 var length = array == null ? 0 : array.length; 9517 if (!length) { 9518 return -1; 9519 } 9520 var index = fromIndex == null ? 0 : toInteger(fromIndex); 9521 if (index < 0) { 9522 index = nativeMax(length + index, 0); 9523 } 9524 return baseFindIndex(array, getIteratee(predicate, 3), index); 9525 } 9526 9527 /** 9528 * This method is like `_.findIndex` except that it iterates over elements 9529 * of `collection` from right to left. 9530 * 9531 * @static 9532 * @memberOf _ 9533 * @since 2.0.0 9534 * @category Array 9535 * @param {Array} array The array to inspect. 9536 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9537 * @param {number} [fromIndex=array.length-1] The index to search from. 9538 * @returns {number} Returns the index of the found element, else `-1`. 9539 * @example 9540 * 9541 * var users = [ 9542 * { 'user': 'barney', 'active': true }, 9543 * { 'user': 'fred', 'active': false }, 9544 * { 'user': 'pebbles', 'active': false } 9545 * ]; 9546 * 9547 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); 9548 * // => 2 9549 * 9550 * // The `_.matches` iteratee shorthand. 9551 * _.findLastIndex(users, { 'user': 'barney', 'active': true }); 9552 * // => 0 9553 * 9554 * // The `_.matchesProperty` iteratee shorthand. 9555 * _.findLastIndex(users, ['active', false]); 9556 * // => 2 9557 * 9558 * // The `_.property` iteratee shorthand. 9559 * _.findLastIndex(users, 'active'); 9560 * // => 0 9561 */ 9562 function findLastIndex(array, predicate, fromIndex) { 9563 var length = array == null ? 0 : array.length; 9564 if (!length) { 9565 return -1; 9566 } 9567 var index = length - 1; 9568 if (fromIndex !== undefined) { 9569 index = toInteger(fromIndex); 9570 index = fromIndex < 0 9571 ? nativeMax(length + index, 0) 9572 : nativeMin(index, length - 1); 9573 } 9574 return baseFindIndex(array, getIteratee(predicate, 3), index, true); 9575 } 9576 9577 /** 9578 * Flattens `array` a single level deep. 9579 * 9580 * @static 9581 * @memberOf _ 9582 * @since 0.1.0 9583 * @category Array 9584 * @param {Array} array The array to flatten. 9585 * @returns {Array} Returns the new flattened array. 9586 * @example 9587 * 9588 * _.flatten([1, [2, [3, [4]], 5]]); 9589 * // => [1, 2, [3, [4]], 5] 9590 */ 9591 function flatten(array) { 9592 var length = array == null ? 0 : array.length; 9593 return length ? baseFlatten(array, 1) : []; 9594 } 9595 9596 /** 9597 * Recursively flattens `array`. 9598 * 9599 * @static 9600 * @memberOf _ 9601 * @since 3.0.0 9602 * @category Array 9603 * @param {Array} array The array to flatten. 9604 * @returns {Array} Returns the new flattened array. 9605 * @example 9606 * 9607 * _.flattenDeep([1, [2, [3, [4]], 5]]); 9608 * // => [1, 2, 3, 4, 5] 9609 */ 9610 function flattenDeep(array) { 9611 var length = array == null ? 0 : array.length; 9612 return length ? baseFlatten(array, INFINITY) : []; 9613 } 9614 9615 /** 9616 * Recursively flatten `array` up to `depth` times. 9617 * 9618 * @static 9619 * @memberOf _ 9620 * @since 4.4.0 9621 * @category Array 9622 * @param {Array} array The array to flatten. 9623 * @param {number} [depth=1] The maximum recursion depth. 9624 * @returns {Array} Returns the new flattened array. 9625 * @example 9626 * 9627 * var array = [1, [2, [3, [4]], 5]]; 9628 * 9629 * _.flattenDepth(array, 1); 9630 * // => [1, 2, [3, [4]], 5] 9631 * 9632 * _.flattenDepth(array, 2); 9633 * // => [1, 2, 3, [4], 5] 9634 */ 9635 function flattenDepth(array, depth) { 9636 var length = array == null ? 0 : array.length; 9637 if (!length) { 9638 return []; 9639 } 9640 depth = depth === undefined ? 1 : toInteger(depth); 9641 return baseFlatten(array, depth); 9642 } 9643 9644 /** 9645 * The inverse of `_.toPairs`; this method returns an object composed 9646 * from key-value `pairs`. 9647 * 9648 * @static 9649 * @memberOf _ 9650 * @since 4.0.0 9651 * @category Array 9652 * @param {Array} pairs The key-value pairs. 9653 * @returns {Object} Returns the new object. 9654 * @example 9655 * 9656 * _.fromPairs([['a', 1], ['b', 2]]); 9657 * // => { 'a': 1, 'b': 2 } 9658 */ 9659 function fromPairs(pairs) { 9660 var index = -1, 9661 length = pairs == null ? 0 : pairs.length, 9662 result = {}; 9663 9664 while (++index < length) { 9665 var pair = pairs[index]; 9666 result[pair[0]] = pair[1]; 9667 } 9668 return result; 9669 } 9670 9671 /** 9672 * Gets the first element of `array`. 9673 * 9674 * @static 9675 * @memberOf _ 9676 * @since 0.1.0 9677 * @alias first 9678 * @category Array 9679 * @param {Array} array The array to query. 9680 * @returns {*} Returns the first element of `array`. 9681 * @example 9682 * 9683 * _.head([1, 2, 3]); 9684 * // => 1 9685 * 9686 * _.head([]); 9687 * // => undefined 9688 */ 9689 function head(array) { 9690 return (array && array.length) ? array[0] : undefined; 9691 } 9692 9693 /** 9694 * Gets the index at which the first occurrence of `value` is found in `array` 9695 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9696 * for equality comparisons. If `fromIndex` is negative, it's used as the 9697 * offset from the end of `array`. 9698 * 9699 * @static 9700 * @memberOf _ 9701 * @since 0.1.0 9702 * @category Array 9703 * @param {Array} array The array to inspect. 9704 * @param {*} value The value to search for. 9705 * @param {number} [fromIndex=0] The index to search from. 9706 * @returns {number} Returns the index of the matched value, else `-1`. 9707 * @example 9708 * 9709 * _.indexOf([1, 2, 1, 2], 2); 9710 * // => 1 9711 * 9712 * // Search from the `fromIndex`. 9713 * _.indexOf([1, 2, 1, 2], 2, 2); 9714 * // => 3 9715 */ 9716 function indexOf(array, value, fromIndex) { 9717 var length = array == null ? 0 : array.length; 9718 if (!length) { 9719 return -1; 9720 } 9721 var index = fromIndex == null ? 0 : toInteger(fromIndex); 9722 if (index < 0) { 9723 index = nativeMax(length + index, 0); 9724 } 9725 return baseIndexOf(array, value, index); 9726 } 9727 9728 /** 9729 * Gets all but the last element of `array`. 9730 * 9731 * @static 9732 * @memberOf _ 9733 * @since 0.1.0 9734 * @category Array 9735 * @param {Array} array The array to query. 9736 * @returns {Array} Returns the slice of `array`. 9737 * @example 9738 * 9739 * _.initial([1, 2, 3]); 9740 * // => [1, 2] 9741 */ 9742 function initial(array) { 9743 var length = array == null ? 0 : array.length; 9744 return length ? baseSlice(array, 0, -1) : []; 9745 } 9746 9747 /** 9748 * Creates an array of unique values that are included in all given arrays 9749 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9750 * for equality comparisons. The order and references of result values are 9751 * determined by the first array. 9752 * 9753 * @static 9754 * @memberOf _ 9755 * @since 0.1.0 9756 * @category Array 9757 * @param {...Array} [arrays] The arrays to inspect. 9758 * @returns {Array} Returns the new array of intersecting values. 9759 * @example 9760 * 9761 * _.intersection([2, 1], [2, 3]); 9762 * // => [2] 9763 */ 9764 var intersection = baseRest(function(arrays) { 9765 var mapped = arrayMap(arrays, castArrayLikeObject); 9766 return (mapped.length && mapped[0] === arrays[0]) 9767 ? baseIntersection(mapped) 9768 : []; 9769 }); 9770 9771 /** 9772 * This method is like `_.intersection` except that it accepts `iteratee` 9773 * which is invoked for each element of each `arrays` to generate the criterion 9774 * by which they're compared. The order and references of result values are 9775 * determined by the first array. The iteratee is invoked with one argument: 9776 * (value). 9777 * 9778 * @static 9779 * @memberOf _ 9780 * @since 4.0.0 9781 * @category Array 9782 * @param {...Array} [arrays] The arrays to inspect. 9783 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 9784 * @returns {Array} Returns the new array of intersecting values. 9785 * @example 9786 * 9787 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); 9788 * // => [2.1] 9789 * 9790 * // The `_.property` iteratee shorthand. 9791 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 9792 * // => [{ 'x': 1 }] 9793 */ 9794 var intersectionBy = baseRest(function(arrays) { 9795 var iteratee = last(arrays), 9796 mapped = arrayMap(arrays, castArrayLikeObject); 9797 9798 if (iteratee === last(mapped)) { 9799 iteratee = undefined; 9800 } else { 9801 mapped.pop(); 9802 } 9803 return (mapped.length && mapped[0] === arrays[0]) 9804 ? baseIntersection(mapped, getIteratee(iteratee, 2)) 9805 : []; 9806 }); 9807 9808 /** 9809 * This method is like `_.intersection` except that it accepts `comparator` 9810 * which is invoked to compare elements of `arrays`. The order and references 9811 * of result values are determined by the first array. The comparator is 9812 * invoked with two arguments: (arrVal, othVal). 9813 * 9814 * @static 9815 * @memberOf _ 9816 * @since 4.0.0 9817 * @category Array 9818 * @param {...Array} [arrays] The arrays to inspect. 9819 * @param {Function} [comparator] The comparator invoked per element. 9820 * @returns {Array} Returns the new array of intersecting values. 9821 * @example 9822 * 9823 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 9824 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 9825 * 9826 * _.intersectionWith(objects, others, _.isEqual); 9827 * // => [{ 'x': 1, 'y': 2 }] 9828 */ 9829 var intersectionWith = baseRest(function(arrays) { 9830 var comparator = last(arrays), 9831 mapped = arrayMap(arrays, castArrayLikeObject); 9832 9833 comparator = typeof comparator == 'function' ? comparator : undefined; 9834 if (comparator) { 9835 mapped.pop(); 9836 } 9837 return (mapped.length && mapped[0] === arrays[0]) 9838 ? baseIntersection(mapped, undefined, comparator) 9839 : []; 9840 }); 9841 9842 /** 9843 * Converts all elements in `array` into a string separated by `separator`. 9844 * 9845 * @static 9846 * @memberOf _ 9847 * @since 4.0.0 9848 * @category Array 9849 * @param {Array} array The array to convert. 9850 * @param {string} [separator=','] The element separator. 9851 * @returns {string} Returns the joined string. 9852 * @example 9853 * 9854 * _.join(['a', 'b', 'c'], '~'); 9855 * // => 'a~b~c' 9856 */ 9857 function join(array, separator) { 9858 return array == null ? '' : nativeJoin.call(array, separator); 9859 } 9860 9861 /** 9862 * Gets the last element of `array`. 9863 * 9864 * @static 9865 * @memberOf _ 9866 * @since 0.1.0 9867 * @category Array 9868 * @param {Array} array The array to query. 9869 * @returns {*} Returns the last element of `array`. 9870 * @example 9871 * 9872 * _.last([1, 2, 3]); 9873 * // => 3 9874 */ 9875 function last(array) { 9876 var length = array == null ? 0 : array.length; 9877 return length ? array[length - 1] : undefined; 9878 } 9879 9880 /** 9881 * This method is like `_.indexOf` except that it iterates over elements of 9882 * `array` from right to left. 9883 * 9884 * @static 9885 * @memberOf _ 9886 * @since 0.1.0 9887 * @category Array 9888 * @param {Array} array The array to inspect. 9889 * @param {*} value The value to search for. 9890 * @param {number} [fromIndex=array.length-1] The index to search from. 9891 * @returns {number} Returns the index of the matched value, else `-1`. 9892 * @example 9893 * 9894 * _.lastIndexOf([1, 2, 1, 2], 2); 9895 * // => 3 9896 * 9897 * // Search from the `fromIndex`. 9898 * _.lastIndexOf([1, 2, 1, 2], 2, 2); 9899 * // => 1 9900 */ 9901 function lastIndexOf(array, value, fromIndex) { 9902 var length = array == null ? 0 : array.length; 9903 if (!length) { 9904 return -1; 9905 } 9906 var index = length; 9907 if (fromIndex !== undefined) { 9908 index = toInteger(fromIndex); 9909 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); 9910 } 9911 return value === value 9912 ? strictLastIndexOf(array, value, index) 9913 : baseFindIndex(array, baseIsNaN, index, true); 9914 } 9915 9916 /** 9917 * Gets the element at index `n` of `array`. If `n` is negative, the nth 9918 * element from the end is returned. 9919 * 9920 * @static 9921 * @memberOf _ 9922 * @since 4.11.0 9923 * @category Array 9924 * @param {Array} array The array to query. 9925 * @param {number} [n=0] The index of the element to return. 9926 * @returns {*} Returns the nth element of `array`. 9927 * @example 9928 * 9929 * var array = ['a', 'b', 'c', 'd']; 9930 * 9931 * _.nth(array, 1); 9932 * // => 'b' 9933 * 9934 * _.nth(array, -2); 9935 * // => 'c'; 9936 */ 9937 function nth(array, n) { 9938 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; 9939 } 9940 9941 /** 9942 * Removes all given values from `array` using 9943 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9944 * for equality comparisons. 9945 * 9946 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` 9947 * to remove elements from an array by predicate. 9948 * 9949 * @static 9950 * @memberOf _ 9951 * @since 2.0.0 9952 * @category Array 9953 * @param {Array} array The array to modify. 9954 * @param {...*} [values] The values to remove. 9955 * @returns {Array} Returns `array`. 9956 * @example 9957 * 9958 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 9959 * 9960 * _.pull(array, 'a', 'c'); 9961 * console.log(array); 9962 * // => ['b', 'b'] 9963 */ 9964 var pull = baseRest(pullAll); 9965 9966 /** 9967 * This method is like `_.pull` except that it accepts an array of values to remove. 9968 * 9969 * **Note:** Unlike `_.difference`, this method mutates `array`. 9970 * 9971 * @static 9972 * @memberOf _ 9973 * @since 4.0.0 9974 * @category Array 9975 * @param {Array} array The array to modify. 9976 * @param {Array} values The values to remove. 9977 * @returns {Array} Returns `array`. 9978 * @example 9979 * 9980 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 9981 * 9982 * _.pullAll(array, ['a', 'c']); 9983 * console.log(array); 9984 * // => ['b', 'b'] 9985 */ 9986 function pullAll(array, values) { 9987 return (array && array.length && values && values.length) 9988 ? basePullAll(array, values) 9989 : array; 9990 } 9991 9992 /** 9993 * This method is like `_.pullAll` except that it accepts `iteratee` which is 9994 * invoked for each element of `array` and `values` to generate the criterion 9995 * by which they're compared. The iteratee is invoked with one argument: (value). 9996 * 9997 * **Note:** Unlike `_.differenceBy`, this method mutates `array`. 9998 * 9999 * @static 10000 * @memberOf _ 10001 * @since 4.0.0 10002 * @category Array 10003 * @param {Array} array The array to modify. 10004 * @param {Array} values The values to remove. 10005 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10006 * @returns {Array} Returns `array`. 10007 * @example 10008 * 10009 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; 10010 * 10011 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); 10012 * console.log(array); 10013 * // => [{ 'x': 2 }] 10014 */ 10015 function pullAllBy(array, values, iteratee) { 10016 return (array && array.length && values && values.length) 10017 ? basePullAll(array, values, getIteratee(iteratee, 2)) 10018 : array; 10019 } 10020 10021 /** 10022 * This method is like `_.pullAll` except that it accepts `comparator` which 10023 * is invoked to compare elements of `array` to `values`. The comparator is 10024 * invoked with two arguments: (arrVal, othVal). 10025 * 10026 * **Note:** Unlike `_.differenceWith`, this method mutates `array`. 10027 * 10028 * @static 10029 * @memberOf _ 10030 * @since 4.6.0 10031 * @category Array 10032 * @param {Array} array The array to modify. 10033 * @param {Array} values The values to remove. 10034 * @param {Function} [comparator] The comparator invoked per element. 10035 * @returns {Array} Returns `array`. 10036 * @example 10037 * 10038 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; 10039 * 10040 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); 10041 * console.log(array); 10042 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] 10043 */ 10044 function pullAllWith(array, values, comparator) { 10045 return (array && array.length && values && values.length) 10046 ? basePullAll(array, values, undefined, comparator) 10047 : array; 10048 } 10049 10050 /** 10051 * Removes elements from `array` corresponding to `indexes` and returns an 10052 * array of removed elements. 10053 * 10054 * **Note:** Unlike `_.at`, this method mutates `array`. 10055 * 10056 * @static 10057 * @memberOf _ 10058 * @since 3.0.0 10059 * @category Array 10060 * @param {Array} array The array to modify. 10061 * @param {...(number|number[])} [indexes] The indexes of elements to remove. 10062 * @returns {Array} Returns the new array of removed elements. 10063 * @example 10064 * 10065 * var array = ['a', 'b', 'c', 'd']; 10066 * var pulled = _.pullAt(array, [1, 3]); 10067 * 10068 * console.log(array); 10069 * // => ['a', 'c'] 10070 * 10071 * console.log(pulled); 10072 * // => ['b', 'd'] 10073 */ 10074 var pullAt = flatRest(function(array, indexes) { 10075 var length = array == null ? 0 : array.length, 10076 result = baseAt(array, indexes); 10077 10078 basePullAt(array, arrayMap(indexes, function(index) { 10079 return isIndex(index, length) ? +index : index; 10080 }).sort(compareAscending)); 10081 10082 return result; 10083 }); 10084 10085 /** 10086 * Removes all elements from `array` that `predicate` returns truthy for 10087 * and returns an array of the removed elements. The predicate is invoked 10088 * with three arguments: (value, index, array). 10089 * 10090 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` 10091 * to pull elements from an array by value. 10092 * 10093 * @static 10094 * @memberOf _ 10095 * @since 2.0.0 10096 * @category Array 10097 * @param {Array} array The array to modify. 10098 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10099 * @returns {Array} Returns the new array of removed elements. 10100 * @example 10101 * 10102 * var array = [1, 2, 3, 4]; 10103 * var evens = _.remove(array, function(n) { 10104 * return n % 2 == 0; 10105 * }); 10106 * 10107 * console.log(array); 10108 * // => [1, 3] 10109 * 10110 * console.log(evens); 10111 * // => [2, 4] 10112 */ 10113 function remove(array, predicate) { 10114 var result = []; 10115 if (!(array && array.length)) { 10116 return result; 10117 } 10118 var index = -1, 10119 indexes = [], 10120 length = array.length; 10121 10122 predicate = getIteratee(predicate, 3); 10123 while (++index < length) { 10124 var value = array[index]; 10125 if (predicate(value, index, array)) { 10126 result.push(value); 10127 indexes.push(index); 10128 } 10129 } 10130 basePullAt(array, indexes); 10131 return result; 10132 } 10133 10134 /** 10135 * Reverses `array` so that the first element becomes the last, the second 10136 * element becomes the second to last, and so on. 10137 * 10138 * **Note:** This method mutates `array` and is based on 10139 * [`Array#reverse`](https://mdn.io/Array/reverse). 10140 * 10141 * @static 10142 * @memberOf _ 10143 * @since 4.0.0 10144 * @category Array 10145 * @param {Array} array The array to modify. 10146 * @returns {Array} Returns `array`. 10147 * @example 10148 * 10149 * var array = [1, 2, 3]; 10150 * 10151 * _.reverse(array); 10152 * // => [3, 2, 1] 10153 * 10154 * console.log(array); 10155 * // => [3, 2, 1] 10156 */ 10157 function reverse(array) { 10158 return array == null ? array : nativeReverse.call(array); 10159 } 10160 10161 /** 10162 * Creates a slice of `array` from `start` up to, but not including, `end`. 10163 * 10164 * **Note:** This method is used instead of 10165 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are 10166 * returned. 10167 * 10168 * @static 10169 * @memberOf _ 10170 * @since 3.0.0 10171 * @category Array 10172 * @param {Array} array The array to slice. 10173 * @param {number} [start=0] The start position. 10174 * @param {number} [end=array.length] The end position. 10175 * @returns {Array} Returns the slice of `array`. 10176 */ 10177 function slice(array, start, end) { 10178 var length = array == null ? 0 : array.length; 10179 if (!length) { 10180 return []; 10181 } 10182 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { 10183 start = 0; 10184 end = length; 10185 } 10186 else { 10187 start = start == null ? 0 : toInteger(start); 10188 end = end === undefined ? length : toInteger(end); 10189 } 10190 return baseSlice(array, start, end); 10191 } 10192 10193 /** 10194 * Uses a binary search to determine the lowest index at which `value` 10195 * should be inserted into `array` in order to maintain its sort order. 10196 * 10197 * @static 10198 * @memberOf _ 10199 * @since 0.1.0 10200 * @category Array 10201 * @param {Array} array The sorted array to inspect. 10202 * @param {*} value The value to evaluate. 10203 * @returns {number} Returns the index at which `value` should be inserted 10204 * into `array`. 10205 * @example 10206 * 10207 * _.sortedIndex([30, 50], 40); 10208 * // => 1 10209 */ 10210 function sortedIndex(array, value) { 10211 return baseSortedIndex(array, value); 10212 } 10213 10214 /** 10215 * This method is like `_.sortedIndex` except that it accepts `iteratee` 10216 * which is invoked for `value` and each element of `array` to compute their 10217 * sort ranking. The iteratee is invoked with one argument: (value). 10218 * 10219 * @static 10220 * @memberOf _ 10221 * @since 4.0.0 10222 * @category Array 10223 * @param {Array} array The sorted array to inspect. 10224 * @param {*} value The value to evaluate. 10225 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10226 * @returns {number} Returns the index at which `value` should be inserted 10227 * into `array`. 10228 * @example 10229 * 10230 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 10231 * 10232 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 10233 * // => 0 10234 * 10235 * // The `_.property` iteratee shorthand. 10236 * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); 10237 * // => 0 10238 */ 10239 function sortedIndexBy(array, value, iteratee) { 10240 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); 10241 } 10242 10243 /** 10244 * This method is like `_.indexOf` except that it performs a binary 10245 * search on a sorted `array`. 10246 * 10247 * @static 10248 * @memberOf _ 10249 * @since 4.0.0 10250 * @category Array 10251 * @param {Array} array The array to inspect. 10252 * @param {*} value The value to search for. 10253 * @returns {number} Returns the index of the matched value, else `-1`. 10254 * @example 10255 * 10256 * _.sortedIndexOf([4, 5, 5, 5, 6], 5); 10257 * // => 1 10258 */ 10259 function sortedIndexOf(array, value) { 10260 var length = array == null ? 0 : array.length; 10261 if (length) { 10262 var index = baseSortedIndex(array, value); 10263 if (index < length && eq(array[index], value)) { 10264 return index; 10265 } 10266 } 10267 return -1; 10268 } 10269 10270 /** 10271 * This method is like `_.sortedIndex` except that it returns the highest 10272 * index at which `value` should be inserted into `array` in order to 10273 * maintain its sort order. 10274 * 10275 * @static 10276 * @memberOf _ 10277 * @since 3.0.0 10278 * @category Array 10279 * @param {Array} array The sorted array to inspect. 10280 * @param {*} value The value to evaluate. 10281 * @returns {number} Returns the index at which `value` should be inserted 10282 * into `array`. 10283 * @example 10284 * 10285 * _.sortedLastIndex([4, 5, 5, 5, 6], 5); 10286 * // => 4 10287 */ 10288 function sortedLastIndex(array, value) { 10289 return baseSortedIndex(array, value, true); 10290 } 10291 10292 /** 10293 * This method is like `_.sortedLastIndex` except that it accepts `iteratee` 10294 * which is invoked for `value` and each element of `array` to compute their 10295 * sort ranking. The iteratee is invoked with one argument: (value). 10296 * 10297 * @static 10298 * @memberOf _ 10299 * @since 4.0.0 10300 * @category Array 10301 * @param {Array} array The sorted array to inspect. 10302 * @param {*} value The value to evaluate. 10303 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10304 * @returns {number} Returns the index at which `value` should be inserted 10305 * into `array`. 10306 * @example 10307 * 10308 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 10309 * 10310 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 10311 * // => 1 10312 * 10313 * // The `_.property` iteratee shorthand. 10314 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); 10315 * // => 1 10316 */ 10317 function sortedLastIndexBy(array, value, iteratee) { 10318 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); 10319 } 10320 10321 /** 10322 * This method is like `_.lastIndexOf` except that it performs a binary 10323 * search on a sorted `array`. 10324 * 10325 * @static 10326 * @memberOf _ 10327 * @since 4.0.0 10328 * @category Array 10329 * @param {Array} array The array to inspect. 10330 * @param {*} value The value to search for. 10331 * @returns {number} Returns the index of the matched value, else `-1`. 10332 * @example 10333 * 10334 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); 10335 * // => 3 10336 */ 10337 function sortedLastIndexOf(array, value) { 10338 var length = array == null ? 0 : array.length; 10339 if (length) { 10340 var index = baseSortedIndex(array, value, true) - 1; 10341 if (eq(array[index], value)) { 10342 return index; 10343 } 10344 } 10345 return -1; 10346 } 10347 10348 /** 10349 * This method is like `_.uniq` except that it's designed and optimized 10350 * for sorted arrays. 10351 * 10352 * @static 10353 * @memberOf _ 10354 * @since 4.0.0 10355 * @category Array 10356 * @param {Array} array The array to inspect. 10357 * @returns {Array} Returns the new duplicate free array. 10358 * @example 10359 * 10360 * _.sortedUniq([1, 1, 2]); 10361 * // => [1, 2] 10362 */ 10363 function sortedUniq(array) { 10364 return (array && array.length) 10365 ? baseSortedUniq(array) 10366 : []; 10367 } 10368 10369 /** 10370 * This method is like `_.uniqBy` except that it's designed and optimized 10371 * for sorted arrays. 10372 * 10373 * @static 10374 * @memberOf _ 10375 * @since 4.0.0 10376 * @category Array 10377 * @param {Array} array The array to inspect. 10378 * @param {Function} [iteratee] The iteratee invoked per element. 10379 * @returns {Array} Returns the new duplicate free array. 10380 * @example 10381 * 10382 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); 10383 * // => [1.1, 2.3] 10384 */ 10385 function sortedUniqBy(array, iteratee) { 10386 return (array && array.length) 10387 ? baseSortedUniq(array, getIteratee(iteratee, 2)) 10388 : []; 10389 } 10390 10391 /** 10392 * Gets all but the first element of `array`. 10393 * 10394 * @static 10395 * @memberOf _ 10396 * @since 4.0.0 10397 * @category Array 10398 * @param {Array} array The array to query. 10399 * @returns {Array} Returns the slice of `array`. 10400 * @example 10401 * 10402 * _.tail([1, 2, 3]); 10403 * // => [2, 3] 10404 */ 10405 function tail(array) { 10406 var length = array == null ? 0 : array.length; 10407 return length ? baseSlice(array, 1, length) : []; 10408 } 10409 10410 /** 10411 * Creates a slice of `array` with `n` elements taken from the beginning. 10412 * 10413 * @static 10414 * @memberOf _ 10415 * @since 0.1.0 10416 * @category Array 10417 * @param {Array} array The array to query. 10418 * @param {number} [n=1] The number of elements to take. 10419 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 10420 * @returns {Array} Returns the slice of `array`. 10421 * @example 10422 * 10423 * _.take([1, 2, 3]); 10424 * // => [1] 10425 * 10426 * _.take([1, 2, 3], 2); 10427 * // => [1, 2] 10428 * 10429 * _.take([1, 2, 3], 5); 10430 * // => [1, 2, 3] 10431 * 10432 * _.take([1, 2, 3], 0); 10433 * // => [] 10434 */ 10435 function take(array, n, guard) { 10436 if (!(array && array.length)) { 10437 return []; 10438 } 10439 n = (guard || n === undefined) ? 1 : toInteger(n); 10440 return baseSlice(array, 0, n < 0 ? 0 : n); 10441 } 10442 10443 /** 10444 * Creates a slice of `array` with `n` elements taken from the end. 10445 * 10446 * @static 10447 * @memberOf _ 10448 * @since 3.0.0 10449 * @category Array 10450 * @param {Array} array The array to query. 10451 * @param {number} [n=1] The number of elements to take. 10452 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 10453 * @returns {Array} Returns the slice of `array`. 10454 * @example 10455 * 10456 * _.takeRight([1, 2, 3]); 10457 * // => [3] 10458 * 10459 * _.takeRight([1, 2, 3], 2); 10460 * // => [2, 3] 10461 * 10462 * _.takeRight([1, 2, 3], 5); 10463 * // => [1, 2, 3] 10464 * 10465 * _.takeRight([1, 2, 3], 0); 10466 * // => [] 10467 */ 10468 function takeRight(array, n, guard) { 10469 var length = array == null ? 0 : array.length; 10470 if (!length) { 10471 return []; 10472 } 10473 n = (guard || n === undefined) ? 1 : toInteger(n); 10474 n = length - n; 10475 return baseSlice(array, n < 0 ? 0 : n, length); 10476 } 10477 10478 /** 10479 * Creates a slice of `array` with elements taken from the end. Elements are 10480 * taken until `predicate` returns falsey. The predicate is invoked with 10481 * three arguments: (value, index, array). 10482 * 10483 * @static 10484 * @memberOf _ 10485 * @since 3.0.0 10486 * @category Array 10487 * @param {Array} array The array to query. 10488 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10489 * @returns {Array} Returns the slice of `array`. 10490 * @example 10491 * 10492 * var users = [ 10493 * { 'user': 'barney', 'active': true }, 10494 * { 'user': 'fred', 'active': false }, 10495 * { 'user': 'pebbles', 'active': false } 10496 * ]; 10497 * 10498 * _.takeRightWhile(users, function(o) { return !o.active; }); 10499 * // => objects for ['fred', 'pebbles'] 10500 * 10501 * // The `_.matches` iteratee shorthand. 10502 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); 10503 * // => objects for ['pebbles'] 10504 * 10505 * // The `_.matchesProperty` iteratee shorthand. 10506 * _.takeRightWhile(users, ['active', false]); 10507 * // => objects for ['fred', 'pebbles'] 10508 * 10509 * // The `_.property` iteratee shorthand. 10510 * _.takeRightWhile(users, 'active'); 10511 * // => [] 10512 */ 10513 function takeRightWhile(array, predicate) { 10514 return (array && array.length) 10515 ? baseWhile(array, getIteratee(predicate, 3), false, true) 10516 : []; 10517 } 10518 10519 /** 10520 * Creates a slice of `array` with elements taken from the beginning. Elements 10521 * are taken until `predicate` returns falsey. The predicate is invoked with 10522 * three arguments: (value, index, array). 10523 * 10524 * @static 10525 * @memberOf _ 10526 * @since 3.0.0 10527 * @category Array 10528 * @param {Array} array The array to query. 10529 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10530 * @returns {Array} Returns the slice of `array`. 10531 * @example 10532 * 10533 * var users = [ 10534 * { 'user': 'barney', 'active': false }, 10535 * { 'user': 'fred', 'active': false }, 10536 * { 'user': 'pebbles', 'active': true } 10537 * ]; 10538 * 10539 * _.takeWhile(users, function(o) { return !o.active; }); 10540 * // => objects for ['barney', 'fred'] 10541 * 10542 * // The `_.matches` iteratee shorthand. 10543 * _.takeWhile(users, { 'user': 'barney', 'active': false }); 10544 * // => objects for ['barney'] 10545 * 10546 * // The `_.matchesProperty` iteratee shorthand. 10547 * _.takeWhile(users, ['active', false]); 10548 * // => objects for ['barney', 'fred'] 10549 * 10550 * // The `_.property` iteratee shorthand. 10551 * _.takeWhile(users, 'active'); 10552 * // => [] 10553 */ 10554 function takeWhile(array, predicate) { 10555 return (array && array.length) 10556 ? baseWhile(array, getIteratee(predicate, 3)) 10557 : []; 10558 } 10559 10560 /** 10561 * Creates an array of unique values, in order, from all given arrays using 10562 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 10563 * for equality comparisons. 10564 * 10565 * @static 10566 * @memberOf _ 10567 * @since 0.1.0 10568 * @category Array 10569 * @param {...Array} [arrays] The arrays to inspect. 10570 * @returns {Array} Returns the new array of combined values. 10571 * @example 10572 * 10573 * _.union([2], [1, 2]); 10574 * // => [2, 1] 10575 */ 10576 var union = baseRest(function(arrays) { 10577 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); 10578 }); 10579 10580 /** 10581 * This method is like `_.union` except that it accepts `iteratee` which is 10582 * invoked for each element of each `arrays` to generate the criterion by 10583 * which uniqueness is computed. Result values are chosen from the first 10584 * array in which the value occurs. The iteratee is invoked with one argument: 10585 * (value). 10586 * 10587 * @static 10588 * @memberOf _ 10589 * @since 4.0.0 10590 * @category Array 10591 * @param {...Array} [arrays] The arrays to inspect. 10592 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10593 * @returns {Array} Returns the new array of combined values. 10594 * @example 10595 * 10596 * _.unionBy([2.1], [1.2, 2.3], Math.floor); 10597 * // => [2.1, 1.2] 10598 * 10599 * // The `_.property` iteratee shorthand. 10600 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 10601 * // => [{ 'x': 1 }, { 'x': 2 }] 10602 */ 10603 var unionBy = baseRest(function(arrays) { 10604 var iteratee = last(arrays); 10605 if (isArrayLikeObject(iteratee)) { 10606 iteratee = undefined; 10607 } 10608 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); 10609 }); 10610 10611 /** 10612 * This method is like `_.union` except that it accepts `comparator` which 10613 * is invoked to compare elements of `arrays`. Result values are chosen from 10614 * the first array in which the value occurs. The comparator is invoked 10615 * with two arguments: (arrVal, othVal). 10616 * 10617 * @static 10618 * @memberOf _ 10619 * @since 4.0.0 10620 * @category Array 10621 * @param {...Array} [arrays] The arrays to inspect. 10622 * @param {Function} [comparator] The comparator invoked per element. 10623 * @returns {Array} Returns the new array of combined values. 10624 * @example 10625 * 10626 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 10627 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 10628 * 10629 * _.unionWith(objects, others, _.isEqual); 10630 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 10631 */ 10632 var unionWith = baseRest(function(arrays) { 10633 var comparator = last(arrays); 10634 comparator = typeof comparator == 'function' ? comparator : undefined; 10635 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); 10636 }); 10637 10638 /** 10639 * Creates a duplicate-free version of an array, using 10640 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 10641 * for equality comparisons, in which only the first occurrence of each element 10642 * is kept. The order of result values is determined by the order they occur 10643 * in the array. 10644 * 10645 * @static 10646 * @memberOf _ 10647 * @since 0.1.0 10648 * @category Array 10649 * @param {Array} array The array to inspect. 10650 * @returns {Array} Returns the new duplicate free array. 10651 * @example 10652 * 10653 * _.uniq([2, 1, 2]); 10654 * // => [2, 1] 10655 */ 10656 function uniq(array) { 10657 return (array && array.length) ? baseUniq(array) : []; 10658 } 10659 10660 /** 10661 * This method is like `_.uniq` except that it accepts `iteratee` which is 10662 * invoked for each element in `array` to generate the criterion by which 10663 * uniqueness is computed. The order of result values is determined by the 10664 * order they occur in the array. The iteratee is invoked with one argument: 10665 * (value). 10666 * 10667 * @static 10668 * @memberOf _ 10669 * @since 4.0.0 10670 * @category Array 10671 * @param {Array} array The array to inspect. 10672 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10673 * @returns {Array} Returns the new duplicate free array. 10674 * @example 10675 * 10676 * _.uniqBy([2.1, 1.2, 2.3], Math.floor); 10677 * // => [2.1, 1.2] 10678 * 10679 * // The `_.property` iteratee shorthand. 10680 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); 10681 * // => [{ 'x': 1 }, { 'x': 2 }] 10682 */ 10683 function uniqBy(array, iteratee) { 10684 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; 10685 } 10686 10687 /** 10688 * This method is like `_.uniq` except that it accepts `comparator` which 10689 * is invoked to compare elements of `array`. The order of result values is 10690 * determined by the order they occur in the array.The comparator is invoked 10691 * with two arguments: (arrVal, othVal). 10692 * 10693 * @static 10694 * @memberOf _ 10695 * @since 4.0.0 10696 * @category Array 10697 * @param {Array} array The array to inspect. 10698 * @param {Function} [comparator] The comparator invoked per element. 10699 * @returns {Array} Returns the new duplicate free array. 10700 * @example 10701 * 10702 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; 10703 * 10704 * _.uniqWith(objects, _.isEqual); 10705 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] 10706 */ 10707 function uniqWith(array, comparator) { 10708 comparator = typeof comparator == 'function' ? comparator : undefined; 10709 return (array && array.length) ? baseUniq(array, undefined, comparator) : []; 10710 } 10711 10712 /** 10713 * This method is like `_.zip` except that it accepts an array of grouped 10714 * elements and creates an array regrouping the elements to their pre-zip 10715 * configuration. 10716 * 10717 * @static 10718 * @memberOf _ 10719 * @since 1.2.0 10720 * @category Array 10721 * @param {Array} array The array of grouped elements to process. 10722 * @returns {Array} Returns the new array of regrouped elements. 10723 * @example 10724 * 10725 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); 10726 * // => [['a', 1, true], ['b', 2, false]] 10727 * 10728 * _.unzip(zipped); 10729 * // => [['a', 'b'], [1, 2], [true, false]] 10730 */ 10731 function unzip(array) { 10732 if (!(array && array.length)) { 10733 return []; 10734 } 10735 var length = 0; 10736 array = arrayFilter(array, function(group) { 10737 if (isArrayLikeObject(group)) { 10738 length = nativeMax(group.length, length); 10739 return true; 10740 } 10741 }); 10742 return baseTimes(length, function(index) { 10743 return arrayMap(array, baseProperty(index)); 10744 }); 10745 } 10746 10747 /** 10748 * This method is like `_.unzip` except that it accepts `iteratee` to specify 10749 * how regrouped values should be combined. The iteratee is invoked with the 10750 * elements of each group: (...group). 10751 * 10752 * @static 10753 * @memberOf _ 10754 * @since 3.8.0 10755 * @category Array 10756 * @param {Array} array The array of grouped elements to process. 10757 * @param {Function} [iteratee=_.identity] The function to combine 10758 * regrouped values. 10759 * @returns {Array} Returns the new array of regrouped elements. 10760 * @example 10761 * 10762 * var zipped = _.zip([1, 2], [10, 20], [100, 200]); 10763 * // => [[1, 10, 100], [2, 20, 200]] 10764 * 10765 * _.unzipWith(zipped, _.add); 10766 * // => [3, 30, 300] 10767 */ 10768 function unzipWith(array, iteratee) { 10769 if (!(array && array.length)) { 10770 return []; 10771 } 10772 var result = unzip(array); 10773 if (iteratee == null) { 10774 return result; 10775 } 10776 return arrayMap(result, function(group) { 10777 return apply(iteratee, undefined, group); 10778 }); 10779 } 10780 10781 /** 10782 * Creates an array excluding all given values using 10783 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 10784 * for equality comparisons. 10785 * 10786 * **Note:** Unlike `_.pull`, this method returns a new array. 10787 * 10788 * @static 10789 * @memberOf _ 10790 * @since 0.1.0 10791 * @category Array 10792 * @param {Array} array The array to inspect. 10793 * @param {...*} [values] The values to exclude. 10794 * @returns {Array} Returns the new array of filtered values. 10795 * @see _.difference, _.xor 10796 * @example 10797 * 10798 * _.without([2, 1, 2, 3], 1, 2); 10799 * // => [3] 10800 */ 10801 var without = baseRest(function(array, values) { 10802 return isArrayLikeObject(array) 10803 ? baseDifference(array, values) 10804 : []; 10805 }); 10806 10807 /** 10808 * Creates an array of unique values that is the 10809 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) 10810 * of the given arrays. The order of result values is determined by the order 10811 * they occur in the arrays. 10812 * 10813 * @static 10814 * @memberOf _ 10815 * @since 2.4.0 10816 * @category Array 10817 * @param {...Array} [arrays] The arrays to inspect. 10818 * @returns {Array} Returns the new array of filtered values. 10819 * @see _.difference, _.without 10820 * @example 10821 * 10822 * _.xor([2, 1], [2, 3]); 10823 * // => [1, 3] 10824 */ 10825 var xor = baseRest(function(arrays) { 10826 return baseXor(arrayFilter(arrays, isArrayLikeObject)); 10827 }); 10828 10829 /** 10830 * This method is like `_.xor` except that it accepts `iteratee` which is 10831 * invoked for each element of each `arrays` to generate the criterion by 10832 * which by which they're compared. The order of result values is determined 10833 * by the order they occur in the arrays. The iteratee is invoked with one 10834 * argument: (value). 10835 * 10836 * @static 10837 * @memberOf _ 10838 * @since 4.0.0 10839 * @category Array 10840 * @param {...Array} [arrays] The arrays to inspect. 10841 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10842 * @returns {Array} Returns the new array of filtered values. 10843 * @example 10844 * 10845 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); 10846 * // => [1.2, 3.4] 10847 * 10848 * // The `_.property` iteratee shorthand. 10849 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 10850 * // => [{ 'x': 2 }] 10851 */ 10852 var xorBy = baseRest(function(arrays) { 10853 var iteratee = last(arrays); 10854 if (isArrayLikeObject(iteratee)) { 10855 iteratee = undefined; 10856 } 10857 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); 10858 }); 10859 10860 /** 10861 * This method is like `_.xor` except that it accepts `comparator` which is 10862 * invoked to compare elements of `arrays`. The order of result values is 10863 * determined by the order they occur in the arrays. The comparator is invoked 10864 * with two arguments: (arrVal, othVal). 10865 * 10866 * @static 10867 * @memberOf _ 10868 * @since 4.0.0 10869 * @category Array 10870 * @param {...Array} [arrays] The arrays to inspect. 10871 * @param {Function} [comparator] The comparator invoked per element. 10872 * @returns {Array} Returns the new array of filtered values. 10873 * @example 10874 * 10875 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 10876 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 10877 * 10878 * _.xorWith(objects, others, _.isEqual); 10879 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 10880 */ 10881 var xorWith = baseRest(function(arrays) { 10882 var comparator = last(arrays); 10883 comparator = typeof comparator == 'function' ? comparator : undefined; 10884 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); 10885 }); 10886 10887 /** 10888 * Creates an array of grouped elements, the first of which contains the 10889 * first elements of the given arrays, the second of which contains the 10890 * second elements of the given arrays, and so on. 10891 * 10892 * @static 10893 * @memberOf _ 10894 * @since 0.1.0 10895 * @category Array 10896 * @param {...Array} [arrays] The arrays to process. 10897 * @returns {Array} Returns the new array of grouped elements. 10898 * @example 10899 * 10900 * _.zip(['a', 'b'], [1, 2], [true, false]); 10901 * // => [['a', 1, true], ['b', 2, false]] 10902 */ 10903 var zip = baseRest(unzip); 10904 10905 /** 10906 * This method is like `_.fromPairs` except that it accepts two arrays, 10907 * one of property identifiers and one of corresponding values. 10908 * 10909 * @static 10910 * @memberOf _ 10911 * @since 0.4.0 10912 * @category Array 10913 * @param {Array} [props=[]] The property identifiers. 10914 * @param {Array} [values=[]] The property values. 10915 * @returns {Object} Returns the new object. 10916 * @example 10917 * 10918 * _.zipObject(['a', 'b'], [1, 2]); 10919 * // => { 'a': 1, 'b': 2 } 10920 */ 10921 function zipObject(props, values) { 10922 return baseZipObject(props || [], values || [], assignValue); 10923 } 10924 10925 /** 10926 * This method is like `_.zipObject` except that it supports property paths. 10927 * 10928 * @static 10929 * @memberOf _ 10930 * @since 4.1.0 10931 * @category Array 10932 * @param {Array} [props=[]] The property identifiers. 10933 * @param {Array} [values=[]] The property values. 10934 * @returns {Object} Returns the new object. 10935 * @example 10936 * 10937 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); 10938 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } 10939 */ 10940 function zipObjectDeep(props, values) { 10941 return baseZipObject(props || [], values || [], baseSet); 10942 } 10943 10944 /** 10945 * This method is like `_.zip` except that it accepts `iteratee` to specify 10946 * how grouped values should be combined. The iteratee is invoked with the 10947 * elements of each group: (...group). 10948 * 10949 * @static 10950 * @memberOf _ 10951 * @since 3.8.0 10952 * @category Array 10953 * @param {...Array} [arrays] The arrays to process. 10954 * @param {Function} [iteratee=_.identity] The function to combine 10955 * grouped values. 10956 * @returns {Array} Returns the new array of grouped elements. 10957 * @example 10958 * 10959 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { 10960 * return a + b + c; 10961 * }); 10962 * // => [111, 222] 10963 */ 10964 var zipWith = baseRest(function(arrays) { 10965 var length = arrays.length, 10966 iteratee = length > 1 ? arrays[length - 1] : undefined; 10967 10968 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; 10969 return unzipWith(arrays, iteratee); 10970 }); 10971 10972 /*------------------------------------------------------------------------*/ 10973 10974 /** 10975 * Creates a `lodash` wrapper instance that wraps `value` with explicit method 10976 * chain sequences enabled. The result of such sequences must be unwrapped 10977 * with `_#value`. 10978 * 10979 * @static 10980 * @memberOf _ 10981 * @since 1.3.0 10982 * @category Seq 10983 * @param {*} value The value to wrap. 10984 * @returns {Object} Returns the new `lodash` wrapper instance. 10985 * @example 10986 * 10987 * var users = [ 10988 * { 'user': 'barney', 'age': 36 }, 10989 * { 'user': 'fred', 'age': 40 }, 10990 * { 'user': 'pebbles', 'age': 1 } 10991 * ]; 10992 * 10993 * var youngest = _ 10994 * .chain(users) 10995 * .sortBy('age') 10996 * .map(function(o) { 10997 * return o.user + ' is ' + o.age; 10998 * }) 10999 * .head() 11000 * .value(); 11001 * // => 'pebbles is 1' 11002 */ 11003 function chain(value) { 11004 var result = lodash(value); 11005 result.__chain__ = true; 11006 return result; 11007 } 11008 11009 /** 11010 * This method invokes `interceptor` and returns `value`. The interceptor 11011 * is invoked with one argument; (value). The purpose of this method is to 11012 * "tap into" a method chain sequence in order to modify intermediate results. 11013 * 11014 * @static 11015 * @memberOf _ 11016 * @since 0.1.0 11017 * @category Seq 11018 * @param {*} value The value to provide to `interceptor`. 11019 * @param {Function} interceptor The function to invoke. 11020 * @returns {*} Returns `value`. 11021 * @example 11022 * 11023 * _([1, 2, 3]) 11024 * .tap(function(array) { 11025 * // Mutate input array. 11026 * array.pop(); 11027 * }) 11028 * .reverse() 11029 * .value(); 11030 * // => [2, 1] 11031 */ 11032 function tap(value, interceptor) { 11033 interceptor(value); 11034 return value; 11035 } 11036 11037 /** 11038 * This method is like `_.tap` except that it returns the result of `interceptor`. 11039 * The purpose of this method is to "pass thru" values replacing intermediate 11040 * results in a method chain sequence. 11041 * 11042 * @static 11043 * @memberOf _ 11044 * @since 3.0.0 11045 * @category Seq 11046 * @param {*} value The value to provide to `interceptor`. 11047 * @param {Function} interceptor The function to invoke. 11048 * @returns {*} Returns the result of `interceptor`. 11049 * @example 11050 * 11051 * _(' abc ') 11052 * .chain() 11053 * .trim() 11054 * .thru(function(value) { 11055 * return [value]; 11056 * }) 11057 * .value(); 11058 * // => ['abc'] 11059 */ 11060 function thru(value, interceptor) { 11061 return interceptor(value); 11062 } 11063 11064 /** 11065 * This method is the wrapper version of `_.at`. 11066 * 11067 * @name at 11068 * @memberOf _ 11069 * @since 1.0.0 11070 * @category Seq 11071 * @param {...(string|string[])} [paths] The property paths to pick. 11072 * @returns {Object} Returns the new `lodash` wrapper instance. 11073 * @example 11074 * 11075 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 11076 * 11077 * _(object).at(['a[0].b.c', 'a[1]']).value(); 11078 * // => [3, 4] 11079 */ 11080 var wrapperAt = flatRest(function(paths) { 11081 var length = paths.length, 11082 start = length ? paths[0] : 0, 11083 value = this.__wrapped__, 11084 interceptor = function(object) { return baseAt(object, paths); }; 11085 11086 if (length > 1 || this.__actions__.length || 11087 !(value instanceof LazyWrapper) || !isIndex(start)) { 11088 return this.thru(interceptor); 11089 } 11090 value = value.slice(start, +start + (length ? 1 : 0)); 11091 value.__actions__.push({ 11092 'func': thru, 11093 'args': [interceptor], 11094 'thisArg': undefined 11095 }); 11096 return new LodashWrapper(value, this.__chain__).thru(function(array) { 11097 if (length && !array.length) { 11098 array.push(undefined); 11099 } 11100 return array; 11101 }); 11102 }); 11103 11104 /** 11105 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. 11106 * 11107 * @name chain 11108 * @memberOf _ 11109 * @since 0.1.0 11110 * @category Seq 11111 * @returns {Object} Returns the new `lodash` wrapper instance. 11112 * @example 11113 * 11114 * var users = [ 11115 * { 'user': 'barney', 'age': 36 }, 11116 * { 'user': 'fred', 'age': 40 } 11117 * ]; 11118 * 11119 * // A sequence without explicit chaining. 11120 * _(users).head(); 11121 * // => { 'user': 'barney', 'age': 36 } 11122 * 11123 * // A sequence with explicit chaining. 11124 * _(users) 11125 * .chain() 11126 * .head() 11127 * .pick('user') 11128 * .value(); 11129 * // => { 'user': 'barney' } 11130 */ 11131 function wrapperChain() { 11132 return chain(this); 11133 } 11134 11135 /** 11136 * Executes the chain sequence and returns the wrapped result. 11137 * 11138 * @name commit 11139 * @memberOf _ 11140 * @since 3.2.0 11141 * @category Seq 11142 * @returns {Object} Returns the new `lodash` wrapper instance. 11143 * @example 11144 * 11145 * var array = [1, 2]; 11146 * var wrapped = _(array).push(3); 11147 * 11148 * console.log(array); 11149 * // => [1, 2] 11150 * 11151 * wrapped = wrapped.commit(); 11152 * console.log(array); 11153 * // => [1, 2, 3] 11154 * 11155 * wrapped.last(); 11156 * // => 3 11157 * 11158 * console.log(array); 11159 * // => [1, 2, 3] 11160 */ 11161 function wrapperCommit() { 11162 return new LodashWrapper(this.value(), this.__chain__); 11163 } 11164 11165 /** 11166 * Gets the next value on a wrapped object following the 11167 * [iterator protocol](https://mdn.io/iteration_protocols#iterator). 11168 * 11169 * @name next 11170 * @memberOf _ 11171 * @since 4.0.0 11172 * @category Seq 11173 * @returns {Object} Returns the next iterator value. 11174 * @example 11175 * 11176 * var wrapped = _([1, 2]); 11177 * 11178 * wrapped.next(); 11179 * // => { 'done': false, 'value': 1 } 11180 * 11181 * wrapped.next(); 11182 * // => { 'done': false, 'value': 2 } 11183 * 11184 * wrapped.next(); 11185 * // => { 'done': true, 'value': undefined } 11186 */ 11187 function wrapperNext() { 11188 if (this.__values__ === undefined) { 11189 this.__values__ = toArray(this.value()); 11190 } 11191 var done = this.__index__ >= this.__values__.length, 11192 value = done ? undefined : this.__values__[this.__index__++]; 11193 11194 return { 'done': done, 'value': value }; 11195 } 11196 11197 /** 11198 * Enables the wrapper to be iterable. 11199 * 11200 * @name Symbol.iterator 11201 * @memberOf _ 11202 * @since 4.0.0 11203 * @category Seq 11204 * @returns {Object} Returns the wrapper object. 11205 * @example 11206 * 11207 * var wrapped = _([1, 2]); 11208 * 11209 * wrapped[Symbol.iterator]() === wrapped; 11210 * // => true 11211 * 11212 * Array.from(wrapped); 11213 * // => [1, 2] 11214 */ 11215 function wrapperToIterator() { 11216 return this; 11217 } 11218 11219 /** 11220 * Creates a clone of the chain sequence planting `value` as the wrapped value. 11221 * 11222 * @name plant 11223 * @memberOf _ 11224 * @since 3.2.0 11225 * @category Seq 11226 * @param {*} value The value to plant. 11227 * @returns {Object} Returns the new `lodash` wrapper instance. 11228 * @example 11229 * 11230 * function square(n) { 11231 * return n * n; 11232 * } 11233 * 11234 * var wrapped = _([1, 2]).map(square); 11235 * var other = wrapped.plant([3, 4]); 11236 * 11237 * other.value(); 11238 * // => [9, 16] 11239 * 11240 * wrapped.value(); 11241 * // => [1, 4] 11242 */ 11243 function wrapperPlant(value) { 11244 var result, 11245 parent = this; 11246 11247 while (parent instanceof baseLodash) { 11248 var clone = wrapperClone(parent); 11249 clone.__index__ = 0; 11250 clone.__values__ = undefined; 11251 if (result) { 11252 previous.__wrapped__ = clone; 11253 } else { 11254 result = clone; 11255 } 11256 var previous = clone; 11257 parent = parent.__wrapped__; 11258 } 11259 previous.__wrapped__ = value; 11260 return result; 11261 } 11262 11263 /** 11264 * This method is the wrapper version of `_.reverse`. 11265 * 11266 * **Note:** This method mutates the wrapped array. 11267 * 11268 * @name reverse 11269 * @memberOf _ 11270 * @since 0.1.0 11271 * @category Seq 11272 * @returns {Object} Returns the new `lodash` wrapper instance. 11273 * @example 11274 * 11275 * var array = [1, 2, 3]; 11276 * 11277 * _(array).reverse().value() 11278 * // => [3, 2, 1] 11279 * 11280 * console.log(array); 11281 * // => [3, 2, 1] 11282 */ 11283 function wrapperReverse() { 11284 var value = this.__wrapped__; 11285 if (value instanceof LazyWrapper) { 11286 var wrapped = value; 11287 if (this.__actions__.length) { 11288 wrapped = new LazyWrapper(this); 11289 } 11290 wrapped = wrapped.reverse(); 11291 wrapped.__actions__.push({ 11292 'func': thru, 11293 'args': [reverse], 11294 'thisArg': undefined 11295 }); 11296 return new LodashWrapper(wrapped, this.__chain__); 11297 } 11298 return this.thru(reverse); 11299 } 11300 11301 /** 11302 * Executes the chain sequence to resolve the unwrapped value. 11303 * 11304 * @name value 11305 * @memberOf _ 11306 * @since 0.1.0 11307 * @alias toJSON, valueOf 11308 * @category Seq 11309 * @returns {*} Returns the resolved unwrapped value. 11310 * @example 11311 * 11312 * _([1, 2, 3]).value(); 11313 * // => [1, 2, 3] 11314 */ 11315 function wrapperValue() { 11316 return baseWrapperValue(this.__wrapped__, this.__actions__); 11317 } 11318 11319 /*------------------------------------------------------------------------*/ 11320 11321 /** 11322 * Creates an object composed of keys generated from the results of running 11323 * each element of `collection` thru `iteratee`. The corresponding value of 11324 * each key is the number of times the key was returned by `iteratee`. The 11325 * iteratee is invoked with one argument: (value). 11326 * 11327 * @static 11328 * @memberOf _ 11329 * @since 0.5.0 11330 * @category Collection 11331 * @param {Array|Object} collection The collection to iterate over. 11332 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 11333 * @returns {Object} Returns the composed aggregate object. 11334 * @example 11335 * 11336 * _.countBy([6.1, 4.2, 6.3], Math.floor); 11337 * // => { '4': 1, '6': 2 } 11338 * 11339 * // The `_.property` iteratee shorthand. 11340 * _.countBy(['one', 'two', 'three'], 'length'); 11341 * // => { '3': 2, '5': 1 } 11342 */ 11343 var countBy = createAggregator(function(result, value, key) { 11344 if (hasOwnProperty.call(result, key)) { 11345 ++result[key]; 11346 } else { 11347 baseAssignValue(result, key, 1); 11348 } 11349 }); 11350 11351 /** 11352 * Checks if `predicate` returns truthy for **all** elements of `collection`. 11353 * Iteration is stopped once `predicate` returns falsey. The predicate is 11354 * invoked with three arguments: (value, index|key, collection). 11355 * 11356 * **Note:** This method returns `true` for 11357 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because 11358 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of 11359 * elements of empty collections. 11360 * 11361 * @static 11362 * @memberOf _ 11363 * @since 0.1.0 11364 * @category Collection 11365 * @param {Array|Object} collection The collection to iterate over. 11366 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11367 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 11368 * @returns {boolean} Returns `true` if all elements pass the predicate check, 11369 * else `false`. 11370 * @example 11371 * 11372 * _.every([true, 1, null, 'yes'], Boolean); 11373 * // => false 11374 * 11375 * var users = [ 11376 * { 'user': 'barney', 'age': 36, 'active': false }, 11377 * { 'user': 'fred', 'age': 40, 'active': false } 11378 * ]; 11379 * 11380 * // The `_.matches` iteratee shorthand. 11381 * _.every(users, { 'user': 'barney', 'active': false }); 11382 * // => false 11383 * 11384 * // The `_.matchesProperty` iteratee shorthand. 11385 * _.every(users, ['active', false]); 11386 * // => true 11387 * 11388 * // The `_.property` iteratee shorthand. 11389 * _.every(users, 'active'); 11390 * // => false 11391 */ 11392 function every(collection, predicate, guard) { 11393 var func = isArray(collection) ? arrayEvery : baseEvery; 11394 if (guard && isIterateeCall(collection, predicate, guard)) { 11395 predicate = undefined; 11396 } 11397 return func(collection, getIteratee(predicate, 3)); 11398 } 11399 11400 /** 11401 * Iterates over elements of `collection`, returning an array of all elements 11402 * `predicate` returns truthy for. The predicate is invoked with three 11403 * arguments: (value, index|key, collection). 11404 * 11405 * **Note:** Unlike `_.remove`, this method returns a new array. 11406 * 11407 * @static 11408 * @memberOf _ 11409 * @since 0.1.0 11410 * @category Collection 11411 * @param {Array|Object} collection The collection to iterate over. 11412 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11413 * @returns {Array} Returns the new filtered array. 11414 * @see _.reject 11415 * @example 11416 * 11417 * var users = [ 11418 * { 'user': 'barney', 'age': 36, 'active': true }, 11419 * { 'user': 'fred', 'age': 40, 'active': false } 11420 * ]; 11421 * 11422 * _.filter(users, function(o) { return !o.active; }); 11423 * // => objects for ['fred'] 11424 * 11425 * // The `_.matches` iteratee shorthand. 11426 * _.filter(users, { 'age': 36, 'active': true }); 11427 * // => objects for ['barney'] 11428 * 11429 * // The `_.matchesProperty` iteratee shorthand. 11430 * _.filter(users, ['active', false]); 11431 * // => objects for ['fred'] 11432 * 11433 * // The `_.property` iteratee shorthand. 11434 * _.filter(users, 'active'); 11435 * // => objects for ['barney'] 11436 * 11437 * // Combining several predicates using `_.overEvery` or `_.overSome`. 11438 * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); 11439 * // => objects for ['fred', 'barney'] 11440 */ 11441 function filter(collection, predicate) { 11442 var func = isArray(collection) ? arrayFilter : baseFilter; 11443 return func(collection, getIteratee(predicate, 3)); 11444 } 11445 11446 /** 11447 * Iterates over elements of `collection`, returning the first element 11448 * `predicate` returns truthy for. The predicate is invoked with three 11449 * arguments: (value, index|key, collection). 11450 * 11451 * @static 11452 * @memberOf _ 11453 * @since 0.1.0 11454 * @category Collection 11455 * @param {Array|Object} collection The collection to inspect. 11456 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11457 * @param {number} [fromIndex=0] The index to search from. 11458 * @returns {*} Returns the matched element, else `undefined`. 11459 * @example 11460 * 11461 * var users = [ 11462 * { 'user': 'barney', 'age': 36, 'active': true }, 11463 * { 'user': 'fred', 'age': 40, 'active': false }, 11464 * { 'user': 'pebbles', 'age': 1, 'active': true } 11465 * ]; 11466 * 11467 * _.find(users, function(o) { return o.age < 40; }); 11468 * // => object for 'barney' 11469 * 11470 * // The `_.matches` iteratee shorthand. 11471 * _.find(users, { 'age': 1, 'active': true }); 11472 * // => object for 'pebbles' 11473 * 11474 * // The `_.matchesProperty` iteratee shorthand. 11475 * _.find(users, ['active', false]); 11476 * // => object for 'fred' 11477 * 11478 * // The `_.property` iteratee shorthand. 11479 * _.find(users, 'active'); 11480 * // => object for 'barney' 11481 */ 11482 var find = createFind(findIndex); 11483 11484 /** 11485 * This method is like `_.find` except that it iterates over elements of 11486 * `collection` from right to left. 11487 * 11488 * @static 11489 * @memberOf _ 11490 * @since 2.0.0 11491 * @category Collection 11492 * @param {Array|Object} collection The collection to inspect. 11493 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11494 * @param {number} [fromIndex=collection.length-1] The index to search from. 11495 * @returns {*} Returns the matched element, else `undefined`. 11496 * @example 11497 * 11498 * _.findLast([1, 2, 3, 4], function(n) { 11499 * return n % 2 == 1; 11500 * }); 11501 * // => 3 11502 */ 11503 var findLast = createFind(findLastIndex); 11504 11505 /** 11506 * Creates a flattened array of values by running each element in `collection` 11507 * thru `iteratee` and flattening the mapped results. The iteratee is invoked 11508 * with three arguments: (value, index|key, collection). 11509 * 11510 * @static 11511 * @memberOf _ 11512 * @since 4.0.0 11513 * @category Collection 11514 * @param {Array|Object} collection The collection to iterate over. 11515 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11516 * @returns {Array} Returns the new flattened array. 11517 * @example 11518 * 11519 * function duplicate(n) { 11520 * return [n, n]; 11521 * } 11522 * 11523 * _.flatMap([1, 2], duplicate); 11524 * // => [1, 1, 2, 2] 11525 */ 11526 function flatMap(collection, iteratee) { 11527 return baseFlatten(map(collection, iteratee), 1); 11528 } 11529 11530 /** 11531 * This method is like `_.flatMap` except that it recursively flattens the 11532 * mapped results. 11533 * 11534 * @static 11535 * @memberOf _ 11536 * @since 4.7.0 11537 * @category Collection 11538 * @param {Array|Object} collection The collection to iterate over. 11539 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11540 * @returns {Array} Returns the new flattened array. 11541 * @example 11542 * 11543 * function duplicate(n) { 11544 * return [[[n, n]]]; 11545 * } 11546 * 11547 * _.flatMapDeep([1, 2], duplicate); 11548 * // => [1, 1, 2, 2] 11549 */ 11550 function flatMapDeep(collection, iteratee) { 11551 return baseFlatten(map(collection, iteratee), INFINITY); 11552 } 11553 11554 /** 11555 * This method is like `_.flatMap` except that it recursively flattens the 11556 * mapped results up to `depth` times. 11557 * 11558 * @static 11559 * @memberOf _ 11560 * @since 4.7.0 11561 * @category Collection 11562 * @param {Array|Object} collection The collection to iterate over. 11563 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11564 * @param {number} [depth=1] The maximum recursion depth. 11565 * @returns {Array} Returns the new flattened array. 11566 * @example 11567 * 11568 * function duplicate(n) { 11569 * return [[[n, n]]]; 11570 * } 11571 * 11572 * _.flatMapDepth([1, 2], duplicate, 2); 11573 * // => [[1, 1], [2, 2]] 11574 */ 11575 function flatMapDepth(collection, iteratee, depth) { 11576 depth = depth === undefined ? 1 : toInteger(depth); 11577 return baseFlatten(map(collection, iteratee), depth); 11578 } 11579 11580 /** 11581 * Iterates over elements of `collection` and invokes `iteratee` for each element. 11582 * The iteratee is invoked with three arguments: (value, index|key, collection). 11583 * Iteratee functions may exit iteration early by explicitly returning `false`. 11584 * 11585 * **Note:** As with other "Collections" methods, objects with a "length" 11586 * property are iterated like arrays. To avoid this behavior use `_.forIn` 11587 * or `_.forOwn` for object iteration. 11588 * 11589 * @static 11590 * @memberOf _ 11591 * @since 0.1.0 11592 * @alias each 11593 * @category Collection 11594 * @param {Array|Object} collection The collection to iterate over. 11595 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11596 * @returns {Array|Object} Returns `collection`. 11597 * @see _.forEachRight 11598 * @example 11599 * 11600 * _.forEach([1, 2], function(value) { 11601 * console.log(value); 11602 * }); 11603 * // => Logs `1` then `2`. 11604 * 11605 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 11606 * console.log(key); 11607 * }); 11608 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 11609 */ 11610 function forEach(collection, iteratee) { 11611 var func = isArray(collection) ? arrayEach : baseEach; 11612 return func(collection, getIteratee(iteratee, 3)); 11613 } 11614 11615 /** 11616 * This method is like `_.forEach` except that it iterates over elements of 11617 * `collection` from right to left. 11618 * 11619 * @static 11620 * @memberOf _ 11621 * @since 2.0.0 11622 * @alias eachRight 11623 * @category Collection 11624 * @param {Array|Object} collection The collection to iterate over. 11625 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11626 * @returns {Array|Object} Returns `collection`. 11627 * @see _.forEach 11628 * @example 11629 * 11630 * _.forEachRight([1, 2], function(value) { 11631 * console.log(value); 11632 * }); 11633 * // => Logs `2` then `1`. 11634 */ 11635 function forEachRight(collection, iteratee) { 11636 var func = isArray(collection) ? arrayEachRight : baseEachRight; 11637 return func(collection, getIteratee(iteratee, 3)); 11638 } 11639 11640 /** 11641 * Creates an object composed of keys generated from the results of running 11642 * each element of `collection` thru `iteratee`. The order of grouped values 11643 * is determined by the order they occur in `collection`. The corresponding 11644 * value of each key is an array of elements responsible for generating the 11645 * key. The iteratee is invoked with one argument: (value). 11646 * 11647 * @static 11648 * @memberOf _ 11649 * @since 0.1.0 11650 * @category Collection 11651 * @param {Array|Object} collection The collection to iterate over. 11652 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 11653 * @returns {Object} Returns the composed aggregate object. 11654 * @example 11655 * 11656 * _.groupBy([6.1, 4.2, 6.3], Math.floor); 11657 * // => { '4': [4.2], '6': [6.1, 6.3] } 11658 * 11659 * // The `_.property` iteratee shorthand. 11660 * _.groupBy(['one', 'two', 'three'], 'length'); 11661 * // => { '3': ['one', 'two'], '5': ['three'] } 11662 */ 11663 var groupBy = createAggregator(function(result, value, key) { 11664 if (hasOwnProperty.call(result, key)) { 11665 result[key].push(value); 11666 } else { 11667 baseAssignValue(result, key, [value]); 11668 } 11669 }); 11670 11671 /** 11672 * Checks if `value` is in `collection`. If `collection` is a string, it's 11673 * checked for a substring of `value`, otherwise 11674 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 11675 * is used for equality comparisons. If `fromIndex` is negative, it's used as 11676 * the offset from the end of `collection`. 11677 * 11678 * @static 11679 * @memberOf _ 11680 * @since 0.1.0 11681 * @category Collection 11682 * @param {Array|Object|string} collection The collection to inspect. 11683 * @param {*} value The value to search for. 11684 * @param {number} [fromIndex=0] The index to search from. 11685 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 11686 * @returns {boolean} Returns `true` if `value` is found, else `false`. 11687 * @example 11688 * 11689 * _.includes([1, 2, 3], 1); 11690 * // => true 11691 * 11692 * _.includes([1, 2, 3], 1, 2); 11693 * // => false 11694 * 11695 * _.includes({ 'a': 1, 'b': 2 }, 1); 11696 * // => true 11697 * 11698 * _.includes('abcd', 'bc'); 11699 * // => true 11700 */ 11701 function includes(collection, value, fromIndex, guard) { 11702 collection = isArrayLike(collection) ? collection : values(collection); 11703 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; 11704 11705 var length = collection.length; 11706 if (fromIndex < 0) { 11707 fromIndex = nativeMax(length + fromIndex, 0); 11708 } 11709 return isString(collection) 11710 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) 11711 : (!!length && baseIndexOf(collection, value, fromIndex) > -1); 11712 } 11713 11714 /** 11715 * Invokes the method at `path` of each element in `collection`, returning 11716 * an array of the results of each invoked method. Any additional arguments 11717 * are provided to each invoked method. If `path` is a function, it's invoked 11718 * for, and `this` bound to, each element in `collection`. 11719 * 11720 * @static 11721 * @memberOf _ 11722 * @since 4.0.0 11723 * @category Collection 11724 * @param {Array|Object} collection The collection to iterate over. 11725 * @param {Array|Function|string} path The path of the method to invoke or 11726 * the function invoked per iteration. 11727 * @param {...*} [args] The arguments to invoke each method with. 11728 * @returns {Array} Returns the array of results. 11729 * @example 11730 * 11731 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); 11732 * // => [[1, 5, 7], [1, 2, 3]] 11733 * 11734 * _.invokeMap([123, 456], String.prototype.split, ''); 11735 * // => [['1', '2', '3'], ['4', '5', '6']] 11736 */ 11737 var invokeMap = baseRest(function(collection, path, args) { 11738 var index = -1, 11739 isFunc = typeof path == 'function', 11740 result = isArrayLike(collection) ? Array(collection.length) : []; 11741 11742 baseEach(collection, function(value) { 11743 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); 11744 }); 11745 return result; 11746 }); 11747 11748 /** 11749 * Creates an object composed of keys generated from the results of running 11750 * each element of `collection` thru `iteratee`. The corresponding value of 11751 * each key is the last element responsible for generating the key. The 11752 * iteratee is invoked with one argument: (value). 11753 * 11754 * @static 11755 * @memberOf _ 11756 * @since 4.0.0 11757 * @category Collection 11758 * @param {Array|Object} collection The collection to iterate over. 11759 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 11760 * @returns {Object} Returns the composed aggregate object. 11761 * @example 11762 * 11763 * var array = [ 11764 * { 'dir': 'left', 'code': 97 }, 11765 * { 'dir': 'right', 'code': 100 } 11766 * ]; 11767 * 11768 * _.keyBy(array, function(o) { 11769 * return String.fromCharCode(o.code); 11770 * }); 11771 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } 11772 * 11773 * _.keyBy(array, 'dir'); 11774 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } 11775 */ 11776 var keyBy = createAggregator(function(result, value, key) { 11777 baseAssignValue(result, key, value); 11778 }); 11779 11780 /** 11781 * Creates an array of values by running each element in `collection` thru 11782 * `iteratee`. The iteratee is invoked with three arguments: 11783 * (value, index|key, collection). 11784 * 11785 * Many lodash methods are guarded to work as iteratees for methods like 11786 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. 11787 * 11788 * The guarded methods are: 11789 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, 11790 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, 11791 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, 11792 * `template`, `trim`, `trimEnd`, `trimStart`, and `words` 11793 * 11794 * @static 11795 * @memberOf _ 11796 * @since 0.1.0 11797 * @category Collection 11798 * @param {Array|Object} collection The collection to iterate over. 11799 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11800 * @returns {Array} Returns the new mapped array. 11801 * @example 11802 * 11803 * function square(n) { 11804 * return n * n; 11805 * } 11806 * 11807 * _.map([4, 8], square); 11808 * // => [16, 64] 11809 * 11810 * _.map({ 'a': 4, 'b': 8 }, square); 11811 * // => [16, 64] (iteration order is not guaranteed) 11812 * 11813 * var users = [ 11814 * { 'user': 'barney' }, 11815 * { 'user': 'fred' } 11816 * ]; 11817 * 11818 * // The `_.property` iteratee shorthand. 11819 * _.map(users, 'user'); 11820 * // => ['barney', 'fred'] 11821 */ 11822 function map(collection, iteratee) { 11823 var func = isArray(collection) ? arrayMap : baseMap; 11824 return func(collection, getIteratee(iteratee, 3)); 11825 } 11826 11827 /** 11828 * This method is like `_.sortBy` except that it allows specifying the sort 11829 * orders of the iteratees to sort by. If `orders` is unspecified, all values 11830 * are sorted in ascending order. Otherwise, specify an order of "desc" for 11831 * descending or "asc" for ascending sort order of corresponding values. 11832 * 11833 * @static 11834 * @memberOf _ 11835 * @since 4.0.0 11836 * @category Collection 11837 * @param {Array|Object} collection The collection to iterate over. 11838 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] 11839 * The iteratees to sort by. 11840 * @param {string[]} [orders] The sort orders of `iteratees`. 11841 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 11842 * @returns {Array} Returns the new sorted array. 11843 * @example 11844 * 11845 * var users = [ 11846 * { 'user': 'fred', 'age': 48 }, 11847 * { 'user': 'barney', 'age': 34 }, 11848 * { 'user': 'fred', 'age': 40 }, 11849 * { 'user': 'barney', 'age': 36 } 11850 * ]; 11851 * 11852 * // Sort by `user` in ascending order and by `age` in descending order. 11853 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); 11854 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 11855 */ 11856 function orderBy(collection, iteratees, orders, guard) { 11857 if (collection == null) { 11858 return []; 11859 } 11860 if (!isArray(iteratees)) { 11861 iteratees = iteratees == null ? [] : [iteratees]; 11862 } 11863 orders = guard ? undefined : orders; 11864 if (!isArray(orders)) { 11865 orders = orders == null ? [] : [orders]; 11866 } 11867 return baseOrderBy(collection, iteratees, orders); 11868 } 11869 11870 /** 11871 * Creates an array of elements split into two groups, the first of which 11872 * contains elements `predicate` returns truthy for, the second of which 11873 * contains elements `predicate` returns falsey for. The predicate is 11874 * invoked with one argument: (value). 11875 * 11876 * @static 11877 * @memberOf _ 11878 * @since 3.0.0 11879 * @category Collection 11880 * @param {Array|Object} collection The collection to iterate over. 11881 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11882 * @returns {Array} Returns the array of grouped elements. 11883 * @example 11884 * 11885 * var users = [ 11886 * { 'user': 'barney', 'age': 36, 'active': false }, 11887 * { 'user': 'fred', 'age': 40, 'active': true }, 11888 * { 'user': 'pebbles', 'age': 1, 'active': false } 11889 * ]; 11890 * 11891 * _.partition(users, function(o) { return o.active; }); 11892 * // => objects for [['fred'], ['barney', 'pebbles']] 11893 * 11894 * // The `_.matches` iteratee shorthand. 11895 * _.partition(users, { 'age': 1, 'active': false }); 11896 * // => objects for [['pebbles'], ['barney', 'fred']] 11897 * 11898 * // The `_.matchesProperty` iteratee shorthand. 11899 * _.partition(users, ['active', false]); 11900 * // => objects for [['barney', 'pebbles'], ['fred']] 11901 * 11902 * // The `_.property` iteratee shorthand. 11903 * _.partition(users, 'active'); 11904 * // => objects for [['fred'], ['barney', 'pebbles']] 11905 */ 11906 var partition = createAggregator(function(result, value, key) { 11907 result[key ? 0 : 1].push(value); 11908 }, function() { return [[], []]; }); 11909 11910 /** 11911 * Reduces `collection` to a value which is the accumulated result of running 11912 * each element in `collection` thru `iteratee`, where each successive 11913 * invocation is supplied the return value of the previous. If `accumulator` 11914 * is not given, the first element of `collection` is used as the initial 11915 * value. The iteratee is invoked with four arguments: 11916 * (accumulator, value, index|key, collection). 11917 * 11918 * Many lodash methods are guarded to work as iteratees for methods like 11919 * `_.reduce`, `_.reduceRight`, and `_.transform`. 11920 * 11921 * The guarded methods are: 11922 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, 11923 * and `sortBy` 11924 * 11925 * @static 11926 * @memberOf _ 11927 * @since 0.1.0 11928 * @category Collection 11929 * @param {Array|Object} collection The collection to iterate over. 11930 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11931 * @param {*} [accumulator] The initial value. 11932 * @returns {*} Returns the accumulated value. 11933 * @see _.reduceRight 11934 * @example 11935 * 11936 * _.reduce([1, 2], function(sum, n) { 11937 * return sum + n; 11938 * }, 0); 11939 * // => 3 11940 * 11941 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 11942 * (result[value] || (result[value] = [])).push(key); 11943 * return result; 11944 * }, {}); 11945 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) 11946 */ 11947 function reduce(collection, iteratee, accumulator) { 11948 var func = isArray(collection) ? arrayReduce : baseReduce, 11949 initAccum = arguments.length < 3; 11950 11951 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); 11952 } 11953 11954 /** 11955 * This method is like `_.reduce` except that it iterates over elements of 11956 * `collection` from right to left. 11957 * 11958 * @static 11959 * @memberOf _ 11960 * @since 0.1.0 11961 * @category Collection 11962 * @param {Array|Object} collection The collection to iterate over. 11963 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11964 * @param {*} [accumulator] The initial value. 11965 * @returns {*} Returns the accumulated value. 11966 * @see _.reduce 11967 * @example 11968 * 11969 * var array = [[0, 1], [2, 3], [4, 5]]; 11970 * 11971 * _.reduceRight(array, function(flattened, other) { 11972 * return flattened.concat(other); 11973 * }, []); 11974 * // => [4, 5, 2, 3, 0, 1] 11975 */ 11976 function reduceRight(collection, iteratee, accumulator) { 11977 var func = isArray(collection) ? arrayReduceRight : baseReduce, 11978 initAccum = arguments.length < 3; 11979 11980 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); 11981 } 11982 11983 /** 11984 * The opposite of `_.filter`; this method returns the elements of `collection` 11985 * that `predicate` does **not** return truthy for. 11986 * 11987 * @static 11988 * @memberOf _ 11989 * @since 0.1.0 11990 * @category Collection 11991 * @param {Array|Object} collection The collection to iterate over. 11992 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11993 * @returns {Array} Returns the new filtered array. 11994 * @see _.filter 11995 * @example 11996 * 11997 * var users = [ 11998 * { 'user': 'barney', 'age': 36, 'active': false }, 11999 * { 'user': 'fred', 'age': 40, 'active': true } 12000 * ]; 12001 * 12002 * _.reject(users, function(o) { return !o.active; }); 12003 * // => objects for ['fred'] 12004 * 12005 * // The `_.matches` iteratee shorthand. 12006 * _.reject(users, { 'age': 40, 'active': true }); 12007 * // => objects for ['barney'] 12008 * 12009 * // The `_.matchesProperty` iteratee shorthand. 12010 * _.reject(users, ['active', false]); 12011 * // => objects for ['fred'] 12012 * 12013 * // The `_.property` iteratee shorthand. 12014 * _.reject(users, 'active'); 12015 * // => objects for ['barney'] 12016 */ 12017 function reject(collection, predicate) { 12018 var func = isArray(collection) ? arrayFilter : baseFilter; 12019 return func(collection, negate(getIteratee(predicate, 3))); 12020 } 12021 12022 /** 12023 * Gets a random element from `collection`. 12024 * 12025 * @static 12026 * @memberOf _ 12027 * @since 2.0.0 12028 * @category Collection 12029 * @param {Array|Object} collection The collection to sample. 12030 * @returns {*} Returns the random element. 12031 * @example 12032 * 12033 * _.sample([1, 2, 3, 4]); 12034 * // => 2 12035 */ 12036 function sample(collection) { 12037 var func = isArray(collection) ? arraySample : baseSample; 12038 return func(collection); 12039 } 12040 12041 /** 12042 * Gets `n` random elements at unique keys from `collection` up to the 12043 * size of `collection`. 12044 * 12045 * @static 12046 * @memberOf _ 12047 * @since 4.0.0 12048 * @category Collection 12049 * @param {Array|Object} collection The collection to sample. 12050 * @param {number} [n=1] The number of elements to sample. 12051 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12052 * @returns {Array} Returns the random elements. 12053 * @example 12054 * 12055 * _.sampleSize([1, 2, 3], 2); 12056 * // => [3, 1] 12057 * 12058 * _.sampleSize([1, 2, 3], 4); 12059 * // => [2, 3, 1] 12060 */ 12061 function sampleSize(collection, n, guard) { 12062 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { 12063 n = 1; 12064 } else { 12065 n = toInteger(n); 12066 } 12067 var func = isArray(collection) ? arraySampleSize : baseSampleSize; 12068 return func(collection, n); 12069 } 12070 12071 /** 12072 * Creates an array of shuffled values, using a version of the 12073 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). 12074 * 12075 * @static 12076 * @memberOf _ 12077 * @since 0.1.0 12078 * @category Collection 12079 * @param {Array|Object} collection The collection to shuffle. 12080 * @returns {Array} Returns the new shuffled array. 12081 * @example 12082 * 12083 * _.shuffle([1, 2, 3, 4]); 12084 * // => [4, 1, 3, 2] 12085 */ 12086 function shuffle(collection) { 12087 var func = isArray(collection) ? arrayShuffle : baseShuffle; 12088 return func(collection); 12089 } 12090 12091 /** 12092 * Gets the size of `collection` by returning its length for array-like 12093 * values or the number of own enumerable string keyed properties for objects. 12094 * 12095 * @static 12096 * @memberOf _ 12097 * @since 0.1.0 12098 * @category Collection 12099 * @param {Array|Object|string} collection The collection to inspect. 12100 * @returns {number} Returns the collection size. 12101 * @example 12102 * 12103 * _.size([1, 2, 3]); 12104 * // => 3 12105 * 12106 * _.size({ 'a': 1, 'b': 2 }); 12107 * // => 2 12108 * 12109 * _.size('pebbles'); 12110 * // => 7 12111 */ 12112 function size(collection) { 12113 if (collection == null) { 12114 return 0; 12115 } 12116 if (isArrayLike(collection)) { 12117 return isString(collection) ? stringSize(collection) : collection.length; 12118 } 12119 var tag = getTag(collection); 12120 if (tag == mapTag || tag == setTag) { 12121 return collection.size; 12122 } 12123 return baseKeys(collection).length; 12124 } 12125 12126 /** 12127 * Checks if `predicate` returns truthy for **any** element of `collection`. 12128 * Iteration is stopped once `predicate` returns truthy. The predicate is 12129 * invoked with three arguments: (value, index|key, collection). 12130 * 12131 * @static 12132 * @memberOf _ 12133 * @since 0.1.0 12134 * @category Collection 12135 * @param {Array|Object} collection The collection to iterate over. 12136 * @param {Function} [predicate=_.identity] The function invoked per iteration. 12137 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12138 * @returns {boolean} Returns `true` if any element passes the predicate check, 12139 * else `false`. 12140 * @example 12141 * 12142 * _.some([null, 0, 'yes', false], Boolean); 12143 * // => true 12144 * 12145 * var users = [ 12146 * { 'user': 'barney', 'active': true }, 12147 * { 'user': 'fred', 'active': false } 12148 * ]; 12149 * 12150 * // The `_.matches` iteratee shorthand. 12151 * _.some(users, { 'user': 'barney', 'active': false }); 12152 * // => false 12153 * 12154 * // The `_.matchesProperty` iteratee shorthand. 12155 * _.some(users, ['active', false]); 12156 * // => true 12157 * 12158 * // The `_.property` iteratee shorthand. 12159 * _.some(users, 'active'); 12160 * // => true 12161 */ 12162 function some(collection, predicate, guard) { 12163 var func = isArray(collection) ? arraySome : baseSome; 12164 if (guard && isIterateeCall(collection, predicate, guard)) { 12165 predicate = undefined; 12166 } 12167 return func(collection, getIteratee(predicate, 3)); 12168 } 12169 12170 /** 12171 * Creates an array of elements, sorted in ascending order by the results of 12172 * running each element in a collection thru each iteratee. This method 12173 * performs a stable sort, that is, it preserves the original sort order of 12174 * equal elements. The iteratees are invoked with one argument: (value). 12175 * 12176 * @static 12177 * @memberOf _ 12178 * @since 0.1.0 12179 * @category Collection 12180 * @param {Array|Object} collection The collection to iterate over. 12181 * @param {...(Function|Function[])} [iteratees=[_.identity]] 12182 * The iteratees to sort by. 12183 * @returns {Array} Returns the new sorted array. 12184 * @example 12185 * 12186 * var users = [ 12187 * { 'user': 'fred', 'age': 48 }, 12188 * { 'user': 'barney', 'age': 36 }, 12189 * { 'user': 'fred', 'age': 30 }, 12190 * { 'user': 'barney', 'age': 34 } 12191 * ]; 12192 * 12193 * _.sortBy(users, [function(o) { return o.user; }]); 12194 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] 12195 * 12196 * _.sortBy(users, ['user', 'age']); 12197 * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] 12198 */ 12199 var sortBy = baseRest(function(collection, iteratees) { 12200 if (collection == null) { 12201 return []; 12202 } 12203 var length = iteratees.length; 12204 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { 12205 iteratees = []; 12206 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { 12207 iteratees = [iteratees[0]]; 12208 } 12209 return baseOrderBy(collection, baseFlatten(iteratees, 1), []); 12210 }); 12211 12212 /*------------------------------------------------------------------------*/ 12213 12214 /** 12215 * Gets the timestamp of the number of milliseconds that have elapsed since 12216 * the Unix epoch (1 January 1970 00:00:00 UTC). 12217 * 12218 * @static 12219 * @memberOf _ 12220 * @since 2.4.0 12221 * @category Date 12222 * @returns {number} Returns the timestamp. 12223 * @example 12224 * 12225 * _.defer(function(stamp) { 12226 * console.log(_.now() - stamp); 12227 * }, _.now()); 12228 * // => Logs the number of milliseconds it took for the deferred invocation. 12229 */ 12230 var now = ctxNow || function() { 12231 return root.Date.now(); 12232 }; 12233 12234 /*------------------------------------------------------------------------*/ 12235 12236 /** 12237 * The opposite of `_.before`; this method creates a function that invokes 12238 * `func` once it's called `n` or more times. 12239 * 12240 * @static 12241 * @memberOf _ 12242 * @since 0.1.0 12243 * @category Function 12244 * @param {number} n The number of calls before `func` is invoked. 12245 * @param {Function} func The function to restrict. 12246 * @returns {Function} Returns the new restricted function. 12247 * @example 12248 * 12249 * var saves = ['profile', 'settings']; 12250 * 12251 * var done = _.after(saves.length, function() { 12252 * console.log('done saving!'); 12253 * }); 12254 * 12255 * _.forEach(saves, function(type) { 12256 * asyncSave({ 'type': type, 'complete': done }); 12257 * }); 12258 * // => Logs 'done saving!' after the two async saves have completed. 12259 */ 12260 function after(n, func) { 12261 if (typeof func != 'function') { 12262 throw new TypeError(FUNC_ERROR_TEXT); 12263 } 12264 n = toInteger(n); 12265 return function() { 12266 if (--n < 1) { 12267 return func.apply(this, arguments); 12268 } 12269 }; 12270 } 12271 12272 /** 12273 * Creates a function that invokes `func`, with up to `n` arguments, 12274 * ignoring any additional arguments. 12275 * 12276 * @static 12277 * @memberOf _ 12278 * @since 3.0.0 12279 * @category Function 12280 * @param {Function} func The function to cap arguments for. 12281 * @param {number} [n=func.length] The arity cap. 12282 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12283 * @returns {Function} Returns the new capped function. 12284 * @example 12285 * 12286 * _.map(['6', '8', '10'], _.ary(parseInt, 1)); 12287 * // => [6, 8, 10] 12288 */ 12289 function ary(func, n, guard) { 12290 n = guard ? undefined : n; 12291 n = (func && n == null) ? func.length : n; 12292 return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); 12293 } 12294 12295 /** 12296 * Creates a function that invokes `func`, with the `this` binding and arguments 12297 * of the created function, while it's called less than `n` times. Subsequent 12298 * calls to the created function return the result of the last `func` invocation. 12299 * 12300 * @static 12301 * @memberOf _ 12302 * @since 3.0.0 12303 * @category Function 12304 * @param {number} n The number of calls at which `func` is no longer invoked. 12305 * @param {Function} func The function to restrict. 12306 * @returns {Function} Returns the new restricted function. 12307 * @example 12308 * 12309 * jQuery(element).on('click', _.before(5, addContactToList)); 12310 * // => Allows adding up to 4 contacts to the list. 12311 */ 12312 function before(n, func) { 12313 var result; 12314 if (typeof func != 'function') { 12315 throw new TypeError(FUNC_ERROR_TEXT); 12316 } 12317 n = toInteger(n); 12318 return function() { 12319 if (--n > 0) { 12320 result = func.apply(this, arguments); 12321 } 12322 if (n <= 1) { 12323 func = undefined; 12324 } 12325 return result; 12326 }; 12327 } 12328 12329 /** 12330 * Creates a function that invokes `func` with the `this` binding of `thisArg` 12331 * and `partials` prepended to the arguments it receives. 12332 * 12333 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, 12334 * may be used as a placeholder for partially applied arguments. 12335 * 12336 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" 12337 * property of bound functions. 12338 * 12339 * @static 12340 * @memberOf _ 12341 * @since 0.1.0 12342 * @category Function 12343 * @param {Function} func The function to bind. 12344 * @param {*} thisArg The `this` binding of `func`. 12345 * @param {...*} [partials] The arguments to be partially applied. 12346 * @returns {Function} Returns the new bound function. 12347 * @example 12348 * 12349 * function greet(greeting, punctuation) { 12350 * return greeting + ' ' + this.user + punctuation; 12351 * } 12352 * 12353 * var object = { 'user': 'fred' }; 12354 * 12355 * var bound = _.bind(greet, object, 'hi'); 12356 * bound('!'); 12357 * // => 'hi fred!' 12358 * 12359 * // Bound with placeholders. 12360 * var bound = _.bind(greet, object, _, '!'); 12361 * bound('hi'); 12362 * // => 'hi fred!' 12363 */ 12364 var bind = baseRest(function(func, thisArg, partials) { 12365 var bitmask = WRAP_BIND_FLAG; 12366 if (partials.length) { 12367 var holders = replaceHolders(partials, getHolder(bind)); 12368 bitmask |= WRAP_PARTIAL_FLAG; 12369 } 12370 return createWrap(func, bitmask, thisArg, partials, holders); 12371 }); 12372 12373 /** 12374 * Creates a function that invokes the method at `object[key]` with `partials` 12375 * prepended to the arguments it receives. 12376 * 12377 * This method differs from `_.bind` by allowing bound functions to reference 12378 * methods that may be redefined or don't yet exist. See 12379 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) 12380 * for more details. 12381 * 12382 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic 12383 * builds, may be used as a placeholder for partially applied arguments. 12384 * 12385 * @static 12386 * @memberOf _ 12387 * @since 0.10.0 12388 * @category Function 12389 * @param {Object} object The object to invoke the method on. 12390 * @param {string} key The key of the method. 12391 * @param {...*} [partials] The arguments to be partially applied. 12392 * @returns {Function} Returns the new bound function. 12393 * @example 12394 * 12395 * var object = { 12396 * 'user': 'fred', 12397 * 'greet': function(greeting, punctuation) { 12398 * return greeting + ' ' + this.user + punctuation; 12399 * } 12400 * }; 12401 * 12402 * var bound = _.bindKey(object, 'greet', 'hi'); 12403 * bound('!'); 12404 * // => 'hi fred!' 12405 * 12406 * object.greet = function(greeting, punctuation) { 12407 * return greeting + 'ya ' + this.user + punctuation; 12408 * }; 12409 * 12410 * bound('!'); 12411 * // => 'hiya fred!' 12412 * 12413 * // Bound with placeholders. 12414 * var bound = _.bindKey(object, 'greet', _, '!'); 12415 * bound('hi'); 12416 * // => 'hiya fred!' 12417 */ 12418 var bindKey = baseRest(function(object, key, partials) { 12419 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; 12420 if (partials.length) { 12421 var holders = replaceHolders(partials, getHolder(bindKey)); 12422 bitmask |= WRAP_PARTIAL_FLAG; 12423 } 12424 return createWrap(key, bitmask, object, partials, holders); 12425 }); 12426 12427 /** 12428 * Creates a function that accepts arguments of `func` and either invokes 12429 * `func` returning its result, if at least `arity` number of arguments have 12430 * been provided, or returns a function that accepts the remaining `func` 12431 * arguments, and so on. The arity of `func` may be specified if `func.length` 12432 * is not sufficient. 12433 * 12434 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, 12435 * may be used as a placeholder for provided arguments. 12436 * 12437 * **Note:** This method doesn't set the "length" property of curried functions. 12438 * 12439 * @static 12440 * @memberOf _ 12441 * @since 2.0.0 12442 * @category Function 12443 * @param {Function} func The function to curry. 12444 * @param {number} [arity=func.length] The arity of `func`. 12445 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12446 * @returns {Function} Returns the new curried function. 12447 * @example 12448 * 12449 * var abc = function(a, b, c) { 12450 * return [a, b, c]; 12451 * }; 12452 * 12453 * var curried = _.curry(abc); 12454 * 12455 * curried(1)(2)(3); 12456 * // => [1, 2, 3] 12457 * 12458 * curried(1, 2)(3); 12459 * // => [1, 2, 3] 12460 * 12461 * curried(1, 2, 3); 12462 * // => [1, 2, 3] 12463 * 12464 * // Curried with placeholders. 12465 * curried(1)(_, 3)(2); 12466 * // => [1, 2, 3] 12467 */ 12468 function curry(func, arity, guard) { 12469 arity = guard ? undefined : arity; 12470 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 12471 result.placeholder = curry.placeholder; 12472 return result; 12473 } 12474 12475 /** 12476 * This method is like `_.curry` except that arguments are applied to `func` 12477 * in the manner of `_.partialRight` instead of `_.partial`. 12478 * 12479 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic 12480 * builds, may be used as a placeholder for provided arguments. 12481 * 12482 * **Note:** This method doesn't set the "length" property of curried functions. 12483 * 12484 * @static 12485 * @memberOf _ 12486 * @since 3.0.0 12487 * @category Function 12488 * @param {Function} func The function to curry. 12489 * @param {number} [arity=func.length] The arity of `func`. 12490 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12491 * @returns {Function} Returns the new curried function. 12492 * @example 12493 * 12494 * var abc = function(a, b, c) { 12495 * return [a, b, c]; 12496 * }; 12497 * 12498 * var curried = _.curryRight(abc); 12499 * 12500 * curried(3)(2)(1); 12501 * // => [1, 2, 3] 12502 * 12503 * curried(2, 3)(1); 12504 * // => [1, 2, 3] 12505 * 12506 * curried(1, 2, 3); 12507 * // => [1, 2, 3] 12508 * 12509 * // Curried with placeholders. 12510 * curried(3)(1, _)(2); 12511 * // => [1, 2, 3] 12512 */ 12513 function curryRight(func, arity, guard) { 12514 arity = guard ? undefined : arity; 12515 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 12516 result.placeholder = curryRight.placeholder; 12517 return result; 12518 } 12519 12520 /** 12521 * Creates a debounced function that delays invoking `func` until after `wait` 12522 * milliseconds have elapsed since the last time the debounced function was 12523 * invoked. The debounced function comes with a `cancel` method to cancel 12524 * delayed `func` invocations and a `flush` method to immediately invoke them. 12525 * Provide `options` to indicate whether `func` should be invoked on the 12526 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 12527 * with the last arguments provided to the debounced function. Subsequent 12528 * calls to the debounced function return the result of the last `func` 12529 * invocation. 12530 * 12531 * **Note:** If `leading` and `trailing` options are `true`, `func` is 12532 * invoked on the trailing edge of the timeout only if the debounced function 12533 * is invoked more than once during the `wait` timeout. 12534 * 12535 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 12536 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 12537 * 12538 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 12539 * for details over the differences between `_.debounce` and `_.throttle`. 12540 * 12541 * @static 12542 * @memberOf _ 12543 * @since 0.1.0 12544 * @category Function 12545 * @param {Function} func The function to debounce. 12546 * @param {number} [wait=0] The number of milliseconds to delay. 12547 * @param {Object} [options={}] The options object. 12548 * @param {boolean} [options.leading=false] 12549 * Specify invoking on the leading edge of the timeout. 12550 * @param {number} [options.maxWait] 12551 * The maximum time `func` is allowed to be delayed before it's invoked. 12552 * @param {boolean} [options.trailing=true] 12553 * Specify invoking on the trailing edge of the timeout. 12554 * @returns {Function} Returns the new debounced function. 12555 * @example 12556 * 12557 * // Avoid costly calculations while the window size is in flux. 12558 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 12559 * 12560 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 12561 * jQuery(element).on('click', _.debounce(sendMail, 300, { 12562 * 'leading': true, 12563 * 'trailing': false 12564 * })); 12565 * 12566 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 12567 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 12568 * var source = new EventSource('/stream'); 12569 * jQuery(source).on('message', debounced); 12570 * 12571 * // Cancel the trailing debounced invocation. 12572 * jQuery(window).on('popstate', debounced.cancel); 12573 */ 12574 function debounce(func, wait, options) { 12575 var lastArgs, 12576 lastThis, 12577 maxWait, 12578 result, 12579 timerId, 12580 lastCallTime, 12581 lastInvokeTime = 0, 12582 leading = false, 12583 maxing = false, 12584 trailing = true; 12585 12586 if (typeof func != 'function') { 12587 throw new TypeError(FUNC_ERROR_TEXT); 12588 } 12589 wait = toNumber(wait) || 0; 12590 if (isObject(options)) { 12591 leading = !!options.leading; 12592 maxing = 'maxWait' in options; 12593 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; 12594 trailing = 'trailing' in options ? !!options.trailing : trailing; 12595 } 12596 12597 function invokeFunc(time) { 12598 var args = lastArgs, 12599 thisArg = lastThis; 12600 12601 lastArgs = lastThis = undefined; 12602 lastInvokeTime = time; 12603 result = func.apply(thisArg, args); 12604 return result; 12605 } 12606 12607 function leadingEdge(time) { 12608 // Reset any `maxWait` timer. 12609 lastInvokeTime = time; 12610 // Start the timer for the trailing edge. 12611 timerId = setTimeout(timerExpired, wait); 12612 // Invoke the leading edge. 12613 return leading ? invokeFunc(time) : result; 12614 } 12615 12616 function remainingWait(time) { 12617 var timeSinceLastCall = time - lastCallTime, 12618 timeSinceLastInvoke = time - lastInvokeTime, 12619 timeWaiting = wait - timeSinceLastCall; 12620 12621 return maxing 12622 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) 12623 : timeWaiting; 12624 } 12625 12626 function shouldInvoke(time) { 12627 var timeSinceLastCall = time - lastCallTime, 12628 timeSinceLastInvoke = time - lastInvokeTime; 12629 12630 // Either this is the first call, activity has stopped and we're at the 12631 // trailing edge, the system time has gone backwards and we're treating 12632 // it as the trailing edge, or we've hit the `maxWait` limit. 12633 return (lastCallTime === undefined || (timeSinceLastCall >= wait) || 12634 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 12635 } 12636 12637 function timerExpired() { 12638 var time = now(); 12639 if (shouldInvoke(time)) { 12640 return trailingEdge(time); 12641 } 12642 // Restart the timer. 12643 timerId = setTimeout(timerExpired, remainingWait(time)); 12644 } 12645 12646 function trailingEdge(time) { 12647 timerId = undefined; 12648 12649 // Only invoke if we have `lastArgs` which means `func` has been 12650 // debounced at least once. 12651 if (trailing && lastArgs) { 12652 return invokeFunc(time); 12653 } 12654 lastArgs = lastThis = undefined; 12655 return result; 12656 } 12657 12658 function cancel() { 12659 if (timerId !== undefined) { 12660 clearTimeout(timerId); 12661 } 12662 lastInvokeTime = 0; 12663 lastArgs = lastCallTime = lastThis = timerId = undefined; 12664 } 12665 12666 function flush() { 12667 return timerId === undefined ? result : trailingEdge(now()); 12668 } 12669 12670 function debounced() { 12671 var time = now(), 12672 isInvoking = shouldInvoke(time); 12673 12674 lastArgs = arguments; 12675 lastThis = this; 12676 lastCallTime = time; 12677 12678 if (isInvoking) { 12679 if (timerId === undefined) { 12680 return leadingEdge(lastCallTime); 12681 } 12682 if (maxing) { 12683 // Handle invocations in a tight loop. 12684 clearTimeout(timerId); 12685 timerId = setTimeout(timerExpired, wait); 12686 return invokeFunc(lastCallTime); 12687 } 12688 } 12689 if (timerId === undefined) { 12690 timerId = setTimeout(timerExpired, wait); 12691 } 12692 return result; 12693 } 12694 debounced.cancel = cancel; 12695 debounced.flush = flush; 12696 return debounced; 12697 } 12698 12699 /** 12700 * Defers invoking the `func` until the current call stack has cleared. Any 12701 * additional arguments are provided to `func` when it's invoked. 12702 * 12703 * @static 12704 * @memberOf _ 12705 * @since 0.1.0 12706 * @category Function 12707 * @param {Function} func The function to defer. 12708 * @param {...*} [args] The arguments to invoke `func` with. 12709 * @returns {number} Returns the timer id. 12710 * @example 12711 * 12712 * _.defer(function(text) { 12713 * console.log(text); 12714 * }, 'deferred'); 12715 * // => Logs 'deferred' after one millisecond. 12716 */ 12717 var defer = baseRest(function(func, args) { 12718 return baseDelay(func, 1, args); 12719 }); 12720 12721 /** 12722 * Invokes `func` after `wait` milliseconds. Any additional arguments are 12723 * provided to `func` when it's invoked. 12724 * 12725 * @static 12726 * @memberOf _ 12727 * @since 0.1.0 12728 * @category Function 12729 * @param {Function} func The function to delay. 12730 * @param {number} wait The number of milliseconds to delay invocation. 12731 * @param {...*} [args] The arguments to invoke `func` with. 12732 * @returns {number} Returns the timer id. 12733 * @example 12734 * 12735 * _.delay(function(text) { 12736 * console.log(text); 12737 * }, 1000, 'later'); 12738 * // => Logs 'later' after one second. 12739 */ 12740 var delay = baseRest(function(func, wait, args) { 12741 return baseDelay(func, toNumber(wait) || 0, args); 12742 }); 12743 12744 /** 12745 * Creates a function that invokes `func` with arguments reversed. 12746 * 12747 * @static 12748 * @memberOf _ 12749 * @since 4.0.0 12750 * @category Function 12751 * @param {Function} func The function to flip arguments for. 12752 * @returns {Function} Returns the new flipped function. 12753 * @example 12754 * 12755 * var flipped = _.flip(function() { 12756 * return _.toArray(arguments); 12757 * }); 12758 * 12759 * flipped('a', 'b', 'c', 'd'); 12760 * // => ['d', 'c', 'b', 'a'] 12761 */ 12762 function flip(func) { 12763 return createWrap(func, WRAP_FLIP_FLAG); 12764 } 12765 12766 /** 12767 * Creates a function that memoizes the result of `func`. If `resolver` is 12768 * provided, it determines the cache key for storing the result based on the 12769 * arguments provided to the memoized function. By default, the first argument 12770 * provided to the memoized function is used as the map cache key. The `func` 12771 * is invoked with the `this` binding of the memoized function. 12772 * 12773 * **Note:** The cache is exposed as the `cache` property on the memoized 12774 * function. Its creation may be customized by replacing the `_.memoize.Cache` 12775 * constructor with one whose instances implement the 12776 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) 12777 * method interface of `clear`, `delete`, `get`, `has`, and `set`. 12778 * 12779 * @static 12780 * @memberOf _ 12781 * @since 0.1.0 12782 * @category Function 12783 * @param {Function} func The function to have its output memoized. 12784 * @param {Function} [resolver] The function to resolve the cache key. 12785 * @returns {Function} Returns the new memoized function. 12786 * @example 12787 * 12788 * var object = { 'a': 1, 'b': 2 }; 12789 * var other = { 'c': 3, 'd': 4 }; 12790 * 12791 * var values = _.memoize(_.values); 12792 * values(object); 12793 * // => [1, 2] 12794 * 12795 * values(other); 12796 * // => [3, 4] 12797 * 12798 * object.a = 2; 12799 * values(object); 12800 * // => [1, 2] 12801 * 12802 * // Modify the result cache. 12803 * values.cache.set(object, ['a', 'b']); 12804 * values(object); 12805 * // => ['a', 'b'] 12806 * 12807 * // Replace `_.memoize.Cache`. 12808 * _.memoize.Cache = WeakMap; 12809 */ 12810 function memoize(func, resolver) { 12811 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { 12812 throw new TypeError(FUNC_ERROR_TEXT); 12813 } 12814 var memoized = function() { 12815 var args = arguments, 12816 key = resolver ? resolver.apply(this, args) : args[0], 12817 cache = memoized.cache; 12818 12819 if (cache.has(key)) { 12820 return cache.get(key); 12821 } 12822 var result = func.apply(this, args); 12823 memoized.cache = cache.set(key, result) || cache; 12824 return result; 12825 }; 12826 memoized.cache = new (memoize.Cache || MapCache); 12827 return memoized; 12828 } 12829 12830 // Expose `MapCache`. 12831 memoize.Cache = MapCache; 12832 12833 /** 12834 * Creates a function that negates the result of the predicate `func`. The 12835 * `func` predicate is invoked with the `this` binding and arguments of the 12836 * created function. 12837 * 12838 * @static 12839 * @memberOf _ 12840 * @since 3.0.0 12841 * @category Function 12842 * @param {Function} predicate The predicate to negate. 12843 * @returns {Function} Returns the new negated function. 12844 * @example 12845 * 12846 * function isEven(n) { 12847 * return n % 2 == 0; 12848 * } 12849 * 12850 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); 12851 * // => [1, 3, 5] 12852 */ 12853 function negate(predicate) { 12854 if (typeof predicate != 'function') { 12855 throw new TypeError(FUNC_ERROR_TEXT); 12856 } 12857 return function() { 12858 var args = arguments; 12859 switch (args.length) { 12860 case 0: return !predicate.call(this); 12861 case 1: return !predicate.call(this, args[0]); 12862 case 2: return !predicate.call(this, args[0], args[1]); 12863 case 3: return !predicate.call(this, args[0], args[1], args[2]); 12864 } 12865 return !predicate.apply(this, args); 12866 }; 12867 } 12868 12869 /** 12870 * Creates a function that is restricted to invoking `func` once. Repeat calls 12871 * to the function return the value of the first invocation. The `func` is 12872 * invoked with the `this` binding and arguments of the created function. 12873 * 12874 * @static 12875 * @memberOf _ 12876 * @since 0.1.0 12877 * @category Function 12878 * @param {Function} func The function to restrict. 12879 * @returns {Function} Returns the new restricted function. 12880 * @example 12881 * 12882 * var initialize = _.once(createApplication); 12883 * initialize(); 12884 * initialize(); 12885 * // => `createApplication` is invoked once 12886 */ 12887 function once(func) { 12888 return before(2, func); 12889 } 12890 12891 /** 12892 * Creates a function that invokes `func` with its arguments transformed. 12893 * 12894 * @static 12895 * @since 4.0.0 12896 * @memberOf _ 12897 * @category Function 12898 * @param {Function} func The function to wrap. 12899 * @param {...(Function|Function[])} [transforms=[_.identity]] 12900 * The argument transforms. 12901 * @returns {Function} Returns the new function. 12902 * @example 12903 * 12904 * function doubled(n) { 12905 * return n * 2; 12906 * } 12907 * 12908 * function square(n) { 12909 * return n * n; 12910 * } 12911 * 12912 * var func = _.overArgs(function(x, y) { 12913 * return [x, y]; 12914 * }, [square, doubled]); 12915 * 12916 * func(9, 3); 12917 * // => [81, 6] 12918 * 12919 * func(10, 5); 12920 * // => [100, 10] 12921 */ 12922 var overArgs = castRest(function(func, transforms) { 12923 transforms = (transforms.length == 1 && isArray(transforms[0])) 12924 ? arrayMap(transforms[0], baseUnary(getIteratee())) 12925 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); 12926 12927 var funcsLength = transforms.length; 12928 return baseRest(function(args) { 12929 var index = -1, 12930 length = nativeMin(args.length, funcsLength); 12931 12932 while (++index < length) { 12933 args[index] = transforms[index].call(this, args[index]); 12934 } 12935 return apply(func, this, args); 12936 }); 12937 }); 12938 12939 /** 12940 * Creates a function that invokes `func` with `partials` prepended to the 12941 * arguments it receives. This method is like `_.bind` except it does **not** 12942 * alter the `this` binding. 12943 * 12944 * The `_.partial.placeholder` value, which defaults to `_` in monolithic 12945 * builds, may be used as a placeholder for partially applied arguments. 12946 * 12947 * **Note:** This method doesn't set the "length" property of partially 12948 * applied functions. 12949 * 12950 * @static 12951 * @memberOf _ 12952 * @since 0.2.0 12953 * @category Function 12954 * @param {Function} func The function to partially apply arguments to. 12955 * @param {...*} [partials] The arguments to be partially applied. 12956 * @returns {Function} Returns the new partially applied function. 12957 * @example 12958 * 12959 * function greet(greeting, name) { 12960 * return greeting + ' ' + name; 12961 * } 12962 * 12963 * var sayHelloTo = _.partial(greet, 'hello'); 12964 * sayHelloTo('fred'); 12965 * // => 'hello fred' 12966 * 12967 * // Partially applied with placeholders. 12968 * var greetFred = _.partial(greet, _, 'fred'); 12969 * greetFred('hi'); 12970 * // => 'hi fred' 12971 */ 12972 var partial = baseRest(function(func, partials) { 12973 var holders = replaceHolders(partials, getHolder(partial)); 12974 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); 12975 }); 12976 12977 /** 12978 * This method is like `_.partial` except that partially applied arguments 12979 * are appended to the arguments it receives. 12980 * 12981 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic 12982 * builds, may be used as a placeholder for partially applied arguments. 12983 * 12984 * **Note:** This method doesn't set the "length" property of partially 12985 * applied functions. 12986 * 12987 * @static 12988 * @memberOf _ 12989 * @since 1.0.0 12990 * @category Function 12991 * @param {Function} func The function to partially apply arguments to. 12992 * @param {...*} [partials] The arguments to be partially applied. 12993 * @returns {Function} Returns the new partially applied function. 12994 * @example 12995 * 12996 * function greet(greeting, name) { 12997 * return greeting + ' ' + name; 12998 * } 12999 * 13000 * var greetFred = _.partialRight(greet, 'fred'); 13001 * greetFred('hi'); 13002 * // => 'hi fred' 13003 * 13004 * // Partially applied with placeholders. 13005 * var sayHelloTo = _.partialRight(greet, 'hello', _); 13006 * sayHelloTo('fred'); 13007 * // => 'hello fred' 13008 */ 13009 var partialRight = baseRest(function(func, partials) { 13010 var holders = replaceHolders(partials, getHolder(partialRight)); 13011 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); 13012 }); 13013 13014 /** 13015 * Creates a function that invokes `func` with arguments arranged according 13016 * to the specified `indexes` where the argument value at the first index is 13017 * provided as the first argument, the argument value at the second index is 13018 * provided as the second argument, and so on. 13019 * 13020 * @static 13021 * @memberOf _ 13022 * @since 3.0.0 13023 * @category Function 13024 * @param {Function} func The function to rearrange arguments for. 13025 * @param {...(number|number[])} indexes The arranged argument indexes. 13026 * @returns {Function} Returns the new function. 13027 * @example 13028 * 13029 * var rearged = _.rearg(function(a, b, c) { 13030 * return [a, b, c]; 13031 * }, [2, 0, 1]); 13032 * 13033 * rearged('b', 'c', 'a') 13034 * // => ['a', 'b', 'c'] 13035 */ 13036 var rearg = flatRest(function(func, indexes) { 13037 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); 13038 }); 13039 13040 /** 13041 * Creates a function that invokes `func` with the `this` binding of the 13042 * created function and arguments from `start` and beyond provided as 13043 * an array. 13044 * 13045 * **Note:** This method is based on the 13046 * [rest parameter](https://mdn.io/rest_parameters). 13047 * 13048 * @static 13049 * @memberOf _ 13050 * @since 4.0.0 13051 * @category Function 13052 * @param {Function} func The function to apply a rest parameter to. 13053 * @param {number} [start=func.length-1] The start position of the rest parameter. 13054 * @returns {Function} Returns the new function. 13055 * @example 13056 * 13057 * var say = _.rest(function(what, names) { 13058 * return what + ' ' + _.initial(names).join(', ') + 13059 * (_.size(names) > 1 ? ', & ' : '') + _.last(names); 13060 * }); 13061 * 13062 * say('hello', 'fred', 'barney', 'pebbles'); 13063 * // => 'hello fred, barney, & pebbles' 13064 */ 13065 function rest(func, start) { 13066 if (typeof func != 'function') { 13067 throw new TypeError(FUNC_ERROR_TEXT); 13068 } 13069 start = start === undefined ? start : toInteger(start); 13070 return baseRest(func, start); 13071 } 13072 13073 /** 13074 * Creates a function that invokes `func` with the `this` binding of the 13075 * create function and an array of arguments much like 13076 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). 13077 * 13078 * **Note:** This method is based on the 13079 * [spread operator](https://mdn.io/spread_operator). 13080 * 13081 * @static 13082 * @memberOf _ 13083 * @since 3.2.0 13084 * @category Function 13085 * @param {Function} func The function to spread arguments over. 13086 * @param {number} [start=0] The start position of the spread. 13087 * @returns {Function} Returns the new function. 13088 * @example 13089 * 13090 * var say = _.spread(function(who, what) { 13091 * return who + ' says ' + what; 13092 * }); 13093 * 13094 * say(['fred', 'hello']); 13095 * // => 'fred says hello' 13096 * 13097 * var numbers = Promise.all([ 13098 * Promise.resolve(40), 13099 * Promise.resolve(36) 13100 * ]); 13101 * 13102 * numbers.then(_.spread(function(x, y) { 13103 * return x + y; 13104 * })); 13105 * // => a Promise of 76 13106 */ 13107 function spread(func, start) { 13108 if (typeof func != 'function') { 13109 throw new TypeError(FUNC_ERROR_TEXT); 13110 } 13111 start = start == null ? 0 : nativeMax(toInteger(start), 0); 13112 return baseRest(function(args) { 13113 var array = args[start], 13114 otherArgs = castSlice(args, 0, start); 13115 13116 if (array) { 13117 arrayPush(otherArgs, array); 13118 } 13119 return apply(func, this, otherArgs); 13120 }); 13121 } 13122 13123 /** 13124 * Creates a throttled function that only invokes `func` at most once per 13125 * every `wait` milliseconds. The throttled function comes with a `cancel` 13126 * method to cancel delayed `func` invocations and a `flush` method to 13127 * immediately invoke them. Provide `options` to indicate whether `func` 13128 * should be invoked on the leading and/or trailing edge of the `wait` 13129 * timeout. The `func` is invoked with the last arguments provided to the 13130 * throttled function. Subsequent calls to the throttled function return the 13131 * result of the last `func` invocation. 13132 * 13133 * **Note:** If `leading` and `trailing` options are `true`, `func` is 13134 * invoked on the trailing edge of the timeout only if the throttled function 13135 * is invoked more than once during the `wait` timeout. 13136 * 13137 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 13138 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 13139 * 13140 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 13141 * for details over the differences between `_.throttle` and `_.debounce`. 13142 * 13143 * @static 13144 * @memberOf _ 13145 * @since 0.1.0 13146 * @category Function 13147 * @param {Function} func The function to throttle. 13148 * @param {number} [wait=0] The number of milliseconds to throttle invocations to. 13149 * @param {Object} [options={}] The options object. 13150 * @param {boolean} [options.leading=true] 13151 * Specify invoking on the leading edge of the timeout. 13152 * @param {boolean} [options.trailing=true] 13153 * Specify invoking on the trailing edge of the timeout. 13154 * @returns {Function} Returns the new throttled function. 13155 * @example 13156 * 13157 * // Avoid excessively updating the position while scrolling. 13158 * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); 13159 * 13160 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. 13161 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); 13162 * jQuery(element).on('click', throttled); 13163 * 13164 * // Cancel the trailing throttled invocation. 13165 * jQuery(window).on('popstate', throttled.cancel); 13166 */ 13167 function throttle(func, wait, options) { 13168 var leading = true, 13169 trailing = true; 13170 13171 if (typeof func != 'function') { 13172 throw new TypeError(FUNC_ERROR_TEXT); 13173 } 13174 if (isObject(options)) { 13175 leading = 'leading' in options ? !!options.leading : leading; 13176 trailing = 'trailing' in options ? !!options.trailing : trailing; 13177 } 13178 return debounce(func, wait, { 13179 'leading': leading, 13180 'maxWait': wait, 13181 'trailing': trailing 13182 }); 13183 } 13184 13185 /** 13186 * Creates a function that accepts up to one argument, ignoring any 13187 * additional arguments. 13188 * 13189 * @static 13190 * @memberOf _ 13191 * @since 4.0.0 13192 * @category Function 13193 * @param {Function} func The function to cap arguments for. 13194 * @returns {Function} Returns the new capped function. 13195 * @example 13196 * 13197 * _.map(['6', '8', '10'], _.unary(parseInt)); 13198 * // => [6, 8, 10] 13199 */ 13200 function unary(func) { 13201 return ary(func, 1); 13202 } 13203 13204 /** 13205 * Creates a function that provides `value` to `wrapper` as its first 13206 * argument. Any additional arguments provided to the function are appended 13207 * to those provided to the `wrapper`. The wrapper is invoked with the `this` 13208 * binding of the created function. 13209 * 13210 * @static 13211 * @memberOf _ 13212 * @since 0.1.0 13213 * @category Function 13214 * @param {*} value The value to wrap. 13215 * @param {Function} [wrapper=identity] The wrapper function. 13216 * @returns {Function} Returns the new function. 13217 * @example 13218 * 13219 * var p = _.wrap(_.escape, function(func, text) { 13220 * return '<p>' + func(text) + '</p>'; 13221 * }); 13222 * 13223 * p('fred, barney, & pebbles'); 13224 * // => '<p>fred, barney, & pebbles</p>' 13225 */ 13226 function wrap(value, wrapper) { 13227 return partial(castFunction(wrapper), value); 13228 } 13229 13230 /*------------------------------------------------------------------------*/ 13231 13232 /** 13233 * Casts `value` as an array if it's not one. 13234 * 13235 * @static 13236 * @memberOf _ 13237 * @since 4.4.0 13238 * @category Lang 13239 * @param {*} value The value to inspect. 13240 * @returns {Array} Returns the cast array. 13241 * @example 13242 * 13243 * _.castArray(1); 13244 * // => [1] 13245 * 13246 * _.castArray({ 'a': 1 }); 13247 * // => [{ 'a': 1 }] 13248 * 13249 * _.castArray('abc'); 13250 * // => ['abc'] 13251 * 13252 * _.castArray(null); 13253 * // => [null] 13254 * 13255 * _.castArray(undefined); 13256 * // => [undefined] 13257 * 13258 * _.castArray(); 13259 * // => [] 13260 * 13261 * var array = [1, 2, 3]; 13262 * console.log(_.castArray(array) === array); 13263 * // => true 13264 */ 13265 function castArray() { 13266 if (!arguments.length) { 13267 return []; 13268 } 13269 var value = arguments[0]; 13270 return isArray(value) ? value : [value]; 13271 } 13272 13273 /** 13274 * Creates a shallow clone of `value`. 13275 * 13276 * **Note:** This method is loosely based on the 13277 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) 13278 * and supports cloning arrays, array buffers, booleans, date objects, maps, 13279 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed 13280 * arrays. The own enumerable properties of `arguments` objects are cloned 13281 * as plain objects. An empty object is returned for uncloneable values such 13282 * as error objects, functions, DOM nodes, and WeakMaps. 13283 * 13284 * @static 13285 * @memberOf _ 13286 * @since 0.1.0 13287 * @category Lang 13288 * @param {*} value The value to clone. 13289 * @returns {*} Returns the cloned value. 13290 * @see _.cloneDeep 13291 * @example 13292 * 13293 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 13294 * 13295 * var shallow = _.clone(objects); 13296 * console.log(shallow[0] === objects[0]); 13297 * // => true 13298 */ 13299 function clone(value) { 13300 return baseClone(value, CLONE_SYMBOLS_FLAG); 13301 } 13302 13303 /** 13304 * This method is like `_.clone` except that it accepts `customizer` which 13305 * is invoked to produce the cloned value. If `customizer` returns `undefined`, 13306 * cloning is handled by the method instead. The `customizer` is invoked with 13307 * up to four arguments; (value [, index|key, object, stack]). 13308 * 13309 * @static 13310 * @memberOf _ 13311 * @since 4.0.0 13312 * @category Lang 13313 * @param {*} value The value to clone. 13314 * @param {Function} [customizer] The function to customize cloning. 13315 * @returns {*} Returns the cloned value. 13316 * @see _.cloneDeepWith 13317 * @example 13318 * 13319 * function customizer(value) { 13320 * if (_.isElement(value)) { 13321 * return value.cloneNode(false); 13322 * } 13323 * } 13324 * 13325 * var el = _.cloneWith(document.body, customizer); 13326 * 13327 * console.log(el === document.body); 13328 * // => false 13329 * console.log(el.nodeName); 13330 * // => 'BODY' 13331 * console.log(el.childNodes.length); 13332 * // => 0 13333 */ 13334 function cloneWith(value, customizer) { 13335 customizer = typeof customizer == 'function' ? customizer : undefined; 13336 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); 13337 } 13338 13339 /** 13340 * This method is like `_.clone` except that it recursively clones `value`. 13341 * 13342 * @static 13343 * @memberOf _ 13344 * @since 1.0.0 13345 * @category Lang 13346 * @param {*} value The value to recursively clone. 13347 * @returns {*} Returns the deep cloned value. 13348 * @see _.clone 13349 * @example 13350 * 13351 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 13352 * 13353 * var deep = _.cloneDeep(objects); 13354 * console.log(deep[0] === objects[0]); 13355 * // => false 13356 */ 13357 function cloneDeep(value) { 13358 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); 13359 } 13360 13361 /** 13362 * This method is like `_.cloneWith` except that it recursively clones `value`. 13363 * 13364 * @static 13365 * @memberOf _ 13366 * @since 4.0.0 13367 * @category Lang 13368 * @param {*} value The value to recursively clone. 13369 * @param {Function} [customizer] The function to customize cloning. 13370 * @returns {*} Returns the deep cloned value. 13371 * @see _.cloneWith 13372 * @example 13373 * 13374 * function customizer(value) { 13375 * if (_.isElement(value)) { 13376 * return value.cloneNode(true); 13377 * } 13378 * } 13379 * 13380 * var el = _.cloneDeepWith(document.body, customizer); 13381 * 13382 * console.log(el === document.body); 13383 * // => false 13384 * console.log(el.nodeName); 13385 * // => 'BODY' 13386 * console.log(el.childNodes.length); 13387 * // => 20 13388 */ 13389 function cloneDeepWith(value, customizer) { 13390 customizer = typeof customizer == 'function' ? customizer : undefined; 13391 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); 13392 } 13393 13394 /** 13395 * Checks if `object` conforms to `source` by invoking the predicate 13396 * properties of `source` with the corresponding property values of `object`. 13397 * 13398 * **Note:** This method is equivalent to `_.conforms` when `source` is 13399 * partially applied. 13400 * 13401 * @static 13402 * @memberOf _ 13403 * @since 4.14.0 13404 * @category Lang 13405 * @param {Object} object The object to inspect. 13406 * @param {Object} source The object of property predicates to conform to. 13407 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 13408 * @example 13409 * 13410 * var object = { 'a': 1, 'b': 2 }; 13411 * 13412 * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); 13413 * // => true 13414 * 13415 * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); 13416 * // => false 13417 */ 13418 function conformsTo(object, source) { 13419 return source == null || baseConformsTo(object, source, keys(source)); 13420 } 13421 13422 /** 13423 * Performs a 13424 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 13425 * comparison between two values to determine if they are equivalent. 13426 * 13427 * @static 13428 * @memberOf _ 13429 * @since 4.0.0 13430 * @category Lang 13431 * @param {*} value The value to compare. 13432 * @param {*} other The other value to compare. 13433 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 13434 * @example 13435 * 13436 * var object = { 'a': 1 }; 13437 * var other = { 'a': 1 }; 13438 * 13439 * _.eq(object, object); 13440 * // => true 13441 * 13442 * _.eq(object, other); 13443 * // => false 13444 * 13445 * _.eq('a', 'a'); 13446 * // => true 13447 * 13448 * _.eq('a', Object('a')); 13449 * // => false 13450 * 13451 * _.eq(NaN, NaN); 13452 * // => true 13453 */ 13454 function eq(value, other) { 13455 return value === other || (value !== value && other !== other); 13456 } 13457 13458 /** 13459 * Checks if `value` is greater than `other`. 13460 * 13461 * @static 13462 * @memberOf _ 13463 * @since 3.9.0 13464 * @category Lang 13465 * @param {*} value The value to compare. 13466 * @param {*} other The other value to compare. 13467 * @returns {boolean} Returns `true` if `value` is greater than `other`, 13468 * else `false`. 13469 * @see _.lt 13470 * @example 13471 * 13472 * _.gt(3, 1); 13473 * // => true 13474 * 13475 * _.gt(3, 3); 13476 * // => false 13477 * 13478 * _.gt(1, 3); 13479 * // => false 13480 */ 13481 var gt = createRelationalOperation(baseGt); 13482 13483 /** 13484 * Checks if `value` is greater than or equal to `other`. 13485 * 13486 * @static 13487 * @memberOf _ 13488 * @since 3.9.0 13489 * @category Lang 13490 * @param {*} value The value to compare. 13491 * @param {*} other The other value to compare. 13492 * @returns {boolean} Returns `true` if `value` is greater than or equal to 13493 * `other`, else `false`. 13494 * @see _.lte 13495 * @example 13496 * 13497 * _.gte(3, 1); 13498 * // => true 13499 * 13500 * _.gte(3, 3); 13501 * // => true 13502 * 13503 * _.gte(1, 3); 13504 * // => false 13505 */ 13506 var gte = createRelationalOperation(function(value, other) { 13507 return value >= other; 13508 }); 13509 13510 /** 13511 * Checks if `value` is likely an `arguments` object. 13512 * 13513 * @static 13514 * @memberOf _ 13515 * @since 0.1.0 13516 * @category Lang 13517 * @param {*} value The value to check. 13518 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 13519 * else `false`. 13520 * @example 13521 * 13522 * _.isArguments(function() { return arguments; }()); 13523 * // => true 13524 * 13525 * _.isArguments([1, 2, 3]); 13526 * // => false 13527 */ 13528 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { 13529 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && 13530 !propertyIsEnumerable.call(value, 'callee'); 13531 }; 13532 13533 /** 13534 * Checks if `value` is classified as an `Array` object. 13535 * 13536 * @static 13537 * @memberOf _ 13538 * @since 0.1.0 13539 * @category Lang 13540 * @param {*} value The value to check. 13541 * @returns {boolean} Returns `true` if `value` is an array, else `false`. 13542 * @example 13543 * 13544 * _.isArray([1, 2, 3]); 13545 * // => true 13546 * 13547 * _.isArray(document.body.children); 13548 * // => false 13549 * 13550 * _.isArray('abc'); 13551 * // => false 13552 * 13553 * _.isArray(_.noop); 13554 * // => false 13555 */ 13556 var isArray = Array.isArray; 13557 13558 /** 13559 * Checks if `value` is classified as an `ArrayBuffer` object. 13560 * 13561 * @static 13562 * @memberOf _ 13563 * @since 4.3.0 13564 * @category Lang 13565 * @param {*} value The value to check. 13566 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 13567 * @example 13568 * 13569 * _.isArrayBuffer(new ArrayBuffer(2)); 13570 * // => true 13571 * 13572 * _.isArrayBuffer(new Array(2)); 13573 * // => false 13574 */ 13575 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; 13576 13577 /** 13578 * Checks if `value` is array-like. A value is considered array-like if it's 13579 * not a function and has a `value.length` that's an integer greater than or 13580 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. 13581 * 13582 * @static 13583 * @memberOf _ 13584 * @since 4.0.0 13585 * @category Lang 13586 * @param {*} value The value to check. 13587 * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 13588 * @example 13589 * 13590 * _.isArrayLike([1, 2, 3]); 13591 * // => true 13592 * 13593 * _.isArrayLike(document.body.children); 13594 * // => true 13595 * 13596 * _.isArrayLike('abc'); 13597 * // => true 13598 * 13599 * _.isArrayLike(_.noop); 13600 * // => false 13601 */ 13602 function isArrayLike(value) { 13603 return value != null && isLength(value.length) && !isFunction(value); 13604 } 13605 13606 /** 13607 * This method is like `_.isArrayLike` except that it also checks if `value` 13608 * is an object. 13609 * 13610 * @static 13611 * @memberOf _ 13612 * @since 4.0.0 13613 * @category Lang 13614 * @param {*} value The value to check. 13615 * @returns {boolean} Returns `true` if `value` is an array-like object, 13616 * else `false`. 13617 * @example 13618 * 13619 * _.isArrayLikeObject([1, 2, 3]); 13620 * // => true 13621 * 13622 * _.isArrayLikeObject(document.body.children); 13623 * // => true 13624 * 13625 * _.isArrayLikeObject('abc'); 13626 * // => false 13627 * 13628 * _.isArrayLikeObject(_.noop); 13629 * // => false 13630 */ 13631 function isArrayLikeObject(value) { 13632 return isObjectLike(value) && isArrayLike(value); 13633 } 13634 13635 /** 13636 * Checks if `value` is classified as a boolean primitive or object. 13637 * 13638 * @static 13639 * @memberOf _ 13640 * @since 0.1.0 13641 * @category Lang 13642 * @param {*} value The value to check. 13643 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. 13644 * @example 13645 * 13646 * _.isBoolean(false); 13647 * // => true 13648 * 13649 * _.isBoolean(null); 13650 * // => false 13651 */ 13652 function isBoolean(value) { 13653 return value === true || value === false || 13654 (isObjectLike(value) && baseGetTag(value) == boolTag); 13655 } 13656 13657 /** 13658 * Checks if `value` is a buffer. 13659 * 13660 * @static 13661 * @memberOf _ 13662 * @since 4.3.0 13663 * @category Lang 13664 * @param {*} value The value to check. 13665 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. 13666 * @example 13667 * 13668 * _.isBuffer(new Buffer(2)); 13669 * // => true 13670 * 13671 * _.isBuffer(new Uint8Array(2)); 13672 * // => false 13673 */ 13674 var isBuffer = nativeIsBuffer || stubFalse; 13675 13676 /** 13677 * Checks if `value` is classified as a `Date` object. 13678 * 13679 * @static 13680 * @memberOf _ 13681 * @since 0.1.0 13682 * @category Lang 13683 * @param {*} value The value to check. 13684 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 13685 * @example 13686 * 13687 * _.isDate(new Date); 13688 * // => true 13689 * 13690 * _.isDate('Mon April 23 2012'); 13691 * // => false 13692 */ 13693 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; 13694 13695 /** 13696 * Checks if `value` is likely a DOM element. 13697 * 13698 * @static 13699 * @memberOf _ 13700 * @since 0.1.0 13701 * @category Lang 13702 * @param {*} value The value to check. 13703 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. 13704 * @example 13705 * 13706 * _.isElement(document.body); 13707 * // => true 13708 * 13709 * _.isElement('<body>'); 13710 * // => false 13711 */ 13712 function isElement(value) { 13713 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); 13714 } 13715 13716 /** 13717 * Checks if `value` is an empty object, collection, map, or set. 13718 * 13719 * Objects are considered empty if they have no own enumerable string keyed 13720 * properties. 13721 * 13722 * Array-like values such as `arguments` objects, arrays, buffers, strings, or 13723 * jQuery-like collections are considered empty if they have a `length` of `0`. 13724 * Similarly, maps and sets are considered empty if they have a `size` of `0`. 13725 * 13726 * @static 13727 * @memberOf _ 13728 * @since 0.1.0 13729 * @category Lang 13730 * @param {*} value The value to check. 13731 * @returns {boolean} Returns `true` if `value` is empty, else `false`. 13732 * @example 13733 * 13734 * _.isEmpty(null); 13735 * // => true 13736 * 13737 * _.isEmpty(true); 13738 * // => true 13739 * 13740 * _.isEmpty(1); 13741 * // => true 13742 * 13743 * _.isEmpty([1, 2, 3]); 13744 * // => false 13745 * 13746 * _.isEmpty({ 'a': 1 }); 13747 * // => false 13748 */ 13749 function isEmpty(value) { 13750 if (value == null) { 13751 return true; 13752 } 13753 if (isArrayLike(value) && 13754 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || 13755 isBuffer(value) || isTypedArray(value) || isArguments(value))) { 13756 return !value.length; 13757 } 13758 var tag = getTag(value); 13759 if (tag == mapTag || tag == setTag) { 13760 return !value.size; 13761 } 13762 if (isPrototype(value)) { 13763 return !baseKeys(value).length; 13764 } 13765 for (var key in value) { 13766 if (hasOwnProperty.call(value, key)) { 13767 return false; 13768 } 13769 } 13770 return true; 13771 } 13772 13773 /** 13774 * Performs a deep comparison between two values to determine if they are 13775 * equivalent. 13776 * 13777 * **Note:** This method supports comparing arrays, array buffers, booleans, 13778 * date objects, error objects, maps, numbers, `Object` objects, regexes, 13779 * sets, strings, symbols, and typed arrays. `Object` objects are compared 13780 * by their own, not inherited, enumerable properties. Functions and DOM 13781 * nodes are compared by strict equality, i.e. `===`. 13782 * 13783 * @static 13784 * @memberOf _ 13785 * @since 0.1.0 13786 * @category Lang 13787 * @param {*} value The value to compare. 13788 * @param {*} other The other value to compare. 13789 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 13790 * @example 13791 * 13792 * var object = { 'a': 1 }; 13793 * var other = { 'a': 1 }; 13794 * 13795 * _.isEqual(object, other); 13796 * // => true 13797 * 13798 * object === other; 13799 * // => false 13800 */ 13801 function isEqual(value, other) { 13802 return baseIsEqual(value, other); 13803 } 13804 13805 /** 13806 * This method is like `_.isEqual` except that it accepts `customizer` which 13807 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 13808 * are handled by the method instead. The `customizer` is invoked with up to 13809 * six arguments: (objValue, othValue [, index|key, object, other, stack]). 13810 * 13811 * @static 13812 * @memberOf _ 13813 * @since 4.0.0 13814 * @category Lang 13815 * @param {*} value The value to compare. 13816 * @param {*} other The other value to compare. 13817 * @param {Function} [customizer] The function to customize comparisons. 13818 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 13819 * @example 13820 * 13821 * function isGreeting(value) { 13822 * return /^h(?:i|ello)$/.test(value); 13823 * } 13824 * 13825 * function customizer(objValue, othValue) { 13826 * if (isGreeting(objValue) && isGreeting(othValue)) { 13827 * return true; 13828 * } 13829 * } 13830 * 13831 * var array = ['hello', 'goodbye']; 13832 * var other = ['hi', 'goodbye']; 13833 * 13834 * _.isEqualWith(array, other, customizer); 13835 * // => true 13836 */ 13837 function isEqualWith(value, other, customizer) { 13838 customizer = typeof customizer == 'function' ? customizer : undefined; 13839 var result = customizer ? customizer(value, other) : undefined; 13840 return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; 13841 } 13842 13843 /** 13844 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, 13845 * `SyntaxError`, `TypeError`, or `URIError` object. 13846 * 13847 * @static 13848 * @memberOf _ 13849 * @since 3.0.0 13850 * @category Lang 13851 * @param {*} value The value to check. 13852 * @returns {boolean} Returns `true` if `value` is an error object, else `false`. 13853 * @example 13854 * 13855 * _.isError(new Error); 13856 * // => true 13857 * 13858 * _.isError(Error); 13859 * // => false 13860 */ 13861 function isError(value) { 13862 if (!isObjectLike(value)) { 13863 return false; 13864 } 13865 var tag = baseGetTag(value); 13866 return tag == errorTag || tag == domExcTag || 13867 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); 13868 } 13869 13870 /** 13871 * Checks if `value` is a finite primitive number. 13872 * 13873 * **Note:** This method is based on 13874 * [`Number.isFinite`](https://mdn.io/Number/isFinite). 13875 * 13876 * @static 13877 * @memberOf _ 13878 * @since 0.1.0 13879 * @category Lang 13880 * @param {*} value The value to check. 13881 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. 13882 * @example 13883 * 13884 * _.isFinite(3); 13885 * // => true 13886 * 13887 * _.isFinite(Number.MIN_VALUE); 13888 * // => true 13889 * 13890 * _.isFinite(Infinity); 13891 * // => false 13892 * 13893 * _.isFinite('3'); 13894 * // => false 13895 */ 13896 function isFinite(value) { 13897 return typeof value == 'number' && nativeIsFinite(value); 13898 } 13899 13900 /** 13901 * Checks if `value` is classified as a `Function` object. 13902 * 13903 * @static 13904 * @memberOf _ 13905 * @since 0.1.0 13906 * @category Lang 13907 * @param {*} value The value to check. 13908 * @returns {boolean} Returns `true` if `value` is a function, else `false`. 13909 * @example 13910 * 13911 * _.isFunction(_); 13912 * // => true 13913 * 13914 * _.isFunction(/abc/); 13915 * // => false 13916 */ 13917 function isFunction(value) { 13918 if (!isObject(value)) { 13919 return false; 13920 } 13921 // The use of `Object#toString` avoids issues with the `typeof` operator 13922 // in Safari 9 which returns 'object' for typed arrays and other constructors. 13923 var tag = baseGetTag(value); 13924 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; 13925 } 13926 13927 /** 13928 * Checks if `value` is an integer. 13929 * 13930 * **Note:** This method is based on 13931 * [`Number.isInteger`](https://mdn.io/Number/isInteger). 13932 * 13933 * @static 13934 * @memberOf _ 13935 * @since 4.0.0 13936 * @category Lang 13937 * @param {*} value The value to check. 13938 * @returns {boolean} Returns `true` if `value` is an integer, else `false`. 13939 * @example 13940 * 13941 * _.isInteger(3); 13942 * // => true 13943 * 13944 * _.isInteger(Number.MIN_VALUE); 13945 * // => false 13946 * 13947 * _.isInteger(Infinity); 13948 * // => false 13949 * 13950 * _.isInteger('3'); 13951 * // => false 13952 */ 13953 function isInteger(value) { 13954 return typeof value == 'number' && value == toInteger(value); 13955 } 13956 13957 /** 13958 * Checks if `value` is a valid array-like length. 13959 * 13960 * **Note:** This method is loosely based on 13961 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 13962 * 13963 * @static 13964 * @memberOf _ 13965 * @since 4.0.0 13966 * @category Lang 13967 * @param {*} value The value to check. 13968 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 13969 * @example 13970 * 13971 * _.isLength(3); 13972 * // => true 13973 * 13974 * _.isLength(Number.MIN_VALUE); 13975 * // => false 13976 * 13977 * _.isLength(Infinity); 13978 * // => false 13979 * 13980 * _.isLength('3'); 13981 * // => false 13982 */ 13983 function isLength(value) { 13984 return typeof value == 'number' && 13985 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 13986 } 13987 13988 /** 13989 * Checks if `value` is the 13990 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 13991 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 13992 * 13993 * @static 13994 * @memberOf _ 13995 * @since 0.1.0 13996 * @category Lang 13997 * @param {*} value The value to check. 13998 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 13999 * @example 14000 * 14001 * _.isObject({}); 14002 * // => true 14003 * 14004 * _.isObject([1, 2, 3]); 14005 * // => true 14006 * 14007 * _.isObject(_.noop); 14008 * // => true 14009 * 14010 * _.isObject(null); 14011 * // => false 14012 */ 14013 function isObject(value) { 14014 var type = typeof value; 14015 return value != null && (type == 'object' || type == 'function'); 14016 } 14017 14018 /** 14019 * Checks if `value` is object-like. A value is object-like if it's not `null` 14020 * and has a `typeof` result of "object". 14021 * 14022 * @static 14023 * @memberOf _ 14024 * @since 4.0.0 14025 * @category Lang 14026 * @param {*} value The value to check. 14027 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 14028 * @example 14029 * 14030 * _.isObjectLike({}); 14031 * // => true 14032 * 14033 * _.isObjectLike([1, 2, 3]); 14034 * // => true 14035 * 14036 * _.isObjectLike(_.noop); 14037 * // => false 14038 * 14039 * _.isObjectLike(null); 14040 * // => false 14041 */ 14042 function isObjectLike(value) { 14043 return value != null && typeof value == 'object'; 14044 } 14045 14046 /** 14047 * Checks if `value` is classified as a `Map` object. 14048 * 14049 * @static 14050 * @memberOf _ 14051 * @since 4.3.0 14052 * @category Lang 14053 * @param {*} value The value to check. 14054 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 14055 * @example 14056 * 14057 * _.isMap(new Map); 14058 * // => true 14059 * 14060 * _.isMap(new WeakMap); 14061 * // => false 14062 */ 14063 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; 14064 14065 /** 14066 * Performs a partial deep comparison between `object` and `source` to 14067 * determine if `object` contains equivalent property values. 14068 * 14069 * **Note:** This method is equivalent to `_.matches` when `source` is 14070 * partially applied. 14071 * 14072 * Partial comparisons will match empty array and empty object `source` 14073 * values against any array or object value, respectively. See `_.isEqual` 14074 * for a list of supported value comparisons. 14075 * 14076 * @static 14077 * @memberOf _ 14078 * @since 3.0.0 14079 * @category Lang 14080 * @param {Object} object The object to inspect. 14081 * @param {Object} source The object of property values to match. 14082 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 14083 * @example 14084 * 14085 * var object = { 'a': 1, 'b': 2 }; 14086 * 14087 * _.isMatch(object, { 'b': 2 }); 14088 * // => true 14089 * 14090 * _.isMatch(object, { 'b': 1 }); 14091 * // => false 14092 */ 14093 function isMatch(object, source) { 14094 return object === source || baseIsMatch(object, source, getMatchData(source)); 14095 } 14096 14097 /** 14098 * This method is like `_.isMatch` except that it accepts `customizer` which 14099 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 14100 * are handled by the method instead. The `customizer` is invoked with five 14101 * arguments: (objValue, srcValue, index|key, object, source). 14102 * 14103 * @static 14104 * @memberOf _ 14105 * @since 4.0.0 14106 * @category Lang 14107 * @param {Object} object The object to inspect. 14108 * @param {Object} source The object of property values to match. 14109 * @param {Function} [customizer] The function to customize comparisons. 14110 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 14111 * @example 14112 * 14113 * function isGreeting(value) { 14114 * return /^h(?:i|ello)$/.test(value); 14115 * } 14116 * 14117 * function customizer(objValue, srcValue) { 14118 * if (isGreeting(objValue) && isGreeting(srcValue)) { 14119 * return true; 14120 * } 14121 * } 14122 * 14123 * var object = { 'greeting': 'hello' }; 14124 * var source = { 'greeting': 'hi' }; 14125 * 14126 * _.isMatchWith(object, source, customizer); 14127 * // => true 14128 */ 14129 function isMatchWith(object, source, customizer) { 14130 customizer = typeof customizer == 'function' ? customizer : undefined; 14131 return baseIsMatch(object, source, getMatchData(source), customizer); 14132 } 14133 14134 /** 14135 * Checks if `value` is `NaN`. 14136 * 14137 * **Note:** This method is based on 14138 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as 14139 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for 14140 * `undefined` and other non-number values. 14141 * 14142 * @static 14143 * @memberOf _ 14144 * @since 0.1.0 14145 * @category Lang 14146 * @param {*} value The value to check. 14147 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 14148 * @example 14149 * 14150 * _.isNaN(NaN); 14151 * // => true 14152 * 14153 * _.isNaN(new Number(NaN)); 14154 * // => true 14155 * 14156 * isNaN(undefined); 14157 * // => true 14158 * 14159 * _.isNaN(undefined); 14160 * // => false 14161 */ 14162 function isNaN(value) { 14163 // An `NaN` primitive is the only value that is not equal to itself. 14164 // Perform the `toStringTag` check first to avoid errors with some 14165 // ActiveX objects in IE. 14166 return isNumber(value) && value != +value; 14167 } 14168 14169 /** 14170 * Checks if `value` is a pristine native function. 14171 * 14172 * **Note:** This method can't reliably detect native functions in the presence 14173 * of the core-js package because core-js circumvents this kind of detection. 14174 * Despite multiple requests, the core-js maintainer has made it clear: any 14175 * attempt to fix the detection will be obstructed. As a result, we're left 14176 * with little choice but to throw an error. Unfortunately, this also affects 14177 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), 14178 * which rely on core-js. 14179 * 14180 * @static 14181 * @memberOf _ 14182 * @since 3.0.0 14183 * @category Lang 14184 * @param {*} value The value to check. 14185 * @returns {boolean} Returns `true` if `value` is a native function, 14186 * else `false`. 14187 * @example 14188 * 14189 * _.isNative(Array.prototype.push); 14190 * // => true 14191 * 14192 * _.isNative(_); 14193 * // => false 14194 */ 14195 function isNative(value) { 14196 if (isMaskable(value)) { 14197 throw new Error(CORE_ERROR_TEXT); 14198 } 14199 return baseIsNative(value); 14200 } 14201 14202 /** 14203 * Checks if `value` is `null`. 14204 * 14205 * @static 14206 * @memberOf _ 14207 * @since 0.1.0 14208 * @category Lang 14209 * @param {*} value The value to check. 14210 * @returns {boolean} Returns `true` if `value` is `null`, else `false`. 14211 * @example 14212 * 14213 * _.isNull(null); 14214 * // => true 14215 * 14216 * _.isNull(void 0); 14217 * // => false 14218 */ 14219 function isNull(value) { 14220 return value === null; 14221 } 14222 14223 /** 14224 * Checks if `value` is `null` or `undefined`. 14225 * 14226 * @static 14227 * @memberOf _ 14228 * @since 4.0.0 14229 * @category Lang 14230 * @param {*} value The value to check. 14231 * @returns {boolean} Returns `true` if `value` is nullish, else `false`. 14232 * @example 14233 * 14234 * _.isNil(null); 14235 * // => true 14236 * 14237 * _.isNil(void 0); 14238 * // => true 14239 * 14240 * _.isNil(NaN); 14241 * // => false 14242 */ 14243 function isNil(value) { 14244 return value == null; 14245 } 14246 14247 /** 14248 * Checks if `value` is classified as a `Number` primitive or object. 14249 * 14250 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are 14251 * classified as numbers, use the `_.isFinite` method. 14252 * 14253 * @static 14254 * @memberOf _ 14255 * @since 0.1.0 14256 * @category Lang 14257 * @param {*} value The value to check. 14258 * @returns {boolean} Returns `true` if `value` is a number, else `false`. 14259 * @example 14260 * 14261 * _.isNumber(3); 14262 * // => true 14263 * 14264 * _.isNumber(Number.MIN_VALUE); 14265 * // => true 14266 * 14267 * _.isNumber(Infinity); 14268 * // => true 14269 * 14270 * _.isNumber('3'); 14271 * // => false 14272 */ 14273 function isNumber(value) { 14274 return typeof value == 'number' || 14275 (isObjectLike(value) && baseGetTag(value) == numberTag); 14276 } 14277 14278 /** 14279 * Checks if `value` is a plain object, that is, an object created by the 14280 * `Object` constructor or one with a `[[Prototype]]` of `null`. 14281 * 14282 * @static 14283 * @memberOf _ 14284 * @since 0.8.0 14285 * @category Lang 14286 * @param {*} value The value to check. 14287 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 14288 * @example 14289 * 14290 * function Foo() { 14291 * this.a = 1; 14292 * } 14293 * 14294 * _.isPlainObject(new Foo); 14295 * // => false 14296 * 14297 * _.isPlainObject([1, 2, 3]); 14298 * // => false 14299 * 14300 * _.isPlainObject({ 'x': 0, 'y': 0 }); 14301 * // => true 14302 * 14303 * _.isPlainObject(Object.create(null)); 14304 * // => true 14305 */ 14306 function isPlainObject(value) { 14307 if (!isObjectLike(value) || baseGetTag(value) != objectTag) { 14308 return false; 14309 } 14310 var proto = getPrototype(value); 14311 if (proto === null) { 14312 return true; 14313 } 14314 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 14315 return typeof Ctor == 'function' && Ctor instanceof Ctor && 14316 funcToString.call(Ctor) == objectCtorString; 14317 } 14318 14319 /** 14320 * Checks if `value` is classified as a `RegExp` object. 14321 * 14322 * @static 14323 * @memberOf _ 14324 * @since 0.1.0 14325 * @category Lang 14326 * @param {*} value The value to check. 14327 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 14328 * @example 14329 * 14330 * _.isRegExp(/abc/); 14331 * // => true 14332 * 14333 * _.isRegExp('/abc/'); 14334 * // => false 14335 */ 14336 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; 14337 14338 /** 14339 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 14340 * double precision number which isn't the result of a rounded unsafe integer. 14341 * 14342 * **Note:** This method is based on 14343 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). 14344 * 14345 * @static 14346 * @memberOf _ 14347 * @since 4.0.0 14348 * @category Lang 14349 * @param {*} value The value to check. 14350 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. 14351 * @example 14352 * 14353 * _.isSafeInteger(3); 14354 * // => true 14355 * 14356 * _.isSafeInteger(Number.MIN_VALUE); 14357 * // => false 14358 * 14359 * _.isSafeInteger(Infinity); 14360 * // => false 14361 * 14362 * _.isSafeInteger('3'); 14363 * // => false 14364 */ 14365 function isSafeInteger(value) { 14366 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; 14367 } 14368 14369 /** 14370 * Checks if `value` is classified as a `Set` object. 14371 * 14372 * @static 14373 * @memberOf _ 14374 * @since 4.3.0 14375 * @category Lang 14376 * @param {*} value The value to check. 14377 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 14378 * @example 14379 * 14380 * _.isSet(new Set); 14381 * // => true 14382 * 14383 * _.isSet(new WeakSet); 14384 * // => false 14385 */ 14386 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; 14387 14388 /** 14389 * Checks if `value` is classified as a `String` primitive or object. 14390 * 14391 * @static 14392 * @since 0.1.0 14393 * @memberOf _ 14394 * @category Lang 14395 * @param {*} value The value to check. 14396 * @returns {boolean} Returns `true` if `value` is a string, else `false`. 14397 * @example 14398 * 14399 * _.isString('abc'); 14400 * // => true 14401 * 14402 * _.isString(1); 14403 * // => false 14404 */ 14405 function isString(value) { 14406 return typeof value == 'string' || 14407 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); 14408 } 14409 14410 /** 14411 * Checks if `value` is classified as a `Symbol` primitive or object. 14412 * 14413 * @static 14414 * @memberOf _ 14415 * @since 4.0.0 14416 * @category Lang 14417 * @param {*} value The value to check. 14418 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 14419 * @example 14420 * 14421 * _.isSymbol(Symbol.iterator); 14422 * // => true 14423 * 14424 * _.isSymbol('abc'); 14425 * // => false 14426 */ 14427 function isSymbol(value) { 14428 return typeof value == 'symbol' || 14429 (isObjectLike(value) && baseGetTag(value) == symbolTag); 14430 } 14431 14432 /** 14433 * Checks if `value` is classified as a typed array. 14434 * 14435 * @static 14436 * @memberOf _ 14437 * @since 3.0.0 14438 * @category Lang 14439 * @param {*} value The value to check. 14440 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 14441 * @example 14442 * 14443 * _.isTypedArray(new Uint8Array); 14444 * // => true 14445 * 14446 * _.isTypedArray([]); 14447 * // => false 14448 */ 14449 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; 14450 14451 /** 14452 * Checks if `value` is `undefined`. 14453 * 14454 * @static 14455 * @since 0.1.0 14456 * @memberOf _ 14457 * @category Lang 14458 * @param {*} value The value to check. 14459 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. 14460 * @example 14461 * 14462 * _.isUndefined(void 0); 14463 * // => true 14464 * 14465 * _.isUndefined(null); 14466 * // => false 14467 */ 14468 function isUndefined(value) { 14469 return value === undefined; 14470 } 14471 14472 /** 14473 * Checks if `value` is classified as a `WeakMap` object. 14474 * 14475 * @static 14476 * @memberOf _ 14477 * @since 4.3.0 14478 * @category Lang 14479 * @param {*} value The value to check. 14480 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. 14481 * @example 14482 * 14483 * _.isWeakMap(new WeakMap); 14484 * // => true 14485 * 14486 * _.isWeakMap(new Map); 14487 * // => false 14488 */ 14489 function isWeakMap(value) { 14490 return isObjectLike(value) && getTag(value) == weakMapTag; 14491 } 14492 14493 /** 14494 * Checks if `value` is classified as a `WeakSet` object. 14495 * 14496 * @static 14497 * @memberOf _ 14498 * @since 4.3.0 14499 * @category Lang 14500 * @param {*} value The value to check. 14501 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. 14502 * @example 14503 * 14504 * _.isWeakSet(new WeakSet); 14505 * // => true 14506 * 14507 * _.isWeakSet(new Set); 14508 * // => false 14509 */ 14510 function isWeakSet(value) { 14511 return isObjectLike(value) && baseGetTag(value) == weakSetTag; 14512 } 14513 14514 /** 14515 * Checks if `value` is less than `other`. 14516 * 14517 * @static 14518 * @memberOf _ 14519 * @since 3.9.0 14520 * @category Lang 14521 * @param {*} value The value to compare. 14522 * @param {*} other The other value to compare. 14523 * @returns {boolean} Returns `true` if `value` is less than `other`, 14524 * else `false`. 14525 * @see _.gt 14526 * @example 14527 * 14528 * _.lt(1, 3); 14529 * // => true 14530 * 14531 * _.lt(3, 3); 14532 * // => false 14533 * 14534 * _.lt(3, 1); 14535 * // => false 14536 */ 14537 var lt = createRelationalOperation(baseLt); 14538 14539 /** 14540 * Checks if `value` is less than or equal to `other`. 14541 * 14542 * @static 14543 * @memberOf _ 14544 * @since 3.9.0 14545 * @category Lang 14546 * @param {*} value The value to compare. 14547 * @param {*} other The other value to compare. 14548 * @returns {boolean} Returns `true` if `value` is less than or equal to 14549 * `other`, else `false`. 14550 * @see _.gte 14551 * @example 14552 * 14553 * _.lte(1, 3); 14554 * // => true 14555 * 14556 * _.lte(3, 3); 14557 * // => true 14558 * 14559 * _.lte(3, 1); 14560 * // => false 14561 */ 14562 var lte = createRelationalOperation(function(value, other) { 14563 return value <= other; 14564 }); 14565 14566 /** 14567 * Converts `value` to an array. 14568 * 14569 * @static 14570 * @since 0.1.0 14571 * @memberOf _ 14572 * @category Lang 14573 * @param {*} value The value to convert. 14574 * @returns {Array} Returns the converted array. 14575 * @example 14576 * 14577 * _.toArray({ 'a': 1, 'b': 2 }); 14578 * // => [1, 2] 14579 * 14580 * _.toArray('abc'); 14581 * // => ['a', 'b', 'c'] 14582 * 14583 * _.toArray(1); 14584 * // => [] 14585 * 14586 * _.toArray(null); 14587 * // => [] 14588 */ 14589 function toArray(value) { 14590 if (!value) { 14591 return []; 14592 } 14593 if (isArrayLike(value)) { 14594 return isString(value) ? stringToArray(value) : copyArray(value); 14595 } 14596 if (symIterator && value[symIterator]) { 14597 return iteratorToArray(value[symIterator]()); 14598 } 14599 var tag = getTag(value), 14600 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); 14601 14602 return func(value); 14603 } 14604 14605 /** 14606 * Converts `value` to a finite number. 14607 * 14608 * @static 14609 * @memberOf _ 14610 * @since 4.12.0 14611 * @category Lang 14612 * @param {*} value The value to convert. 14613 * @returns {number} Returns the converted number. 14614 * @example 14615 * 14616 * _.toFinite(3.2); 14617 * // => 3.2 14618 * 14619 * _.toFinite(Number.MIN_VALUE); 14620 * // => 5e-324 14621 * 14622 * _.toFinite(Infinity); 14623 * // => 1.7976931348623157e+308 14624 * 14625 * _.toFinite('3.2'); 14626 * // => 3.2 14627 */ 14628 function toFinite(value) { 14629 if (!value) { 14630 return value === 0 ? value : 0; 14631 } 14632 value = toNumber(value); 14633 if (value === INFINITY || value === -INFINITY) { 14634 var sign = (value < 0 ? -1 : 1); 14635 return sign * MAX_INTEGER; 14636 } 14637 return value === value ? value : 0; 14638 } 14639 14640 /** 14641 * Converts `value` to an integer. 14642 * 14643 * **Note:** This method is loosely based on 14644 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). 14645 * 14646 * @static 14647 * @memberOf _ 14648 * @since 4.0.0 14649 * @category Lang 14650 * @param {*} value The value to convert. 14651 * @returns {number} Returns the converted integer. 14652 * @example 14653 * 14654 * _.toInteger(3.2); 14655 * // => 3 14656 * 14657 * _.toInteger(Number.MIN_VALUE); 14658 * // => 0 14659 * 14660 * _.toInteger(Infinity); 14661 * // => 1.7976931348623157e+308 14662 * 14663 * _.toInteger('3.2'); 14664 * // => 3 14665 */ 14666 function toInteger(value) { 14667 var result = toFinite(value), 14668 remainder = result % 1; 14669 14670 return result === result ? (remainder ? result - remainder : result) : 0; 14671 } 14672 14673 /** 14674 * Converts `value` to an integer suitable for use as the length of an 14675 * array-like object. 14676 * 14677 * **Note:** This method is based on 14678 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 14679 * 14680 * @static 14681 * @memberOf _ 14682 * @since 4.0.0 14683 * @category Lang 14684 * @param {*} value The value to convert. 14685 * @returns {number} Returns the converted integer. 14686 * @example 14687 * 14688 * _.toLength(3.2); 14689 * // => 3 14690 * 14691 * _.toLength(Number.MIN_VALUE); 14692 * // => 0 14693 * 14694 * _.toLength(Infinity); 14695 * // => 4294967295 14696 * 14697 * _.toLength('3.2'); 14698 * // => 3 14699 */ 14700 function toLength(value) { 14701 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; 14702 } 14703 14704 /** 14705 * Converts `value` to a number. 14706 * 14707 * @static 14708 * @memberOf _ 14709 * @since 4.0.0 14710 * @category Lang 14711 * @param {*} value The value to process. 14712 * @returns {number} Returns the number. 14713 * @example 14714 * 14715 * _.toNumber(3.2); 14716 * // => 3.2 14717 * 14718 * _.toNumber(Number.MIN_VALUE); 14719 * // => 5e-324 14720 * 14721 * _.toNumber(Infinity); 14722 * // => Infinity 14723 * 14724 * _.toNumber('3.2'); 14725 * // => 3.2 14726 */ 14727 function toNumber(value) { 14728 if (typeof value == 'number') { 14729 return value; 14730 } 14731 if (isSymbol(value)) { 14732 return NAN; 14733 } 14734 if (isObject(value)) { 14735 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 14736 value = isObject(other) ? (other + '') : other; 14737 } 14738 if (typeof value != 'string') { 14739 return value === 0 ? value : +value; 14740 } 14741 value = baseTrim(value); 14742 var isBinary = reIsBinary.test(value); 14743 return (isBinary || reIsOctal.test(value)) 14744 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 14745 : (reIsBadHex.test(value) ? NAN : +value); 14746 } 14747 14748 /** 14749 * Converts `value` to a plain object flattening inherited enumerable string 14750 * keyed properties of `value` to own properties of the plain object. 14751 * 14752 * @static 14753 * @memberOf _ 14754 * @since 3.0.0 14755 * @category Lang 14756 * @param {*} value The value to convert. 14757 * @returns {Object} Returns the converted plain object. 14758 * @example 14759 * 14760 * function Foo() { 14761 * this.b = 2; 14762 * } 14763 * 14764 * Foo.prototype.c = 3; 14765 * 14766 * _.assign({ 'a': 1 }, new Foo); 14767 * // => { 'a': 1, 'b': 2 } 14768 * 14769 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); 14770 * // => { 'a': 1, 'b': 2, 'c': 3 } 14771 */ 14772 function toPlainObject(value) { 14773 return copyObject(value, keysIn(value)); 14774 } 14775 14776 /** 14777 * Converts `value` to a safe integer. A safe integer can be compared and 14778 * represented correctly. 14779 * 14780 * @static 14781 * @memberOf _ 14782 * @since 4.0.0 14783 * @category Lang 14784 * @param {*} value The value to convert. 14785 * @returns {number} Returns the converted integer. 14786 * @example 14787 * 14788 * _.toSafeInteger(3.2); 14789 * // => 3 14790 * 14791 * _.toSafeInteger(Number.MIN_VALUE); 14792 * // => 0 14793 * 14794 * _.toSafeInteger(Infinity); 14795 * // => 9007199254740991 14796 * 14797 * _.toSafeInteger('3.2'); 14798 * // => 3 14799 */ 14800 function toSafeInteger(value) { 14801 return value 14802 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) 14803 : (value === 0 ? value : 0); 14804 } 14805 14806 /** 14807 * Converts `value` to a string. An empty string is returned for `null` 14808 * and `undefined` values. The sign of `-0` is preserved. 14809 * 14810 * @static 14811 * @memberOf _ 14812 * @since 4.0.0 14813 * @category Lang 14814 * @param {*} value The value to convert. 14815 * @returns {string} Returns the converted string. 14816 * @example 14817 * 14818 * _.toString(null); 14819 * // => '' 14820 * 14821 * _.toString(-0); 14822 * // => '-0' 14823 * 14824 * _.toString([1, 2, 3]); 14825 * // => '1,2,3' 14826 */ 14827 function toString(value) { 14828 return value == null ? '' : baseToString(value); 14829 } 14830 14831 /*------------------------------------------------------------------------*/ 14832 14833 /** 14834 * Assigns own enumerable string keyed properties of source objects to the 14835 * destination object. Source objects are applied from left to right. 14836 * Subsequent sources overwrite property assignments of previous sources. 14837 * 14838 * **Note:** This method mutates `object` and is loosely based on 14839 * [`Object.assign`](https://mdn.io/Object/assign). 14840 * 14841 * @static 14842 * @memberOf _ 14843 * @since 0.10.0 14844 * @category Object 14845 * @param {Object} object The destination object. 14846 * @param {...Object} [sources] The source objects. 14847 * @returns {Object} Returns `object`. 14848 * @see _.assignIn 14849 * @example 14850 * 14851 * function Foo() { 14852 * this.a = 1; 14853 * } 14854 * 14855 * function Bar() { 14856 * this.c = 3; 14857 * } 14858 * 14859 * Foo.prototype.b = 2; 14860 * Bar.prototype.d = 4; 14861 * 14862 * _.assign({ 'a': 0 }, new Foo, new Bar); 14863 * // => { 'a': 1, 'c': 3 } 14864 */ 14865 var assign = createAssigner(function(object, source) { 14866 if (isPrototype(source) || isArrayLike(source)) { 14867 copyObject(source, keys(source), object); 14868 return; 14869 } 14870 for (var key in source) { 14871 if (hasOwnProperty.call(source, key)) { 14872 assignValue(object, key, source[key]); 14873 } 14874 } 14875 }); 14876 14877 /** 14878 * This method is like `_.assign` except that it iterates over own and 14879 * inherited source properties. 14880 * 14881 * **Note:** This method mutates `object`. 14882 * 14883 * @static 14884 * @memberOf _ 14885 * @since 4.0.0 14886 * @alias extend 14887 * @category Object 14888 * @param {Object} object The destination object. 14889 * @param {...Object} [sources] The source objects. 14890 * @returns {Object} Returns `object`. 14891 * @see _.assign 14892 * @example 14893 * 14894 * function Foo() { 14895 * this.a = 1; 14896 * } 14897 * 14898 * function Bar() { 14899 * this.c = 3; 14900 * } 14901 * 14902 * Foo.prototype.b = 2; 14903 * Bar.prototype.d = 4; 14904 * 14905 * _.assignIn({ 'a': 0 }, new Foo, new Bar); 14906 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } 14907 */ 14908 var assignIn = createAssigner(function(object, source) { 14909 copyObject(source, keysIn(source), object); 14910 }); 14911 14912 /** 14913 * This method is like `_.assignIn` except that it accepts `customizer` 14914 * which is invoked to produce the assigned values. If `customizer` returns 14915 * `undefined`, assignment is handled by the method instead. The `customizer` 14916 * is invoked with five arguments: (objValue, srcValue, key, object, source). 14917 * 14918 * **Note:** This method mutates `object`. 14919 * 14920 * @static 14921 * @memberOf _ 14922 * @since 4.0.0 14923 * @alias extendWith 14924 * @category Object 14925 * @param {Object} object The destination object. 14926 * @param {...Object} sources The source objects. 14927 * @param {Function} [customizer] The function to customize assigned values. 14928 * @returns {Object} Returns `object`. 14929 * @see _.assignWith 14930 * @example 14931 * 14932 * function customizer(objValue, srcValue) { 14933 * return _.isUndefined(objValue) ? srcValue : objValue; 14934 * } 14935 * 14936 * var defaults = _.partialRight(_.assignInWith, customizer); 14937 * 14938 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 14939 * // => { 'a': 1, 'b': 2 } 14940 */ 14941 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { 14942 copyObject(source, keysIn(source), object, customizer); 14943 }); 14944 14945 /** 14946 * This method is like `_.assign` except that it accepts `customizer` 14947 * which is invoked to produce the assigned values. If `customizer` returns 14948 * `undefined`, assignment is handled by the method instead. The `customizer` 14949 * is invoked with five arguments: (objValue, srcValue, key, object, source). 14950 * 14951 * **Note:** This method mutates `object`. 14952 * 14953 * @static 14954 * @memberOf _ 14955 * @since 4.0.0 14956 * @category Object 14957 * @param {Object} object The destination object. 14958 * @param {...Object} sources The source objects. 14959 * @param {Function} [customizer] The function to customize assigned values. 14960 * @returns {Object} Returns `object`. 14961 * @see _.assignInWith 14962 * @example 14963 * 14964 * function customizer(objValue, srcValue) { 14965 * return _.isUndefined(objValue) ? srcValue : objValue; 14966 * } 14967 * 14968 * var defaults = _.partialRight(_.assignWith, customizer); 14969 * 14970 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 14971 * // => { 'a': 1, 'b': 2 } 14972 */ 14973 var assignWith = createAssigner(function(object, source, srcIndex, customizer) { 14974 copyObject(source, keys(source), object, customizer); 14975 }); 14976 14977 /** 14978 * Creates an array of values corresponding to `paths` of `object`. 14979 * 14980 * @static 14981 * @memberOf _ 14982 * @since 1.0.0 14983 * @category Object 14984 * @param {Object} object The object to iterate over. 14985 * @param {...(string|string[])} [paths] The property paths to pick. 14986 * @returns {Array} Returns the picked values. 14987 * @example 14988 * 14989 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 14990 * 14991 * _.at(object, ['a[0].b.c', 'a[1]']); 14992 * // => [3, 4] 14993 */ 14994 var at = flatRest(baseAt); 14995 14996 /** 14997 * Creates an object that inherits from the `prototype` object. If a 14998 * `properties` object is given, its own enumerable string keyed properties 14999 * are assigned to the created object. 15000 * 15001 * @static 15002 * @memberOf _ 15003 * @since 2.3.0 15004 * @category Object 15005 * @param {Object} prototype The object to inherit from. 15006 * @param {Object} [properties] The properties to assign to the object. 15007 * @returns {Object} Returns the new object. 15008 * @example 15009 * 15010 * function Shape() { 15011 * this.x = 0; 15012 * this.y = 0; 15013 * } 15014 * 15015 * function Circle() { 15016 * Shape.call(this); 15017 * } 15018 * 15019 * Circle.prototype = _.create(Shape.prototype, { 15020 * 'constructor': Circle 15021 * }); 15022 * 15023 * var circle = new Circle; 15024 * circle instanceof Circle; 15025 * // => true 15026 * 15027 * circle instanceof Shape; 15028 * // => true 15029 */ 15030 function create(prototype, properties) { 15031 var result = baseCreate(prototype); 15032 return properties == null ? result : baseAssign(result, properties); 15033 } 15034 15035 /** 15036 * Assigns own and inherited enumerable string keyed properties of source 15037 * objects to the destination object for all destination properties that 15038 * resolve to `undefined`. Source objects are applied from left to right. 15039 * Once a property is set, additional values of the same property are ignored. 15040 * 15041 * **Note:** This method mutates `object`. 15042 * 15043 * @static 15044 * @since 0.1.0 15045 * @memberOf _ 15046 * @category Object 15047 * @param {Object} object The destination object. 15048 * @param {...Object} [sources] The source objects. 15049 * @returns {Object} Returns `object`. 15050 * @see _.defaultsDeep 15051 * @example 15052 * 15053 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 15054 * // => { 'a': 1, 'b': 2 } 15055 */ 15056 var defaults = baseRest(function(object, sources) { 15057 object = Object(object); 15058 15059 var index = -1; 15060 var length = sources.length; 15061 var guard = length > 2 ? sources[2] : undefined; 15062 15063 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 15064 length = 1; 15065 } 15066 15067 while (++index < length) { 15068 var source = sources[index]; 15069 var props = keysIn(source); 15070 var propsIndex = -1; 15071 var propsLength = props.length; 15072 15073 while (++propsIndex < propsLength) { 15074 var key = props[propsIndex]; 15075 var value = object[key]; 15076 15077 if (value === undefined || 15078 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { 15079 object[key] = source[key]; 15080 } 15081 } 15082 } 15083 15084 return object; 15085 }); 15086 15087 /** 15088 * This method is like `_.defaults` except that it recursively assigns 15089 * default properties. 15090 * 15091 * **Note:** This method mutates `object`. 15092 * 15093 * @static 15094 * @memberOf _ 15095 * @since 3.10.0 15096 * @category Object 15097 * @param {Object} object The destination object. 15098 * @param {...Object} [sources] The source objects. 15099 * @returns {Object} Returns `object`. 15100 * @see _.defaults 15101 * @example 15102 * 15103 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); 15104 * // => { 'a': { 'b': 2, 'c': 3 } } 15105 */ 15106 var defaultsDeep = baseRest(function(args) { 15107 args.push(undefined, customDefaultsMerge); 15108 return apply(mergeWith, undefined, args); 15109 }); 15110 15111 /** 15112 * This method is like `_.find` except that it returns the key of the first 15113 * element `predicate` returns truthy for instead of the element itself. 15114 * 15115 * @static 15116 * @memberOf _ 15117 * @since 1.1.0 15118 * @category Object 15119 * @param {Object} object The object to inspect. 15120 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15121 * @returns {string|undefined} Returns the key of the matched element, 15122 * else `undefined`. 15123 * @example 15124 * 15125 * var users = { 15126 * 'barney': { 'age': 36, 'active': true }, 15127 * 'fred': { 'age': 40, 'active': false }, 15128 * 'pebbles': { 'age': 1, 'active': true } 15129 * }; 15130 * 15131 * _.findKey(users, function(o) { return o.age < 40; }); 15132 * // => 'barney' (iteration order is not guaranteed) 15133 * 15134 * // The `_.matches` iteratee shorthand. 15135 * _.findKey(users, { 'age': 1, 'active': true }); 15136 * // => 'pebbles' 15137 * 15138 * // The `_.matchesProperty` iteratee shorthand. 15139 * _.findKey(users, ['active', false]); 15140 * // => 'fred' 15141 * 15142 * // The `_.property` iteratee shorthand. 15143 * _.findKey(users, 'active'); 15144 * // => 'barney' 15145 */ 15146 function findKey(object, predicate) { 15147 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); 15148 } 15149 15150 /** 15151 * This method is like `_.findKey` except that it iterates over elements of 15152 * a collection in the opposite order. 15153 * 15154 * @static 15155 * @memberOf _ 15156 * @since 2.0.0 15157 * @category Object 15158 * @param {Object} object The object to inspect. 15159 * @param {Function} [predicate=_.identity] The function invoked per iteration. 15160 * @returns {string|undefined} Returns the key of the matched element, 15161 * else `undefined`. 15162 * @example 15163 * 15164 * var users = { 15165 * 'barney': { 'age': 36, 'active': true }, 15166 * 'fred': { 'age': 40, 'active': false }, 15167 * 'pebbles': { 'age': 1, 'active': true } 15168 * }; 15169 * 15170 * _.findLastKey(users, function(o) { return o.age < 40; }); 15171 * // => returns 'pebbles' assuming `_.findKey` returns 'barney' 15172 * 15173 * // The `_.matches` iteratee shorthand. 15174 * _.findLastKey(users, { 'age': 36, 'active': true }); 15175 * // => 'barney' 15176 * 15177 * // The `_.matchesProperty` iteratee shorthand. 15178 * _.findLastKey(users, ['active', false]); 15179 * // => 'fred' 15180 * 15181 * // The `_.property` iteratee shorthand. 15182 * _.findLastKey(users, 'active'); 15183 * // => 'pebbles' 15184 */ 15185 function findLastKey(object, predicate) { 15186 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); 15187 } 15188 15189 /** 15190 * Iterates over own and inherited enumerable string keyed properties of an 15191 * object and invokes `iteratee` for each property. The iteratee is invoked 15192 * with three arguments: (value, key, object). Iteratee functions may exit 15193 * iteration early by explicitly returning `false`. 15194 * 15195 * @static 15196 * @memberOf _ 15197 * @since 0.3.0 15198 * @category Object 15199 * @param {Object} object The object to iterate over. 15200 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15201 * @returns {Object} Returns `object`. 15202 * @see _.forInRight 15203 * @example 15204 * 15205 * function Foo() { 15206 * this.a = 1; 15207 * this.b = 2; 15208 * } 15209 * 15210 * Foo.prototype.c = 3; 15211 * 15212 * _.forIn(new Foo, function(value, key) { 15213 * console.log(key); 15214 * }); 15215 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). 15216 */ 15217 function forIn(object, iteratee) { 15218 return object == null 15219 ? object 15220 : baseFor(object, getIteratee(iteratee, 3), keysIn); 15221 } 15222 15223 /** 15224 * This method is like `_.forIn` except that it iterates over properties of 15225 * `object` in the opposite order. 15226 * 15227 * @static 15228 * @memberOf _ 15229 * @since 2.0.0 15230 * @category Object 15231 * @param {Object} object The object to iterate over. 15232 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15233 * @returns {Object} Returns `object`. 15234 * @see _.forIn 15235 * @example 15236 * 15237 * function Foo() { 15238 * this.a = 1; 15239 * this.b = 2; 15240 * } 15241 * 15242 * Foo.prototype.c = 3; 15243 * 15244 * _.forInRight(new Foo, function(value, key) { 15245 * console.log(key); 15246 * }); 15247 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. 15248 */ 15249 function forInRight(object, iteratee) { 15250 return object == null 15251 ? object 15252 : baseForRight(object, getIteratee(iteratee, 3), keysIn); 15253 } 15254 15255 /** 15256 * Iterates over own enumerable string keyed properties of an object and 15257 * invokes `iteratee` for each property. The iteratee is invoked with three 15258 * arguments: (value, key, object). Iteratee functions may exit iteration 15259 * early by explicitly returning `false`. 15260 * 15261 * @static 15262 * @memberOf _ 15263 * @since 0.3.0 15264 * @category Object 15265 * @param {Object} object The object to iterate over. 15266 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15267 * @returns {Object} Returns `object`. 15268 * @see _.forOwnRight 15269 * @example 15270 * 15271 * function Foo() { 15272 * this.a = 1; 15273 * this.b = 2; 15274 * } 15275 * 15276 * Foo.prototype.c = 3; 15277 * 15278 * _.forOwn(new Foo, function(value, key) { 15279 * console.log(key); 15280 * }); 15281 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 15282 */ 15283 function forOwn(object, iteratee) { 15284 return object && baseForOwn(object, getIteratee(iteratee, 3)); 15285 } 15286 15287 /** 15288 * This method is like `_.forOwn` except that it iterates over properties of 15289 * `object` in the opposite order. 15290 * 15291 * @static 15292 * @memberOf _ 15293 * @since 2.0.0 15294 * @category Object 15295 * @param {Object} object The object to iterate over. 15296 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15297 * @returns {Object} Returns `object`. 15298 * @see _.forOwn 15299 * @example 15300 * 15301 * function Foo() { 15302 * this.a = 1; 15303 * this.b = 2; 15304 * } 15305 * 15306 * Foo.prototype.c = 3; 15307 * 15308 * _.forOwnRight(new Foo, function(value, key) { 15309 * console.log(key); 15310 * }); 15311 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. 15312 */ 15313 function forOwnRight(object, iteratee) { 15314 return object && baseForOwnRight(object, getIteratee(iteratee, 3)); 15315 } 15316 15317 /** 15318 * Creates an array of function property names from own enumerable properties 15319 * of `object`. 15320 * 15321 * @static 15322 * @since 0.1.0 15323 * @memberOf _ 15324 * @category Object 15325 * @param {Object} object The object to inspect. 15326 * @returns {Array} Returns the function names. 15327 * @see _.functionsIn 15328 * @example 15329 * 15330 * function Foo() { 15331 * this.a = _.constant('a'); 15332 * this.b = _.constant('b'); 15333 * } 15334 * 15335 * Foo.prototype.c = _.constant('c'); 15336 * 15337 * _.functions(new Foo); 15338 * // => ['a', 'b'] 15339 */ 15340 function functions(object) { 15341 return object == null ? [] : baseFunctions(object, keys(object)); 15342 } 15343 15344 /** 15345 * Creates an array of function property names from own and inherited 15346 * enumerable properties of `object`. 15347 * 15348 * @static 15349 * @memberOf _ 15350 * @since 4.0.0 15351 * @category Object 15352 * @param {Object} object The object to inspect. 15353 * @returns {Array} Returns the function names. 15354 * @see _.functions 15355 * @example 15356 * 15357 * function Foo() { 15358 * this.a = _.constant('a'); 15359 * this.b = _.constant('b'); 15360 * } 15361 * 15362 * Foo.prototype.c = _.constant('c'); 15363 * 15364 * _.functionsIn(new Foo); 15365 * // => ['a', 'b', 'c'] 15366 */ 15367 function functionsIn(object) { 15368 return object == null ? [] : baseFunctions(object, keysIn(object)); 15369 } 15370 15371 /** 15372 * Gets the value at `path` of `object`. If the resolved value is 15373 * `undefined`, the `defaultValue` is returned in its place. 15374 * 15375 * @static 15376 * @memberOf _ 15377 * @since 3.7.0 15378 * @category Object 15379 * @param {Object} object The object to query. 15380 * @param {Array|string} path The path of the property to get. 15381 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 15382 * @returns {*} Returns the resolved value. 15383 * @example 15384 * 15385 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 15386 * 15387 * _.get(object, 'a[0].b.c'); 15388 * // => 3 15389 * 15390 * _.get(object, ['a', '0', 'b', 'c']); 15391 * // => 3 15392 * 15393 * _.get(object, 'a.b.c', 'default'); 15394 * // => 'default' 15395 */ 15396 function get(object, path, defaultValue) { 15397 var result = object == null ? undefined : baseGet(object, path); 15398 return result === undefined ? defaultValue : result; 15399 } 15400 15401 /** 15402 * Checks if `path` is a direct property of `object`. 15403 * 15404 * @static 15405 * @since 0.1.0 15406 * @memberOf _ 15407 * @category Object 15408 * @param {Object} object The object to query. 15409 * @param {Array|string} path The path to check. 15410 * @returns {boolean} Returns `true` if `path` exists, else `false`. 15411 * @example 15412 * 15413 * var object = { 'a': { 'b': 2 } }; 15414 * var other = _.create({ 'a': _.create({ 'b': 2 }) }); 15415 * 15416 * _.has(object, 'a'); 15417 * // => true 15418 * 15419 * _.has(object, 'a.b'); 15420 * // => true 15421 * 15422 * _.has(object, ['a', 'b']); 15423 * // => true 15424 * 15425 * _.has(other, 'a'); 15426 * // => false 15427 */ 15428 function has(object, path) { 15429 return object != null && hasPath(object, path, baseHas); 15430 } 15431 15432 /** 15433 * Checks if `path` is a direct or inherited property of `object`. 15434 * 15435 * @static 15436 * @memberOf _ 15437 * @since 4.0.0 15438 * @category Object 15439 * @param {Object} object The object to query. 15440 * @param {Array|string} path The path to check. 15441 * @returns {boolean} Returns `true` if `path` exists, else `false`. 15442 * @example 15443 * 15444 * var object = _.create({ 'a': _.create({ 'b': 2 }) }); 15445 * 15446 * _.hasIn(object, 'a'); 15447 * // => true 15448 * 15449 * _.hasIn(object, 'a.b'); 15450 * // => true 15451 * 15452 * _.hasIn(object, ['a', 'b']); 15453 * // => true 15454 * 15455 * _.hasIn(object, 'b'); 15456 * // => false 15457 */ 15458 function hasIn(object, path) { 15459 return object != null && hasPath(object, path, baseHasIn); 15460 } 15461 15462 /** 15463 * Creates an object composed of the inverted keys and values of `object`. 15464 * If `object` contains duplicate values, subsequent values overwrite 15465 * property assignments of previous values. 15466 * 15467 * @static 15468 * @memberOf _ 15469 * @since 0.7.0 15470 * @category Object 15471 * @param {Object} object The object to invert. 15472 * @returns {Object} Returns the new inverted object. 15473 * @example 15474 * 15475 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 15476 * 15477 * _.invert(object); 15478 * // => { '1': 'c', '2': 'b' } 15479 */ 15480 var invert = createInverter(function(result, value, key) { 15481 if (value != null && 15482 typeof value.toString != 'function') { 15483 value = nativeObjectToString.call(value); 15484 } 15485 15486 result[value] = key; 15487 }, constant(identity)); 15488 15489 /** 15490 * This method is like `_.invert` except that the inverted object is generated 15491 * from the results of running each element of `object` thru `iteratee`. The 15492 * corresponding inverted value of each inverted key is an array of keys 15493 * responsible for generating the inverted value. The iteratee is invoked 15494 * with one argument: (value). 15495 * 15496 * @static 15497 * @memberOf _ 15498 * @since 4.1.0 15499 * @category Object 15500 * @param {Object} object The object to invert. 15501 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 15502 * @returns {Object} Returns the new inverted object. 15503 * @example 15504 * 15505 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 15506 * 15507 * _.invertBy(object); 15508 * // => { '1': ['a', 'c'], '2': ['b'] } 15509 * 15510 * _.invertBy(object, function(value) { 15511 * return 'group' + value; 15512 * }); 15513 * // => { 'group1': ['a', 'c'], 'group2': ['b'] } 15514 */ 15515 var invertBy = createInverter(function(result, value, key) { 15516 if (value != null && 15517 typeof value.toString != 'function') { 15518 value = nativeObjectToString.call(value); 15519 } 15520 15521 if (hasOwnProperty.call(result, value)) { 15522 result[value].push(key); 15523 } else { 15524 result[value] = [key]; 15525 } 15526 }, getIteratee); 15527 15528 /** 15529 * Invokes the method at `path` of `object`. 15530 * 15531 * @static 15532 * @memberOf _ 15533 * @since 4.0.0 15534 * @category Object 15535 * @param {Object} object The object to query. 15536 * @param {Array|string} path The path of the method to invoke. 15537 * @param {...*} [args] The arguments to invoke the method with. 15538 * @returns {*} Returns the result of the invoked method. 15539 * @example 15540 * 15541 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; 15542 * 15543 * _.invoke(object, 'a[0].b.c.slice', 1, 3); 15544 * // => [2, 3] 15545 */ 15546 var invoke = baseRest(baseInvoke); 15547 15548 /** 15549 * Creates an array of the own enumerable property names of `object`. 15550 * 15551 * **Note:** Non-object values are coerced to objects. See the 15552 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 15553 * for more details. 15554 * 15555 * @static 15556 * @since 0.1.0 15557 * @memberOf _ 15558 * @category Object 15559 * @param {Object} object The object to query. 15560 * @returns {Array} Returns the array of property names. 15561 * @example 15562 * 15563 * function Foo() { 15564 * this.a = 1; 15565 * this.b = 2; 15566 * } 15567 * 15568 * Foo.prototype.c = 3; 15569 * 15570 * _.keys(new Foo); 15571 * // => ['a', 'b'] (iteration order is not guaranteed) 15572 * 15573 * _.keys('hi'); 15574 * // => ['0', '1'] 15575 */ 15576 function keys(object) { 15577 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); 15578 } 15579 15580 /** 15581 * Creates an array of the own and inherited enumerable property names of `object`. 15582 * 15583 * **Note:** Non-object values are coerced to objects. 15584 * 15585 * @static 15586 * @memberOf _ 15587 * @since 3.0.0 15588 * @category Object 15589 * @param {Object} object The object to query. 15590 * @returns {Array} Returns the array of property names. 15591 * @example 15592 * 15593 * function Foo() { 15594 * this.a = 1; 15595 * this.b = 2; 15596 * } 15597 * 15598 * Foo.prototype.c = 3; 15599 * 15600 * _.keysIn(new Foo); 15601 * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 15602 */ 15603 function keysIn(object) { 15604 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); 15605 } 15606 15607 /** 15608 * The opposite of `_.mapValues`; this method creates an object with the 15609 * same values as `object` and keys generated by running each own enumerable 15610 * string keyed property of `object` thru `iteratee`. The iteratee is invoked 15611 * with three arguments: (value, key, object). 15612 * 15613 * @static 15614 * @memberOf _ 15615 * @since 3.8.0 15616 * @category Object 15617 * @param {Object} object The object to iterate over. 15618 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15619 * @returns {Object} Returns the new mapped object. 15620 * @see _.mapValues 15621 * @example 15622 * 15623 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { 15624 * return key + value; 15625 * }); 15626 * // => { 'a1': 1, 'b2': 2 } 15627 */ 15628 function mapKeys(object, iteratee) { 15629 var result = {}; 15630 iteratee = getIteratee(iteratee, 3); 15631 15632 baseForOwn(object, function(value, key, object) { 15633 baseAssignValue(result, iteratee(value, key, object), value); 15634 }); 15635 return result; 15636 } 15637 15638 /** 15639 * Creates an object with the same keys as `object` and values generated 15640 * by running each own enumerable string keyed property of `object` thru 15641 * `iteratee`. The iteratee is invoked with three arguments: 15642 * (value, key, object). 15643 * 15644 * @static 15645 * @memberOf _ 15646 * @since 2.4.0 15647 * @category Object 15648 * @param {Object} object The object to iterate over. 15649 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15650 * @returns {Object} Returns the new mapped object. 15651 * @see _.mapKeys 15652 * @example 15653 * 15654 * var users = { 15655 * 'fred': { 'user': 'fred', 'age': 40 }, 15656 * 'pebbles': { 'user': 'pebbles', 'age': 1 } 15657 * }; 15658 * 15659 * _.mapValues(users, function(o) { return o.age; }); 15660 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 15661 * 15662 * // The `_.property` iteratee shorthand. 15663 * _.mapValues(users, 'age'); 15664 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 15665 */ 15666 function mapValues(object, iteratee) { 15667 var result = {}; 15668 iteratee = getIteratee(iteratee, 3); 15669 15670 baseForOwn(object, function(value, key, object) { 15671 baseAssignValue(result, key, iteratee(value, key, object)); 15672 }); 15673 return result; 15674 } 15675 15676 /** 15677 * This method is like `_.assign` except that it recursively merges own and 15678 * inherited enumerable string keyed properties of source objects into the 15679 * destination object. Source properties that resolve to `undefined` are 15680 * skipped if a destination value exists. Array and plain object properties 15681 * are merged recursively. Other objects and value types are overridden by 15682 * assignment. Source objects are applied from left to right. Subsequent 15683 * sources overwrite property assignments of previous sources. 15684 * 15685 * **Note:** This method mutates `object`. 15686 * 15687 * @static 15688 * @memberOf _ 15689 * @since 0.5.0 15690 * @category Object 15691 * @param {Object} object The destination object. 15692 * @param {...Object} [sources] The source objects. 15693 * @returns {Object} Returns `object`. 15694 * @example 15695 * 15696 * var object = { 15697 * 'a': [{ 'b': 2 }, { 'd': 4 }] 15698 * }; 15699 * 15700 * var other = { 15701 * 'a': [{ 'c': 3 }, { 'e': 5 }] 15702 * }; 15703 * 15704 * _.merge(object, other); 15705 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } 15706 */ 15707 var merge = createAssigner(function(object, source, srcIndex) { 15708 baseMerge(object, source, srcIndex); 15709 }); 15710 15711 /** 15712 * This method is like `_.merge` except that it accepts `customizer` which 15713 * is invoked to produce the merged values of the destination and source 15714 * properties. If `customizer` returns `undefined`, merging is handled by the 15715 * method instead. The `customizer` is invoked with six arguments: 15716 * (objValue, srcValue, key, object, source, stack). 15717 * 15718 * **Note:** This method mutates `object`. 15719 * 15720 * @static 15721 * @memberOf _ 15722 * @since 4.0.0 15723 * @category Object 15724 * @param {Object} object The destination object. 15725 * @param {...Object} sources The source objects. 15726 * @param {Function} customizer The function to customize assigned values. 15727 * @returns {Object} Returns `object`. 15728 * @example 15729 * 15730 * function customizer(objValue, srcValue) { 15731 * if (_.isArray(objValue)) { 15732 * return objValue.concat(srcValue); 15733 * } 15734 * } 15735 * 15736 * var object = { 'a': [1], 'b': [2] }; 15737 * var other = { 'a': [3], 'b': [4] }; 15738 * 15739 * _.mergeWith(object, other, customizer); 15740 * // => { 'a': [1, 3], 'b': [2, 4] } 15741 */ 15742 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { 15743 baseMerge(object, source, srcIndex, customizer); 15744 }); 15745 15746 /** 15747 * The opposite of `_.pick`; this method creates an object composed of the 15748 * own and inherited enumerable property paths of `object` that are not omitted. 15749 * 15750 * **Note:** This method is considerably slower than `_.pick`. 15751 * 15752 * @static 15753 * @since 0.1.0 15754 * @memberOf _ 15755 * @category Object 15756 * @param {Object} object The source object. 15757 * @param {...(string|string[])} [paths] The property paths to omit. 15758 * @returns {Object} Returns the new object. 15759 * @example 15760 * 15761 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15762 * 15763 * _.omit(object, ['a', 'c']); 15764 * // => { 'b': '2' } 15765 */ 15766 var omit = flatRest(function(object, paths) { 15767 var result = {}; 15768 if (object == null) { 15769 return result; 15770 } 15771 var isDeep = false; 15772 paths = arrayMap(paths, function(path) { 15773 path = castPath(path, object); 15774 isDeep || (isDeep = path.length > 1); 15775 return path; 15776 }); 15777 copyObject(object, getAllKeysIn(object), result); 15778 if (isDeep) { 15779 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); 15780 } 15781 var length = paths.length; 15782 while (length--) { 15783 baseUnset(result, paths[length]); 15784 } 15785 return result; 15786 }); 15787 15788 /** 15789 * The opposite of `_.pickBy`; this method creates an object composed of 15790 * the own and inherited enumerable string keyed properties of `object` that 15791 * `predicate` doesn't return truthy for. The predicate is invoked with two 15792 * arguments: (value, key). 15793 * 15794 * @static 15795 * @memberOf _ 15796 * @since 4.0.0 15797 * @category Object 15798 * @param {Object} object The source object. 15799 * @param {Function} [predicate=_.identity] The function invoked per property. 15800 * @returns {Object} Returns the new object. 15801 * @example 15802 * 15803 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15804 * 15805 * _.omitBy(object, _.isNumber); 15806 * // => { 'b': '2' } 15807 */ 15808 function omitBy(object, predicate) { 15809 return pickBy(object, negate(getIteratee(predicate))); 15810 } 15811 15812 /** 15813 * Creates an object composed of the picked `object` properties. 15814 * 15815 * @static 15816 * @since 0.1.0 15817 * @memberOf _ 15818 * @category Object 15819 * @param {Object} object The source object. 15820 * @param {...(string|string[])} [paths] The property paths to pick. 15821 * @returns {Object} Returns the new object. 15822 * @example 15823 * 15824 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15825 * 15826 * _.pick(object, ['a', 'c']); 15827 * // => { 'a': 1, 'c': 3 } 15828 */ 15829 var pick = flatRest(function(object, paths) { 15830 return object == null ? {} : basePick(object, paths); 15831 }); 15832 15833 /** 15834 * Creates an object composed of the `object` properties `predicate` returns 15835 * truthy for. The predicate is invoked with two arguments: (value, key). 15836 * 15837 * @static 15838 * @memberOf _ 15839 * @since 4.0.0 15840 * @category Object 15841 * @param {Object} object The source object. 15842 * @param {Function} [predicate=_.identity] The function invoked per property. 15843 * @returns {Object} Returns the new object. 15844 * @example 15845 * 15846 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15847 * 15848 * _.pickBy(object, _.isNumber); 15849 * // => { 'a': 1, 'c': 3 } 15850 */ 15851 function pickBy(object, predicate) { 15852 if (object == null) { 15853 return {}; 15854 } 15855 var props = arrayMap(getAllKeysIn(object), function(prop) { 15856 return [prop]; 15857 }); 15858 predicate = getIteratee(predicate); 15859 return basePickBy(object, props, function(value, path) { 15860 return predicate(value, path[0]); 15861 }); 15862 } 15863 15864 /** 15865 * This method is like `_.get` except that if the resolved value is a 15866 * function it's invoked with the `this` binding of its parent object and 15867 * its result is returned. 15868 * 15869 * @static 15870 * @since 0.1.0 15871 * @memberOf _ 15872 * @category Object 15873 * @param {Object} object The object to query. 15874 * @param {Array|string} path The path of the property to resolve. 15875 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 15876 * @returns {*} Returns the resolved value. 15877 * @example 15878 * 15879 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; 15880 * 15881 * _.result(object, 'a[0].b.c1'); 15882 * // => 3 15883 * 15884 * _.result(object, 'a[0].b.c2'); 15885 * // => 4 15886 * 15887 * _.result(object, 'a[0].b.c3', 'default'); 15888 * // => 'default' 15889 * 15890 * _.result(object, 'a[0].b.c3', _.constant('default')); 15891 * // => 'default' 15892 */ 15893 function result(object, path, defaultValue) { 15894 path = castPath(path, object); 15895 15896 var index = -1, 15897 length = path.length; 15898 15899 // Ensure the loop is entered when path is empty. 15900 if (!length) { 15901 length = 1; 15902 object = undefined; 15903 } 15904 while (++index < length) { 15905 var value = object == null ? undefined : object[toKey(path[index])]; 15906 if (value === undefined) { 15907 index = length; 15908 value = defaultValue; 15909 } 15910 object = isFunction(value) ? value.call(object) : value; 15911 } 15912 return object; 15913 } 15914 15915 /** 15916 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, 15917 * it's created. Arrays are created for missing index properties while objects 15918 * are created for all other missing properties. Use `_.setWith` to customize 15919 * `path` creation. 15920 * 15921 * **Note:** This method mutates `object`. 15922 * 15923 * @static 15924 * @memberOf _ 15925 * @since 3.7.0 15926 * @category Object 15927 * @param {Object} object The object to modify. 15928 * @param {Array|string} path The path of the property to set. 15929 * @param {*} value The value to set. 15930 * @returns {Object} Returns `object`. 15931 * @example 15932 * 15933 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 15934 * 15935 * _.set(object, 'a[0].b.c', 4); 15936 * console.log(object.a[0].b.c); 15937 * // => 4 15938 * 15939 * _.set(object, ['x', '0', 'y', 'z'], 5); 15940 * console.log(object.x[0].y.z); 15941 * // => 5 15942 */ 15943 function set(object, path, value) { 15944 return object == null ? object : baseSet(object, path, value); 15945 } 15946 15947 /** 15948 * This method is like `_.set` except that it accepts `customizer` which is 15949 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 15950 * path creation is handled by the method instead. The `customizer` is invoked 15951 * with three arguments: (nsValue, key, nsObject). 15952 * 15953 * **Note:** This method mutates `object`. 15954 * 15955 * @static 15956 * @memberOf _ 15957 * @since 4.0.0 15958 * @category Object 15959 * @param {Object} object The object to modify. 15960 * @param {Array|string} path The path of the property to set. 15961 * @param {*} value The value to set. 15962 * @param {Function} [customizer] The function to customize assigned values. 15963 * @returns {Object} Returns `object`. 15964 * @example 15965 * 15966 * var object = {}; 15967 * 15968 * _.setWith(object, '[0][1]', 'a', Object); 15969 * // => { '0': { '1': 'a' } } 15970 */ 15971 function setWith(object, path, value, customizer) { 15972 customizer = typeof customizer == 'function' ? customizer : undefined; 15973 return object == null ? object : baseSet(object, path, value, customizer); 15974 } 15975 15976 /** 15977 * Creates an array of own enumerable string keyed-value pairs for `object` 15978 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its 15979 * entries are returned. 15980 * 15981 * @static 15982 * @memberOf _ 15983 * @since 4.0.0 15984 * @alias entries 15985 * @category Object 15986 * @param {Object} object The object to query. 15987 * @returns {Array} Returns the key-value pairs. 15988 * @example 15989 * 15990 * function Foo() { 15991 * this.a = 1; 15992 * this.b = 2; 15993 * } 15994 * 15995 * Foo.prototype.c = 3; 15996 * 15997 * _.toPairs(new Foo); 15998 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) 15999 */ 16000 var toPairs = createToPairs(keys); 16001 16002 /** 16003 * Creates an array of own and inherited enumerable string keyed-value pairs 16004 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map 16005 * or set, its entries are returned. 16006 * 16007 * @static 16008 * @memberOf _ 16009 * @since 4.0.0 16010 * @alias entriesIn 16011 * @category Object 16012 * @param {Object} object The object to query. 16013 * @returns {Array} Returns the key-value pairs. 16014 * @example 16015 * 16016 * function Foo() { 16017 * this.a = 1; 16018 * this.b = 2; 16019 * } 16020 * 16021 * Foo.prototype.c = 3; 16022 * 16023 * _.toPairsIn(new Foo); 16024 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) 16025 */ 16026 var toPairsIn = createToPairs(keysIn); 16027 16028 /** 16029 * An alternative to `_.reduce`; this method transforms `object` to a new 16030 * `accumulator` object which is the result of running each of its own 16031 * enumerable string keyed properties thru `iteratee`, with each invocation 16032 * potentially mutating the `accumulator` object. If `accumulator` is not 16033 * provided, a new object with the same `[[Prototype]]` will be used. The 16034 * iteratee is invoked with four arguments: (accumulator, value, key, object). 16035 * Iteratee functions may exit iteration early by explicitly returning `false`. 16036 * 16037 * @static 16038 * @memberOf _ 16039 * @since 1.3.0 16040 * @category Object 16041 * @param {Object} object The object to iterate over. 16042 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 16043 * @param {*} [accumulator] The custom accumulator value. 16044 * @returns {*} Returns the accumulated value. 16045 * @example 16046 * 16047 * _.transform([2, 3, 4], function(result, n) { 16048 * result.push(n *= n); 16049 * return n % 2 == 0; 16050 * }, []); 16051 * // => [4, 9] 16052 * 16053 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 16054 * (result[value] || (result[value] = [])).push(key); 16055 * }, {}); 16056 * // => { '1': ['a', 'c'], '2': ['b'] } 16057 */ 16058 function transform(object, iteratee, accumulator) { 16059 var isArr = isArray(object), 16060 isArrLike = isArr || isBuffer(object) || isTypedArray(object); 16061 16062 iteratee = getIteratee(iteratee, 4); 16063 if (accumulator == null) { 16064 var Ctor = object && object.constructor; 16065 if (isArrLike) { 16066 accumulator = isArr ? new Ctor : []; 16067 } 16068 else if (isObject(object)) { 16069 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; 16070 } 16071 else { 16072 accumulator = {}; 16073 } 16074 } 16075 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { 16076 return iteratee(accumulator, value, index, object); 16077 }); 16078 return accumulator; 16079 } 16080 16081 /** 16082 * Removes the property at `path` of `object`. 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 unset. 16092 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 16093 * @example 16094 * 16095 * var object = { 'a': [{ 'b': { 'c': 7 } }] }; 16096 * _.unset(object, 'a[0].b.c'); 16097 * // => true 16098 * 16099 * console.log(object); 16100 * // => { 'a': [{ 'b': {} }] }; 16101 * 16102 * _.unset(object, ['a', '0', 'b', 'c']); 16103 * // => true 16104 * 16105 * console.log(object); 16106 * // => { 'a': [{ 'b': {} }] }; 16107 */ 16108 function unset(object, path) { 16109 return object == null ? true : baseUnset(object, path); 16110 } 16111 16112 /** 16113 * This method is like `_.set` except that accepts `updater` to produce the 16114 * value to set. Use `_.updateWith` to customize `path` creation. The `updater` 16115 * is invoked with one argument: (value). 16116 * 16117 * **Note:** This method mutates `object`. 16118 * 16119 * @static 16120 * @memberOf _ 16121 * @since 4.6.0 16122 * @category Object 16123 * @param {Object} object The object to modify. 16124 * @param {Array|string} path The path of the property to set. 16125 * @param {Function} updater The function to produce the updated value. 16126 * @returns {Object} Returns `object`. 16127 * @example 16128 * 16129 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 16130 * 16131 * _.update(object, 'a[0].b.c', function(n) { return n * n; }); 16132 * console.log(object.a[0].b.c); 16133 * // => 9 16134 * 16135 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); 16136 * console.log(object.x[0].y.z); 16137 * // => 0 16138 */ 16139 function update(object, path, updater) { 16140 return object == null ? object : baseUpdate(object, path, castFunction(updater)); 16141 } 16142 16143 /** 16144 * This method is like `_.update` except that it accepts `customizer` which is 16145 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 16146 * path creation is handled by the method instead. The `customizer` is invoked 16147 * with three arguments: (nsValue, key, nsObject). 16148 * 16149 * **Note:** This method mutates `object`. 16150 * 16151 * @static 16152 * @memberOf _ 16153 * @since 4.6.0 16154 * @category Object 16155 * @param {Object} object The object to modify. 16156 * @param {Array|string} path The path of the property to set. 16157 * @param {Function} updater The function to produce the updated value. 16158 * @param {Function} [customizer] The function to customize assigned values. 16159 * @returns {Object} Returns `object`. 16160 * @example 16161 * 16162 * var object = {}; 16163 * 16164 * _.updateWith(object, '[0][1]', _.constant('a'), Object); 16165 * // => { '0': { '1': 'a' } } 16166 */ 16167 function updateWith(object, path, updater, customizer) { 16168 customizer = typeof customizer == 'function' ? customizer : undefined; 16169 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); 16170 } 16171 16172 /** 16173 * Creates an array of the own enumerable string keyed property values of `object`. 16174 * 16175 * **Note:** Non-object values are coerced to objects. 16176 * 16177 * @static 16178 * @since 0.1.0 16179 * @memberOf _ 16180 * @category Object 16181 * @param {Object} object The object to query. 16182 * @returns {Array} Returns the array of property values. 16183 * @example 16184 * 16185 * function Foo() { 16186 * this.a = 1; 16187 * this.b = 2; 16188 * } 16189 * 16190 * Foo.prototype.c = 3; 16191 * 16192 * _.values(new Foo); 16193 * // => [1, 2] (iteration order is not guaranteed) 16194 * 16195 * _.values('hi'); 16196 * // => ['h', 'i'] 16197 */ 16198 function values(object) { 16199 return object == null ? [] : baseValues(object, keys(object)); 16200 } 16201 16202 /** 16203 * Creates an array of the own and inherited enumerable string keyed property 16204 * values of `object`. 16205 * 16206 * **Note:** Non-object values are coerced to objects. 16207 * 16208 * @static 16209 * @memberOf _ 16210 * @since 3.0.0 16211 * @category Object 16212 * @param {Object} object The object to query. 16213 * @returns {Array} Returns the array of property values. 16214 * @example 16215 * 16216 * function Foo() { 16217 * this.a = 1; 16218 * this.b = 2; 16219 * } 16220 * 16221 * Foo.prototype.c = 3; 16222 * 16223 * _.valuesIn(new Foo); 16224 * // => [1, 2, 3] (iteration order is not guaranteed) 16225 */ 16226 function valuesIn(object) { 16227 return object == null ? [] : baseValues(object, keysIn(object)); 16228 } 16229 16230 /*------------------------------------------------------------------------*/ 16231 16232 /** 16233 * Clamps `number` within the inclusive `lower` and `upper` bounds. 16234 * 16235 * @static 16236 * @memberOf _ 16237 * @since 4.0.0 16238 * @category Number 16239 * @param {number} number The number to clamp. 16240 * @param {number} [lower] The lower bound. 16241 * @param {number} upper The upper bound. 16242 * @returns {number} Returns the clamped number. 16243 * @example 16244 * 16245 * _.clamp(-10, -5, 5); 16246 * // => -5 16247 * 16248 * _.clamp(10, -5, 5); 16249 * // => 5 16250 */ 16251 function clamp(number, lower, upper) { 16252 if (upper === undefined) { 16253 upper = lower; 16254 lower = undefined; 16255 } 16256 if (upper !== undefined) { 16257 upper = toNumber(upper); 16258 upper = upper === upper ? upper : 0; 16259 } 16260 if (lower !== undefined) { 16261 lower = toNumber(lower); 16262 lower = lower === lower ? lower : 0; 16263 } 16264 return baseClamp(toNumber(number), lower, upper); 16265 } 16266 16267 /** 16268 * Checks if `n` is between `start` and up to, but not including, `end`. If 16269 * `end` is not specified, it's set to `start` with `start` then set to `0`. 16270 * If `start` is greater than `end` the params are swapped to support 16271 * negative ranges. 16272 * 16273 * @static 16274 * @memberOf _ 16275 * @since 3.3.0 16276 * @category Number 16277 * @param {number} number The number to check. 16278 * @param {number} [start=0] The start of the range. 16279 * @param {number} end The end of the range. 16280 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 16281 * @see _.range, _.rangeRight 16282 * @example 16283 * 16284 * _.inRange(3, 2, 4); 16285 * // => true 16286 * 16287 * _.inRange(4, 8); 16288 * // => true 16289 * 16290 * _.inRange(4, 2); 16291 * // => false 16292 * 16293 * _.inRange(2, 2); 16294 * // => false 16295 * 16296 * _.inRange(1.2, 2); 16297 * // => true 16298 * 16299 * _.inRange(5.2, 4); 16300 * // => false 16301 * 16302 * _.inRange(-3, -2, -6); 16303 * // => true 16304 */ 16305 function inRange(number, start, end) { 16306 start = toFinite(start); 16307 if (end === undefined) { 16308 end = start; 16309 start = 0; 16310 } else { 16311 end = toFinite(end); 16312 } 16313 number = toNumber(number); 16314 return baseInRange(number, start, end); 16315 } 16316 16317 /** 16318 * Produces a random number between the inclusive `lower` and `upper` bounds. 16319 * If only one argument is provided a number between `0` and the given number 16320 * is returned. If `floating` is `true`, or either `lower` or `upper` are 16321 * floats, a floating-point number is returned instead of an integer. 16322 * 16323 * **Note:** JavaScript follows the IEEE-754 standard for resolving 16324 * floating-point values which can produce unexpected results. 16325 * 16326 * @static 16327 * @memberOf _ 16328 * @since 0.7.0 16329 * @category Number 16330 * @param {number} [lower=0] The lower bound. 16331 * @param {number} [upper=1] The upper bound. 16332 * @param {boolean} [floating] Specify returning a floating-point number. 16333 * @returns {number} Returns the random number. 16334 * @example 16335 * 16336 * _.random(0, 5); 16337 * // => an integer between 0 and 5 16338 * 16339 * _.random(5); 16340 * // => also an integer between 0 and 5 16341 * 16342 * _.random(5, true); 16343 * // => a floating-point number between 0 and 5 16344 * 16345 * _.random(1.2, 5.2); 16346 * // => a floating-point number between 1.2 and 5.2 16347 */ 16348 function random(lower, upper, floating) { 16349 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { 16350 upper = floating = undefined; 16351 } 16352 if (floating === undefined) { 16353 if (typeof upper == 'boolean') { 16354 floating = upper; 16355 upper = undefined; 16356 } 16357 else if (typeof lower == 'boolean') { 16358 floating = lower; 16359 lower = undefined; 16360 } 16361 } 16362 if (lower === undefined && upper === undefined) { 16363 lower = 0; 16364 upper = 1; 16365 } 16366 else { 16367 lower = toFinite(lower); 16368 if (upper === undefined) { 16369 upper = lower; 16370 lower = 0; 16371 } else { 16372 upper = toFinite(upper); 16373 } 16374 } 16375 if (lower > upper) { 16376 var temp = lower; 16377 lower = upper; 16378 upper = temp; 16379 } 16380 if (floating || lower % 1 || upper % 1) { 16381 var rand = nativeRandom(); 16382 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); 16383 } 16384 return baseRandom(lower, upper); 16385 } 16386 16387 /*------------------------------------------------------------------------*/ 16388 16389 /** 16390 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). 16391 * 16392 * @static 16393 * @memberOf _ 16394 * @since 3.0.0 16395 * @category String 16396 * @param {string} [string=''] The string to convert. 16397 * @returns {string} Returns the camel cased string. 16398 * @example 16399 * 16400 * _.camelCase('Foo Bar'); 16401 * // => 'fooBar' 16402 * 16403 * _.camelCase('--foo-bar--'); 16404 * // => 'fooBar' 16405 * 16406 * _.camelCase('__FOO_BAR__'); 16407 * // => 'fooBar' 16408 */ 16409 var camelCase = createCompounder(function(result, word, index) { 16410 word = word.toLowerCase(); 16411 return result + (index ? capitalize(word) : word); 16412 }); 16413 16414 /** 16415 * Converts the first character of `string` to upper case and the remaining 16416 * to lower case. 16417 * 16418 * @static 16419 * @memberOf _ 16420 * @since 3.0.0 16421 * @category String 16422 * @param {string} [string=''] The string to capitalize. 16423 * @returns {string} Returns the capitalized string. 16424 * @example 16425 * 16426 * _.capitalize('FRED'); 16427 * // => 'Fred' 16428 */ 16429 function capitalize(string) { 16430 return upperFirst(toString(string).toLowerCase()); 16431 } 16432 16433 /** 16434 * Deburrs `string` by converting 16435 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) 16436 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) 16437 * letters to basic Latin letters and removing 16438 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). 16439 * 16440 * @static 16441 * @memberOf _ 16442 * @since 3.0.0 16443 * @category String 16444 * @param {string} [string=''] The string to deburr. 16445 * @returns {string} Returns the deburred string. 16446 * @example 16447 * 16448 * _.deburr('déjàvu'); 16449 * // => 'deja vu' 16450 */ 16451 function deburr(string) { 16452 string = toString(string); 16453 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); 16454 } 16455 16456 /** 16457 * Checks if `string` ends with the given target string. 16458 * 16459 * @static 16460 * @memberOf _ 16461 * @since 3.0.0 16462 * @category String 16463 * @param {string} [string=''] The string to inspect. 16464 * @param {string} [target] The string to search for. 16465 * @param {number} [position=string.length] The position to search up to. 16466 * @returns {boolean} Returns `true` if `string` ends with `target`, 16467 * else `false`. 16468 * @example 16469 * 16470 * _.endsWith('abc', 'c'); 16471 * // => true 16472 * 16473 * _.endsWith('abc', 'b'); 16474 * // => false 16475 * 16476 * _.endsWith('abc', 'b', 2); 16477 * // => true 16478 */ 16479 function endsWith(string, target, position) { 16480 string = toString(string); 16481 target = baseToString(target); 16482 16483 var length = string.length; 16484 position = position === undefined 16485 ? length 16486 : baseClamp(toInteger(position), 0, length); 16487 16488 var end = position; 16489 position -= target.length; 16490 return position >= 0 && string.slice(position, end) == target; 16491 } 16492 16493 /** 16494 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their 16495 * corresponding HTML entities. 16496 * 16497 * **Note:** No other characters are escaped. To escape additional 16498 * characters use a third-party library like [_he_](https://mths.be/he). 16499 * 16500 * Though the ">" character is escaped for symmetry, characters like 16501 * ">" and "/" don't need escaping in HTML and have no special meaning 16502 * unless they're part of a tag or unquoted attribute value. See 16503 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) 16504 * (under "semi-related fun fact") for more details. 16505 * 16506 * When working with HTML you should always 16507 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce 16508 * XSS vectors. 16509 * 16510 * @static 16511 * @since 0.1.0 16512 * @memberOf _ 16513 * @category String 16514 * @param {string} [string=''] The string to escape. 16515 * @returns {string} Returns the escaped string. 16516 * @example 16517 * 16518 * _.escape('fred, barney, & pebbles'); 16519 * // => 'fred, barney, & pebbles' 16520 */ 16521 function escape(string) { 16522 string = toString(string); 16523 return (string && reHasUnescapedHtml.test(string)) 16524 ? string.replace(reUnescapedHtml, escapeHtmlChar) 16525 : string; 16526 } 16527 16528 /** 16529 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", 16530 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. 16531 * 16532 * @static 16533 * @memberOf _ 16534 * @since 3.0.0 16535 * @category String 16536 * @param {string} [string=''] The string to escape. 16537 * @returns {string} Returns the escaped string. 16538 * @example 16539 * 16540 * _.escapeRegExp('[lodash](https://lodash.com/)'); 16541 * // => '\[lodash\]\(https://lodash\.com/\)' 16542 */ 16543 function escapeRegExp(string) { 16544 string = toString(string); 16545 return (string && reHasRegExpChar.test(string)) 16546 ? string.replace(reRegExpChar, '\\$&') 16547 : string; 16548 } 16549 16550 /** 16551 * Converts `string` to 16552 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 16553 * 16554 * @static 16555 * @memberOf _ 16556 * @since 3.0.0 16557 * @category String 16558 * @param {string} [string=''] The string to convert. 16559 * @returns {string} Returns the kebab cased string. 16560 * @example 16561 * 16562 * _.kebabCase('Foo Bar'); 16563 * // => 'foo-bar' 16564 * 16565 * _.kebabCase('fooBar'); 16566 * // => 'foo-bar' 16567 * 16568 * _.kebabCase('__FOO_BAR__'); 16569 * // => 'foo-bar' 16570 */ 16571 var kebabCase = createCompounder(function(result, word, index) { 16572 return result + (index ? '-' : '') + word.toLowerCase(); 16573 }); 16574 16575 /** 16576 * Converts `string`, as space separated words, to lower case. 16577 * 16578 * @static 16579 * @memberOf _ 16580 * @since 4.0.0 16581 * @category String 16582 * @param {string} [string=''] The string to convert. 16583 * @returns {string} Returns the lower cased string. 16584 * @example 16585 * 16586 * _.lowerCase('--Foo-Bar--'); 16587 * // => 'foo bar' 16588 * 16589 * _.lowerCase('fooBar'); 16590 * // => 'foo bar' 16591 * 16592 * _.lowerCase('__FOO_BAR__'); 16593 * // => 'foo bar' 16594 */ 16595 var lowerCase = createCompounder(function(result, word, index) { 16596 return result + (index ? ' ' : '') + word.toLowerCase(); 16597 }); 16598 16599 /** 16600 * Converts the first character of `string` to lower case. 16601 * 16602 * @static 16603 * @memberOf _ 16604 * @since 4.0.0 16605 * @category String 16606 * @param {string} [string=''] The string to convert. 16607 * @returns {string} Returns the converted string. 16608 * @example 16609 * 16610 * _.lowerFirst('Fred'); 16611 * // => 'fred' 16612 * 16613 * _.lowerFirst('FRED'); 16614 * // => 'fRED' 16615 */ 16616 var lowerFirst = createCaseFirst('toLowerCase'); 16617 16618 /** 16619 * Pads `string` on the left and right sides if it's shorter than `length`. 16620 * Padding characters are truncated if they can't be evenly divided by `length`. 16621 * 16622 * @static 16623 * @memberOf _ 16624 * @since 3.0.0 16625 * @category String 16626 * @param {string} [string=''] The string to pad. 16627 * @param {number} [length=0] The padding length. 16628 * @param {string} [chars=' '] The string used as padding. 16629 * @returns {string} Returns the padded string. 16630 * @example 16631 * 16632 * _.pad('abc', 8); 16633 * // => ' abc ' 16634 * 16635 * _.pad('abc', 8, '_-'); 16636 * // => '_-abc_-_' 16637 * 16638 * _.pad('abc', 3); 16639 * // => 'abc' 16640 */ 16641 function pad(string, length, chars) { 16642 string = toString(string); 16643 length = toInteger(length); 16644 16645 var strLength = length ? stringSize(string) : 0; 16646 if (!length || strLength >= length) { 16647 return string; 16648 } 16649 var mid = (length - strLength) / 2; 16650 return ( 16651 createPadding(nativeFloor(mid), chars) + 16652 string + 16653 createPadding(nativeCeil(mid), chars) 16654 ); 16655 } 16656 16657 /** 16658 * Pads `string` on the right side if it's shorter than `length`. Padding 16659 * characters are truncated if they exceed `length`. 16660 * 16661 * @static 16662 * @memberOf _ 16663 * @since 4.0.0 16664 * @category String 16665 * @param {string} [string=''] The string to pad. 16666 * @param {number} [length=0] The padding length. 16667 * @param {string} [chars=' '] The string used as padding. 16668 * @returns {string} Returns the padded string. 16669 * @example 16670 * 16671 * _.padEnd('abc', 6); 16672 * // => 'abc ' 16673 * 16674 * _.padEnd('abc', 6, '_-'); 16675 * // => 'abc_-_' 16676 * 16677 * _.padEnd('abc', 3); 16678 * // => 'abc' 16679 */ 16680 function padEnd(string, length, chars) { 16681 string = toString(string); 16682 length = toInteger(length); 16683 16684 var strLength = length ? stringSize(string) : 0; 16685 return (length && strLength < length) 16686 ? (string + createPadding(length - strLength, chars)) 16687 : string; 16688 } 16689 16690 /** 16691 * Pads `string` on the left side if it's shorter than `length`. Padding 16692 * characters are truncated if they exceed `length`. 16693 * 16694 * @static 16695 * @memberOf _ 16696 * @since 4.0.0 16697 * @category String 16698 * @param {string} [string=''] The string to pad. 16699 * @param {number} [length=0] The padding length. 16700 * @param {string} [chars=' '] The string used as padding. 16701 * @returns {string} Returns the padded string. 16702 * @example 16703 * 16704 * _.padStart('abc', 6); 16705 * // => ' abc' 16706 * 16707 * _.padStart('abc', 6, '_-'); 16708 * // => '_-_abc' 16709 * 16710 * _.padStart('abc', 3); 16711 * // => 'abc' 16712 */ 16713 function padStart(string, length, chars) { 16714 string = toString(string); 16715 length = toInteger(length); 16716 16717 var strLength = length ? stringSize(string) : 0; 16718 return (length && strLength < length) 16719 ? (createPadding(length - strLength, chars) + string) 16720 : string; 16721 } 16722 16723 /** 16724 * Converts `string` to an integer of the specified radix. If `radix` is 16725 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a 16726 * hexadecimal, in which case a `radix` of `16` is used. 16727 * 16728 * **Note:** This method aligns with the 16729 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. 16730 * 16731 * @static 16732 * @memberOf _ 16733 * @since 1.1.0 16734 * @category String 16735 * @param {string} string The string to convert. 16736 * @param {number} [radix=10] The radix to interpret `value` by. 16737 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16738 * @returns {number} Returns the converted integer. 16739 * @example 16740 * 16741 * _.parseInt('08'); 16742 * // => 8 16743 * 16744 * _.map(['6', '08', '10'], _.parseInt); 16745 * // => [6, 8, 10] 16746 */ 16747 function parseInt(string, radix, guard) { 16748 if (guard || radix == null) { 16749 radix = 0; 16750 } else if (radix) { 16751 radix = +radix; 16752 } 16753 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); 16754 } 16755 16756 /** 16757 * Repeats the given string `n` times. 16758 * 16759 * @static 16760 * @memberOf _ 16761 * @since 3.0.0 16762 * @category String 16763 * @param {string} [string=''] The string to repeat. 16764 * @param {number} [n=1] The number of times to repeat the string. 16765 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16766 * @returns {string} Returns the repeated string. 16767 * @example 16768 * 16769 * _.repeat('*', 3); 16770 * // => '***' 16771 * 16772 * _.repeat('abc', 2); 16773 * // => 'abcabc' 16774 * 16775 * _.repeat('abc', 0); 16776 * // => '' 16777 */ 16778 function repeat(string, n, guard) { 16779 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { 16780 n = 1; 16781 } else { 16782 n = toInteger(n); 16783 } 16784 return baseRepeat(toString(string), n); 16785 } 16786 16787 /** 16788 * Replaces matches for `pattern` in `string` with `replacement`. 16789 * 16790 * **Note:** This method is based on 16791 * [`String#replace`](https://mdn.io/String/replace). 16792 * 16793 * @static 16794 * @memberOf _ 16795 * @since 4.0.0 16796 * @category String 16797 * @param {string} [string=''] The string to modify. 16798 * @param {RegExp|string} pattern The pattern to replace. 16799 * @param {Function|string} replacement The match replacement. 16800 * @returns {string} Returns the modified string. 16801 * @example 16802 * 16803 * _.replace('Hi Fred', 'Fred', 'Barney'); 16804 * // => 'Hi Barney' 16805 */ 16806 function replace() { 16807 var args = arguments, 16808 string = toString(args[0]); 16809 16810 return args.length < 3 ? string : string.replace(args[1], args[2]); 16811 } 16812 16813 /** 16814 * Converts `string` to 16815 * [snake case](https://en.wikipedia.org/wiki/Snake_case). 16816 * 16817 * @static 16818 * @memberOf _ 16819 * @since 3.0.0 16820 * @category String 16821 * @param {string} [string=''] The string to convert. 16822 * @returns {string} Returns the snake cased string. 16823 * @example 16824 * 16825 * _.snakeCase('Foo Bar'); 16826 * // => 'foo_bar' 16827 * 16828 * _.snakeCase('fooBar'); 16829 * // => 'foo_bar' 16830 * 16831 * _.snakeCase('--FOO-BAR--'); 16832 * // => 'foo_bar' 16833 */ 16834 var snakeCase = createCompounder(function(result, word, index) { 16835 return result + (index ? '_' : '') + word.toLowerCase(); 16836 }); 16837 16838 /** 16839 * Splits `string` by `separator`. 16840 * 16841 * **Note:** This method is based on 16842 * [`String#split`](https://mdn.io/String/split). 16843 * 16844 * @static 16845 * @memberOf _ 16846 * @since 4.0.0 16847 * @category String 16848 * @param {string} [string=''] The string to split. 16849 * @param {RegExp|string} separator The separator pattern to split by. 16850 * @param {number} [limit] The length to truncate results to. 16851 * @returns {Array} Returns the string segments. 16852 * @example 16853 * 16854 * _.split('a-b-c', '-', 2); 16855 * // => ['a', 'b'] 16856 */ 16857 function split(string, separator, limit) { 16858 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { 16859 separator = limit = undefined; 16860 } 16861 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; 16862 if (!limit) { 16863 return []; 16864 } 16865 string = toString(string); 16866 if (string && ( 16867 typeof separator == 'string' || 16868 (separator != null && !isRegExp(separator)) 16869 )) { 16870 separator = baseToString(separator); 16871 if (!separator && hasUnicode(string)) { 16872 return castSlice(stringToArray(string), 0, limit); 16873 } 16874 } 16875 return string.split(separator, limit); 16876 } 16877 16878 /** 16879 * Converts `string` to 16880 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). 16881 * 16882 * @static 16883 * @memberOf _ 16884 * @since 3.1.0 16885 * @category String 16886 * @param {string} [string=''] The string to convert. 16887 * @returns {string} Returns the start cased string. 16888 * @example 16889 * 16890 * _.startCase('--foo-bar--'); 16891 * // => 'Foo Bar' 16892 * 16893 * _.startCase('fooBar'); 16894 * // => 'Foo Bar' 16895 * 16896 * _.startCase('__FOO_BAR__'); 16897 * // => 'FOO BAR' 16898 */ 16899 var startCase = createCompounder(function(result, word, index) { 16900 return result + (index ? ' ' : '') + upperFirst(word); 16901 }); 16902 16903 /** 16904 * Checks if `string` starts with the given target string. 16905 * 16906 * @static 16907 * @memberOf _ 16908 * @since 3.0.0 16909 * @category String 16910 * @param {string} [string=''] The string to inspect. 16911 * @param {string} [target] The string to search for. 16912 * @param {number} [position=0] The position to search from. 16913 * @returns {boolean} Returns `true` if `string` starts with `target`, 16914 * else `false`. 16915 * @example 16916 * 16917 * _.startsWith('abc', 'a'); 16918 * // => true 16919 * 16920 * _.startsWith('abc', 'b'); 16921 * // => false 16922 * 16923 * _.startsWith('abc', 'b', 1); 16924 * // => true 16925 */ 16926 function startsWith(string, target, position) { 16927 string = toString(string); 16928 position = position == null 16929 ? 0 16930 : baseClamp(toInteger(position), 0, string.length); 16931 16932 target = baseToString(target); 16933 return string.slice(position, position + target.length) == target; 16934 } 16935 16936 /** 16937 * Creates a compiled template function that can interpolate data properties 16938 * in "interpolate" delimiters, HTML-escape interpolated data properties in 16939 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data 16940 * properties may be accessed as free variables in the template. If a setting 16941 * object is given, it takes precedence over `_.templateSettings` values. 16942 * 16943 * **Note:** In the development build `_.template` utilizes 16944 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) 16945 * for easier debugging. 16946 * 16947 * For more information on precompiling templates see 16948 * [lodash's custom builds documentation](https://lodash.com/custom-builds). 16949 * 16950 * For more information on Chrome extension sandboxes see 16951 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). 16952 * 16953 * @static 16954 * @since 0.1.0 16955 * @memberOf _ 16956 * @category String 16957 * @param {string} [string=''] The template string. 16958 * @param {Object} [options={}] The options object. 16959 * @param {RegExp} [options.escape=_.templateSettings.escape] 16960 * The HTML "escape" delimiter. 16961 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] 16962 * The "evaluate" delimiter. 16963 * @param {Object} [options.imports=_.templateSettings.imports] 16964 * An object to import into the template as free variables. 16965 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] 16966 * The "interpolate" delimiter. 16967 * @param {string} [options.sourceURL='lodash.templateSources[n]'] 16968 * The sourceURL of the compiled template. 16969 * @param {string} [options.variable='obj'] 16970 * The data object variable name. 16971 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16972 * @returns {Function} Returns the compiled template function. 16973 * @example 16974 * 16975 * // Use the "interpolate" delimiter to create a compiled template. 16976 * var compiled = _.template('hello <%= user %>!'); 16977 * compiled({ 'user': 'fred' }); 16978 * // => 'hello fred!' 16979 * 16980 * // Use the HTML "escape" delimiter to escape data property values. 16981 * var compiled = _.template('<b><%- value %></b>'); 16982 * compiled({ 'value': '<script>' }); 16983 * // => '<b><script></b>' 16984 * 16985 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. 16986 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); 16987 * compiled({ 'users': ['fred', 'barney'] }); 16988 * // => '<li>fred</li><li>barney</li>' 16989 * 16990 * // Use the internal `print` function in "evaluate" delimiters. 16991 * var compiled = _.template('<% print("hello " + user); %>!'); 16992 * compiled({ 'user': 'barney' }); 16993 * // => 'hello barney!' 16994 * 16995 * // Use the ES template literal delimiter as an "interpolate" delimiter. 16996 * // Disable support by replacing the "interpolate" delimiter. 16997 * var compiled = _.template('hello ${ user }!'); 16998 * compiled({ 'user': 'pebbles' }); 16999 * // => 'hello pebbles!' 17000 * 17001 * // Use backslashes to treat delimiters as plain text. 17002 * var compiled = _.template('<%= "\\<%- value %\\>" %>'); 17003 * compiled({ 'value': 'ignored' }); 17004 * // => '<%- value %>' 17005 * 17006 * // Use the `imports` option to import `jQuery` as `jq`. 17007 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; 17008 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); 17009 * compiled({ 'users': ['fred', 'barney'] }); 17010 * // => '<li>fred</li><li>barney</li>' 17011 * 17012 * // Use the `sourceURL` option to specify a custom sourceURL for the template. 17013 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); 17014 * compiled(data); 17015 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. 17016 * 17017 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. 17018 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); 17019 * compiled.source; 17020 * // => function(data) { 17021 * // var __t, __p = ''; 17022 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; 17023 * // return __p; 17024 * // } 17025 * 17026 * // Use custom template delimiters. 17027 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; 17028 * var compiled = _.template('hello {{ user }}!'); 17029 * compiled({ 'user': 'mustache' }); 17030 * // => 'hello mustache!' 17031 * 17032 * // Use the `source` property to inline compiled templates for meaningful 17033 * // line numbers in error messages and stack traces. 17034 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ 17035 * var JST = {\ 17036 * "main": ' + _.template(mainText).source + '\ 17037 * };\ 17038 * '); 17039 */ 17040 function template(string, options, guard) { 17041 // Based on John Resig's `tmpl` implementation 17042 // (http://ejohn.org/blog/javascript-micro-templating/) 17043 // and Laura Doktorova's doT.js (https://github.com/olado/doT). 17044 var settings = lodash.templateSettings; 17045 17046 if (guard && isIterateeCall(string, options, guard)) { 17047 options = undefined; 17048 } 17049 string = toString(string); 17050 options = assignInWith({}, options, settings, customDefaultsAssignIn); 17051 17052 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), 17053 importsKeys = keys(imports), 17054 importsValues = baseValues(imports, importsKeys); 17055 17056 var isEscaping, 17057 isEvaluating, 17058 index = 0, 17059 interpolate = options.interpolate || reNoMatch, 17060 source = "__p += '"; 17061 17062 // Compile the regexp to match each delimiter. 17063 var reDelimiters = RegExp( 17064 (options.escape || reNoMatch).source + '|' + 17065 interpolate.source + '|' + 17066 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + 17067 (options.evaluate || reNoMatch).source + '|$' 17068 , 'g'); 17069 17070 // Use a sourceURL for easier debugging. 17071 // The sourceURL gets injected into the source that's eval-ed, so be careful 17072 // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in 17073 // and escape the comment, thus injecting code that gets evaled. 17074 var sourceURL = '//# sourceURL=' + 17075 (hasOwnProperty.call(options, 'sourceURL') 17076 ? (options.sourceURL + '').replace(/\s/g, ' ') 17077 : ('lodash.templateSources[' + (++templateCounter) + ']') 17078 ) + '\n'; 17079 17080 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { 17081 interpolateValue || (interpolateValue = esTemplateValue); 17082 17083 // Escape characters that can't be included in string literals. 17084 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); 17085 17086 // Replace delimiters with snippets. 17087 if (escapeValue) { 17088 isEscaping = true; 17089 source += "' +\n__e(" + escapeValue + ") +\n'"; 17090 } 17091 if (evaluateValue) { 17092 isEvaluating = true; 17093 source += "';\n" + evaluateValue + ";\n__p += '"; 17094 } 17095 if (interpolateValue) { 17096 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; 17097 } 17098 index = offset + match.length; 17099 17100 // The JS engine embedded in Adobe products needs `match` returned in 17101 // order to produce the correct `offset` value. 17102 return match; 17103 }); 17104 17105 source += "';\n"; 17106 17107 // If `variable` is not specified wrap a with-statement around the generated 17108 // code to add the data object to the top of the scope chain. 17109 var variable = hasOwnProperty.call(options, 'variable') && options.variable; 17110 if (!variable) { 17111 source = 'with (obj) {\n' + source + '\n}\n'; 17112 } 17113 // Throw an error if a forbidden character was found in `variable`, to prevent 17114 // potential command injection attacks. 17115 else if (reForbiddenIdentifierChars.test(variable)) { 17116 throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT); 17117 } 17118 17119 // Cleanup code by stripping empty strings. 17120 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) 17121 .replace(reEmptyStringMiddle, '$1') 17122 .replace(reEmptyStringTrailing, '$1;'); 17123 17124 // Frame code as the function body. 17125 source = 'function(' + (variable || 'obj') + ') {\n' + 17126 (variable 17127 ? '' 17128 : 'obj || (obj = {});\n' 17129 ) + 17130 "var __t, __p = ''" + 17131 (isEscaping 17132 ? ', __e = _.escape' 17133 : '' 17134 ) + 17135 (isEvaluating 17136 ? ', __j = Array.prototype.join;\n' + 17137 "function print() { __p += __j.call(arguments, '') }\n" 17138 : ';\n' 17139 ) + 17140 source + 17141 'return __p\n}'; 17142 17143 var result = attempt(function() { 17144 return Function(importsKeys, sourceURL + 'return ' + source) 17145 .apply(undefined, importsValues); 17146 }); 17147 17148 // Provide the compiled function's source by its `toString` method or 17149 // the `source` property as a convenience for inlining compiled templates. 17150 result.source = source; 17151 if (isError(result)) { 17152 throw result; 17153 } 17154 return result; 17155 } 17156 17157 /** 17158 * Converts `string`, as a whole, to lower case just like 17159 * [String#toLowerCase](https://mdn.io/toLowerCase). 17160 * 17161 * @static 17162 * @memberOf _ 17163 * @since 4.0.0 17164 * @category String 17165 * @param {string} [string=''] The string to convert. 17166 * @returns {string} Returns the lower cased string. 17167 * @example 17168 * 17169 * _.toLower('--Foo-Bar--'); 17170 * // => '--foo-bar--' 17171 * 17172 * _.toLower('fooBar'); 17173 * // => 'foobar' 17174 * 17175 * _.toLower('__FOO_BAR__'); 17176 * // => '__foo_bar__' 17177 */ 17178 function toLower(value) { 17179 return toString(value).toLowerCase(); 17180 } 17181 17182 /** 17183 * Converts `string`, as a whole, to upper case just like 17184 * [String#toUpperCase](https://mdn.io/toUpperCase). 17185 * 17186 * @static 17187 * @memberOf _ 17188 * @since 4.0.0 17189 * @category String 17190 * @param {string} [string=''] The string to convert. 17191 * @returns {string} Returns the upper cased string. 17192 * @example 17193 * 17194 * _.toUpper('--foo-bar--'); 17195 * // => '--FOO-BAR--' 17196 * 17197 * _.toUpper('fooBar'); 17198 * // => 'FOOBAR' 17199 * 17200 * _.toUpper('__foo_bar__'); 17201 * // => '__FOO_BAR__' 17202 */ 17203 function toUpper(value) { 17204 return toString(value).toUpperCase(); 17205 } 17206 17207 /** 17208 * Removes leading and trailing whitespace or specified characters from `string`. 17209 * 17210 * @static 17211 * @memberOf _ 17212 * @since 3.0.0 17213 * @category String 17214 * @param {string} [string=''] The string to trim. 17215 * @param {string} [chars=whitespace] The characters to trim. 17216 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17217 * @returns {string} Returns the trimmed string. 17218 * @example 17219 * 17220 * _.trim(' abc '); 17221 * // => 'abc' 17222 * 17223 * _.trim('-_-abc-_-', '_-'); 17224 * // => 'abc' 17225 * 17226 * _.map([' foo ', ' bar '], _.trim); 17227 * // => ['foo', 'bar'] 17228 */ 17229 function trim(string, chars, guard) { 17230 string = toString(string); 17231 if (string && (guard || chars === undefined)) { 17232 return baseTrim(string); 17233 } 17234 if (!string || !(chars = baseToString(chars))) { 17235 return string; 17236 } 17237 var strSymbols = stringToArray(string), 17238 chrSymbols = stringToArray(chars), 17239 start = charsStartIndex(strSymbols, chrSymbols), 17240 end = charsEndIndex(strSymbols, chrSymbols) + 1; 17241 17242 return castSlice(strSymbols, start, end).join(''); 17243 } 17244 17245 /** 17246 * Removes trailing whitespace or specified characters from `string`. 17247 * 17248 * @static 17249 * @memberOf _ 17250 * @since 4.0.0 17251 * @category String 17252 * @param {string} [string=''] The string to trim. 17253 * @param {string} [chars=whitespace] The characters to trim. 17254 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17255 * @returns {string} Returns the trimmed string. 17256 * @example 17257 * 17258 * _.trimEnd(' abc '); 17259 * // => ' abc' 17260 * 17261 * _.trimEnd('-_-abc-_-', '_-'); 17262 * // => '-_-abc' 17263 */ 17264 function trimEnd(string, chars, guard) { 17265 string = toString(string); 17266 if (string && (guard || chars === undefined)) { 17267 return string.slice(0, trimmedEndIndex(string) + 1); 17268 } 17269 if (!string || !(chars = baseToString(chars))) { 17270 return string; 17271 } 17272 var strSymbols = stringToArray(string), 17273 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; 17274 17275 return castSlice(strSymbols, 0, end).join(''); 17276 } 17277 17278 /** 17279 * Removes leading whitespace or specified characters from `string`. 17280 * 17281 * @static 17282 * @memberOf _ 17283 * @since 4.0.0 17284 * @category String 17285 * @param {string} [string=''] The string to trim. 17286 * @param {string} [chars=whitespace] The characters to trim. 17287 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17288 * @returns {string} Returns the trimmed string. 17289 * @example 17290 * 17291 * _.trimStart(' abc '); 17292 * // => 'abc ' 17293 * 17294 * _.trimStart('-_-abc-_-', '_-'); 17295 * // => 'abc-_-' 17296 */ 17297 function trimStart(string, chars, guard) { 17298 string = toString(string); 17299 if (string && (guard || chars === undefined)) { 17300 return string.replace(reTrimStart, ''); 17301 } 17302 if (!string || !(chars = baseToString(chars))) { 17303 return string; 17304 } 17305 var strSymbols = stringToArray(string), 17306 start = charsStartIndex(strSymbols, stringToArray(chars)); 17307 17308 return castSlice(strSymbols, start).join(''); 17309 } 17310 17311 /** 17312 * Truncates `string` if it's longer than the given maximum string length. 17313 * The last characters of the truncated string are replaced with the omission 17314 * string which defaults to "...". 17315 * 17316 * @static 17317 * @memberOf _ 17318 * @since 4.0.0 17319 * @category String 17320 * @param {string} [string=''] The string to truncate. 17321 * @param {Object} [options={}] The options object. 17322 * @param {number} [options.length=30] The maximum string length. 17323 * @param {string} [options.omission='...'] The string to indicate text is omitted. 17324 * @param {RegExp|string} [options.separator] The separator pattern to truncate to. 17325 * @returns {string} Returns the truncated string. 17326 * @example 17327 * 17328 * _.truncate('hi-diddly-ho there, neighborino'); 17329 * // => 'hi-diddly-ho there, neighbo...' 17330 * 17331 * _.truncate('hi-diddly-ho there, neighborino', { 17332 * 'length': 24, 17333 * 'separator': ' ' 17334 * }); 17335 * // => 'hi-diddly-ho there,...' 17336 * 17337 * _.truncate('hi-diddly-ho there, neighborino', { 17338 * 'length': 24, 17339 * 'separator': /,? +/ 17340 * }); 17341 * // => 'hi-diddly-ho there...' 17342 * 17343 * _.truncate('hi-diddly-ho there, neighborino', { 17344 * 'omission': ' [...]' 17345 * }); 17346 * // => 'hi-diddly-ho there, neig [...]' 17347 */ 17348 function truncate(string, options) { 17349 var length = DEFAULT_TRUNC_LENGTH, 17350 omission = DEFAULT_TRUNC_OMISSION; 17351 17352 if (isObject(options)) { 17353 var separator = 'separator' in options ? options.separator : separator; 17354 length = 'length' in options ? toInteger(options.length) : length; 17355 omission = 'omission' in options ? baseToString(options.omission) : omission; 17356 } 17357 string = toString(string); 17358 17359 var strLength = string.length; 17360 if (hasUnicode(string)) { 17361 var strSymbols = stringToArray(string); 17362 strLength = strSymbols.length; 17363 } 17364 if (length >= strLength) { 17365 return string; 17366 } 17367 var end = length - stringSize(omission); 17368 if (end < 1) { 17369 return omission; 17370 } 17371 var result = strSymbols 17372 ? castSlice(strSymbols, 0, end).join('') 17373 : string.slice(0, end); 17374 17375 if (separator === undefined) { 17376 return result + omission; 17377 } 17378 if (strSymbols) { 17379 end += (result.length - end); 17380 } 17381 if (isRegExp(separator)) { 17382 if (string.slice(end).search(separator)) { 17383 var match, 17384 substring = result; 17385 17386 if (!separator.global) { 17387 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); 17388 } 17389 separator.lastIndex = 0; 17390 while ((match = separator.exec(substring))) { 17391 var newEnd = match.index; 17392 } 17393 result = result.slice(0, newEnd === undefined ? end : newEnd); 17394 } 17395 } else if (string.indexOf(baseToString(separator), end) != end) { 17396 var index = result.lastIndexOf(separator); 17397 if (index > -1) { 17398 result = result.slice(0, index); 17399 } 17400 } 17401 return result + omission; 17402 } 17403 17404 /** 17405 * The inverse of `_.escape`; this method converts the HTML entities 17406 * `&`, `<`, `>`, `"`, and `'` in `string` to 17407 * their corresponding characters. 17408 * 17409 * **Note:** No other HTML entities are unescaped. To unescape additional 17410 * HTML entities use a third-party library like [_he_](https://mths.be/he). 17411 * 17412 * @static 17413 * @memberOf _ 17414 * @since 0.6.0 17415 * @category String 17416 * @param {string} [string=''] The string to unescape. 17417 * @returns {string} Returns the unescaped string. 17418 * @example 17419 * 17420 * _.unescape('fred, barney, & pebbles'); 17421 * // => 'fred, barney, & pebbles' 17422 */ 17423 function unescape(string) { 17424 string = toString(string); 17425 return (string && reHasEscapedHtml.test(string)) 17426 ? string.replace(reEscapedHtml, unescapeHtmlChar) 17427 : string; 17428 } 17429 17430 /** 17431 * Converts `string`, as space separated words, to upper case. 17432 * 17433 * @static 17434 * @memberOf _ 17435 * @since 4.0.0 17436 * @category String 17437 * @param {string} [string=''] The string to convert. 17438 * @returns {string} Returns the upper cased string. 17439 * @example 17440 * 17441 * _.upperCase('--foo-bar'); 17442 * // => 'FOO BAR' 17443 * 17444 * _.upperCase('fooBar'); 17445 * // => 'FOO BAR' 17446 * 17447 * _.upperCase('__foo_bar__'); 17448 * // => 'FOO BAR' 17449 */ 17450 var upperCase = createCompounder(function(result, word, index) { 17451 return result + (index ? ' ' : '') + word.toUpperCase(); 17452 }); 17453 17454 /** 17455 * Converts the first character of `string` to upper case. 17456 * 17457 * @static 17458 * @memberOf _ 17459 * @since 4.0.0 17460 * @category String 17461 * @param {string} [string=''] The string to convert. 17462 * @returns {string} Returns the converted string. 17463 * @example 17464 * 17465 * _.upperFirst('fred'); 17466 * // => 'Fred' 17467 * 17468 * _.upperFirst('FRED'); 17469 * // => 'FRED' 17470 */ 17471 var upperFirst = createCaseFirst('toUpperCase'); 17472 17473 /** 17474 * Splits `string` into an array of its words. 17475 * 17476 * @static 17477 * @memberOf _ 17478 * @since 3.0.0 17479 * @category String 17480 * @param {string} [string=''] The string to inspect. 17481 * @param {RegExp|string} [pattern] The pattern to match words. 17482 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 17483 * @returns {Array} Returns the words of `string`. 17484 * @example 17485 * 17486 * _.words('fred, barney, & pebbles'); 17487 * // => ['fred', 'barney', 'pebbles'] 17488 * 17489 * _.words('fred, barney, & pebbles', /[^, ]+/g); 17490 * // => ['fred', 'barney', '&', 'pebbles'] 17491 */ 17492 function words(string, pattern, guard) { 17493 string = toString(string); 17494 pattern = guard ? undefined : pattern; 17495 17496 if (pattern === undefined) { 17497 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); 17498 } 17499 return string.match(pattern) || []; 17500 } 17501 17502 /*------------------------------------------------------------------------*/ 17503 17504 /** 17505 * Attempts to invoke `func`, returning either the result or the caught error 17506 * object. Any additional arguments are provided to `func` when it's invoked. 17507 * 17508 * @static 17509 * @memberOf _ 17510 * @since 3.0.0 17511 * @category Util 17512 * @param {Function} func The function to attempt. 17513 * @param {...*} [args] The arguments to invoke `func` with. 17514 * @returns {*} Returns the `func` result or error object. 17515 * @example 17516 * 17517 * // Avoid throwing errors for invalid selectors. 17518 * var elements = _.attempt(function(selector) { 17519 * return document.querySelectorAll(selector); 17520 * }, '>_>'); 17521 * 17522 * if (_.isError(elements)) { 17523 * elements = []; 17524 * } 17525 */ 17526 var attempt = baseRest(function(func, args) { 17527 try { 17528 return apply(func, undefined, args); 17529 } catch (e) { 17530 return isError(e) ? e : new Error(e); 17531 } 17532 }); 17533 17534 /** 17535 * Binds methods of an object to the object itself, overwriting the existing 17536 * method. 17537 * 17538 * **Note:** This method doesn't set the "length" property of bound functions. 17539 * 17540 * @static 17541 * @since 0.1.0 17542 * @memberOf _ 17543 * @category Util 17544 * @param {Object} object The object to bind and assign the bound methods to. 17545 * @param {...(string|string[])} methodNames The object method names to bind. 17546 * @returns {Object} Returns `object`. 17547 * @example 17548 * 17549 * var view = { 17550 * 'label': 'docs', 17551 * 'click': function() { 17552 * console.log('clicked ' + this.label); 17553 * } 17554 * }; 17555 * 17556 * _.bindAll(view, ['click']); 17557 * jQuery(element).on('click', view.click); 17558 * // => Logs 'clicked docs' when clicked. 17559 */ 17560 var bindAll = flatRest(function(object, methodNames) { 17561 arrayEach(methodNames, function(key) { 17562 key = toKey(key); 17563 baseAssignValue(object, key, bind(object[key], object)); 17564 }); 17565 return object; 17566 }); 17567 17568 /** 17569 * Creates a function that iterates over `pairs` and invokes the corresponding 17570 * function of the first predicate to return truthy. The predicate-function 17571 * pairs are invoked with the `this` binding and arguments of the created 17572 * function. 17573 * 17574 * @static 17575 * @memberOf _ 17576 * @since 4.0.0 17577 * @category Util 17578 * @param {Array} pairs The predicate-function pairs. 17579 * @returns {Function} Returns the new composite function. 17580 * @example 17581 * 17582 * var func = _.cond([ 17583 * [_.matches({ 'a': 1 }), _.constant('matches A')], 17584 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], 17585 * [_.stubTrue, _.constant('no match')] 17586 * ]); 17587 * 17588 * func({ 'a': 1, 'b': 2 }); 17589 * // => 'matches A' 17590 * 17591 * func({ 'a': 0, 'b': 1 }); 17592 * // => 'matches B' 17593 * 17594 * func({ 'a': '1', 'b': '2' }); 17595 * // => 'no match' 17596 */ 17597 function cond(pairs) { 17598 var length = pairs == null ? 0 : pairs.length, 17599 toIteratee = getIteratee(); 17600 17601 pairs = !length ? [] : arrayMap(pairs, function(pair) { 17602 if (typeof pair[1] != 'function') { 17603 throw new TypeError(FUNC_ERROR_TEXT); 17604 } 17605 return [toIteratee(pair[0]), pair[1]]; 17606 }); 17607 17608 return baseRest(function(args) { 17609 var index = -1; 17610 while (++index < length) { 17611 var pair = pairs[index]; 17612 if (apply(pair[0], this, args)) { 17613 return apply(pair[1], this, args); 17614 } 17615 } 17616 }); 17617 } 17618 17619 /** 17620 * Creates a function that invokes the predicate properties of `source` with 17621 * the corresponding property values of a given object, returning `true` if 17622 * all predicates return truthy, else `false`. 17623 * 17624 * **Note:** The created function is equivalent to `_.conformsTo` with 17625 * `source` partially applied. 17626 * 17627 * @static 17628 * @memberOf _ 17629 * @since 4.0.0 17630 * @category Util 17631 * @param {Object} source The object of property predicates to conform to. 17632 * @returns {Function} Returns the new spec function. 17633 * @example 17634 * 17635 * var objects = [ 17636 * { 'a': 2, 'b': 1 }, 17637 * { 'a': 1, 'b': 2 } 17638 * ]; 17639 * 17640 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); 17641 * // => [{ 'a': 1, 'b': 2 }] 17642 */ 17643 function conforms(source) { 17644 return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); 17645 } 17646 17647 /** 17648 * Creates a function that returns `value`. 17649 * 17650 * @static 17651 * @memberOf _ 17652 * @since 2.4.0 17653 * @category Util 17654 * @param {*} value The value to return from the new function. 17655 * @returns {Function} Returns the new constant function. 17656 * @example 17657 * 17658 * var objects = _.times(2, _.constant({ 'a': 1 })); 17659 * 17660 * console.log(objects); 17661 * // => [{ 'a': 1 }, { 'a': 1 }] 17662 * 17663 * console.log(objects[0] === objects[1]); 17664 * // => true 17665 */ 17666 function constant(value) { 17667 return function() { 17668 return value; 17669 }; 17670 } 17671 17672 /** 17673 * Checks `value` to determine whether a default value should be returned in 17674 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, 17675 * or `undefined`. 17676 * 17677 * @static 17678 * @memberOf _ 17679 * @since 4.14.0 17680 * @category Util 17681 * @param {*} value The value to check. 17682 * @param {*} defaultValue The default value. 17683 * @returns {*} Returns the resolved value. 17684 * @example 17685 * 17686 * _.defaultTo(1, 10); 17687 * // => 1 17688 * 17689 * _.defaultTo(undefined, 10); 17690 * // => 10 17691 */ 17692 function defaultTo(value, defaultValue) { 17693 return (value == null || value !== value) ? defaultValue : value; 17694 } 17695 17696 /** 17697 * Creates a function that returns the result of invoking the given functions 17698 * with the `this` binding of the created function, where each successive 17699 * invocation is supplied the return value of the previous. 17700 * 17701 * @static 17702 * @memberOf _ 17703 * @since 3.0.0 17704 * @category Util 17705 * @param {...(Function|Function[])} [funcs] The functions to invoke. 17706 * @returns {Function} Returns the new composite function. 17707 * @see _.flowRight 17708 * @example 17709 * 17710 * function square(n) { 17711 * return n * n; 17712 * } 17713 * 17714 * var addSquare = _.flow([_.add, square]); 17715 * addSquare(1, 2); 17716 * // => 9 17717 */ 17718 var flow = createFlow(); 17719 17720 /** 17721 * This method is like `_.flow` except that it creates a function that 17722 * invokes the given functions from right to left. 17723 * 17724 * @static 17725 * @since 3.0.0 17726 * @memberOf _ 17727 * @category Util 17728 * @param {...(Function|Function[])} [funcs] The functions to invoke. 17729 * @returns {Function} Returns the new composite function. 17730 * @see _.flow 17731 * @example 17732 * 17733 * function square(n) { 17734 * return n * n; 17735 * } 17736 * 17737 * var addSquare = _.flowRight([square, _.add]); 17738 * addSquare(1, 2); 17739 * // => 9 17740 */ 17741 var flowRight = createFlow(true); 17742 17743 /** 17744 * This method returns the first argument it receives. 17745 * 17746 * @static 17747 * @since 0.1.0 17748 * @memberOf _ 17749 * @category Util 17750 * @param {*} value Any value. 17751 * @returns {*} Returns `value`. 17752 * @example 17753 * 17754 * var object = { 'a': 1 }; 17755 * 17756 * console.log(_.identity(object) === object); 17757 * // => true 17758 */ 17759 function identity(value) { 17760 return value; 17761 } 17762 17763 /** 17764 * Creates a function that invokes `func` with the arguments of the created 17765 * function. If `func` is a property name, the created function returns the 17766 * property value for a given element. If `func` is an array or object, the 17767 * created function returns `true` for elements that contain the equivalent 17768 * source properties, otherwise it returns `false`. 17769 * 17770 * @static 17771 * @since 4.0.0 17772 * @memberOf _ 17773 * @category Util 17774 * @param {*} [func=_.identity] The value to convert to a callback. 17775 * @returns {Function} Returns the callback. 17776 * @example 17777 * 17778 * var users = [ 17779 * { 'user': 'barney', 'age': 36, 'active': true }, 17780 * { 'user': 'fred', 'age': 40, 'active': false } 17781 * ]; 17782 * 17783 * // The `_.matches` iteratee shorthand. 17784 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); 17785 * // => [{ 'user': 'barney', 'age': 36, 'active': true }] 17786 * 17787 * // The `_.matchesProperty` iteratee shorthand. 17788 * _.filter(users, _.iteratee(['user', 'fred'])); 17789 * // => [{ 'user': 'fred', 'age': 40 }] 17790 * 17791 * // The `_.property` iteratee shorthand. 17792 * _.map(users, _.iteratee('user')); 17793 * // => ['barney', 'fred'] 17794 * 17795 * // Create custom iteratee shorthands. 17796 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { 17797 * return !_.isRegExp(func) ? iteratee(func) : function(string) { 17798 * return func.test(string); 17799 * }; 17800 * }); 17801 * 17802 * _.filter(['abc', 'def'], /ef/); 17803 * // => ['def'] 17804 */ 17805 function iteratee(func) { 17806 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); 17807 } 17808 17809 /** 17810 * Creates a function that performs a partial deep comparison between a given 17811 * object and `source`, returning `true` if the given object has equivalent 17812 * property values, else `false`. 17813 * 17814 * **Note:** The created function is equivalent to `_.isMatch` with `source` 17815 * partially applied. 17816 * 17817 * Partial comparisons will match empty array and empty object `source` 17818 * values against any array or object value, respectively. See `_.isEqual` 17819 * for a list of supported value comparisons. 17820 * 17821 * **Note:** Multiple values can be checked by combining several matchers 17822 * using `_.overSome` 17823 * 17824 * @static 17825 * @memberOf _ 17826 * @since 3.0.0 17827 * @category Util 17828 * @param {Object} source The object of property values to match. 17829 * @returns {Function} Returns the new spec function. 17830 * @example 17831 * 17832 * var objects = [ 17833 * { 'a': 1, 'b': 2, 'c': 3 }, 17834 * { 'a': 4, 'b': 5, 'c': 6 } 17835 * ]; 17836 * 17837 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); 17838 * // => [{ 'a': 4, 'b': 5, 'c': 6 }] 17839 * 17840 * // Checking for several possible values 17841 * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); 17842 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 17843 */ 17844 function matches(source) { 17845 return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); 17846 } 17847 17848 /** 17849 * Creates a function that performs a partial deep comparison between the 17850 * value at `path` of a given object to `srcValue`, returning `true` if the 17851 * object value is equivalent, else `false`. 17852 * 17853 * **Note:** Partial comparisons will match empty array and empty object 17854 * `srcValue` values against any array or object value, respectively. See 17855 * `_.isEqual` for a list of supported value comparisons. 17856 * 17857 * **Note:** Multiple values can be checked by combining several matchers 17858 * using `_.overSome` 17859 * 17860 * @static 17861 * @memberOf _ 17862 * @since 3.2.0 17863 * @category Util 17864 * @param {Array|string} path The path of the property to get. 17865 * @param {*} srcValue The value to match. 17866 * @returns {Function} Returns the new spec function. 17867 * @example 17868 * 17869 * var objects = [ 17870 * { 'a': 1, 'b': 2, 'c': 3 }, 17871 * { 'a': 4, 'b': 5, 'c': 6 } 17872 * ]; 17873 * 17874 * _.find(objects, _.matchesProperty('a', 4)); 17875 * // => { 'a': 4, 'b': 5, 'c': 6 } 17876 * 17877 * // Checking for several possible values 17878 * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)])); 17879 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 17880 */ 17881 function matchesProperty(path, srcValue) { 17882 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); 17883 } 17884 17885 /** 17886 * Creates a function that invokes the method at `path` of a given object. 17887 * Any additional arguments are provided to the invoked method. 17888 * 17889 * @static 17890 * @memberOf _ 17891 * @since 3.7.0 17892 * @category Util 17893 * @param {Array|string} path The path of the method to invoke. 17894 * @param {...*} [args] The arguments to invoke the method with. 17895 * @returns {Function} Returns the new invoker function. 17896 * @example 17897 * 17898 * var objects = [ 17899 * { 'a': { 'b': _.constant(2) } }, 17900 * { 'a': { 'b': _.constant(1) } } 17901 * ]; 17902 * 17903 * _.map(objects, _.method('a.b')); 17904 * // => [2, 1] 17905 * 17906 * _.map(objects, _.method(['a', 'b'])); 17907 * // => [2, 1] 17908 */ 17909 var method = baseRest(function(path, args) { 17910 return function(object) { 17911 return baseInvoke(object, path, args); 17912 }; 17913 }); 17914 17915 /** 17916 * The opposite of `_.method`; this method creates a function that invokes 17917 * the method at a given path of `object`. Any additional arguments are 17918 * provided to the invoked method. 17919 * 17920 * @static 17921 * @memberOf _ 17922 * @since 3.7.0 17923 * @category Util 17924 * @param {Object} object The object to query. 17925 * @param {...*} [args] The arguments to invoke the method with. 17926 * @returns {Function} Returns the new invoker function. 17927 * @example 17928 * 17929 * var array = _.times(3, _.constant), 17930 * object = { 'a': array, 'b': array, 'c': array }; 17931 * 17932 * _.map(['a[2]', 'c[0]'], _.methodOf(object)); 17933 * // => [2, 0] 17934 * 17935 * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); 17936 * // => [2, 0] 17937 */ 17938 var methodOf = baseRest(function(object, args) { 17939 return function(path) { 17940 return baseInvoke(object, path, args); 17941 }; 17942 }); 17943 17944 /** 17945 * Adds all own enumerable string keyed function properties of a source 17946 * object to the destination object. If `object` is a function, then methods 17947 * are added to its prototype as well. 17948 * 17949 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to 17950 * avoid conflicts caused by modifying the original. 17951 * 17952 * @static 17953 * @since 0.1.0 17954 * @memberOf _ 17955 * @category Util 17956 * @param {Function|Object} [object=lodash] The destination object. 17957 * @param {Object} source The object of functions to add. 17958 * @param {Object} [options={}] The options object. 17959 * @param {boolean} [options.chain=true] Specify whether mixins are chainable. 17960 * @returns {Function|Object} Returns `object`. 17961 * @example 17962 * 17963 * function vowels(string) { 17964 * return _.filter(string, function(v) { 17965 * return /[aeiou]/i.test(v); 17966 * }); 17967 * } 17968 * 17969 * _.mixin({ 'vowels': vowels }); 17970 * _.vowels('fred'); 17971 * // => ['e'] 17972 * 17973 * _('fred').vowels().value(); 17974 * // => ['e'] 17975 * 17976 * _.mixin({ 'vowels': vowels }, { 'chain': false }); 17977 * _('fred').vowels(); 17978 * // => ['e'] 17979 */ 17980 function mixin(object, source, options) { 17981 var props = keys(source), 17982 methodNames = baseFunctions(source, props); 17983 17984 if (options == null && 17985 !(isObject(source) && (methodNames.length || !props.length))) { 17986 options = source; 17987 source = object; 17988 object = this; 17989 methodNames = baseFunctions(source, keys(source)); 17990 } 17991 var chain = !(isObject(options) && 'chain' in options) || !!options.chain, 17992 isFunc = isFunction(object); 17993 17994 arrayEach(methodNames, function(methodName) { 17995 var func = source[methodName]; 17996 object[methodName] = func; 17997 if (isFunc) { 17998 object.prototype[methodName] = function() { 17999 var chainAll = this.__chain__; 18000 if (chain || chainAll) { 18001 var result = object(this.__wrapped__), 18002 actions = result.__actions__ = copyArray(this.__actions__); 18003 18004 actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); 18005 result.__chain__ = chainAll; 18006 return result; 18007 } 18008 return func.apply(object, arrayPush([this.value()], arguments)); 18009 }; 18010 } 18011 }); 18012 18013 return object; 18014 } 18015 18016 /** 18017 * Reverts the `_` variable to its previous value and returns a reference to 18018 * the `lodash` function. 18019 * 18020 * @static 18021 * @since 0.1.0 18022 * @memberOf _ 18023 * @category Util 18024 * @returns {Function} Returns the `lodash` function. 18025 * @example 18026 * 18027 * var lodash = _.noConflict(); 18028 */ 18029 function noConflict() { 18030 if (root._ === this) { 18031 root._ = oldDash; 18032 } 18033 return this; 18034 } 18035 18036 /** 18037 * This method returns `undefined`. 18038 * 18039 * @static 18040 * @memberOf _ 18041 * @since 2.3.0 18042 * @category Util 18043 * @example 18044 * 18045 * _.times(2, _.noop); 18046 * // => [undefined, undefined] 18047 */ 18048 function noop() { 18049 // No operation performed. 18050 } 18051 18052 /** 18053 * Creates a function that gets the argument at index `n`. If `n` is negative, 18054 * the nth argument from the end is returned. 18055 * 18056 * @static 18057 * @memberOf _ 18058 * @since 4.0.0 18059 * @category Util 18060 * @param {number} [n=0] The index of the argument to return. 18061 * @returns {Function} Returns the new pass-thru function. 18062 * @example 18063 * 18064 * var func = _.nthArg(1); 18065 * func('a', 'b', 'c', 'd'); 18066 * // => 'b' 18067 * 18068 * var func = _.nthArg(-2); 18069 * func('a', 'b', 'c', 'd'); 18070 * // => 'c' 18071 */ 18072 function nthArg(n) { 18073 n = toInteger(n); 18074 return baseRest(function(args) { 18075 return baseNth(args, n); 18076 }); 18077 } 18078 18079 /** 18080 * Creates a function that invokes `iteratees` with the arguments it receives 18081 * and returns their results. 18082 * 18083 * @static 18084 * @memberOf _ 18085 * @since 4.0.0 18086 * @category Util 18087 * @param {...(Function|Function[])} [iteratees=[_.identity]] 18088 * The iteratees to invoke. 18089 * @returns {Function} Returns the new function. 18090 * @example 18091 * 18092 * var func = _.over([Math.max, Math.min]); 18093 * 18094 * func(1, 2, 3, 4); 18095 * // => [4, 1] 18096 */ 18097 var over = createOver(arrayMap); 18098 18099 /** 18100 * Creates a function that checks if **all** of the `predicates` return 18101 * truthy when invoked with the arguments it receives. 18102 * 18103 * Following shorthands are possible for providing predicates. 18104 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 18105 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 18106 * 18107 * @static 18108 * @memberOf _ 18109 * @since 4.0.0 18110 * @category Util 18111 * @param {...(Function|Function[])} [predicates=[_.identity]] 18112 * The predicates to check. 18113 * @returns {Function} Returns the new function. 18114 * @example 18115 * 18116 * var func = _.overEvery([Boolean, isFinite]); 18117 * 18118 * func('1'); 18119 * // => true 18120 * 18121 * func(null); 18122 * // => false 18123 * 18124 * func(NaN); 18125 * // => false 18126 */ 18127 var overEvery = createOver(arrayEvery); 18128 18129 /** 18130 * Creates a function that checks if **any** of the `predicates` return 18131 * truthy when invoked with the arguments it receives. 18132 * 18133 * Following shorthands are possible for providing predicates. 18134 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 18135 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 18136 * 18137 * @static 18138 * @memberOf _ 18139 * @since 4.0.0 18140 * @category Util 18141 * @param {...(Function|Function[])} [predicates=[_.identity]] 18142 * The predicates to check. 18143 * @returns {Function} Returns the new function. 18144 * @example 18145 * 18146 * var func = _.overSome([Boolean, isFinite]); 18147 * 18148 * func('1'); 18149 * // => true 18150 * 18151 * func(null); 18152 * // => true 18153 * 18154 * func(NaN); 18155 * // => false 18156 * 18157 * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }]) 18158 * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]]) 18159 */ 18160 var overSome = createOver(arraySome); 18161 18162 /** 18163 * Creates a function that returns the value at `path` of a given object. 18164 * 18165 * @static 18166 * @memberOf _ 18167 * @since 2.4.0 18168 * @category Util 18169 * @param {Array|string} path The path of the property to get. 18170 * @returns {Function} Returns the new accessor function. 18171 * @example 18172 * 18173 * var objects = [ 18174 * { 'a': { 'b': 2 } }, 18175 * { 'a': { 'b': 1 } } 18176 * ]; 18177 * 18178 * _.map(objects, _.property('a.b')); 18179 * // => [2, 1] 18180 * 18181 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); 18182 * // => [1, 2] 18183 */ 18184 function property(path) { 18185 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); 18186 } 18187 18188 /** 18189 * The opposite of `_.property`; this method creates a function that returns 18190 * the value at a given path of `object`. 18191 * 18192 * @static 18193 * @memberOf _ 18194 * @since 3.0.0 18195 * @category Util 18196 * @param {Object} object The object to query. 18197 * @returns {Function} Returns the new accessor function. 18198 * @example 18199 * 18200 * var array = [0, 1, 2], 18201 * object = { 'a': array, 'b': array, 'c': array }; 18202 * 18203 * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); 18204 * // => [2, 0] 18205 * 18206 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); 18207 * // => [2, 0] 18208 */ 18209 function propertyOf(object) { 18210 return function(path) { 18211 return object == null ? undefined : baseGet(object, path); 18212 }; 18213 } 18214 18215 /** 18216 * Creates an array of numbers (positive and/or negative) progressing from 18217 * `start` up to, but not including, `end`. A step of `-1` is used if a negative 18218 * `start` is specified without an `end` or `step`. If `end` is not specified, 18219 * it's set to `start` with `start` then set to `0`. 18220 * 18221 * **Note:** JavaScript follows the IEEE-754 standard for resolving 18222 * floating-point values which can produce unexpected results. 18223 * 18224 * @static 18225 * @since 0.1.0 18226 * @memberOf _ 18227 * @category Util 18228 * @param {number} [start=0] The start of the range. 18229 * @param {number} end The end of the range. 18230 * @param {number} [step=1] The value to increment or decrement by. 18231 * @returns {Array} Returns the range of numbers. 18232 * @see _.inRange, _.rangeRight 18233 * @example 18234 * 18235 * _.range(4); 18236 * // => [0, 1, 2, 3] 18237 * 18238 * _.range(-4); 18239 * // => [0, -1, -2, -3] 18240 * 18241 * _.range(1, 5); 18242 * // => [1, 2, 3, 4] 18243 * 18244 * _.range(0, 20, 5); 18245 * // => [0, 5, 10, 15] 18246 * 18247 * _.range(0, -4, -1); 18248 * // => [0, -1, -2, -3] 18249 * 18250 * _.range(1, 4, 0); 18251 * // => [1, 1, 1] 18252 * 18253 * _.range(0); 18254 * // => [] 18255 */ 18256 var range = createRange(); 18257 18258 /** 18259 * This method is like `_.range` except that it populates values in 18260 * descending order. 18261 * 18262 * @static 18263 * @memberOf _ 18264 * @since 4.0.0 18265 * @category Util 18266 * @param {number} [start=0] The start of the range. 18267 * @param {number} end The end of the range. 18268 * @param {number} [step=1] The value to increment or decrement by. 18269 * @returns {Array} Returns the range of numbers. 18270 * @see _.inRange, _.range 18271 * @example 18272 * 18273 * _.rangeRight(4); 18274 * // => [3, 2, 1, 0] 18275 * 18276 * _.rangeRight(-4); 18277 * // => [-3, -2, -1, 0] 18278 * 18279 * _.rangeRight(1, 5); 18280 * // => [4, 3, 2, 1] 18281 * 18282 * _.rangeRight(0, 20, 5); 18283 * // => [15, 10, 5, 0] 18284 * 18285 * _.rangeRight(0, -4, -1); 18286 * // => [-3, -2, -1, 0] 18287 * 18288 * _.rangeRight(1, 4, 0); 18289 * // => [1, 1, 1] 18290 * 18291 * _.rangeRight(0); 18292 * // => [] 18293 */ 18294 var rangeRight = createRange(true); 18295 18296 /** 18297 * This method returns a new empty array. 18298 * 18299 * @static 18300 * @memberOf _ 18301 * @since 4.13.0 18302 * @category Util 18303 * @returns {Array} Returns the new empty array. 18304 * @example 18305 * 18306 * var arrays = _.times(2, _.stubArray); 18307 * 18308 * console.log(arrays); 18309 * // => [[], []] 18310 * 18311 * console.log(arrays[0] === arrays[1]); 18312 * // => false 18313 */ 18314 function stubArray() { 18315 return []; 18316 } 18317 18318 /** 18319 * This method returns `false`. 18320 * 18321 * @static 18322 * @memberOf _ 18323 * @since 4.13.0 18324 * @category Util 18325 * @returns {boolean} Returns `false`. 18326 * @example 18327 * 18328 * _.times(2, _.stubFalse); 18329 * // => [false, false] 18330 */ 18331 function stubFalse() { 18332 return false; 18333 } 18334 18335 /** 18336 * This method returns a new empty object. 18337 * 18338 * @static 18339 * @memberOf _ 18340 * @since 4.13.0 18341 * @category Util 18342 * @returns {Object} Returns the new empty object. 18343 * @example 18344 * 18345 * var objects = _.times(2, _.stubObject); 18346 * 18347 * console.log(objects); 18348 * // => [{}, {}] 18349 * 18350 * console.log(objects[0] === objects[1]); 18351 * // => false 18352 */ 18353 function stubObject() { 18354 return {}; 18355 } 18356 18357 /** 18358 * This method returns an empty string. 18359 * 18360 * @static 18361 * @memberOf _ 18362 * @since 4.13.0 18363 * @category Util 18364 * @returns {string} Returns the empty string. 18365 * @example 18366 * 18367 * _.times(2, _.stubString); 18368 * // => ['', ''] 18369 */ 18370 function stubString() { 18371 return ''; 18372 } 18373 18374 /** 18375 * This method returns `true`. 18376 * 18377 * @static 18378 * @memberOf _ 18379 * @since 4.13.0 18380 * @category Util 18381 * @returns {boolean} Returns `true`. 18382 * @example 18383 * 18384 * _.times(2, _.stubTrue); 18385 * // => [true, true] 18386 */ 18387 function stubTrue() { 18388 return true; 18389 } 18390 18391 /** 18392 * Invokes the iteratee `n` times, returning an array of the results of 18393 * each invocation. The iteratee is invoked with one argument; (index). 18394 * 18395 * @static 18396 * @since 0.1.0 18397 * @memberOf _ 18398 * @category Util 18399 * @param {number} n The number of times to invoke `iteratee`. 18400 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 18401 * @returns {Array} Returns the array of results. 18402 * @example 18403 * 18404 * _.times(3, String); 18405 * // => ['0', '1', '2'] 18406 * 18407 * _.times(4, _.constant(0)); 18408 * // => [0, 0, 0, 0] 18409 */ 18410 function times(n, iteratee) { 18411 n = toInteger(n); 18412 if (n < 1 || n > MAX_SAFE_INTEGER) { 18413 return []; 18414 } 18415 var index = MAX_ARRAY_LENGTH, 18416 length = nativeMin(n, MAX_ARRAY_LENGTH); 18417 18418 iteratee = getIteratee(iteratee); 18419 n -= MAX_ARRAY_LENGTH; 18420 18421 var result = baseTimes(length, iteratee); 18422 while (++index < n) { 18423 iteratee(index); 18424 } 18425 return result; 18426 } 18427 18428 /** 18429 * Converts `value` to a property path array. 18430 * 18431 * @static 18432 * @memberOf _ 18433 * @since 4.0.0 18434 * @category Util 18435 * @param {*} value The value to convert. 18436 * @returns {Array} Returns the new property path array. 18437 * @example 18438 * 18439 * _.toPath('a.b.c'); 18440 * // => ['a', 'b', 'c'] 18441 * 18442 * _.toPath('a[0].b.c'); 18443 * // => ['a', '0', 'b', 'c'] 18444 */ 18445 function toPath(value) { 18446 if (isArray(value)) { 18447 return arrayMap(value, toKey); 18448 } 18449 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); 18450 } 18451 18452 /** 18453 * Generates a unique ID. If `prefix` is given, the ID is appended to it. 18454 * 18455 * @static 18456 * @since 0.1.0 18457 * @memberOf _ 18458 * @category Util 18459 * @param {string} [prefix=''] The value to prefix the ID with. 18460 * @returns {string} Returns the unique ID. 18461 * @example 18462 * 18463 * _.uniqueId('contact_'); 18464 * // => 'contact_104' 18465 * 18466 * _.uniqueId(); 18467 * // => '105' 18468 */ 18469 function uniqueId(prefix) { 18470 var id = ++idCounter; 18471 return toString(prefix) + id; 18472 } 18473 18474 /*------------------------------------------------------------------------*/ 18475 18476 /** 18477 * Adds two numbers. 18478 * 18479 * @static 18480 * @memberOf _ 18481 * @since 3.4.0 18482 * @category Math 18483 * @param {number} augend The first number in an addition. 18484 * @param {number} addend The second number in an addition. 18485 * @returns {number} Returns the total. 18486 * @example 18487 * 18488 * _.add(6, 4); 18489 * // => 10 18490 */ 18491 var add = createMathOperation(function(augend, addend) { 18492 return augend + addend; 18493 }, 0); 18494 18495 /** 18496 * Computes `number` rounded up to `precision`. 18497 * 18498 * @static 18499 * @memberOf _ 18500 * @since 3.10.0 18501 * @category Math 18502 * @param {number} number The number to round up. 18503 * @param {number} [precision=0] The precision to round up to. 18504 * @returns {number} Returns the rounded up number. 18505 * @example 18506 * 18507 * _.ceil(4.006); 18508 * // => 5 18509 * 18510 * _.ceil(6.004, 2); 18511 * // => 6.01 18512 * 18513 * _.ceil(6040, -2); 18514 * // => 6100 18515 */ 18516 var ceil = createRound('ceil'); 18517 18518 /** 18519 * Divide two numbers. 18520 * 18521 * @static 18522 * @memberOf _ 18523 * @since 4.7.0 18524 * @category Math 18525 * @param {number} dividend The first number in a division. 18526 * @param {number} divisor The second number in a division. 18527 * @returns {number} Returns the quotient. 18528 * @example 18529 * 18530 * _.divide(6, 4); 18531 * // => 1.5 18532 */ 18533 var divide = createMathOperation(function(dividend, divisor) { 18534 return dividend / divisor; 18535 }, 1); 18536 18537 /** 18538 * Computes `number` rounded down to `precision`. 18539 * 18540 * @static 18541 * @memberOf _ 18542 * @since 3.10.0 18543 * @category Math 18544 * @param {number} number The number to round down. 18545 * @param {number} [precision=0] The precision to round down to. 18546 * @returns {number} Returns the rounded down number. 18547 * @example 18548 * 18549 * _.floor(4.006); 18550 * // => 4 18551 * 18552 * _.floor(0.046, 2); 18553 * // => 0.04 18554 * 18555 * _.floor(4060, -2); 18556 * // => 4000 18557 */ 18558 var floor = createRound('floor'); 18559 18560 /** 18561 * Computes the maximum value of `array`. If `array` is empty or falsey, 18562 * `undefined` is returned. 18563 * 18564 * @static 18565 * @since 0.1.0 18566 * @memberOf _ 18567 * @category Math 18568 * @param {Array} array The array to iterate over. 18569 * @returns {*} Returns the maximum value. 18570 * @example 18571 * 18572 * _.max([4, 2, 8, 6]); 18573 * // => 8 18574 * 18575 * _.max([]); 18576 * // => undefined 18577 */ 18578 function max(array) { 18579 return (array && array.length) 18580 ? baseExtremum(array, identity, baseGt) 18581 : undefined; 18582 } 18583 18584 /** 18585 * This method is like `_.max` except that it accepts `iteratee` which is 18586 * invoked for each element in `array` to generate the criterion by which 18587 * the value is ranked. The iteratee is invoked with one argument: (value). 18588 * 18589 * @static 18590 * @memberOf _ 18591 * @since 4.0.0 18592 * @category Math 18593 * @param {Array} array The array to iterate over. 18594 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18595 * @returns {*} Returns the maximum value. 18596 * @example 18597 * 18598 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 18599 * 18600 * _.maxBy(objects, function(o) { return o.n; }); 18601 * // => { 'n': 2 } 18602 * 18603 * // The `_.property` iteratee shorthand. 18604 * _.maxBy(objects, 'n'); 18605 * // => { 'n': 2 } 18606 */ 18607 function maxBy(array, iteratee) { 18608 return (array && array.length) 18609 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) 18610 : undefined; 18611 } 18612 18613 /** 18614 * Computes the mean of the values in `array`. 18615 * 18616 * @static 18617 * @memberOf _ 18618 * @since 4.0.0 18619 * @category Math 18620 * @param {Array} array The array to iterate over. 18621 * @returns {number} Returns the mean. 18622 * @example 18623 * 18624 * _.mean([4, 2, 8, 6]); 18625 * // => 5 18626 */ 18627 function mean(array) { 18628 return baseMean(array, identity); 18629 } 18630 18631 /** 18632 * This method is like `_.mean` except that it accepts `iteratee` which is 18633 * invoked for each element in `array` to generate the value to be averaged. 18634 * The iteratee is invoked with one argument: (value). 18635 * 18636 * @static 18637 * @memberOf _ 18638 * @since 4.7.0 18639 * @category Math 18640 * @param {Array} array The array to iterate over. 18641 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18642 * @returns {number} Returns the mean. 18643 * @example 18644 * 18645 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 18646 * 18647 * _.meanBy(objects, function(o) { return o.n; }); 18648 * // => 5 18649 * 18650 * // The `_.property` iteratee shorthand. 18651 * _.meanBy(objects, 'n'); 18652 * // => 5 18653 */ 18654 function meanBy(array, iteratee) { 18655 return baseMean(array, getIteratee(iteratee, 2)); 18656 } 18657 18658 /** 18659 * Computes the minimum value of `array`. If `array` is empty or falsey, 18660 * `undefined` is returned. 18661 * 18662 * @static 18663 * @since 0.1.0 18664 * @memberOf _ 18665 * @category Math 18666 * @param {Array} array The array to iterate over. 18667 * @returns {*} Returns the minimum value. 18668 * @example 18669 * 18670 * _.min([4, 2, 8, 6]); 18671 * // => 2 18672 * 18673 * _.min([]); 18674 * // => undefined 18675 */ 18676 function min(array) { 18677 return (array && array.length) 18678 ? baseExtremum(array, identity, baseLt) 18679 : undefined; 18680 } 18681 18682 /** 18683 * This method is like `_.min` except that it accepts `iteratee` which is 18684 * invoked for each element in `array` to generate the criterion by which 18685 * the value is ranked. The iteratee is invoked with one argument: (value). 18686 * 18687 * @static 18688 * @memberOf _ 18689 * @since 4.0.0 18690 * @category Math 18691 * @param {Array} array The array to iterate over. 18692 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18693 * @returns {*} Returns the minimum value. 18694 * @example 18695 * 18696 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 18697 * 18698 * _.minBy(objects, function(o) { return o.n; }); 18699 * // => { 'n': 1 } 18700 * 18701 * // The `_.property` iteratee shorthand. 18702 * _.minBy(objects, 'n'); 18703 * // => { 'n': 1 } 18704 */ 18705 function minBy(array, iteratee) { 18706 return (array && array.length) 18707 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) 18708 : undefined; 18709 } 18710 18711 /** 18712 * Multiply two numbers. 18713 * 18714 * @static 18715 * @memberOf _ 18716 * @since 4.7.0 18717 * @category Math 18718 * @param {number} multiplier The first number in a multiplication. 18719 * @param {number} multiplicand The second number in a multiplication. 18720 * @returns {number} Returns the product. 18721 * @example 18722 * 18723 * _.multiply(6, 4); 18724 * // => 24 18725 */ 18726 var multiply = createMathOperation(function(multiplier, multiplicand) { 18727 return multiplier * multiplicand; 18728 }, 1); 18729 18730 /** 18731 * Computes `number` rounded to `precision`. 18732 * 18733 * @static 18734 * @memberOf _ 18735 * @since 3.10.0 18736 * @category Math 18737 * @param {number} number The number to round. 18738 * @param {number} [precision=0] The precision to round to. 18739 * @returns {number} Returns the rounded number. 18740 * @example 18741 * 18742 * _.round(4.006); 18743 * // => 4 18744 * 18745 * _.round(4.006, 2); 18746 * // => 4.01 18747 * 18748 * _.round(4060, -2); 18749 * // => 4100 18750 */ 18751 var round = createRound('round'); 18752 18753 /** 18754 * Subtract two numbers. 18755 * 18756 * @static 18757 * @memberOf _ 18758 * @since 4.0.0 18759 * @category Math 18760 * @param {number} minuend The first number in a subtraction. 18761 * @param {number} subtrahend The second number in a subtraction. 18762 * @returns {number} Returns the difference. 18763 * @example 18764 * 18765 * _.subtract(6, 4); 18766 * // => 2 18767 */ 18768 var subtract = createMathOperation(function(minuend, subtrahend) { 18769 return minuend - subtrahend; 18770 }, 0); 18771 18772 /** 18773 * Computes the sum of the values in `array`. 18774 * 18775 * @static 18776 * @memberOf _ 18777 * @since 3.4.0 18778 * @category Math 18779 * @param {Array} array The array to iterate over. 18780 * @returns {number} Returns the sum. 18781 * @example 18782 * 18783 * _.sum([4, 2, 8, 6]); 18784 * // => 20 18785 */ 18786 function sum(array) { 18787 return (array && array.length) 18788 ? baseSum(array, identity) 18789 : 0; 18790 } 18791 18792 /** 18793 * This method is like `_.sum` except that it accepts `iteratee` which is 18794 * invoked for each element in `array` to generate the value to be summed. 18795 * The iteratee is invoked with one argument: (value). 18796 * 18797 * @static 18798 * @memberOf _ 18799 * @since 4.0.0 18800 * @category Math 18801 * @param {Array} array The array to iterate over. 18802 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18803 * @returns {number} Returns the sum. 18804 * @example 18805 * 18806 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 18807 * 18808 * _.sumBy(objects, function(o) { return o.n; }); 18809 * // => 20 18810 * 18811 * // The `_.property` iteratee shorthand. 18812 * _.sumBy(objects, 'n'); 18813 * // => 20 18814 */ 18815 function sumBy(array, iteratee) { 18816 return (array && array.length) 18817 ? baseSum(array, getIteratee(iteratee, 2)) 18818 : 0; 18819 } 18820 18821 /*------------------------------------------------------------------------*/ 18822 18823 // Add methods that return wrapped values in chain sequences. 18824 lodash.after = after; 18825 lodash.ary = ary; 18826 lodash.assign = assign; 18827 lodash.assignIn = assignIn; 18828 lodash.assignInWith = assignInWith; 18829 lodash.assignWith = assignWith; 18830 lodash.at = at; 18831 lodash.before = before; 18832 lodash.bind = bind; 18833 lodash.bindAll = bindAll; 18834 lodash.bindKey = bindKey; 18835 lodash.castArray = castArray; 18836 lodash.chain = chain; 18837 lodash.chunk = chunk; 18838 lodash.compact = compact; 18839 lodash.concat = concat; 18840 lodash.cond = cond; 18841 lodash.conforms = conforms; 18842 lodash.constant = constant; 18843 lodash.countBy = countBy; 18844 lodash.create = create; 18845 lodash.curry = curry; 18846 lodash.curryRight = curryRight; 18847 lodash.debounce = debounce; 18848 lodash.defaults = defaults; 18849 lodash.defaultsDeep = defaultsDeep; 18850 lodash.defer = defer; 18851 lodash.delay = delay; 18852 lodash.difference = difference; 18853 lodash.differenceBy = differenceBy; 18854 lodash.differenceWith = differenceWith; 18855 lodash.drop = drop; 18856 lodash.dropRight = dropRight; 18857 lodash.dropRightWhile = dropRightWhile; 18858 lodash.dropWhile = dropWhile; 18859 lodash.fill = fill; 18860 lodash.filter = filter; 18861 lodash.flatMap = flatMap; 18862 lodash.flatMapDeep = flatMapDeep; 18863 lodash.flatMapDepth = flatMapDepth; 18864 lodash.flatten = flatten; 18865 lodash.flattenDeep = flattenDeep; 18866 lodash.flattenDepth = flattenDepth; 18867 lodash.flip = flip; 18868 lodash.flow = flow; 18869 lodash.flowRight = flowRight; 18870 lodash.fromPairs = fromPairs; 18871 lodash.functions = functions; 18872 lodash.functionsIn = functionsIn; 18873 lodash.groupBy = groupBy; 18874 lodash.initial = initial; 18875 lodash.intersection = intersection; 18876 lodash.intersectionBy = intersectionBy; 18877 lodash.intersectionWith = intersectionWith; 18878 lodash.invert = invert; 18879 lodash.invertBy = invertBy; 18880 lodash.invokeMap = invokeMap; 18881 lodash.iteratee = iteratee; 18882 lodash.keyBy = keyBy; 18883 lodash.keys = keys; 18884 lodash.keysIn = keysIn; 18885 lodash.map = map; 18886 lodash.mapKeys = mapKeys; 18887 lodash.mapValues = mapValues; 18888 lodash.matches = matches; 18889 lodash.matchesProperty = matchesProperty; 18890 lodash.memoize = memoize; 18891 lodash.merge = merge; 18892 lodash.mergeWith = mergeWith; 18893 lodash.method = method; 18894 lodash.methodOf = methodOf; 18895 lodash.mixin = mixin; 18896 lodash.negate = negate; 18897 lodash.nthArg = nthArg; 18898 lodash.omit = omit; 18899 lodash.omitBy = omitBy; 18900 lodash.once = once; 18901 lodash.orderBy = orderBy; 18902 lodash.over = over; 18903 lodash.overArgs = overArgs; 18904 lodash.overEvery = overEvery; 18905 lodash.overSome = overSome; 18906 lodash.partial = partial; 18907 lodash.partialRight = partialRight; 18908 lodash.partition = partition; 18909 lodash.pick = pick; 18910 lodash.pickBy = pickBy; 18911 lodash.property = property; 18912 lodash.propertyOf = propertyOf; 18913 lodash.pull = pull; 18914 lodash.pullAll = pullAll; 18915 lodash.pullAllBy = pullAllBy; 18916 lodash.pullAllWith = pullAllWith; 18917 lodash.pullAt = pullAt; 18918 lodash.range = range; 18919 lodash.rangeRight = rangeRight; 18920 lodash.rearg = rearg; 18921 lodash.reject = reject; 18922 lodash.remove = remove; 18923 lodash.rest = rest; 18924 lodash.reverse = reverse; 18925 lodash.sampleSize = sampleSize; 18926 lodash.set = set; 18927 lodash.setWith = setWith; 18928 lodash.shuffle = shuffle; 18929 lodash.slice = slice; 18930 lodash.sortBy = sortBy; 18931 lodash.sortedUniq = sortedUniq; 18932 lodash.sortedUniqBy = sortedUniqBy; 18933 lodash.split = split; 18934 lodash.spread = spread; 18935 lodash.tail = tail; 18936 lodash.take = take; 18937 lodash.takeRight = takeRight; 18938 lodash.takeRightWhile = takeRightWhile; 18939 lodash.takeWhile = takeWhile; 18940 lodash.tap = tap; 18941 lodash.throttle = throttle; 18942 lodash.thru = thru; 18943 lodash.toArray = toArray; 18944 lodash.toPairs = toPairs; 18945 lodash.toPairsIn = toPairsIn; 18946 lodash.toPath = toPath; 18947 lodash.toPlainObject = toPlainObject; 18948 lodash.transform = transform; 18949 lodash.unary = unary; 18950 lodash.union = union; 18951 lodash.unionBy = unionBy; 18952 lodash.unionWith = unionWith; 18953 lodash.uniq = uniq; 18954 lodash.uniqBy = uniqBy; 18955 lodash.uniqWith = uniqWith; 18956 lodash.unset = unset; 18957 lodash.unzip = unzip; 18958 lodash.unzipWith = unzipWith; 18959 lodash.update = update; 18960 lodash.updateWith = updateWith; 18961 lodash.values = values; 18962 lodash.valuesIn = valuesIn; 18963 lodash.without = without; 18964 lodash.words = words; 18965 lodash.wrap = wrap; 18966 lodash.xor = xor; 18967 lodash.xorBy = xorBy; 18968 lodash.xorWith = xorWith; 18969 lodash.zip = zip; 18970 lodash.zipObject = zipObject; 18971 lodash.zipObjectDeep = zipObjectDeep; 18972 lodash.zipWith = zipWith; 18973 18974 // Add aliases. 18975 lodash.entries = toPairs; 18976 lodash.entriesIn = toPairsIn; 18977 lodash.extend = assignIn; 18978 lodash.extendWith = assignInWith; 18979 18980 // Add methods to `lodash.prototype`. 18981 mixin(lodash, lodash); 18982 18983 /*------------------------------------------------------------------------*/ 18984 18985 // Add methods that return unwrapped values in chain sequences. 18986 lodash.add = add; 18987 lodash.attempt = attempt; 18988 lodash.camelCase = camelCase; 18989 lodash.capitalize = capitalize; 18990 lodash.ceil = ceil; 18991 lodash.clamp = clamp; 18992 lodash.clone = clone; 18993 lodash.cloneDeep = cloneDeep; 18994 lodash.cloneDeepWith = cloneDeepWith; 18995 lodash.cloneWith = cloneWith; 18996 lodash.conformsTo = conformsTo; 18997 lodash.deburr = deburr; 18998 lodash.defaultTo = defaultTo; 18999 lodash.divide = divide; 19000 lodash.endsWith = endsWith; 19001 lodash.eq = eq; 19002 lodash.escape = escape; 19003 lodash.escapeRegExp = escapeRegExp; 19004 lodash.every = every; 19005 lodash.find = find; 19006 lodash.findIndex = findIndex; 19007 lodash.findKey = findKey; 19008 lodash.findLast = findLast; 19009 lodash.findLastIndex = findLastIndex; 19010 lodash.findLastKey = findLastKey; 19011 lodash.floor = floor; 19012 lodash.forEach = forEach; 19013 lodash.forEachRight = forEachRight; 19014 lodash.forIn = forIn; 19015 lodash.forInRight = forInRight; 19016 lodash.forOwn = forOwn; 19017 lodash.forOwnRight = forOwnRight; 19018 lodash.get = get; 19019 lodash.gt = gt; 19020 lodash.gte = gte; 19021 lodash.has = has; 19022 lodash.hasIn = hasIn; 19023 lodash.head = head; 19024 lodash.identity = identity; 19025 lodash.includes = includes; 19026 lodash.indexOf = indexOf; 19027 lodash.inRange = inRange; 19028 lodash.invoke = invoke; 19029 lodash.isArguments = isArguments; 19030 lodash.isArray = isArray; 19031 lodash.isArrayBuffer = isArrayBuffer; 19032 lodash.isArrayLike = isArrayLike; 19033 lodash.isArrayLikeObject = isArrayLikeObject; 19034 lodash.isBoolean = isBoolean; 19035 lodash.isBuffer = isBuffer; 19036 lodash.isDate = isDate; 19037 lodash.isElement = isElement; 19038 lodash.isEmpty = isEmpty; 19039 lodash.isEqual = isEqual; 19040 lodash.isEqualWith = isEqualWith; 19041 lodash.isError = isError; 19042 lodash.isFinite = isFinite; 19043 lodash.isFunction = isFunction; 19044 lodash.isInteger = isInteger; 19045 lodash.isLength = isLength; 19046 lodash.isMap = isMap; 19047 lodash.isMatch = isMatch; 19048 lodash.isMatchWith = isMatchWith; 19049 lodash.isNaN = isNaN; 19050 lodash.isNative = isNative; 19051 lodash.isNil = isNil; 19052 lodash.isNull = isNull; 19053 lodash.isNumber = isNumber; 19054 lodash.isObject = isObject; 19055 lodash.isObjectLike = isObjectLike; 19056 lodash.isPlainObject = isPlainObject; 19057 lodash.isRegExp = isRegExp; 19058 lodash.isSafeInteger = isSafeInteger; 19059 lodash.isSet = isSet; 19060 lodash.isString = isString; 19061 lodash.isSymbol = isSymbol; 19062 lodash.isTypedArray = isTypedArray; 19063 lodash.isUndefined = isUndefined; 19064 lodash.isWeakMap = isWeakMap; 19065 lodash.isWeakSet = isWeakSet; 19066 lodash.join = join; 19067 lodash.kebabCase = kebabCase; 19068 lodash.last = last; 19069 lodash.lastIndexOf = lastIndexOf; 19070 lodash.lowerCase = lowerCase; 19071 lodash.lowerFirst = lowerFirst; 19072 lodash.lt = lt; 19073 lodash.lte = lte; 19074 lodash.max = max; 19075 lodash.maxBy = maxBy; 19076 lodash.mean = mean; 19077 lodash.meanBy = meanBy; 19078 lodash.min = min; 19079 lodash.minBy = minBy; 19080 lodash.stubArray = stubArray; 19081 lodash.stubFalse = stubFalse; 19082 lodash.stubObject = stubObject; 19083 lodash.stubString = stubString; 19084 lodash.stubTrue = stubTrue; 19085 lodash.multiply = multiply; 19086 lodash.nth = nth; 19087 lodash.noConflict = noConflict; 19088 lodash.noop = noop; 19089 lodash.now = now; 19090 lodash.pad = pad; 19091 lodash.padEnd = padEnd; 19092 lodash.padStart = padStart; 19093 lodash.parseInt = parseInt; 19094 lodash.random = random; 19095 lodash.reduce = reduce; 19096 lodash.reduceRight = reduceRight; 19097 lodash.repeat = repeat; 19098 lodash.replace = replace; 19099 lodash.result = result; 19100 lodash.round = round; 19101 lodash.runInContext = runInContext; 19102 lodash.sample = sample; 19103 lodash.size = size; 19104 lodash.snakeCase = snakeCase; 19105 lodash.some = some; 19106 lodash.sortedIndex = sortedIndex; 19107 lodash.sortedIndexBy = sortedIndexBy; 19108 lodash.sortedIndexOf = sortedIndexOf; 19109 lodash.sortedLastIndex = sortedLastIndex; 19110 lodash.sortedLastIndexBy = sortedLastIndexBy; 19111 lodash.sortedLastIndexOf = sortedLastIndexOf; 19112 lodash.startCase = startCase; 19113 lodash.startsWith = startsWith; 19114 lodash.subtract = subtract; 19115 lodash.sum = sum; 19116 lodash.sumBy = sumBy; 19117 lodash.template = template; 19118 lodash.times = times; 19119 lodash.toFinite = toFinite; 19120 lodash.toInteger = toInteger; 19121 lodash.toLength = toLength; 19122 lodash.toLower = toLower; 19123 lodash.toNumber = toNumber; 19124 lodash.toSafeInteger = toSafeInteger; 19125 lodash.toString = toString; 19126 lodash.toUpper = toUpper; 19127 lodash.trim = trim; 19128 lodash.trimEnd = trimEnd; 19129 lodash.trimStart = trimStart; 19130 lodash.truncate = truncate; 19131 lodash.unescape = unescape; 19132 lodash.uniqueId = uniqueId; 19133 lodash.upperCase = upperCase; 19134 lodash.upperFirst = upperFirst; 19135 19136 // Add aliases. 19137 lodash.each = forEach; 19138 lodash.eachRight = forEachRight; 19139 lodash.first = head; 19140 19141 mixin(lodash, (function() { 19142 var source = {}; 19143 baseForOwn(lodash, function(func, methodName) { 19144 if (!hasOwnProperty.call(lodash.prototype, methodName)) { 19145 source[methodName] = func; 19146 } 19147 }); 19148 return source; 19149 }()), { 'chain': false }); 19150 19151 /*------------------------------------------------------------------------*/ 19152 19153 /** 19154 * The semantic version number. 19155 * 19156 * @static 19157 * @memberOf _ 19158 * @type {string} 19159 */ 19160 lodash.VERSION = VERSION; 19161 19162 // Assign default placeholders. 19163 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { 19164 lodash[methodName].placeholder = lodash; 19165 }); 19166 19167 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. 19168 arrayEach(['drop', 'take'], function(methodName, index) { 19169 LazyWrapper.prototype[methodName] = function(n) { 19170 n = n === undefined ? 1 : nativeMax(toInteger(n), 0); 19171 19172 var result = (this.__filtered__ && !index) 19173 ? new LazyWrapper(this) 19174 : this.clone(); 19175 19176 if (result.__filtered__) { 19177 result.__takeCount__ = nativeMin(n, result.__takeCount__); 19178 } else { 19179 result.__views__.push({ 19180 'size': nativeMin(n, MAX_ARRAY_LENGTH), 19181 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') 19182 }); 19183 } 19184 return result; 19185 }; 19186 19187 LazyWrapper.prototype[methodName + 'Right'] = function(n) { 19188 return this.reverse()[methodName](n).reverse(); 19189 }; 19190 }); 19191 19192 // Add `LazyWrapper` methods that accept an `iteratee` value. 19193 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { 19194 var type = index + 1, 19195 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; 19196 19197 LazyWrapper.prototype[methodName] = function(iteratee) { 19198 var result = this.clone(); 19199 result.__iteratees__.push({ 19200 'iteratee': getIteratee(iteratee, 3), 19201 'type': type 19202 }); 19203 result.__filtered__ = result.__filtered__ || isFilter; 19204 return result; 19205 }; 19206 }); 19207 19208 // Add `LazyWrapper` methods for `_.head` and `_.last`. 19209 arrayEach(['head', 'last'], function(methodName, index) { 19210 var takeName = 'take' + (index ? 'Right' : ''); 19211 19212 LazyWrapper.prototype[methodName] = function() { 19213 return this[takeName](1).value()[0]; 19214 }; 19215 }); 19216 19217 // Add `LazyWrapper` methods for `_.initial` and `_.tail`. 19218 arrayEach(['initial', 'tail'], function(methodName, index) { 19219 var dropName = 'drop' + (index ? '' : 'Right'); 19220 19221 LazyWrapper.prototype[methodName] = function() { 19222 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); 19223 }; 19224 }); 19225 19226 LazyWrapper.prototype.compact = function() { 19227 return this.filter(identity); 19228 }; 19229 19230 LazyWrapper.prototype.find = function(predicate) { 19231 return this.filter(predicate).head(); 19232 }; 19233 19234 LazyWrapper.prototype.findLast = function(predicate) { 19235 return this.reverse().find(predicate); 19236 }; 19237 19238 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { 19239 if (typeof path == 'function') { 19240 return new LazyWrapper(this); 19241 } 19242 return this.map(function(value) { 19243 return baseInvoke(value, path, args); 19244 }); 19245 }); 19246 19247 LazyWrapper.prototype.reject = function(predicate) { 19248 return this.filter(negate(getIteratee(predicate))); 19249 }; 19250 19251 LazyWrapper.prototype.slice = function(start, end) { 19252 start = toInteger(start); 19253 19254 var result = this; 19255 if (result.__filtered__ && (start > 0 || end < 0)) { 19256 return new LazyWrapper(result); 19257 } 19258 if (start < 0) { 19259 result = result.takeRight(-start); 19260 } else if (start) { 19261 result = result.drop(start); 19262 } 19263 if (end !== undefined) { 19264 end = toInteger(end); 19265 result = end < 0 ? result.dropRight(-end) : result.take(end - start); 19266 } 19267 return result; 19268 }; 19269 19270 LazyWrapper.prototype.takeRightWhile = function(predicate) { 19271 return this.reverse().takeWhile(predicate).reverse(); 19272 }; 19273 19274 LazyWrapper.prototype.toArray = function() { 19275 return this.take(MAX_ARRAY_LENGTH); 19276 }; 19277 19278 // Add `LazyWrapper` methods to `lodash.prototype`. 19279 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 19280 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), 19281 isTaker = /^(?:head|last)$/.test(methodName), 19282 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], 19283 retUnwrapped = isTaker || /^find/.test(methodName); 19284 19285 if (!lodashFunc) { 19286 return; 19287 } 19288 lodash.prototype[methodName] = function() { 19289 var value = this.__wrapped__, 19290 args = isTaker ? [1] : arguments, 19291 isLazy = value instanceof LazyWrapper, 19292 iteratee = args[0], 19293 useLazy = isLazy || isArray(value); 19294 19295 var interceptor = function(value) { 19296 var result = lodashFunc.apply(lodash, arrayPush([value], args)); 19297 return (isTaker && chainAll) ? result[0] : result; 19298 }; 19299 19300 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { 19301 // Avoid lazy use if the iteratee has a "length" value other than `1`. 19302 isLazy = useLazy = false; 19303 } 19304 var chainAll = this.__chain__, 19305 isHybrid = !!this.__actions__.length, 19306 isUnwrapped = retUnwrapped && !chainAll, 19307 onlyLazy = isLazy && !isHybrid; 19308 19309 if (!retUnwrapped && useLazy) { 19310 value = onlyLazy ? value : new LazyWrapper(this); 19311 var result = func.apply(value, args); 19312 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); 19313 return new LodashWrapper(result, chainAll); 19314 } 19315 if (isUnwrapped && onlyLazy) { 19316 return func.apply(this, args); 19317 } 19318 result = this.thru(interceptor); 19319 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; 19320 }; 19321 }); 19322 19323 // Add `Array` methods to `lodash.prototype`. 19324 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { 19325 var func = arrayProto[methodName], 19326 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', 19327 retUnwrapped = /^(?:pop|shift)$/.test(methodName); 19328 19329 lodash.prototype[methodName] = function() { 19330 var args = arguments; 19331 if (retUnwrapped && !this.__chain__) { 19332 var value = this.value(); 19333 return func.apply(isArray(value) ? value : [], args); 19334 } 19335 return this[chainName](function(value) { 19336 return func.apply(isArray(value) ? value : [], args); 19337 }); 19338 }; 19339 }); 19340 19341 // Map minified method names to their real names. 19342 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 19343 var lodashFunc = lodash[methodName]; 19344 if (lodashFunc) { 19345 var key = lodashFunc.name + ''; 19346 if (!hasOwnProperty.call(realNames, key)) { 19347 realNames[key] = []; 19348 } 19349 realNames[key].push({ 'name': methodName, 'func': lodashFunc }); 19350 } 19351 }); 19352 19353 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{ 19354 'name': 'wrapper', 19355 'func': undefined 19356 }]; 19357 19358 // Add methods to `LazyWrapper`. 19359 LazyWrapper.prototype.clone = lazyClone; 19360 LazyWrapper.prototype.reverse = lazyReverse; 19361 LazyWrapper.prototype.value = lazyValue; 19362 19363 // Add chain sequence methods to the `lodash` wrapper. 19364 lodash.prototype.at = wrapperAt; 19365 lodash.prototype.chain = wrapperChain; 19366 lodash.prototype.commit = wrapperCommit; 19367 lodash.prototype.next = wrapperNext; 19368 lodash.prototype.plant = wrapperPlant; 19369 lodash.prototype.reverse = wrapperReverse; 19370 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; 19371 19372 // Add lazy aliases. 19373 lodash.prototype.first = lodash.prototype.head; 19374 19375 if (symIterator) { 19376 lodash.prototype[symIterator] = wrapperToIterator; 19377 } 19378 return lodash; 19379 }); 19380 19381 /*--------------------------------------------------------------------------*/ 19382 19383 // Export lodash. 19384 var _ = runInContext(); 19385 19386 // Some AMD build optimizers, like r.js, check for condition patterns like: 19387 if (true) { 19388 // Expose Lodash on the global object to prevent errors when Lodash is 19389 // loaded by a script tag in the presence of an AMD loader. 19390 // See http://requirejs.org/docs/errors.html#mismatch for more details. 19391 // Use `_.noConflict` to remove Lodash from the global object. 19392 root._ = _; 19393 19394 // Define as an anonymous module so, through path mapping, it can be 19395 // referenced as the "underscore" module. 19396 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { 19397 return _; 19398 }).call(exports, __webpack_require__, exports, module), 19399 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 19400 } 19401 // Check for `exports` after `define` in case a build optimizer adds it. 19402 else {} 19403}.call(this)); 19404 19405 19406/***/ }), 19407
19408/***/ "./resources/sass/production.scss": 19409/*!****************************************!*\ 19410 !*** ./resources/sass/production.scss ***! 19411 \****************************************/ 19412/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 19413 19414"use strict"; 19415__webpack_require__.r(__webpack_exports__); 19416// extracted by mini-css-extract-plugin 19417 19418 19419/***/ }), 19420
19421/***/ "./resources/sass/production-intro.scss": 19422/*!**********************************************!*\ 19423 !*** ./resources/sass/production-intro.scss ***! 19424 \**********************************************/ 19425/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 19426 19427"use strict"; 19428__webpack_require__.r(__webpack_exports__); 19429// extracted by mini-css-extract-plugin 19430 19431 19432/***/ }), 19433
19434/***/ "./resources/sass/production-upcoming.scss": 19435/*!*************************************************!*\ 19436 !*** ./resources/sass/production-upcoming.scss ***! 19437 \*************************************************/ 19438/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 19439 19440"use strict"; 19441__webpack_require__.r(__webpack_exports__); 19442// extracted by mini-css-extract-plugin 19443 19444 19445/***/ }), 19446
19447/***/ "./resources/sass/space.scss": 19448/*!***********************************!*\ 19449 !*** ./resources/sass/space.scss ***! 19450 \***********************************/ 19451/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 19452 19453"use strict"; 19454__webpack_require__.r(__webpack_exports__); 19455// extracted by mini-css-extract-plugin 19456 19457 19458/***/ }), 19459
19460/***/ "./resources/sass/director.scss": 19461/*!**************************************!*\ 19462 !*** ./resources/sass/director.scss ***! 19463 \**************************************/ 19464/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 19465 19466"use strict"; 19467__webpack_require__.r(__webpack_exports__); 19468// extracted by mini-css-extract-plugin 19469 19470 19471/***/ }), 19472
19473/***/ "./resources/sass/director-intro.scss": 19474/*!********************************************!*\ 19475 !*** ./resources/sass/director-intro.scss ***! 19476 \********************************************/ 19477/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 19478 19479"use strict"; 19480__webpack_require__.r(__webpack_exports__); 19481// extracted by mini-css-extract-plugin 19482 19483 19484/***/ }), 19485
19486/***/ "./resources/sass/good.scss": 19487/*!**********************************!*\ 19488 !*** ./resources/sass/good.scss ***! 19489 \**********************************/ 19490/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 19491 19492"use strict"; 19493__webpack_require__.r(__webpack_exports__); 19494// extracted by mini-css-extract-plugin 19495 19496 19497/***/ }), 19498
19499/***/ "./resources/sass/app.scss": 19500/*!*********************************!*\ 19501 !*** ./resources/sass/app.scss ***! 19502 \*********************************/ 19503/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 19504 19505"use strict"; 19506__webpack_require__.r(__webpack_exports__); 19507// extracted by mini-css-extract-plugin 19508 19509 19510/***/ }), 19511
19512/***/ "./resources/sass/admin.scss": 19513/*!***********************************!*\ 19514 !*** ./resources/sass/admin.scss ***! 19515 \***********************************/ 19516/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 19517 19518"use strict"; 19519__webpack_require__.r(__webpack_exports__); 19520// extracted by mini-css-extract-plugin 19521 19522 19523/***/ }), 19524
19525/***/ "./resources/sass/front.scss": 19526/*!***********************************!*\ 19527 !*** ./resources/sass/front.scss ***! 19528 \***********************************/ 19529/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 19530 19531"use strict"; 19532__webpack_require__.r(__webpack_exports__); 19533// extracted by mini-css-extract-plugin 19534 19535 19536/***/ }), 19537
19538/***/ "./resources/sass/home.scss": 19539/*!**********************************!*\ 19540 !*** ./resources/sass/home.scss ***! 19541 \**********************************/ 19542/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 19543 19544"use strict"; 19545__webpack_require__.r(__webpack_exports__); 19546// extracted by mini-css-extract-plugin 19547 19548 19549/***/ }), 19550
19551/***/ "./resources/sass/about.scss": 19552/*!***********************************!*\ 19553 !*** ./resources/sass/about.scss ***! 19554 \***********************************/ 19555/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { 19556 19557"use strict"; 19558__webpack_require__.r(__webpack_exports__); 19559// extracted by mini-css-extract-plugin 19560 19561 19562/***/ }), 19563
vendor: 5,633 bytes, lines 19564-19756
19564/***/ "./node_modules/process/browser.js": 19565/*!*****************************************!*\ 19566 !*** ./node_modules/process/browser.js ***! 19567 \*****************************************/ 19568/***/ ((module) => { 19569 19570// shim for using process in browser 19571var process = module.exports = {}; 19572 19573// cached from whatever global is present so that test runners that stub it 19574// don't break things. But we need to wrap it in a try catch in case it is 19575// wrapped in strict mode code which doesn't define any globals. It's inside a 19576// function because try/catches deoptimize in certain engines. 19577 19578var cachedSetTimeout; 19579var cachedClearTimeout; 19580 19581function defaultSetTimout() { 19582 throw new Error('setTimeout has not been defined'); 19583} 19584function defaultClearTimeout () { 19585 throw new Error('clearTimeout has not been defined'); 19586} 19587(function () { 19588 try { 19589 if (typeof setTimeout === 'function') { 19590 cachedSetTimeout = setTimeout; 19591 } else { 19592 cachedSetTimeout = defaultSetTimout; 19593 } 19594 } catch (e) { 19595 cachedSetTimeout = defaultSetTimout; 19596 } 19597 try { 19598 if (typeof clearTimeout === 'function') { 19599 cachedClearTimeout = clearTimeout; 19600 } else { 19601 cachedClearTimeout = defaultClearTimeout; 19602 } 19603 } catch (e) { 19604 cachedClearTimeout = defaultClearTimeout; 19605 } 19606} ()) 19607function runTimeout(fun) { 19608 if (cachedSetTimeout === setTimeout) { 19609 //normal enviroments in sane situations 19610 return setTimeout(fun, 0); 19611 } 19612 // if setTimeout wasn't available but was latter defined 19613 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { 19614 cachedSetTimeout = setTimeout; 19615 return setTimeout(fun, 0); 19616 } 19617 try { 19618 // when when somebody has screwed with setTimeout but no I.E. maddness 19619 return cachedSetTimeout(fun, 0); 19620 } catch(e){ 19621 try { 19622 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 19623 return cachedSetTimeout.call(null, fun, 0); 19624 } catch(e){ 19625 // 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 19626 return cachedSetTimeout.call(this, fun, 0); 19627 } 19628 } 19629 19630 19631} 19632function runClearTimeout(marker) { 19633 if (cachedClearTimeout === clearTimeout) { 19634 //normal enviroments in sane situations 19635 return clearTimeout(marker); 19636 } 19637 // if clearTimeout wasn't available but was latter defined 19638 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { 19639 cachedClearTimeout = clearTimeout; 19640 return clearTimeout(marker); 19641 } 19642 try { 19643 // when when somebody has screwed with setTimeout but no I.E. maddness 19644 return cachedClearTimeout(marker); 19645 } catch (e){ 19646 try { 19647 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 19648 return cachedClearTimeout.call(null, marker); 19649 } catch (e){ 19650 // 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. 19651 // Some versions of I.E. have different rules for clearTimeout vs setTimeout 19652 return cachedClearTimeout.call(this, marker); 19653 } 19654 } 19655 19656 19657 19658} 19659var queue = []; 19660var draining = false; 19661var currentQueue; 19662var queueIndex = -1; 19663 19664function cleanUpNextTick() { 19665 if (!draining || !currentQueue) { 19666 return; 19667 } 19668 draining = false; 19669 if (currentQueue.length) { 19670 queue = currentQueue.concat(queue); 19671 } else { 19672 queueIndex = -1; 19673 } 19674 if (queue.length) { 19675 drainQueue(); 19676 } 19677} 19678 19679function drainQueue() { 19680 if (draining) { 19681 return; 19682 } 19683 var timeout = runTimeout(cleanUpNextTick); 19684 draining = true; 19685 19686 var len = queue.length; 19687 while(len) { 19688 currentQueue = queue; 19689 queue = []; 19690 while (++queueIndex < len) { 19691 if (currentQueue) { 19692 currentQueue[queueIndex].run(); 19693 } 19694 } 19695 queueIndex = -1; 19696 len = queue.length; 19697 } 19698 currentQueue = null; 19699 draining = false; 19700 runClearTimeout(timeout); 19701} 19702 19703process.nextTick = function (fun) { 19704 var args = new Array(arguments.length - 1); 19705 if (arguments.length > 1) { 19706 for (var i = 1; i < arguments.length; i++) { 19707 args[i - 1] = arguments[i]; 19708 } 19709 } 19710 queue.push(new Item(fun, args)); 19711 if (queue.length === 1 && !draining) { 19712 runTimeout(drainQueue); 19713 } 19714}; 19715 19716// v8 likes predictible objects 19717function Item(fun, array) { 19718 this.fun = fun; 19719 this.array = array; 19720} 19721Item.prototype.run = function () { 19722 this.fun.apply(null, this.array); 19723}; 19724process.title = 'browser'; 19725process.browser = true; 19726process.env = {}; 19727process.argv = []; 19728process.version = ''; // empty string to avoid regexp issues 19729process.versions = {}; 19730 19731function noop() {} 19732 19733process.on = noop; 19734process.addListener = noop; 19735process.once = noop; 19736process.off = noop; 19737process.removeListener = noop; 19738process.removeAllListeners = noop; 19739process.emit = noop; 19740process.prependListener = noop; 19741process.prependOnceListener = noop; 19742 19743process.listeners = function (name) { return [] } 19744 19745process.binding = function (name) { 19746 throw new Error('process.binding is not supported'); 19747}; 19748 19749process.cwd = function () { return '/' }; 19750process.chdir = function (dir) { 19751 throw new Error('process.chdir is not supported'); 19752}; 19753process.umask = function() { return 0; }; 19754 19755 19756/***/ })
vendor: 10,574 bytes, lines 19756-19946
19756 19757 19758/******/ }); 19759/************************************************************************/ 19760/******/ // The module cache 19761/******/ var __webpack_module_cache__ = {}; 19762/******/ 19763/******/ // The require function 19764/******/ function __webpack_require__(moduleId) { 19765/******/ // Check if module is in cache 19766/******/ var cachedModule = __webpack_module_cache__[moduleId]; 19767/******/ if (cachedModule !== undefined) { 19768/******/ return cachedModule.exports; 19769/******/ } 19770/******/ // Create a new module (and put it into the cache) 19771/******/ var module = __webpack_module_cache__[moduleId] = { 19772/******/ id: moduleId, 19773/******/ loaded: false, 19774/******/ exports: {} 19775/******/ }; 19776/******/ 19777/******/ // Execute the module function 19778/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); 19779/******/ 19780/******/ // Flag the module as loaded 19781/******/ module.loaded = true; 19782/******/ 19783/******/ // Return the exports of the module 19784/******/ return module.exports; 19785/******/ } 19786/******/ 19787/******/ // expose the modules object (__webpack_modules__) 19788/******/ __webpack_require__.m = __webpack_modules__; 19789/******/ 19790/************************************************************************/ 19791/******/ /* webpack/runtime/chunk loaded */ 19792/******/ (() => { 19793/******/ var deferred = []; 19794/******/ __webpack_require__.O = (result, chunkIds, fn, priority) => { 19795/******/ if(chunkIds) { 19796/******/ priority = priority || 0; 19797/******/ for(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1]; 19798/******/ deferred[i] = [chunkIds, fn, priority]; 19799/******/ return; 19800/******/ } 19801/******/ var notFulfilled = Infinity; 19802/******/ for (var i = 0; i < deferred.length; i++) { 19803/******/ var [chunkIds, fn, priority] = deferred[i]; 19804/******/ var fulfilled = true; 19805/******/ for (var j = 0; j < chunkIds.length; j++) { 19806/******/ if ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) { 19807/******/ chunkIds.splice(j--, 1); 19808/******/ } else { 19809/******/ fulfilled = false; 19810/******/ if(priority < notFulfilled) notFulfilled = priority; 19811/******/ } 19812/******/ } 19813/******/ if(fulfilled) { 19814/******/ deferred.splice(i--, 1) 19815/******/ var r = fn(); 19816/******/ if (r !== undefined) result = r; 19817/******/ } 19818/******/ } 19819/******/ return result; 19820/******/ }; 19821/******/ })(); 19822/******/ 19823/******/ /* webpack/runtime/global */ 19824/******/ (() => { 19825/******/ __webpack_require__.g = (function() { 19826/******/ if (typeof globalThis === 'object') return globalThis; 19827/******/ try { 19828/******/ return this || new Function('return this')(); 19829/******/ } catch (e) { 19830/******/ if (typeof window === 'object') return window; 19831/******/ } 19832/******/ })(); 19833/******/ })(); 19834/******/ 19835/******/ /* webpack/runtime/hasOwnProperty shorthand */ 19836/******/ (() => { 19837/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 19838/******/ })(); 19839/******/ 19840/******/ /* webpack/runtime/make namespace object */ 19841/******/ (() => { 19842/******/ // define __esModule on exports 19843/******/ __webpack_require__.r = (exports) => { 19844/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 19845/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 19846/******/ } 19847/******/ Object.defineProperty(exports, '__esModule', { value: true }); 19848/******/ }; 19849/******/ })(); 19850/******/ 19851/******/ /* webpack/runtime/node module decorator */ 19852/******/ (() => { 19853/******/ __webpack_require__.nmd = (module) => { 19854/******/ module.paths = []; 19855/******/ if (!module.children) module.children = []; 19856/******/ return module; 19857/******/ }; 19858/******/ })(); 19859/******/ 19860/******/ /* webpack/runtime/jsonp chunk loading */ 19861/******/ (() => { 19862/******/ // no baseURI 19863/******/ 19864/******/ // object to store loaded and loading chunks 19865/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched 19866/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded 19867/******/ var installedChunks = { 19868/******/ "/js/app": 0, 19869/******/ "css/about": 0, 19870/******/ "css/home": 0, 19871/******/ "css/app": 0, 19872/******/ "css/good": 0, 19873/******/ "css/director-intro": 0, 19874/******/ "css/director": 0, 19875/******/ "css/space": 0, 19876/******/ "css/production-upcoming": 0, 19877/******/ "css/production-intro": 0, 19878/******/ "css/production": 0, 19879/******/ "css/front": 0, 19880/******/ "css/admin": 0 19881/******/ }; 19882/******/ 19883/******/ // no chunk on demand loading 19884/******/ 19885/******/ // no prefetching 19886/******/ 19887/******/ // no preloaded 19888/******/ 19889/******/ // no HMR 19890/******/ 19891/******/ // no HMR manifest 19892/******/ 19893/******/ __webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0); 19894/******/ 19895/******/ // install a JSONP callback for chunk loading 19896/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => { 19897/******/ var [chunkIds, moreModules, runtime] = data; 19898/******/ // add "moreModules" to the modules object, 19899/******/ // then flag all "chunkIds" as loaded and fire callback 19900/******/ var moduleId, chunkId, i = 0; 19901/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) { 19902/******/ for(moduleId in moreModules) { 19903/******/ if(__webpack_require__.o(moreModules, moduleId)) { 19904/******/ __webpack_require__.m[moduleId] = moreModules[moduleId]; 19905/******/ } 19906/******/ } 19907/******/ if(runtime) var result = runtime(__webpack_require__); 19908/******/ } 19909/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data); 19910/******/ for(;i < chunkIds.length; i++) { 19911/******/ chunkId = chunkIds[i]; 19912/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) { 19913/******/ installedChunks[chunkId][0](); 19914/******/ } 19915/******/ installedChunks[chunkId] = 0; 19916/******/ } 19917/******/ return __webpack_require__.O(result); 19918/******/ } 19919/******/ 19920/******/ var chunkLoadingGlobal = self["webpackChunk"] = self["webpackChunk"] || []; 19921/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0)); 19922/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal)); 19923/******/ })(); 19924/******/ 19925/************************************************************************/ 19926/******/ 19927/******/ // startup 19928/******/ // Load entry module and return exports 19929/******/ // This entry module depends on other loaded chunks and execution need to be delayed 19930/******/ __webpack_require__.O(undefined, ["css/about","css/home","css/app","css/good","css/director-intro","css/director","css/space","css/production-upcoming","css/production-intro","css/production","css/front","css/admin"], () => (__webpack_require__("./resources/js/app.js"))) 19931/******/ __webpack_require__.O(undefined, ["css/about","css/home","css/app","css/good","css/director-intro","css/director","css/space","css/production-upcoming","css/production-intro","css/production","css/front","css/admin"], () => (__webpack_require__("./resources/sass/app.scss"))) 19932/******/ __webpack_require__.O(undefined, ["css/about","css/home","css/app","css/good","css/director-intro","css/director","css/space","css/production-upcoming","css/production-intro","css/production","css/front","css/admin"], () => (__webpack_require__("./resources/sass/admin.scss"))) 19933/******/ __webpack_require__.O(undefined, ["css/about","css/home","css/app","css/good","css/director-intro","css/director","css/space","css/production-upcoming","css/production-intro","css/production","css/front","css/admin"], () => (__webpack_require__("./resources/sass/front.scss"))) 19934/******/ __webpack_require__.O(undefined, ["css/about","css/home","css/app","css/good","css/director-intro","css/director","css/space","css/production-upcoming","css/production-intro","css/production","css/front","css/admin"], () => (__webpack_require__("./resources/sass/home.scss"))) 19935/******/ __webpack_require__.O(undefined, ["css/about","css/home","css/app","css/good","css/director-intro","css/director","css/space","css/production-upcoming","css/production-intro","css/production","css/front","css/admin"], () => (__webpack_require__("./resources/sass/about.scss"))) 19936/******/ __webpack_require__.O(undefined, ["css/about","css/home","css/app","css/good","css/director-intro","css/director","css/space","css/production-upcoming","css/production-intro","css/production","css/front","css/admin"], () => (__webpack_require__("./resources/sass/production.scss"))) 19937/******/ __webpack_require__.O(undefined, ["css/about","css/home","css/app","css/good","css/director-intro","css/director","css/space","css/production-upcoming","css/production-intro","css/production","css/front","css/admin"], () => (__webpack_require__("./resources/sass/production-intro.scss"))) 19938/******/ __webpack_require__.O(undefined, ["css/about","css/home","css/app","css/good","css/director-intro","css/director","css/space","css/production-upcoming","css/production-intro","css/production","css/front","css/admin"], () => (__webpack_require__("./resources/sass/production-upcoming.scss"))) 19939/******/ __webpack_require__.O(undefined, ["css/about","css/home","css/app","css/good","css/director-intro","css/director","css/space","css/production-upcoming","css/production-intro","css/production","css/front","css/admin"], () => (__webpack_require__("./resources/sass/space.scss"))) 19940/******/ __webpack_require__.O(undefined, ["css/about","css/home","css/app","css/good","css/director-intro","css/director","css/space","css/production-upcoming","css/production-intro","css/production","css/front","css/admin"], () => (__webpack_require__("./resources/sass/director.scss"))) 19941/******/ __webpack_require__.O(undefined, ["css/about","css/home","css/app","css/good","css/director-intro","css/director","css/space","css/production-upcoming","css/production-intro","css/production","css/front","css/admin"], () => (__webpack_require__("./resources/sass/director-intro.scss"))) 19942/******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["css/about","css/home","css/app","css/good","css/director-intro","css/director","css/space","css/production-upcoming","css/production-intro","css/production","css/front","css/admin"], () => (__webpack_require__("./resources/sass/good.scss"))) 19943/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__); 19944/******/ 19945/******/ })() 19946;
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.