bundle.js (756297B)
1 (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ 2 /* DOM */ 3 window.morph = require('nanomorph') 4 window.html = require('nanohtml') 5 window.raw = require('nanohtml/raw') 6 window.Component = require('nanocomponent') 7 8 /* State */ 9 window.bus = require('nanobus') 10 window.state = require('nanostate') 11 12 /* Router */ 13 window.wayfarer = require('wayfarer') 14 window.wayfarer.walk = require('wayfarer/walk') 15 window.router = require('nanorouter') 16 17 /* Other */ 18 window.create_debug = require('debug') 19 window.query = (href = window.location.href) => require('nanoquery')(href) 20 window.hash = (hash = window.location.hash) => require('hash-match')(hash) 21 22 /* Utilities */ 23 window._ = require('lodash') 24 window.S = require('s-js') 25 window.he = require('he') 26 window.title = require('title') 27 28 },{"debug":4,"hash-match":8,"he":9,"lodash":13,"nanobus":16,"nanocomponent":17,"nanohtml":20,"nanohtml/raw":22,"nanomorph":24,"nanoquery":27,"nanorouter":28,"nanostate":30,"s-js":36,"title":37,"wayfarer":42,"wayfarer/walk":44}],2:[function(require,module,exports){ 29 (function (global){ 30 'use strict'; 31 32 // compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js 33 // original notice: 34 35 /*! 36 * The buffer module from node.js, for the browser. 37 * 38 * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> 39 * @license MIT 40 */ 41 function compare(a, b) { 42 if (a === b) { 43 return 0; 44 } 45 46 var x = a.length; 47 var y = b.length; 48 49 for (var i = 0, len = Math.min(x, y); i < len; ++i) { 50 if (a[i] !== b[i]) { 51 x = a[i]; 52 y = b[i]; 53 break; 54 } 55 } 56 57 if (x < y) { 58 return -1; 59 } 60 if (y < x) { 61 return 1; 62 } 63 return 0; 64 } 65 function isBuffer(b) { 66 if (global.Buffer && typeof global.Buffer.isBuffer === 'function') { 67 return global.Buffer.isBuffer(b); 68 } 69 return !!(b != null && b._isBuffer); 70 } 71 72 // based on node assert, original notice: 73 74 // http://wiki.commonjs.org/wiki/Unit_Testing/1.0 75 // 76 // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! 77 // 78 // Originally from narwhal.js (http://narwhaljs.org) 79 // Copyright (c) 2009 Thomas Robinson <280north.com> 80 // 81 // Permission is hereby granted, free of charge, to any person obtaining a copy 82 // of this software and associated documentation files (the 'Software'), to 83 // deal in the Software without restriction, including without limitation the 84 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 85 // sell copies of the Software, and to permit persons to whom the Software is 86 // furnished to do so, subject to the following conditions: 87 // 88 // The above copyright notice and this permission notice shall be included in 89 // all copies or substantial portions of the Software. 90 // 91 // THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 92 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 93 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 94 // AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 95 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 96 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 97 98 var util = require('util/'); 99 var hasOwn = Object.prototype.hasOwnProperty; 100 var pSlice = Array.prototype.slice; 101 var functionsHaveNames = (function () { 102 return function foo() {}.name === 'foo'; 103 }()); 104 function pToString (obj) { 105 return Object.prototype.toString.call(obj); 106 } 107 function isView(arrbuf) { 108 if (isBuffer(arrbuf)) { 109 return false; 110 } 111 if (typeof global.ArrayBuffer !== 'function') { 112 return false; 113 } 114 if (typeof ArrayBuffer.isView === 'function') { 115 return ArrayBuffer.isView(arrbuf); 116 } 117 if (!arrbuf) { 118 return false; 119 } 120 if (arrbuf instanceof DataView) { 121 return true; 122 } 123 if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) { 124 return true; 125 } 126 return false; 127 } 128 // 1. The assert module provides functions that throw 129 // AssertionError's when particular conditions are not met. The 130 // assert module must conform to the following interface. 131 132 var assert = module.exports = ok; 133 134 // 2. The AssertionError is defined in assert. 135 // new assert.AssertionError({ message: message, 136 // actual: actual, 137 // expected: expected }) 138 139 var regex = /\s*function\s+([^\(\s]*)\s*/; 140 // based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js 141 function getName(func) { 142 if (!util.isFunction(func)) { 143 return; 144 } 145 if (functionsHaveNames) { 146 return func.name; 147 } 148 var str = func.toString(); 149 var match = str.match(regex); 150 return match && match[1]; 151 } 152 assert.AssertionError = function AssertionError(options) { 153 this.name = 'AssertionError'; 154 this.actual = options.actual; 155 this.expected = options.expected; 156 this.operator = options.operator; 157 if (options.message) { 158 this.message = options.message; 159 this.generatedMessage = false; 160 } else { 161 this.message = getMessage(this); 162 this.generatedMessage = true; 163 } 164 var stackStartFunction = options.stackStartFunction || fail; 165 if (Error.captureStackTrace) { 166 Error.captureStackTrace(this, stackStartFunction); 167 } else { 168 // non v8 browsers so we can have a stacktrace 169 var err = new Error(); 170 if (err.stack) { 171 var out = err.stack; 172 173 // try to strip useless frames 174 var fn_name = getName(stackStartFunction); 175 var idx = out.indexOf('\n' + fn_name); 176 if (idx >= 0) { 177 // once we have located the function frame 178 // we need to strip out everything before it (and its line) 179 var next_line = out.indexOf('\n', idx + 1); 180 out = out.substring(next_line + 1); 181 } 182 183 this.stack = out; 184 } 185 } 186 }; 187 188 // assert.AssertionError instanceof Error 189 util.inherits(assert.AssertionError, Error); 190 191 function truncate(s, n) { 192 if (typeof s === 'string') { 193 return s.length < n ? s : s.slice(0, n); 194 } else { 195 return s; 196 } 197 } 198 function inspect(something) { 199 if (functionsHaveNames || !util.isFunction(something)) { 200 return util.inspect(something); 201 } 202 var rawname = getName(something); 203 var name = rawname ? ': ' + rawname : ''; 204 return '[Function' + name + ']'; 205 } 206 function getMessage(self) { 207 return truncate(inspect(self.actual), 128) + ' ' + 208 self.operator + ' ' + 209 truncate(inspect(self.expected), 128); 210 } 211 212 // At present only the three keys mentioned above are used and 213 // understood by the spec. Implementations or sub modules can pass 214 // other keys to the AssertionError's constructor - they will be 215 // ignored. 216 217 // 3. All of the following functions must throw an AssertionError 218 // when a corresponding condition is not met, with a message that 219 // may be undefined if not provided. All assertion methods provide 220 // both the actual and expected values to the assertion error for 221 // display purposes. 222 223 function fail(actual, expected, message, operator, stackStartFunction) { 224 throw new assert.AssertionError({ 225 message: message, 226 actual: actual, 227 expected: expected, 228 operator: operator, 229 stackStartFunction: stackStartFunction 230 }); 231 } 232 233 // EXTENSION! allows for well behaved errors defined elsewhere. 234 assert.fail = fail; 235 236 // 4. Pure assertion tests whether a value is truthy, as determined 237 // by !!guard. 238 // assert.ok(guard, message_opt); 239 // This statement is equivalent to assert.equal(true, !!guard, 240 // message_opt);. To test strictly for the value true, use 241 // assert.strictEqual(true, guard, message_opt);. 242 243 function ok(value, message) { 244 if (!value) fail(value, true, message, '==', assert.ok); 245 } 246 assert.ok = ok; 247 248 // 5. The equality assertion tests shallow, coercive equality with 249 // ==. 250 // assert.equal(actual, expected, message_opt); 251 252 assert.equal = function equal(actual, expected, message) { 253 if (actual != expected) fail(actual, expected, message, '==', assert.equal); 254 }; 255 256 // 6. The non-equality assertion tests for whether two objects are not equal 257 // with != assert.notEqual(actual, expected, message_opt); 258 259 assert.notEqual = function notEqual(actual, expected, message) { 260 if (actual == expected) { 261 fail(actual, expected, message, '!=', assert.notEqual); 262 } 263 }; 264 265 // 7. The equivalence assertion tests a deep equality relation. 266 // assert.deepEqual(actual, expected, message_opt); 267 268 assert.deepEqual = function deepEqual(actual, expected, message) { 269 if (!_deepEqual(actual, expected, false)) { 270 fail(actual, expected, message, 'deepEqual', assert.deepEqual); 271 } 272 }; 273 274 assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { 275 if (!_deepEqual(actual, expected, true)) { 276 fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual); 277 } 278 }; 279 280 function _deepEqual(actual, expected, strict, memos) { 281 // 7.1. All identical values are equivalent, as determined by ===. 282 if (actual === expected) { 283 return true; 284 } else if (isBuffer(actual) && isBuffer(expected)) { 285 return compare(actual, expected) === 0; 286 287 // 7.2. If the expected value is a Date object, the actual value is 288 // equivalent if it is also a Date object that refers to the same time. 289 } else if (util.isDate(actual) && util.isDate(expected)) { 290 return actual.getTime() === expected.getTime(); 291 292 // 7.3 If the expected value is a RegExp object, the actual value is 293 // equivalent if it is also a RegExp object with the same source and 294 // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). 295 } else if (util.isRegExp(actual) && util.isRegExp(expected)) { 296 return actual.source === expected.source && 297 actual.global === expected.global && 298 actual.multiline === expected.multiline && 299 actual.lastIndex === expected.lastIndex && 300 actual.ignoreCase === expected.ignoreCase; 301 302 // 7.4. Other pairs that do not both pass typeof value == 'object', 303 // equivalence is determined by ==. 304 } else if ((actual === null || typeof actual !== 'object') && 305 (expected === null || typeof expected !== 'object')) { 306 return strict ? actual === expected : actual == expected; 307 308 // If both values are instances of typed arrays, wrap their underlying 309 // ArrayBuffers in a Buffer each to increase performance 310 // This optimization requires the arrays to have the same type as checked by 311 // Object.prototype.toString (aka pToString). Never perform binary 312 // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their 313 // bit patterns are not identical. 314 } else if (isView(actual) && isView(expected) && 315 pToString(actual) === pToString(expected) && 316 !(actual instanceof Float32Array || 317 actual instanceof Float64Array)) { 318 return compare(new Uint8Array(actual.buffer), 319 new Uint8Array(expected.buffer)) === 0; 320 321 // 7.5 For all other Object pairs, including Array objects, equivalence is 322 // determined by having the same number of owned properties (as verified 323 // with Object.prototype.hasOwnProperty.call), the same set of keys 324 // (although not necessarily the same order), equivalent values for every 325 // corresponding key, and an identical 'prototype' property. Note: this 326 // accounts for both named and indexed properties on Arrays. 327 } else if (isBuffer(actual) !== isBuffer(expected)) { 328 return false; 329 } else { 330 memos = memos || {actual: [], expected: []}; 331 332 var actualIndex = memos.actual.indexOf(actual); 333 if (actualIndex !== -1) { 334 if (actualIndex === memos.expected.indexOf(expected)) { 335 return true; 336 } 337 } 338 339 memos.actual.push(actual); 340 memos.expected.push(expected); 341 342 return objEquiv(actual, expected, strict, memos); 343 } 344 } 345 346 function isArguments(object) { 347 return Object.prototype.toString.call(object) == '[object Arguments]'; 348 } 349 350 function objEquiv(a, b, strict, actualVisitedObjects) { 351 if (a === null || a === undefined || b === null || b === undefined) 352 return false; 353 // if one is a primitive, the other must be same 354 if (util.isPrimitive(a) || util.isPrimitive(b)) 355 return a === b; 356 if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) 357 return false; 358 var aIsArgs = isArguments(a); 359 var bIsArgs = isArguments(b); 360 if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs)) 361 return false; 362 if (aIsArgs) { 363 a = pSlice.call(a); 364 b = pSlice.call(b); 365 return _deepEqual(a, b, strict); 366 } 367 var ka = objectKeys(a); 368 var kb = objectKeys(b); 369 var key, i; 370 // having the same number of owned properties (keys incorporates 371 // hasOwnProperty) 372 if (ka.length !== kb.length) 373 return false; 374 //the same set of keys (although not necessarily the same order), 375 ka.sort(); 376 kb.sort(); 377 //~~~cheap key test 378 for (i = ka.length - 1; i >= 0; i--) { 379 if (ka[i] !== kb[i]) 380 return false; 381 } 382 //equivalent values for every corresponding key, and 383 //~~~possibly expensive deep test 384 for (i = ka.length - 1; i >= 0; i--) { 385 key = ka[i]; 386 if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) 387 return false; 388 } 389 return true; 390 } 391 392 // 8. The non-equivalence assertion tests for any deep inequality. 393 // assert.notDeepEqual(actual, expected, message_opt); 394 395 assert.notDeepEqual = function notDeepEqual(actual, expected, message) { 396 if (_deepEqual(actual, expected, false)) { 397 fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); 398 } 399 }; 400 401 assert.notDeepStrictEqual = notDeepStrictEqual; 402 function notDeepStrictEqual(actual, expected, message) { 403 if (_deepEqual(actual, expected, true)) { 404 fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual); 405 } 406 } 407 408 409 // 9. The strict equality assertion tests strict equality, as determined by ===. 410 // assert.strictEqual(actual, expected, message_opt); 411 412 assert.strictEqual = function strictEqual(actual, expected, message) { 413 if (actual !== expected) { 414 fail(actual, expected, message, '===', assert.strictEqual); 415 } 416 }; 417 418 // 10. The strict non-equality assertion tests for strict inequality, as 419 // determined by !==. assert.notStrictEqual(actual, expected, message_opt); 420 421 assert.notStrictEqual = function notStrictEqual(actual, expected, message) { 422 if (actual === expected) { 423 fail(actual, expected, message, '!==', assert.notStrictEqual); 424 } 425 }; 426 427 function expectedException(actual, expected) { 428 if (!actual || !expected) { 429 return false; 430 } 431 432 if (Object.prototype.toString.call(expected) == '[object RegExp]') { 433 return expected.test(actual); 434 } 435 436 try { 437 if (actual instanceof expected) { 438 return true; 439 } 440 } catch (e) { 441 // Ignore. The instanceof check doesn't work for arrow functions. 442 } 443 444 if (Error.isPrototypeOf(expected)) { 445 return false; 446 } 447 448 return expected.call({}, actual) === true; 449 } 450 451 function _tryBlock(block) { 452 var error; 453 try { 454 block(); 455 } catch (e) { 456 error = e; 457 } 458 return error; 459 } 460 461 function _throws(shouldThrow, block, expected, message) { 462 var actual; 463 464 if (typeof block !== 'function') { 465 throw new TypeError('"block" argument must be a function'); 466 } 467 468 if (typeof expected === 'string') { 469 message = expected; 470 expected = null; 471 } 472 473 actual = _tryBlock(block); 474 475 message = (expected && expected.name ? ' (' + expected.name + ').' : '.') + 476 (message ? ' ' + message : '.'); 477 478 if (shouldThrow && !actual) { 479 fail(actual, expected, 'Missing expected exception' + message); 480 } 481 482 var userProvidedMessage = typeof message === 'string'; 483 var isUnwantedException = !shouldThrow && util.isError(actual); 484 var isUnexpectedException = !shouldThrow && actual && !expected; 485 486 if ((isUnwantedException && 487 userProvidedMessage && 488 expectedException(actual, expected)) || 489 isUnexpectedException) { 490 fail(actual, expected, 'Got unwanted exception' + message); 491 } 492 493 if ((shouldThrow && actual && expected && 494 !expectedException(actual, expected)) || (!shouldThrow && actual)) { 495 throw actual; 496 } 497 } 498 499 // 11. Expected to throw an error: 500 // assert.throws(block, Error_opt, message_opt); 501 502 assert.throws = function(block, /*optional*/error, /*optional*/message) { 503 _throws(true, block, error, message); 504 }; 505 506 // EXTENSION! This is annoying to write outside this module. 507 assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) { 508 _throws(false, block, error, message); 509 }; 510 511 assert.ifError = function(err) { if (err) throw err; }; 512 513 var objectKeys = Object.keys || function (obj) { 514 var keys = []; 515 for (var key in obj) { 516 if (hasOwn.call(obj, key)) keys.push(key); 517 } 518 return keys; 519 }; 520 521 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 522 },{"util/":41}],3:[function(require,module,exports){ 523 524 },{}],4:[function(require,module,exports){ 525 (function (process){ 526 /** 527 * This is the web browser implementation of `debug()`. 528 * 529 * Expose `debug()` as the module. 530 */ 531 532 exports = module.exports = require('./debug'); 533 exports.log = log; 534 exports.formatArgs = formatArgs; 535 exports.save = save; 536 exports.load = load; 537 exports.useColors = useColors; 538 exports.storage = 'undefined' != typeof chrome 539 && 'undefined' != typeof chrome.storage 540 ? chrome.storage.local 541 : localstorage(); 542 543 /** 544 * Colors. 545 */ 546 547 exports.colors = [ 548 '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', 549 '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', 550 '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', 551 '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', 552 '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', 553 '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', 554 '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', 555 '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', 556 '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', 557 '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', 558 '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33' 559 ]; 560 561 /** 562 * Currently only WebKit-based Web Inspectors, Firefox >= v31, 563 * and the Firebug extension (any Firefox version) are known 564 * to support "%c" CSS customizations. 565 * 566 * TODO: add a `localStorage` variable to explicitly enable/disable colors 567 */ 568 569 function useColors() { 570 // NB: In an Electron preload script, document will be defined but not fully 571 // initialized. Since we know we're in Chrome, we'll just detect this case 572 // explicitly 573 if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { 574 return true; 575 } 576 577 // Internet Explorer and Edge do not support colors. 578 if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { 579 return false; 580 } 581 582 // is webkit? http://stackoverflow.com/a/16459606/376773 583 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 584 return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || 585 // is firebug? http://stackoverflow.com/a/398120/376773 586 (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || 587 // is firefox >= v31? 588 // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages 589 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || 590 // double check webkit in userAgent just in case we are in a worker 591 (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); 592 } 593 594 /** 595 * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. 596 */ 597 598 exports.formatters.j = function(v) { 599 try { 600 return JSON.stringify(v); 601 } catch (err) { 602 return '[UnexpectedJSONParseError]: ' + err.message; 603 } 604 }; 605 606 607 /** 608 * Colorize log arguments if enabled. 609 * 610 * @api public 611 */ 612 613 function formatArgs(args) { 614 var useColors = this.useColors; 615 616 args[0] = (useColors ? '%c' : '') 617 + this.namespace 618 + (useColors ? ' %c' : ' ') 619 + args[0] 620 + (useColors ? '%c ' : ' ') 621 + '+' + exports.humanize(this.diff); 622 623 if (!useColors) return; 624 625 var c = 'color: ' + this.color; 626 args.splice(1, 0, c, 'color: inherit') 627 628 // the final "%c" is somewhat tricky, because there could be other 629 // arguments passed either before or after the %c, so we need to 630 // figure out the correct index to insert the CSS into 631 var index = 0; 632 var lastC = 0; 633 args[0].replace(/%[a-zA-Z%]/g, function(match) { 634 if ('%%' === match) return; 635 index++; 636 if ('%c' === match) { 637 // we only are interested in the *last* %c 638 // (the user may have provided their own) 639 lastC = index; 640 } 641 }); 642 643 args.splice(lastC, 0, c); 644 } 645 646 /** 647 * Invokes `console.log()` when available. 648 * No-op when `console.log` is not a "function". 649 * 650 * @api public 651 */ 652 653 function log() { 654 // this hackery is required for IE8/9, where 655 // the `console.log` function doesn't have 'apply' 656 return 'object' === typeof console 657 && console.log 658 && Function.prototype.apply.call(console.log, console, arguments); 659 } 660 661 /** 662 * Save `namespaces`. 663 * 664 * @param {String} namespaces 665 * @api private 666 */ 667 668 function save(namespaces) { 669 try { 670 if (null == namespaces) { 671 exports.storage.removeItem('debug'); 672 } else { 673 exports.storage.debug = namespaces; 674 } 675 } catch(e) {} 676 } 677 678 /** 679 * Load `namespaces`. 680 * 681 * @return {String} returns the previously persisted debug modes 682 * @api private 683 */ 684 685 function load() { 686 var r; 687 try { 688 r = exports.storage.debug; 689 } catch(e) {} 690 691 // If debug isn't set in LS, and we're in Electron, try to load $DEBUG 692 if (!r && typeof process !== 'undefined' && 'env' in process) { 693 r = process.env.DEBUG; 694 } 695 696 return r; 697 } 698 699 /** 700 * Enable namespaces listed in `localStorage.debug` initially. 701 */ 702 703 exports.enable(load()); 704 705 /** 706 * Localstorage attempts to return the localstorage. 707 * 708 * This is necessary because safari throws 709 * when a user disables cookies/localstorage 710 * and you attempt to access it. 711 * 712 * @return {LocalStorage} 713 * @api private 714 */ 715 716 function localstorage() { 717 try { 718 return window.localStorage; 719 } catch (e) {} 720 } 721 722 }).call(this,require('_process')) 723 },{"./debug":5,"_process":34}],5:[function(require,module,exports){ 724 725 /** 726 * This is the common logic for both the Node.js and web browser 727 * implementations of `debug()`. 728 * 729 * Expose `debug()` as the module. 730 */ 731 732 exports = module.exports = createDebug.debug = createDebug['default'] = createDebug; 733 exports.coerce = coerce; 734 exports.disable = disable; 735 exports.enable = enable; 736 exports.enabled = enabled; 737 exports.humanize = require('ms'); 738 739 /** 740 * Active `debug` instances. 741 */ 742 exports.instances = []; 743 744 /** 745 * The currently active debug mode names, and names to skip. 746 */ 747 748 exports.names = []; 749 exports.skips = []; 750 751 /** 752 * Map of special "%n" handling functions, for the debug "format" argument. 753 * 754 * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". 755 */ 756 757 exports.formatters = {}; 758 759 /** 760 * Select a color. 761 * @param {String} namespace 762 * @return {Number} 763 * @api private 764 */ 765 766 function selectColor(namespace) { 767 var hash = 0, i; 768 769 for (i in namespace) { 770 hash = ((hash << 5) - hash) + namespace.charCodeAt(i); 771 hash |= 0; // Convert to 32bit integer 772 } 773 774 return exports.colors[Math.abs(hash) % exports.colors.length]; 775 } 776 777 /** 778 * Create a debugger with the given `namespace`. 779 * 780 * @param {String} namespace 781 * @return {Function} 782 * @api public 783 */ 784 785 function createDebug(namespace) { 786 787 var prevTime; 788 789 function debug() { 790 // disabled? 791 if (!debug.enabled) return; 792 793 var self = debug; 794 795 // set `diff` timestamp 796 var curr = +new Date(); 797 var ms = curr - (prevTime || curr); 798 self.diff = ms; 799 self.prev = prevTime; 800 self.curr = curr; 801 prevTime = curr; 802 803 // turn the `arguments` into a proper Array 804 var args = new Array(arguments.length); 805 for (var i = 0; i < args.length; i++) { 806 args[i] = arguments[i]; 807 } 808 809 args[0] = exports.coerce(args[0]); 810 811 if ('string' !== typeof args[0]) { 812 // anything else let's inspect with %O 813 args.unshift('%O'); 814 } 815 816 // apply any `formatters` transformations 817 var index = 0; 818 args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) { 819 // if we encounter an escaped % then don't increase the array index 820 if (match === '%%') return match; 821 index++; 822 var formatter = exports.formatters[format]; 823 if ('function' === typeof formatter) { 824 var val = args[index]; 825 match = formatter.call(self, val); 826 827 // now we need to remove `args[index]` since it's inlined in the `format` 828 args.splice(index, 1); 829 index--; 830 } 831 return match; 832 }); 833 834 // apply env-specific formatting (colors, etc.) 835 exports.formatArgs.call(self, args); 836 837 var logFn = debug.log || exports.log || console.log.bind(console); 838 logFn.apply(self, args); 839 } 840 841 debug.namespace = namespace; 842 debug.enabled = exports.enabled(namespace); 843 debug.useColors = exports.useColors(); 844 debug.color = selectColor(namespace); 845 debug.destroy = destroy; 846 847 // env-specific initialization logic for debug instances 848 if ('function' === typeof exports.init) { 849 exports.init(debug); 850 } 851 852 exports.instances.push(debug); 853 854 return debug; 855 } 856 857 function destroy () { 858 var index = exports.instances.indexOf(this); 859 if (index !== -1) { 860 exports.instances.splice(index, 1); 861 return true; 862 } else { 863 return false; 864 } 865 } 866 867 /** 868 * Enables a debug mode by namespaces. This can include modes 869 * separated by a colon and wildcards. 870 * 871 * @param {String} namespaces 872 * @api public 873 */ 874 875 function enable(namespaces) { 876 exports.save(namespaces); 877 878 exports.names = []; 879 exports.skips = []; 880 881 var i; 882 var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); 883 var len = split.length; 884 885 for (i = 0; i < len; i++) { 886 if (!split[i]) continue; // ignore empty strings 887 namespaces = split[i].replace(/\*/g, '.*?'); 888 if (namespaces[0] === '-') { 889 exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); 890 } else { 891 exports.names.push(new RegExp('^' + namespaces + '$')); 892 } 893 } 894 895 for (i = 0; i < exports.instances.length; i++) { 896 var instance = exports.instances[i]; 897 instance.enabled = exports.enabled(instance.namespace); 898 } 899 } 900 901 /** 902 * Disable debug output. 903 * 904 * @api public 905 */ 906 907 function disable() { 908 exports.enable(''); 909 } 910 911 /** 912 * Returns true if the given mode name is enabled, false otherwise. 913 * 914 * @param {String} name 915 * @return {Boolean} 916 * @api public 917 */ 918 919 function enabled(name) { 920 if (name[name.length - 1] === '*') { 921 return true; 922 } 923 var i, len; 924 for (i = 0, len = exports.skips.length; i < len; i++) { 925 if (exports.skips[i].test(name)) { 926 return false; 927 } 928 } 929 for (i = 0, len = exports.names.length; i < len; i++) { 930 if (exports.names[i].test(name)) { 931 return true; 932 } 933 } 934 return false; 935 } 936 937 /** 938 * Coerce `val`. 939 * 940 * @param {Mixed} val 941 * @return {Mixed} 942 * @api private 943 */ 944 945 function coerce(val) { 946 if (val instanceof Error) return val.stack || val.message; 947 return val; 948 } 949 950 },{"ms":14}],6:[function(require,module,exports){ 951 (function (global){ 952 var topLevel = typeof global !== 'undefined' ? global : 953 typeof window !== 'undefined' ? window : {} 954 var minDoc = require('min-document'); 955 956 var doccy; 957 958 if (typeof document !== 'undefined') { 959 doccy = document; 960 } else { 961 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4']; 962 963 if (!doccy) { 964 doccy = topLevel['__GLOBAL_DOCUMENT_CACHE@4'] = minDoc; 965 } 966 } 967 968 module.exports = doccy; 969 970 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 971 },{"min-document":3}],7:[function(require,module,exports){ 972 (function (global){ 973 var win; 974 975 if (typeof window !== "undefined") { 976 win = window; 977 } else if (typeof global !== "undefined") { 978 win = global; 979 } else if (typeof self !== "undefined"){ 980 win = self; 981 } else { 982 win = {}; 983 } 984 985 module.exports = win; 986 987 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 988 },{}],8:[function(require,module,exports){ 989 module.exports = function hashMatch (hash, prefix) { 990 var pre = prefix || '/'; 991 if (hash.length === 0) return pre; 992 hash = hash.replace('#', ''); 993 hash = hash.replace(/\/$/, '') 994 if (hash.indexOf('/') != 0) hash = '/' + hash; 995 if (pre == '/') return hash; 996 else return hash.replace(pre, ''); 997 } 998 999 },{}],9:[function(require,module,exports){ 1000 (function (global){ 1001 /*! https://mths.be/he v1.1.1 by @mathias | MIT license */ 1002 ;(function(root) { 1003 1004 // Detect free variables `exports`. 1005 var freeExports = typeof exports == 'object' && exports; 1006 1007 // Detect free variable `module`. 1008 var freeModule = typeof module == 'object' && module && 1009 module.exports == freeExports && module; 1010 1011 // Detect free variable `global`, from Node.js or Browserified code, 1012 // and use it as `root`. 1013 var freeGlobal = typeof global == 'object' && global; 1014 if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) { 1015 root = freeGlobal; 1016 } 1017 1018 /*--------------------------------------------------------------------------*/ 1019 1020 // All astral symbols. 1021 var regexAstralSymbols = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g; 1022 // All ASCII symbols (not just printable ASCII) except those listed in the 1023 // first column of the overrides table. 1024 // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides 1025 var regexAsciiWhitelist = /[\x01-\x7F]/g; 1026 // All BMP symbols that are not ASCII newlines, printable ASCII symbols, or 1027 // code points listed in the first column of the overrides table on 1028 // https://html.spec.whatwg.org/multipage/syntax.html#table-charref-overrides. 1029 var regexBmpWhitelist = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g; 1030 1031 var regexEncodeNonAscii = /<\u20D2|=\u20E5|>\u20D2|\u205F\u200A|\u219D\u0338|\u2202\u0338|\u2220\u20D2|\u2229\uFE00|\u222A\uFE00|\u223C\u20D2|\u223D\u0331|\u223E\u0333|\u2242\u0338|\u224B\u0338|\u224D\u20D2|\u224E\u0338|\u224F\u0338|\u2250\u0338|\u2261\u20E5|\u2264\u20D2|\u2265\u20D2|\u2266\u0338|\u2267\u0338|\u2268\uFE00|\u2269\uFE00|\u226A\u0338|\u226A\u20D2|\u226B\u0338|\u226B\u20D2|\u227F\u0338|\u2282\u20D2|\u2283\u20D2|\u228A\uFE00|\u228B\uFE00|\u228F\u0338|\u2290\u0338|\u2293\uFE00|\u2294\uFE00|\u22B4\u20D2|\u22B5\u20D2|\u22D8\u0338|\u22D9\u0338|\u22DA\uFE00|\u22DB\uFE00|\u22F5\u0338|\u22F9\u0338|\u2933\u0338|\u29CF\u0338|\u29D0\u0338|\u2A6D\u0338|\u2A70\u0338|\u2A7D\u0338|\u2A7E\u0338|\u2AA1\u0338|\u2AA2\u0338|\u2AAC\uFE00|\u2AAD\uFE00|\u2AAF\u0338|\u2AB0\u0338|\u2AC5\u0338|\u2AC6\u0338|\u2ACB\uFE00|\u2ACC\uFE00|\u2AFD\u20E5|[\xA0-\u0113\u0116-\u0122\u0124-\u012B\u012E-\u014D\u0150-\u017E\u0192\u01B5\u01F5\u0237\u02C6\u02C7\u02D8-\u02DD\u0311\u0391-\u03A1\u03A3-\u03A9\u03B1-\u03C9\u03D1\u03D2\u03D5\u03D6\u03DC\u03DD\u03F0\u03F1\u03F5\u03F6\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E\u045F\u2002-\u2005\u2007-\u2010\u2013-\u2016\u2018-\u201A\u201C-\u201E\u2020-\u2022\u2025\u2026\u2030-\u2035\u2039\u203A\u203E\u2041\u2043\u2044\u204F\u2057\u205F-\u2063\u20AC\u20DB\u20DC\u2102\u2105\u210A-\u2113\u2115-\u211E\u2122\u2124\u2127-\u2129\u212C\u212D\u212F-\u2131\u2133-\u2138\u2145-\u2148\u2153-\u215E\u2190-\u219B\u219D-\u21A7\u21A9-\u21AE\u21B0-\u21B3\u21B5-\u21B7\u21BA-\u21DB\u21DD\u21E4\u21E5\u21F5\u21FD-\u2205\u2207-\u2209\u220B\u220C\u220F-\u2214\u2216-\u2218\u221A\u221D-\u2238\u223A-\u2257\u2259\u225A\u225C\u225F-\u2262\u2264-\u228B\u228D-\u229B\u229D-\u22A5\u22A7-\u22B0\u22B2-\u22BB\u22BD-\u22DB\u22DE-\u22E3\u22E6-\u22F7\u22F9-\u22FE\u2305\u2306\u2308-\u2310\u2312\u2313\u2315\u2316\u231C-\u231F\u2322\u2323\u232D\u232E\u2336\u233D\u233F\u237C\u23B0\u23B1\u23B4-\u23B6\u23DC-\u23DF\u23E2\u23E7\u2423\u24C8\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2550-\u256C\u2580\u2584\u2588\u2591-\u2593\u25A1\u25AA\u25AB\u25AD\u25AE\u25B1\u25B3-\u25B5\u25B8\u25B9\u25BD-\u25BF\u25C2\u25C3\u25CA\u25CB\u25EC\u25EF\u25F8-\u25FC\u2605\u2606\u260E\u2640\u2642\u2660\u2663\u2665\u2666\u266A\u266D-\u266F\u2713\u2717\u2720\u2736\u2758\u2772\u2773\u27C8\u27C9\u27E6-\u27ED\u27F5-\u27FA\u27FC\u27FF\u2902-\u2905\u290C-\u2913\u2916\u2919-\u2920\u2923-\u292A\u2933\u2935-\u2939\u293C\u293D\u2945\u2948-\u294B\u294E-\u2976\u2978\u2979\u297B-\u297F\u2985\u2986\u298B-\u2996\u299A\u299C\u299D\u29A4-\u29B7\u29B9\u29BB\u29BC\u29BE-\u29C5\u29C9\u29CD-\u29D0\u29DC-\u29DE\u29E3-\u29E5\u29EB\u29F4\u29F6\u2A00-\u2A02\u2A04\u2A06\u2A0C\u2A0D\u2A10-\u2A17\u2A22-\u2A27\u2A29\u2A2A\u2A2D-\u2A31\u2A33-\u2A3C\u2A3F\u2A40\u2A42-\u2A4D\u2A50\u2A53-\u2A58\u2A5A-\u2A5D\u2A5F\u2A66\u2A6A\u2A6D-\u2A75\u2A77-\u2A9A\u2A9D-\u2AA2\u2AA4-\u2AB0\u2AB3-\u2AC8\u2ACB\u2ACC\u2ACF-\u2ADB\u2AE4\u2AE6-\u2AE9\u2AEB-\u2AF3\u2AFD\uFB00-\uFB04]|\uD835[\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDD6B]/g; 1032 var encodeMap = {'\xAD':'shy','\u200C':'zwnj','\u200D':'zwj','\u200E':'lrm','\u2063':'ic','\u2062':'it','\u2061':'af','\u200F':'rlm','\u200B':'ZeroWidthSpace','\u2060':'NoBreak','\u0311':'DownBreve','\u20DB':'tdot','\u20DC':'DotDot','\t':'Tab','\n':'NewLine','\u2008':'puncsp','\u205F':'MediumSpace','\u2009':'thinsp','\u200A':'hairsp','\u2004':'emsp13','\u2002':'ensp','\u2005':'emsp14','\u2003':'emsp','\u2007':'numsp','\xA0':'nbsp','\u205F\u200A':'ThickSpace','\u203E':'oline','_':'lowbar','\u2010':'dash','\u2013':'ndash','\u2014':'mdash','\u2015':'horbar',',':'comma',';':'semi','\u204F':'bsemi',':':'colon','\u2A74':'Colone','!':'excl','\xA1':'iexcl','?':'quest','\xBF':'iquest','.':'period','\u2025':'nldr','\u2026':'mldr','\xB7':'middot','\'':'apos','\u2018':'lsquo','\u2019':'rsquo','\u201A':'sbquo','\u2039':'lsaquo','\u203A':'rsaquo','"':'quot','\u201C':'ldquo','\u201D':'rdquo','\u201E':'bdquo','\xAB':'laquo','\xBB':'raquo','(':'lpar',')':'rpar','[':'lsqb',']':'rsqb','{':'lcub','}':'rcub','\u2308':'lceil','\u2309':'rceil','\u230A':'lfloor','\u230B':'rfloor','\u2985':'lopar','\u2986':'ropar','\u298B':'lbrke','\u298C':'rbrke','\u298D':'lbrkslu','\u298E':'rbrksld','\u298F':'lbrksld','\u2990':'rbrkslu','\u2991':'langd','\u2992':'rangd','\u2993':'lparlt','\u2994':'rpargt','\u2995':'gtlPar','\u2996':'ltrPar','\u27E6':'lobrk','\u27E7':'robrk','\u27E8':'lang','\u27E9':'rang','\u27EA':'Lang','\u27EB':'Rang','\u27EC':'loang','\u27ED':'roang','\u2772':'lbbrk','\u2773':'rbbrk','\u2016':'Vert','\xA7':'sect','\xB6':'para','@':'commat','*':'ast','/':'sol','undefined':null,'&':'amp','#':'num','%':'percnt','\u2030':'permil','\u2031':'pertenk','\u2020':'dagger','\u2021':'Dagger','\u2022':'bull','\u2043':'hybull','\u2032':'prime','\u2033':'Prime','\u2034':'tprime','\u2057':'qprime','\u2035':'bprime','\u2041':'caret','`':'grave','\xB4':'acute','\u02DC':'tilde','^':'Hat','\xAF':'macr','\u02D8':'breve','\u02D9':'dot','\xA8':'die','\u02DA':'ring','\u02DD':'dblac','\xB8':'cedil','\u02DB':'ogon','\u02C6':'circ','\u02C7':'caron','\xB0':'deg','\xA9':'copy','\xAE':'reg','\u2117':'copysr','\u2118':'wp','\u211E':'rx','\u2127':'mho','\u2129':'iiota','\u2190':'larr','\u219A':'nlarr','\u2192':'rarr','\u219B':'nrarr','\u2191':'uarr','\u2193':'darr','\u2194':'harr','\u21AE':'nharr','\u2195':'varr','\u2196':'nwarr','\u2197':'nearr','\u2198':'searr','\u2199':'swarr','\u219D':'rarrw','\u219D\u0338':'nrarrw','\u219E':'Larr','\u219F':'Uarr','\u21A0':'Rarr','\u21A1':'Darr','\u21A2':'larrtl','\u21A3':'rarrtl','\u21A4':'mapstoleft','\u21A5':'mapstoup','\u21A6':'map','\u21A7':'mapstodown','\u21A9':'larrhk','\u21AA':'rarrhk','\u21AB':'larrlp','\u21AC':'rarrlp','\u21AD':'harrw','\u21B0':'lsh','\u21B1':'rsh','\u21B2':'ldsh','\u21B3':'rdsh','\u21B5':'crarr','\u21B6':'cularr','\u21B7':'curarr','\u21BA':'olarr','\u21BB':'orarr','\u21BC':'lharu','\u21BD':'lhard','\u21BE':'uharr','\u21BF':'uharl','\u21C0':'rharu','\u21C1':'rhard','\u21C2':'dharr','\u21C3':'dharl','\u21C4':'rlarr','\u21C5':'udarr','\u21C6':'lrarr','\u21C7':'llarr','\u21C8':'uuarr','\u21C9':'rrarr','\u21CA':'ddarr','\u21CB':'lrhar','\u21CC':'rlhar','\u21D0':'lArr','\u21CD':'nlArr','\u21D1':'uArr','\u21D2':'rArr','\u21CF':'nrArr','\u21D3':'dArr','\u21D4':'iff','\u21CE':'nhArr','\u21D5':'vArr','\u21D6':'nwArr','\u21D7':'neArr','\u21D8':'seArr','\u21D9':'swArr','\u21DA':'lAarr','\u21DB':'rAarr','\u21DD':'zigrarr','\u21E4':'larrb','\u21E5':'rarrb','\u21F5':'duarr','\u21FD':'loarr','\u21FE':'roarr','\u21FF':'hoarr','\u2200':'forall','\u2201':'comp','\u2202':'part','\u2202\u0338':'npart','\u2203':'exist','\u2204':'nexist','\u2205':'empty','\u2207':'Del','\u2208':'in','\u2209':'notin','\u220B':'ni','\u220C':'notni','\u03F6':'bepsi','\u220F':'prod','\u2210':'coprod','\u2211':'sum','+':'plus','\xB1':'pm','\xF7':'div','\xD7':'times','<':'lt','\u226E':'nlt','<\u20D2':'nvlt','=':'equals','\u2260':'ne','=\u20E5':'bne','\u2A75':'Equal','>':'gt','\u226F':'ngt','>\u20D2':'nvgt','\xAC':'not','|':'vert','\xA6':'brvbar','\u2212':'minus','\u2213':'mp','\u2214':'plusdo','\u2044':'frasl','\u2216':'setmn','\u2217':'lowast','\u2218':'compfn','\u221A':'Sqrt','\u221D':'prop','\u221E':'infin','\u221F':'angrt','\u2220':'ang','\u2220\u20D2':'nang','\u2221':'angmsd','\u2222':'angsph','\u2223':'mid','\u2224':'nmid','\u2225':'par','\u2226':'npar','\u2227':'and','\u2228':'or','\u2229':'cap','\u2229\uFE00':'caps','\u222A':'cup','\u222A\uFE00':'cups','\u222B':'int','\u222C':'Int','\u222D':'tint','\u2A0C':'qint','\u222E':'oint','\u222F':'Conint','\u2230':'Cconint','\u2231':'cwint','\u2232':'cwconint','\u2233':'awconint','\u2234':'there4','\u2235':'becaus','\u2236':'ratio','\u2237':'Colon','\u2238':'minusd','\u223A':'mDDot','\u223B':'homtht','\u223C':'sim','\u2241':'nsim','\u223C\u20D2':'nvsim','\u223D':'bsim','\u223D\u0331':'race','\u223E':'ac','\u223E\u0333':'acE','\u223F':'acd','\u2240':'wr','\u2242':'esim','\u2242\u0338':'nesim','\u2243':'sime','\u2244':'nsime','\u2245':'cong','\u2247':'ncong','\u2246':'simne','\u2248':'ap','\u2249':'nap','\u224A':'ape','\u224B':'apid','\u224B\u0338':'napid','\u224C':'bcong','\u224D':'CupCap','\u226D':'NotCupCap','\u224D\u20D2':'nvap','\u224E':'bump','\u224E\u0338':'nbump','\u224F':'bumpe','\u224F\u0338':'nbumpe','\u2250':'doteq','\u2250\u0338':'nedot','\u2251':'eDot','\u2252':'efDot','\u2253':'erDot','\u2254':'colone','\u2255':'ecolon','\u2256':'ecir','\u2257':'cire','\u2259':'wedgeq','\u225A':'veeeq','\u225C':'trie','\u225F':'equest','\u2261':'equiv','\u2262':'nequiv','\u2261\u20E5':'bnequiv','\u2264':'le','\u2270':'nle','\u2264\u20D2':'nvle','\u2265':'ge','\u2271':'nge','\u2265\u20D2':'nvge','\u2266':'lE','\u2266\u0338':'nlE','\u2267':'gE','\u2267\u0338':'ngE','\u2268\uFE00':'lvnE','\u2268':'lnE','\u2269':'gnE','\u2269\uFE00':'gvnE','\u226A':'ll','\u226A\u0338':'nLtv','\u226A\u20D2':'nLt','\u226B':'gg','\u226B\u0338':'nGtv','\u226B\u20D2':'nGt','\u226C':'twixt','\u2272':'lsim','\u2274':'nlsim','\u2273':'gsim','\u2275':'ngsim','\u2276':'lg','\u2278':'ntlg','\u2277':'gl','\u2279':'ntgl','\u227A':'pr','\u2280':'npr','\u227B':'sc','\u2281':'nsc','\u227C':'prcue','\u22E0':'nprcue','\u227D':'sccue','\u22E1':'nsccue','\u227E':'prsim','\u227F':'scsim','\u227F\u0338':'NotSucceedsTilde','\u2282':'sub','\u2284':'nsub','\u2282\u20D2':'vnsub','\u2283':'sup','\u2285':'nsup','\u2283\u20D2':'vnsup','\u2286':'sube','\u2288':'nsube','\u2287':'supe','\u2289':'nsupe','\u228A\uFE00':'vsubne','\u228A':'subne','\u228B\uFE00':'vsupne','\u228B':'supne','\u228D':'cupdot','\u228E':'uplus','\u228F':'sqsub','\u228F\u0338':'NotSquareSubset','\u2290':'sqsup','\u2290\u0338':'NotSquareSuperset','\u2291':'sqsube','\u22E2':'nsqsube','\u2292':'sqsupe','\u22E3':'nsqsupe','\u2293':'sqcap','\u2293\uFE00':'sqcaps','\u2294':'sqcup','\u2294\uFE00':'sqcups','\u2295':'oplus','\u2296':'ominus','\u2297':'otimes','\u2298':'osol','\u2299':'odot','\u229A':'ocir','\u229B':'oast','\u229D':'odash','\u229E':'plusb','\u229F':'minusb','\u22A0':'timesb','\u22A1':'sdotb','\u22A2':'vdash','\u22AC':'nvdash','\u22A3':'dashv','\u22A4':'top','\u22A5':'bot','\u22A7':'models','\u22A8':'vDash','\u22AD':'nvDash','\u22A9':'Vdash','\u22AE':'nVdash','\u22AA':'Vvdash','\u22AB':'VDash','\u22AF':'nVDash','\u22B0':'prurel','\u22B2':'vltri','\u22EA':'nltri','\u22B3':'vrtri','\u22EB':'nrtri','\u22B4':'ltrie','\u22EC':'nltrie','\u22B4\u20D2':'nvltrie','\u22B5':'rtrie','\u22ED':'nrtrie','\u22B5\u20D2':'nvrtrie','\u22B6':'origof','\u22B7':'imof','\u22B8':'mumap','\u22B9':'hercon','\u22BA':'intcal','\u22BB':'veebar','\u22BD':'barvee','\u22BE':'angrtvb','\u22BF':'lrtri','\u22C0':'Wedge','\u22C1':'Vee','\u22C2':'xcap','\u22C3':'xcup','\u22C4':'diam','\u22C5':'sdot','\u22C6':'Star','\u22C7':'divonx','\u22C8':'bowtie','\u22C9':'ltimes','\u22CA':'rtimes','\u22CB':'lthree','\u22CC':'rthree','\u22CD':'bsime','\u22CE':'cuvee','\u22CF':'cuwed','\u22D0':'Sub','\u22D1':'Sup','\u22D2':'Cap','\u22D3':'Cup','\u22D4':'fork','\u22D5':'epar','\u22D6':'ltdot','\u22D7':'gtdot','\u22D8':'Ll','\u22D8\u0338':'nLl','\u22D9':'Gg','\u22D9\u0338':'nGg','\u22DA\uFE00':'lesg','\u22DA':'leg','\u22DB':'gel','\u22DB\uFE00':'gesl','\u22DE':'cuepr','\u22DF':'cuesc','\u22E6':'lnsim','\u22E7':'gnsim','\u22E8':'prnsim','\u22E9':'scnsim','\u22EE':'vellip','\u22EF':'ctdot','\u22F0':'utdot','\u22F1':'dtdot','\u22F2':'disin','\u22F3':'isinsv','\u22F4':'isins','\u22F5':'isindot','\u22F5\u0338':'notindot','\u22F6':'notinvc','\u22F7':'notinvb','\u22F9':'isinE','\u22F9\u0338':'notinE','\u22FA':'nisd','\u22FB':'xnis','\u22FC':'nis','\u22FD':'notnivc','\u22FE':'notnivb','\u2305':'barwed','\u2306':'Barwed','\u230C':'drcrop','\u230D':'dlcrop','\u230E':'urcrop','\u230F':'ulcrop','\u2310':'bnot','\u2312':'profline','\u2313':'profsurf','\u2315':'telrec','\u2316':'target','\u231C':'ulcorn','\u231D':'urcorn','\u231E':'dlcorn','\u231F':'drcorn','\u2322':'frown','\u2323':'smile','\u232D':'cylcty','\u232E':'profalar','\u2336':'topbot','\u233D':'ovbar','\u233F':'solbar','\u237C':'angzarr','\u23B0':'lmoust','\u23B1':'rmoust','\u23B4':'tbrk','\u23B5':'bbrk','\u23B6':'bbrktbrk','\u23DC':'OverParenthesis','\u23DD':'UnderParenthesis','\u23DE':'OverBrace','\u23DF':'UnderBrace','\u23E2':'trpezium','\u23E7':'elinters','\u2423':'blank','\u2500':'boxh','\u2502':'boxv','\u250C':'boxdr','\u2510':'boxdl','\u2514':'boxur','\u2518':'boxul','\u251C':'boxvr','\u2524':'boxvl','\u252C':'boxhd','\u2534':'boxhu','\u253C':'boxvh','\u2550':'boxH','\u2551':'boxV','\u2552':'boxdR','\u2553':'boxDr','\u2554':'boxDR','\u2555':'boxdL','\u2556':'boxDl','\u2557':'boxDL','\u2558':'boxuR','\u2559':'boxUr','\u255A':'boxUR','\u255B':'boxuL','\u255C':'boxUl','\u255D':'boxUL','\u255E':'boxvR','\u255F':'boxVr','\u2560':'boxVR','\u2561':'boxvL','\u2562':'boxVl','\u2563':'boxVL','\u2564':'boxHd','\u2565':'boxhD','\u2566':'boxHD','\u2567':'boxHu','\u2568':'boxhU','\u2569':'boxHU','\u256A':'boxvH','\u256B':'boxVh','\u256C':'boxVH','\u2580':'uhblk','\u2584':'lhblk','\u2588':'block','\u2591':'blk14','\u2592':'blk12','\u2593':'blk34','\u25A1':'squ','\u25AA':'squf','\u25AB':'EmptyVerySmallSquare','\u25AD':'rect','\u25AE':'marker','\u25B1':'fltns','\u25B3':'xutri','\u25B4':'utrif','\u25B5':'utri','\u25B8':'rtrif','\u25B9':'rtri','\u25BD':'xdtri','\u25BE':'dtrif','\u25BF':'dtri','\u25C2':'ltrif','\u25C3':'ltri','\u25CA':'loz','\u25CB':'cir','\u25EC':'tridot','\u25EF':'xcirc','\u25F8':'ultri','\u25F9':'urtri','\u25FA':'lltri','\u25FB':'EmptySmallSquare','\u25FC':'FilledSmallSquare','\u2605':'starf','\u2606':'star','\u260E':'phone','\u2640':'female','\u2642':'male','\u2660':'spades','\u2663':'clubs','\u2665':'hearts','\u2666':'diams','\u266A':'sung','\u2713':'check','\u2717':'cross','\u2720':'malt','\u2736':'sext','\u2758':'VerticalSeparator','\u27C8':'bsolhsub','\u27C9':'suphsol','\u27F5':'xlarr','\u27F6':'xrarr','\u27F7':'xharr','\u27F8':'xlArr','\u27F9':'xrArr','\u27FA':'xhArr','\u27FC':'xmap','\u27FF':'dzigrarr','\u2902':'nvlArr','\u2903':'nvrArr','\u2904':'nvHarr','\u2905':'Map','\u290C':'lbarr','\u290D':'rbarr','\u290E':'lBarr','\u290F':'rBarr','\u2910':'RBarr','\u2911':'DDotrahd','\u2912':'UpArrowBar','\u2913':'DownArrowBar','\u2916':'Rarrtl','\u2919':'latail','\u291A':'ratail','\u291B':'lAtail','\u291C':'rAtail','\u291D':'larrfs','\u291E':'rarrfs','\u291F':'larrbfs','\u2920':'rarrbfs','\u2923':'nwarhk','\u2924':'nearhk','\u2925':'searhk','\u2926':'swarhk','\u2927':'nwnear','\u2928':'toea','\u2929':'tosa','\u292A':'swnwar','\u2933':'rarrc','\u2933\u0338':'nrarrc','\u2935':'cudarrr','\u2936':'ldca','\u2937':'rdca','\u2938':'cudarrl','\u2939':'larrpl','\u293C':'curarrm','\u293D':'cularrp','\u2945':'rarrpl','\u2948':'harrcir','\u2949':'Uarrocir','\u294A':'lurdshar','\u294B':'ldrushar','\u294E':'LeftRightVector','\u294F':'RightUpDownVector','\u2950':'DownLeftRightVector','\u2951':'LeftUpDownVector','\u2952':'LeftVectorBar','\u2953':'RightVectorBar','\u2954':'RightUpVectorBar','\u2955':'RightDownVectorBar','\u2956':'DownLeftVectorBar','\u2957':'DownRightVectorBar','\u2958':'LeftUpVectorBar','\u2959':'LeftDownVectorBar','\u295A':'LeftTeeVector','\u295B':'RightTeeVector','\u295C':'RightUpTeeVector','\u295D':'RightDownTeeVector','\u295E':'DownLeftTeeVector','\u295F':'DownRightTeeVector','\u2960':'LeftUpTeeVector','\u2961':'LeftDownTeeVector','\u2962':'lHar','\u2963':'uHar','\u2964':'rHar','\u2965':'dHar','\u2966':'luruhar','\u2967':'ldrdhar','\u2968':'ruluhar','\u2969':'rdldhar','\u296A':'lharul','\u296B':'llhard','\u296C':'rharul','\u296D':'lrhard','\u296E':'udhar','\u296F':'duhar','\u2970':'RoundImplies','\u2971':'erarr','\u2972':'simrarr','\u2973':'larrsim','\u2974':'rarrsim','\u2975':'rarrap','\u2976':'ltlarr','\u2978':'gtrarr','\u2979':'subrarr','\u297B':'suplarr','\u297C':'lfisht','\u297D':'rfisht','\u297E':'ufisht','\u297F':'dfisht','\u299A':'vzigzag','\u299C':'vangrt','\u299D':'angrtvbd','\u29A4':'ange','\u29A5':'range','\u29A6':'dwangle','\u29A7':'uwangle','\u29A8':'angmsdaa','\u29A9':'angmsdab','\u29AA':'angmsdac','\u29AB':'angmsdad','\u29AC':'angmsdae','\u29AD':'angmsdaf','\u29AE':'angmsdag','\u29AF':'angmsdah','\u29B0':'bemptyv','\u29B1':'demptyv','\u29B2':'cemptyv','\u29B3':'raemptyv','\u29B4':'laemptyv','\u29B5':'ohbar','\u29B6':'omid','\u29B7':'opar','\u29B9':'operp','\u29BB':'olcross','\u29BC':'odsold','\u29BE':'olcir','\u29BF':'ofcir','\u29C0':'olt','\u29C1':'ogt','\u29C2':'cirscir','\u29C3':'cirE','\u29C4':'solb','\u29C5':'bsolb','\u29C9':'boxbox','\u29CD':'trisb','\u29CE':'rtriltri','\u29CF':'LeftTriangleBar','\u29CF\u0338':'NotLeftTriangleBar','\u29D0':'RightTriangleBar','\u29D0\u0338':'NotRightTriangleBar','\u29DC':'iinfin','\u29DD':'infintie','\u29DE':'nvinfin','\u29E3':'eparsl','\u29E4':'smeparsl','\u29E5':'eqvparsl','\u29EB':'lozf','\u29F4':'RuleDelayed','\u29F6':'dsol','\u2A00':'xodot','\u2A01':'xoplus','\u2A02':'xotime','\u2A04':'xuplus','\u2A06':'xsqcup','\u2A0D':'fpartint','\u2A10':'cirfnint','\u2A11':'awint','\u2A12':'rppolint','\u2A13':'scpolint','\u2A14':'npolint','\u2A15':'pointint','\u2A16':'quatint','\u2A17':'intlarhk','\u2A22':'pluscir','\u2A23':'plusacir','\u2A24':'simplus','\u2A25':'plusdu','\u2A26':'plussim','\u2A27':'plustwo','\u2A29':'mcomma','\u2A2A':'minusdu','\u2A2D':'loplus','\u2A2E':'roplus','\u2A2F':'Cross','\u2A30':'timesd','\u2A31':'timesbar','\u2A33':'smashp','\u2A34':'lotimes','\u2A35':'rotimes','\u2A36':'otimesas','\u2A37':'Otimes','\u2A38':'odiv','\u2A39':'triplus','\u2A3A':'triminus','\u2A3B':'tritime','\u2A3C':'iprod','\u2A3F':'amalg','\u2A40':'capdot','\u2A42':'ncup','\u2A43':'ncap','\u2A44':'capand','\u2A45':'cupor','\u2A46':'cupcap','\u2A47':'capcup','\u2A48':'cupbrcap','\u2A49':'capbrcup','\u2A4A':'cupcup','\u2A4B':'capcap','\u2A4C':'ccups','\u2A4D':'ccaps','\u2A50':'ccupssm','\u2A53':'And','\u2A54':'Or','\u2A55':'andand','\u2A56':'oror','\u2A57':'orslope','\u2A58':'andslope','\u2A5A':'andv','\u2A5B':'orv','\u2A5C':'andd','\u2A5D':'ord','\u2A5F':'wedbar','\u2A66':'sdote','\u2A6A':'simdot','\u2A6D':'congdot','\u2A6D\u0338':'ncongdot','\u2A6E':'easter','\u2A6F':'apacir','\u2A70':'apE','\u2A70\u0338':'napE','\u2A71':'eplus','\u2A72':'pluse','\u2A73':'Esim','\u2A77':'eDDot','\u2A78':'equivDD','\u2A79':'ltcir','\u2A7A':'gtcir','\u2A7B':'ltquest','\u2A7C':'gtquest','\u2A7D':'les','\u2A7D\u0338':'nles','\u2A7E':'ges','\u2A7E\u0338':'nges','\u2A7F':'lesdot','\u2A80':'gesdot','\u2A81':'lesdoto','\u2A82':'gesdoto','\u2A83':'lesdotor','\u2A84':'gesdotol','\u2A85':'lap','\u2A86':'gap','\u2A87':'lne','\u2A88':'gne','\u2A89':'lnap','\u2A8A':'gnap','\u2A8B':'lEg','\u2A8C':'gEl','\u2A8D':'lsime','\u2A8E':'gsime','\u2A8F':'lsimg','\u2A90':'gsiml','\u2A91':'lgE','\u2A92':'glE','\u2A93':'lesges','\u2A94':'gesles','\u2A95':'els','\u2A96':'egs','\u2A97':'elsdot','\u2A98':'egsdot','\u2A99':'el','\u2A9A':'eg','\u2A9D':'siml','\u2A9E':'simg','\u2A9F':'simlE','\u2AA0':'simgE','\u2AA1':'LessLess','\u2AA1\u0338':'NotNestedLessLess','\u2AA2':'GreaterGreater','\u2AA2\u0338':'NotNestedGreaterGreater','\u2AA4':'glj','\u2AA5':'gla','\u2AA6':'ltcc','\u2AA7':'gtcc','\u2AA8':'lescc','\u2AA9':'gescc','\u2AAA':'smt','\u2AAB':'lat','\u2AAC':'smte','\u2AAC\uFE00':'smtes','\u2AAD':'late','\u2AAD\uFE00':'lates','\u2AAE':'bumpE','\u2AAF':'pre','\u2AAF\u0338':'npre','\u2AB0':'sce','\u2AB0\u0338':'nsce','\u2AB3':'prE','\u2AB4':'scE','\u2AB5':'prnE','\u2AB6':'scnE','\u2AB7':'prap','\u2AB8':'scap','\u2AB9':'prnap','\u2ABA':'scnap','\u2ABB':'Pr','\u2ABC':'Sc','\u2ABD':'subdot','\u2ABE':'supdot','\u2ABF':'subplus','\u2AC0':'supplus','\u2AC1':'submult','\u2AC2':'supmult','\u2AC3':'subedot','\u2AC4':'supedot','\u2AC5':'subE','\u2AC5\u0338':'nsubE','\u2AC6':'supE','\u2AC6\u0338':'nsupE','\u2AC7':'subsim','\u2AC8':'supsim','\u2ACB\uFE00':'vsubnE','\u2ACB':'subnE','\u2ACC\uFE00':'vsupnE','\u2ACC':'supnE','\u2ACF':'csub','\u2AD0':'csup','\u2AD1':'csube','\u2AD2':'csupe','\u2AD3':'subsup','\u2AD4':'supsub','\u2AD5':'subsub','\u2AD6':'supsup','\u2AD7':'suphsub','\u2AD8':'supdsub','\u2AD9':'forkv','\u2ADA':'topfork','\u2ADB':'mlcp','\u2AE4':'Dashv','\u2AE6':'Vdashl','\u2AE7':'Barv','\u2AE8':'vBar','\u2AE9':'vBarv','\u2AEB':'Vbar','\u2AEC':'Not','\u2AED':'bNot','\u2AEE':'rnmid','\u2AEF':'cirmid','\u2AF0':'midcir','\u2AF1':'topcir','\u2AF2':'nhpar','\u2AF3':'parsim','\u2AFD':'parsl','\u2AFD\u20E5':'nparsl','\u266D':'flat','\u266E':'natur','\u266F':'sharp','\xA4':'curren','\xA2':'cent','$':'dollar','\xA3':'pound','\xA5':'yen','\u20AC':'euro','\xB9':'sup1','\xBD':'half','\u2153':'frac13','\xBC':'frac14','\u2155':'frac15','\u2159':'frac16','\u215B':'frac18','\xB2':'sup2','\u2154':'frac23','\u2156':'frac25','\xB3':'sup3','\xBE':'frac34','\u2157':'frac35','\u215C':'frac38','\u2158':'frac45','\u215A':'frac56','\u215D':'frac58','\u215E':'frac78','\uD835\uDCB6':'ascr','\uD835\uDD52':'aopf','\uD835\uDD1E':'afr','\uD835\uDD38':'Aopf','\uD835\uDD04':'Afr','\uD835\uDC9C':'Ascr','\xAA':'ordf','\xE1':'aacute','\xC1':'Aacute','\xE0':'agrave','\xC0':'Agrave','\u0103':'abreve','\u0102':'Abreve','\xE2':'acirc','\xC2':'Acirc','\xE5':'aring','\xC5':'angst','\xE4':'auml','\xC4':'Auml','\xE3':'atilde','\xC3':'Atilde','\u0105':'aogon','\u0104':'Aogon','\u0101':'amacr','\u0100':'Amacr','\xE6':'aelig','\xC6':'AElig','\uD835\uDCB7':'bscr','\uD835\uDD53':'bopf','\uD835\uDD1F':'bfr','\uD835\uDD39':'Bopf','\u212C':'Bscr','\uD835\uDD05':'Bfr','\uD835\uDD20':'cfr','\uD835\uDCB8':'cscr','\uD835\uDD54':'copf','\u212D':'Cfr','\uD835\uDC9E':'Cscr','\u2102':'Copf','\u0107':'cacute','\u0106':'Cacute','\u0109':'ccirc','\u0108':'Ccirc','\u010D':'ccaron','\u010C':'Ccaron','\u010B':'cdot','\u010A':'Cdot','\xE7':'ccedil','\xC7':'Ccedil','\u2105':'incare','\uD835\uDD21':'dfr','\u2146':'dd','\uD835\uDD55':'dopf','\uD835\uDCB9':'dscr','\uD835\uDC9F':'Dscr','\uD835\uDD07':'Dfr','\u2145':'DD','\uD835\uDD3B':'Dopf','\u010F':'dcaron','\u010E':'Dcaron','\u0111':'dstrok','\u0110':'Dstrok','\xF0':'eth','\xD0':'ETH','\u2147':'ee','\u212F':'escr','\uD835\uDD22':'efr','\uD835\uDD56':'eopf','\u2130':'Escr','\uD835\uDD08':'Efr','\uD835\uDD3C':'Eopf','\xE9':'eacute','\xC9':'Eacute','\xE8':'egrave','\xC8':'Egrave','\xEA':'ecirc','\xCA':'Ecirc','\u011B':'ecaron','\u011A':'Ecaron','\xEB':'euml','\xCB':'Euml','\u0117':'edot','\u0116':'Edot','\u0119':'eogon','\u0118':'Eogon','\u0113':'emacr','\u0112':'Emacr','\uD835\uDD23':'ffr','\uD835\uDD57':'fopf','\uD835\uDCBB':'fscr','\uD835\uDD09':'Ffr','\uD835\uDD3D':'Fopf','\u2131':'Fscr','\uFB00':'fflig','\uFB03':'ffilig','\uFB04':'ffllig','\uFB01':'filig','fj':'fjlig','\uFB02':'fllig','\u0192':'fnof','\u210A':'gscr','\uD835\uDD58':'gopf','\uD835\uDD24':'gfr','\uD835\uDCA2':'Gscr','\uD835\uDD3E':'Gopf','\uD835\uDD0A':'Gfr','\u01F5':'gacute','\u011F':'gbreve','\u011E':'Gbreve','\u011D':'gcirc','\u011C':'Gcirc','\u0121':'gdot','\u0120':'Gdot','\u0122':'Gcedil','\uD835\uDD25':'hfr','\u210E':'planckh','\uD835\uDCBD':'hscr','\uD835\uDD59':'hopf','\u210B':'Hscr','\u210C':'Hfr','\u210D':'Hopf','\u0125':'hcirc','\u0124':'Hcirc','\u210F':'hbar','\u0127':'hstrok','\u0126':'Hstrok','\uD835\uDD5A':'iopf','\uD835\uDD26':'ifr','\uD835\uDCBE':'iscr','\u2148':'ii','\uD835\uDD40':'Iopf','\u2110':'Iscr','\u2111':'Im','\xED':'iacute','\xCD':'Iacute','\xEC':'igrave','\xCC':'Igrave','\xEE':'icirc','\xCE':'Icirc','\xEF':'iuml','\xCF':'Iuml','\u0129':'itilde','\u0128':'Itilde','\u0130':'Idot','\u012F':'iogon','\u012E':'Iogon','\u012B':'imacr','\u012A':'Imacr','\u0133':'ijlig','\u0132':'IJlig','\u0131':'imath','\uD835\uDCBF':'jscr','\uD835\uDD5B':'jopf','\uD835\uDD27':'jfr','\uD835\uDCA5':'Jscr','\uD835\uDD0D':'Jfr','\uD835\uDD41':'Jopf','\u0135':'jcirc','\u0134':'Jcirc','\u0237':'jmath','\uD835\uDD5C':'kopf','\uD835\uDCC0':'kscr','\uD835\uDD28':'kfr','\uD835\uDCA6':'Kscr','\uD835\uDD42':'Kopf','\uD835\uDD0E':'Kfr','\u0137':'kcedil','\u0136':'Kcedil','\uD835\uDD29':'lfr','\uD835\uDCC1':'lscr','\u2113':'ell','\uD835\uDD5D':'lopf','\u2112':'Lscr','\uD835\uDD0F':'Lfr','\uD835\uDD43':'Lopf','\u013A':'lacute','\u0139':'Lacute','\u013E':'lcaron','\u013D':'Lcaron','\u013C':'lcedil','\u013B':'Lcedil','\u0142':'lstrok','\u0141':'Lstrok','\u0140':'lmidot','\u013F':'Lmidot','\uD835\uDD2A':'mfr','\uD835\uDD5E':'mopf','\uD835\uDCC2':'mscr','\uD835\uDD10':'Mfr','\uD835\uDD44':'Mopf','\u2133':'Mscr','\uD835\uDD2B':'nfr','\uD835\uDD5F':'nopf','\uD835\uDCC3':'nscr','\u2115':'Nopf','\uD835\uDCA9':'Nscr','\uD835\uDD11':'Nfr','\u0144':'nacute','\u0143':'Nacute','\u0148':'ncaron','\u0147':'Ncaron','\xF1':'ntilde','\xD1':'Ntilde','\u0146':'ncedil','\u0145':'Ncedil','\u2116':'numero','\u014B':'eng','\u014A':'ENG','\uD835\uDD60':'oopf','\uD835\uDD2C':'ofr','\u2134':'oscr','\uD835\uDCAA':'Oscr','\uD835\uDD12':'Ofr','\uD835\uDD46':'Oopf','\xBA':'ordm','\xF3':'oacute','\xD3':'Oacute','\xF2':'ograve','\xD2':'Ograve','\xF4':'ocirc','\xD4':'Ocirc','\xF6':'ouml','\xD6':'Ouml','\u0151':'odblac','\u0150':'Odblac','\xF5':'otilde','\xD5':'Otilde','\xF8':'oslash','\xD8':'Oslash','\u014D':'omacr','\u014C':'Omacr','\u0153':'oelig','\u0152':'OElig','\uD835\uDD2D':'pfr','\uD835\uDCC5':'pscr','\uD835\uDD61':'popf','\u2119':'Popf','\uD835\uDD13':'Pfr','\uD835\uDCAB':'Pscr','\uD835\uDD62':'qopf','\uD835\uDD2E':'qfr','\uD835\uDCC6':'qscr','\uD835\uDCAC':'Qscr','\uD835\uDD14':'Qfr','\u211A':'Qopf','\u0138':'kgreen','\uD835\uDD2F':'rfr','\uD835\uDD63':'ropf','\uD835\uDCC7':'rscr','\u211B':'Rscr','\u211C':'Re','\u211D':'Ropf','\u0155':'racute','\u0154':'Racute','\u0159':'rcaron','\u0158':'Rcaron','\u0157':'rcedil','\u0156':'Rcedil','\uD835\uDD64':'sopf','\uD835\uDCC8':'sscr','\uD835\uDD30':'sfr','\uD835\uDD4A':'Sopf','\uD835\uDD16':'Sfr','\uD835\uDCAE':'Sscr','\u24C8':'oS','\u015B':'sacute','\u015A':'Sacute','\u015D':'scirc','\u015C':'Scirc','\u0161':'scaron','\u0160':'Scaron','\u015F':'scedil','\u015E':'Scedil','\xDF':'szlig','\uD835\uDD31':'tfr','\uD835\uDCC9':'tscr','\uD835\uDD65':'topf','\uD835\uDCAF':'Tscr','\uD835\uDD17':'Tfr','\uD835\uDD4B':'Topf','\u0165':'tcaron','\u0164':'Tcaron','\u0163':'tcedil','\u0162':'Tcedil','\u2122':'trade','\u0167':'tstrok','\u0166':'Tstrok','\uD835\uDCCA':'uscr','\uD835\uDD66':'uopf','\uD835\uDD32':'ufr','\uD835\uDD4C':'Uopf','\uD835\uDD18':'Ufr','\uD835\uDCB0':'Uscr','\xFA':'uacute','\xDA':'Uacute','\xF9':'ugrave','\xD9':'Ugrave','\u016D':'ubreve','\u016C':'Ubreve','\xFB':'ucirc','\xDB':'Ucirc','\u016F':'uring','\u016E':'Uring','\xFC':'uuml','\xDC':'Uuml','\u0171':'udblac','\u0170':'Udblac','\u0169':'utilde','\u0168':'Utilde','\u0173':'uogon','\u0172':'Uogon','\u016B':'umacr','\u016A':'Umacr','\uD835\uDD33':'vfr','\uD835\uDD67':'vopf','\uD835\uDCCB':'vscr','\uD835\uDD19':'Vfr','\uD835\uDD4D':'Vopf','\uD835\uDCB1':'Vscr','\uD835\uDD68':'wopf','\uD835\uDCCC':'wscr','\uD835\uDD34':'wfr','\uD835\uDCB2':'Wscr','\uD835\uDD4E':'Wopf','\uD835\uDD1A':'Wfr','\u0175':'wcirc','\u0174':'Wcirc','\uD835\uDD35':'xfr','\uD835\uDCCD':'xscr','\uD835\uDD69':'xopf','\uD835\uDD4F':'Xopf','\uD835\uDD1B':'Xfr','\uD835\uDCB3':'Xscr','\uD835\uDD36':'yfr','\uD835\uDCCE':'yscr','\uD835\uDD6A':'yopf','\uD835\uDCB4':'Yscr','\uD835\uDD1C':'Yfr','\uD835\uDD50':'Yopf','\xFD':'yacute','\xDD':'Yacute','\u0177':'ycirc','\u0176':'Ycirc','\xFF':'yuml','\u0178':'Yuml','\uD835\uDCCF':'zscr','\uD835\uDD37':'zfr','\uD835\uDD6B':'zopf','\u2128':'Zfr','\u2124':'Zopf','\uD835\uDCB5':'Zscr','\u017A':'zacute','\u0179':'Zacute','\u017E':'zcaron','\u017D':'Zcaron','\u017C':'zdot','\u017B':'Zdot','\u01B5':'imped','\xFE':'thorn','\xDE':'THORN','\u0149':'napos','\u03B1':'alpha','\u0391':'Alpha','\u03B2':'beta','\u0392':'Beta','\u03B3':'gamma','\u0393':'Gamma','\u03B4':'delta','\u0394':'Delta','\u03B5':'epsi','\u03F5':'epsiv','\u0395':'Epsilon','\u03DD':'gammad','\u03DC':'Gammad','\u03B6':'zeta','\u0396':'Zeta','\u03B7':'eta','\u0397':'Eta','\u03B8':'theta','\u03D1':'thetav','\u0398':'Theta','\u03B9':'iota','\u0399':'Iota','\u03BA':'kappa','\u03F0':'kappav','\u039A':'Kappa','\u03BB':'lambda','\u039B':'Lambda','\u03BC':'mu','\xB5':'micro','\u039C':'Mu','\u03BD':'nu','\u039D':'Nu','\u03BE':'xi','\u039E':'Xi','\u03BF':'omicron','\u039F':'Omicron','\u03C0':'pi','\u03D6':'piv','\u03A0':'Pi','\u03C1':'rho','\u03F1':'rhov','\u03A1':'Rho','\u03C3':'sigma','\u03A3':'Sigma','\u03C2':'sigmaf','\u03C4':'tau','\u03A4':'Tau','\u03C5':'upsi','\u03A5':'Upsilon','\u03D2':'Upsi','\u03C6':'phi','\u03D5':'phiv','\u03A6':'Phi','\u03C7':'chi','\u03A7':'Chi','\u03C8':'psi','\u03A8':'Psi','\u03C9':'omega','\u03A9':'ohm','\u0430':'acy','\u0410':'Acy','\u0431':'bcy','\u0411':'Bcy','\u0432':'vcy','\u0412':'Vcy','\u0433':'gcy','\u0413':'Gcy','\u0453':'gjcy','\u0403':'GJcy','\u0434':'dcy','\u0414':'Dcy','\u0452':'djcy','\u0402':'DJcy','\u0435':'iecy','\u0415':'IEcy','\u0451':'iocy','\u0401':'IOcy','\u0454':'jukcy','\u0404':'Jukcy','\u0436':'zhcy','\u0416':'ZHcy','\u0437':'zcy','\u0417':'Zcy','\u0455':'dscy','\u0405':'DScy','\u0438':'icy','\u0418':'Icy','\u0456':'iukcy','\u0406':'Iukcy','\u0457':'yicy','\u0407':'YIcy','\u0439':'jcy','\u0419':'Jcy','\u0458':'jsercy','\u0408':'Jsercy','\u043A':'kcy','\u041A':'Kcy','\u045C':'kjcy','\u040C':'KJcy','\u043B':'lcy','\u041B':'Lcy','\u0459':'ljcy','\u0409':'LJcy','\u043C':'mcy','\u041C':'Mcy','\u043D':'ncy','\u041D':'Ncy','\u045A':'njcy','\u040A':'NJcy','\u043E':'ocy','\u041E':'Ocy','\u043F':'pcy','\u041F':'Pcy','\u0440':'rcy','\u0420':'Rcy','\u0441':'scy','\u0421':'Scy','\u0442':'tcy','\u0422':'Tcy','\u045B':'tshcy','\u040B':'TSHcy','\u0443':'ucy','\u0423':'Ucy','\u045E':'ubrcy','\u040E':'Ubrcy','\u0444':'fcy','\u0424':'Fcy','\u0445':'khcy','\u0425':'KHcy','\u0446':'tscy','\u0426':'TScy','\u0447':'chcy','\u0427':'CHcy','\u045F':'dzcy','\u040F':'DZcy','\u0448':'shcy','\u0428':'SHcy','\u0449':'shchcy','\u0429':'SHCHcy','\u044A':'hardcy','\u042A':'HARDcy','\u044B':'ycy','\u042B':'Ycy','\u044C':'softcy','\u042C':'SOFTcy','\u044D':'ecy','\u042D':'Ecy','\u044E':'yucy','\u042E':'YUcy','\u044F':'yacy','\u042F':'YAcy','\u2135':'aleph','\u2136':'beth','\u2137':'gimel','\u2138':'daleth'}; 1033 1034 var regexEscape = /["&'<>`]/g; 1035 var escapeMap = { 1036 '"': '"', 1037 '&': '&', 1038 '\'': ''', 1039 '<': '<', 1040 // See https://mathiasbynens.be/notes/ambiguous-ampersands: in HTML, the 1041 // following is not strictly necessary unless it’s part of a tag or an 1042 // unquoted attribute value. We’re only escaping it to support those 1043 // situations, and for XML support. 1044 '>': '>', 1045 // In Internet Explorer ≤ 8, the backtick character can be used 1046 // to break out of (un)quoted attribute values or HTML comments. 1047 // See http://html5sec.org/#102, http://html5sec.org/#108, and 1048 // http://html5sec.org/#133. 1049 '`': '`' 1050 }; 1051 1052 var regexInvalidEntity = /&#(?:[xX][^a-fA-F0-9]|[^0-9xX])/; 1053 var regexInvalidRawCodePoint = /[\0-\x08\x0B\x0E-\x1F\x7F-\x9F\uFDD0-\uFDEF\uFFFE\uFFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDFFE\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; 1054 var regexDecode = /&#([0-9]+)(;?)|&#[xX]([a-fA-F0-9]+)(;?)|&([0-9a-zA-Z]+);|&(Aacute|Agrave|Atilde|Ccedil|Eacute|Egrave|Iacute|Igrave|Ntilde|Oacute|Ograve|Oslash|Otilde|Uacute|Ugrave|Yacute|aacute|agrave|atilde|brvbar|ccedil|curren|divide|eacute|egrave|frac12|frac14|frac34|iacute|igrave|iquest|middot|ntilde|oacute|ograve|oslash|otilde|plusmn|uacute|ugrave|yacute|AElig|Acirc|Aring|Ecirc|Icirc|Ocirc|THORN|Ucirc|acirc|acute|aelig|aring|cedil|ecirc|icirc|iexcl|laquo|micro|ocirc|pound|raquo|szlig|thorn|times|ucirc|Auml|COPY|Euml|Iuml|Ouml|QUOT|Uuml|auml|cent|copy|euml|iuml|macr|nbsp|ordf|ordm|ouml|para|quot|sect|sup1|sup2|sup3|uuml|yuml|AMP|ETH|REG|amp|deg|eth|not|reg|shy|uml|yen|GT|LT|gt|lt)([=a-zA-Z0-9])?/g; 1055 var decodeMap = {'aacute':'\xE1','Aacute':'\xC1','abreve':'\u0103','Abreve':'\u0102','ac':'\u223E','acd':'\u223F','acE':'\u223E\u0333','acirc':'\xE2','Acirc':'\xC2','acute':'\xB4','acy':'\u0430','Acy':'\u0410','aelig':'\xE6','AElig':'\xC6','af':'\u2061','afr':'\uD835\uDD1E','Afr':'\uD835\uDD04','agrave':'\xE0','Agrave':'\xC0','alefsym':'\u2135','aleph':'\u2135','alpha':'\u03B1','Alpha':'\u0391','amacr':'\u0101','Amacr':'\u0100','amalg':'\u2A3F','amp':'&','AMP':'&','and':'\u2227','And':'\u2A53','andand':'\u2A55','andd':'\u2A5C','andslope':'\u2A58','andv':'\u2A5A','ang':'\u2220','ange':'\u29A4','angle':'\u2220','angmsd':'\u2221','angmsdaa':'\u29A8','angmsdab':'\u29A9','angmsdac':'\u29AA','angmsdad':'\u29AB','angmsdae':'\u29AC','angmsdaf':'\u29AD','angmsdag':'\u29AE','angmsdah':'\u29AF','angrt':'\u221F','angrtvb':'\u22BE','angrtvbd':'\u299D','angsph':'\u2222','angst':'\xC5','angzarr':'\u237C','aogon':'\u0105','Aogon':'\u0104','aopf':'\uD835\uDD52','Aopf':'\uD835\uDD38','ap':'\u2248','apacir':'\u2A6F','ape':'\u224A','apE':'\u2A70','apid':'\u224B','apos':'\'','ApplyFunction':'\u2061','approx':'\u2248','approxeq':'\u224A','aring':'\xE5','Aring':'\xC5','ascr':'\uD835\uDCB6','Ascr':'\uD835\uDC9C','Assign':'\u2254','ast':'*','asymp':'\u2248','asympeq':'\u224D','atilde':'\xE3','Atilde':'\xC3','auml':'\xE4','Auml':'\xC4','awconint':'\u2233','awint':'\u2A11','backcong':'\u224C','backepsilon':'\u03F6','backprime':'\u2035','backsim':'\u223D','backsimeq':'\u22CD','Backslash':'\u2216','Barv':'\u2AE7','barvee':'\u22BD','barwed':'\u2305','Barwed':'\u2306','barwedge':'\u2305','bbrk':'\u23B5','bbrktbrk':'\u23B6','bcong':'\u224C','bcy':'\u0431','Bcy':'\u0411','bdquo':'\u201E','becaus':'\u2235','because':'\u2235','Because':'\u2235','bemptyv':'\u29B0','bepsi':'\u03F6','bernou':'\u212C','Bernoullis':'\u212C','beta':'\u03B2','Beta':'\u0392','beth':'\u2136','between':'\u226C','bfr':'\uD835\uDD1F','Bfr':'\uD835\uDD05','bigcap':'\u22C2','bigcirc':'\u25EF','bigcup':'\u22C3','bigodot':'\u2A00','bigoplus':'\u2A01','bigotimes':'\u2A02','bigsqcup':'\u2A06','bigstar':'\u2605','bigtriangledown':'\u25BD','bigtriangleup':'\u25B3','biguplus':'\u2A04','bigvee':'\u22C1','bigwedge':'\u22C0','bkarow':'\u290D','blacklozenge':'\u29EB','blacksquare':'\u25AA','blacktriangle':'\u25B4','blacktriangledown':'\u25BE','blacktriangleleft':'\u25C2','blacktriangleright':'\u25B8','blank':'\u2423','blk12':'\u2592','blk14':'\u2591','blk34':'\u2593','block':'\u2588','bne':'=\u20E5','bnequiv':'\u2261\u20E5','bnot':'\u2310','bNot':'\u2AED','bopf':'\uD835\uDD53','Bopf':'\uD835\uDD39','bot':'\u22A5','bottom':'\u22A5','bowtie':'\u22C8','boxbox':'\u29C9','boxdl':'\u2510','boxdL':'\u2555','boxDl':'\u2556','boxDL':'\u2557','boxdr':'\u250C','boxdR':'\u2552','boxDr':'\u2553','boxDR':'\u2554','boxh':'\u2500','boxH':'\u2550','boxhd':'\u252C','boxhD':'\u2565','boxHd':'\u2564','boxHD':'\u2566','boxhu':'\u2534','boxhU':'\u2568','boxHu':'\u2567','boxHU':'\u2569','boxminus':'\u229F','boxplus':'\u229E','boxtimes':'\u22A0','boxul':'\u2518','boxuL':'\u255B','boxUl':'\u255C','boxUL':'\u255D','boxur':'\u2514','boxuR':'\u2558','boxUr':'\u2559','boxUR':'\u255A','boxv':'\u2502','boxV':'\u2551','boxvh':'\u253C','boxvH':'\u256A','boxVh':'\u256B','boxVH':'\u256C','boxvl':'\u2524','boxvL':'\u2561','boxVl':'\u2562','boxVL':'\u2563','boxvr':'\u251C','boxvR':'\u255E','boxVr':'\u255F','boxVR':'\u2560','bprime':'\u2035','breve':'\u02D8','Breve':'\u02D8','brvbar':'\xA6','bscr':'\uD835\uDCB7','Bscr':'\u212C','bsemi':'\u204F','bsim':'\u223D','bsime':'\u22CD','bsol':'\\','bsolb':'\u29C5','bsolhsub':'\u27C8','bull':'\u2022','bullet':'\u2022','bump':'\u224E','bumpe':'\u224F','bumpE':'\u2AAE','bumpeq':'\u224F','Bumpeq':'\u224E','cacute':'\u0107','Cacute':'\u0106','cap':'\u2229','Cap':'\u22D2','capand':'\u2A44','capbrcup':'\u2A49','capcap':'\u2A4B','capcup':'\u2A47','capdot':'\u2A40','CapitalDifferentialD':'\u2145','caps':'\u2229\uFE00','caret':'\u2041','caron':'\u02C7','Cayleys':'\u212D','ccaps':'\u2A4D','ccaron':'\u010D','Ccaron':'\u010C','ccedil':'\xE7','Ccedil':'\xC7','ccirc':'\u0109','Ccirc':'\u0108','Cconint':'\u2230','ccups':'\u2A4C','ccupssm':'\u2A50','cdot':'\u010B','Cdot':'\u010A','cedil':'\xB8','Cedilla':'\xB8','cemptyv':'\u29B2','cent':'\xA2','centerdot':'\xB7','CenterDot':'\xB7','cfr':'\uD835\uDD20','Cfr':'\u212D','chcy':'\u0447','CHcy':'\u0427','check':'\u2713','checkmark':'\u2713','chi':'\u03C7','Chi':'\u03A7','cir':'\u25CB','circ':'\u02C6','circeq':'\u2257','circlearrowleft':'\u21BA','circlearrowright':'\u21BB','circledast':'\u229B','circledcirc':'\u229A','circleddash':'\u229D','CircleDot':'\u2299','circledR':'\xAE','circledS':'\u24C8','CircleMinus':'\u2296','CirclePlus':'\u2295','CircleTimes':'\u2297','cire':'\u2257','cirE':'\u29C3','cirfnint':'\u2A10','cirmid':'\u2AEF','cirscir':'\u29C2','ClockwiseContourIntegral':'\u2232','CloseCurlyDoubleQuote':'\u201D','CloseCurlyQuote':'\u2019','clubs':'\u2663','clubsuit':'\u2663','colon':':','Colon':'\u2237','colone':'\u2254','Colone':'\u2A74','coloneq':'\u2254','comma':',','commat':'@','comp':'\u2201','compfn':'\u2218','complement':'\u2201','complexes':'\u2102','cong':'\u2245','congdot':'\u2A6D','Congruent':'\u2261','conint':'\u222E','Conint':'\u222F','ContourIntegral':'\u222E','copf':'\uD835\uDD54','Copf':'\u2102','coprod':'\u2210','Coproduct':'\u2210','copy':'\xA9','COPY':'\xA9','copysr':'\u2117','CounterClockwiseContourIntegral':'\u2233','crarr':'\u21B5','cross':'\u2717','Cross':'\u2A2F','cscr':'\uD835\uDCB8','Cscr':'\uD835\uDC9E','csub':'\u2ACF','csube':'\u2AD1','csup':'\u2AD0','csupe':'\u2AD2','ctdot':'\u22EF','cudarrl':'\u2938','cudarrr':'\u2935','cuepr':'\u22DE','cuesc':'\u22DF','cularr':'\u21B6','cularrp':'\u293D','cup':'\u222A','Cup':'\u22D3','cupbrcap':'\u2A48','cupcap':'\u2A46','CupCap':'\u224D','cupcup':'\u2A4A','cupdot':'\u228D','cupor':'\u2A45','cups':'\u222A\uFE00','curarr':'\u21B7','curarrm':'\u293C','curlyeqprec':'\u22DE','curlyeqsucc':'\u22DF','curlyvee':'\u22CE','curlywedge':'\u22CF','curren':'\xA4','curvearrowleft':'\u21B6','curvearrowright':'\u21B7','cuvee':'\u22CE','cuwed':'\u22CF','cwconint':'\u2232','cwint':'\u2231','cylcty':'\u232D','dagger':'\u2020','Dagger':'\u2021','daleth':'\u2138','darr':'\u2193','dArr':'\u21D3','Darr':'\u21A1','dash':'\u2010','dashv':'\u22A3','Dashv':'\u2AE4','dbkarow':'\u290F','dblac':'\u02DD','dcaron':'\u010F','Dcaron':'\u010E','dcy':'\u0434','Dcy':'\u0414','dd':'\u2146','DD':'\u2145','ddagger':'\u2021','ddarr':'\u21CA','DDotrahd':'\u2911','ddotseq':'\u2A77','deg':'\xB0','Del':'\u2207','delta':'\u03B4','Delta':'\u0394','demptyv':'\u29B1','dfisht':'\u297F','dfr':'\uD835\uDD21','Dfr':'\uD835\uDD07','dHar':'\u2965','dharl':'\u21C3','dharr':'\u21C2','DiacriticalAcute':'\xB4','DiacriticalDot':'\u02D9','DiacriticalDoubleAcute':'\u02DD','DiacriticalGrave':'`','DiacriticalTilde':'\u02DC','diam':'\u22C4','diamond':'\u22C4','Diamond':'\u22C4','diamondsuit':'\u2666','diams':'\u2666','die':'\xA8','DifferentialD':'\u2146','digamma':'\u03DD','disin':'\u22F2','div':'\xF7','divide':'\xF7','divideontimes':'\u22C7','divonx':'\u22C7','djcy':'\u0452','DJcy':'\u0402','dlcorn':'\u231E','dlcrop':'\u230D','dollar':'$','dopf':'\uD835\uDD55','Dopf':'\uD835\uDD3B','dot':'\u02D9','Dot':'\xA8','DotDot':'\u20DC','doteq':'\u2250','doteqdot':'\u2251','DotEqual':'\u2250','dotminus':'\u2238','dotplus':'\u2214','dotsquare':'\u22A1','doublebarwedge':'\u2306','DoubleContourIntegral':'\u222F','DoubleDot':'\xA8','DoubleDownArrow':'\u21D3','DoubleLeftArrow':'\u21D0','DoubleLeftRightArrow':'\u21D4','DoubleLeftTee':'\u2AE4','DoubleLongLeftArrow':'\u27F8','DoubleLongLeftRightArrow':'\u27FA','DoubleLongRightArrow':'\u27F9','DoubleRightArrow':'\u21D2','DoubleRightTee':'\u22A8','DoubleUpArrow':'\u21D1','DoubleUpDownArrow':'\u21D5','DoubleVerticalBar':'\u2225','downarrow':'\u2193','Downarrow':'\u21D3','DownArrow':'\u2193','DownArrowBar':'\u2913','DownArrowUpArrow':'\u21F5','DownBreve':'\u0311','downdownarrows':'\u21CA','downharpoonleft':'\u21C3','downharpoonright':'\u21C2','DownLeftRightVector':'\u2950','DownLeftTeeVector':'\u295E','DownLeftVector':'\u21BD','DownLeftVectorBar':'\u2956','DownRightTeeVector':'\u295F','DownRightVector':'\u21C1','DownRightVectorBar':'\u2957','DownTee':'\u22A4','DownTeeArrow':'\u21A7','drbkarow':'\u2910','drcorn':'\u231F','drcrop':'\u230C','dscr':'\uD835\uDCB9','Dscr':'\uD835\uDC9F','dscy':'\u0455','DScy':'\u0405','dsol':'\u29F6','dstrok':'\u0111','Dstrok':'\u0110','dtdot':'\u22F1','dtri':'\u25BF','dtrif':'\u25BE','duarr':'\u21F5','duhar':'\u296F','dwangle':'\u29A6','dzcy':'\u045F','DZcy':'\u040F','dzigrarr':'\u27FF','eacute':'\xE9','Eacute':'\xC9','easter':'\u2A6E','ecaron':'\u011B','Ecaron':'\u011A','ecir':'\u2256','ecirc':'\xEA','Ecirc':'\xCA','ecolon':'\u2255','ecy':'\u044D','Ecy':'\u042D','eDDot':'\u2A77','edot':'\u0117','eDot':'\u2251','Edot':'\u0116','ee':'\u2147','efDot':'\u2252','efr':'\uD835\uDD22','Efr':'\uD835\uDD08','eg':'\u2A9A','egrave':'\xE8','Egrave':'\xC8','egs':'\u2A96','egsdot':'\u2A98','el':'\u2A99','Element':'\u2208','elinters':'\u23E7','ell':'\u2113','els':'\u2A95','elsdot':'\u2A97','emacr':'\u0113','Emacr':'\u0112','empty':'\u2205','emptyset':'\u2205','EmptySmallSquare':'\u25FB','emptyv':'\u2205','EmptyVerySmallSquare':'\u25AB','emsp':'\u2003','emsp13':'\u2004','emsp14':'\u2005','eng':'\u014B','ENG':'\u014A','ensp':'\u2002','eogon':'\u0119','Eogon':'\u0118','eopf':'\uD835\uDD56','Eopf':'\uD835\uDD3C','epar':'\u22D5','eparsl':'\u29E3','eplus':'\u2A71','epsi':'\u03B5','epsilon':'\u03B5','Epsilon':'\u0395','epsiv':'\u03F5','eqcirc':'\u2256','eqcolon':'\u2255','eqsim':'\u2242','eqslantgtr':'\u2A96','eqslantless':'\u2A95','Equal':'\u2A75','equals':'=','EqualTilde':'\u2242','equest':'\u225F','Equilibrium':'\u21CC','equiv':'\u2261','equivDD':'\u2A78','eqvparsl':'\u29E5','erarr':'\u2971','erDot':'\u2253','escr':'\u212F','Escr':'\u2130','esdot':'\u2250','esim':'\u2242','Esim':'\u2A73','eta':'\u03B7','Eta':'\u0397','eth':'\xF0','ETH':'\xD0','euml':'\xEB','Euml':'\xCB','euro':'\u20AC','excl':'!','exist':'\u2203','Exists':'\u2203','expectation':'\u2130','exponentiale':'\u2147','ExponentialE':'\u2147','fallingdotseq':'\u2252','fcy':'\u0444','Fcy':'\u0424','female':'\u2640','ffilig':'\uFB03','fflig':'\uFB00','ffllig':'\uFB04','ffr':'\uD835\uDD23','Ffr':'\uD835\uDD09','filig':'\uFB01','FilledSmallSquare':'\u25FC','FilledVerySmallSquare':'\u25AA','fjlig':'fj','flat':'\u266D','fllig':'\uFB02','fltns':'\u25B1','fnof':'\u0192','fopf':'\uD835\uDD57','Fopf':'\uD835\uDD3D','forall':'\u2200','ForAll':'\u2200','fork':'\u22D4','forkv':'\u2AD9','Fouriertrf':'\u2131','fpartint':'\u2A0D','frac12':'\xBD','frac13':'\u2153','frac14':'\xBC','frac15':'\u2155','frac16':'\u2159','frac18':'\u215B','frac23':'\u2154','frac25':'\u2156','frac34':'\xBE','frac35':'\u2157','frac38':'\u215C','frac45':'\u2158','frac56':'\u215A','frac58':'\u215D','frac78':'\u215E','frasl':'\u2044','frown':'\u2322','fscr':'\uD835\uDCBB','Fscr':'\u2131','gacute':'\u01F5','gamma':'\u03B3','Gamma':'\u0393','gammad':'\u03DD','Gammad':'\u03DC','gap':'\u2A86','gbreve':'\u011F','Gbreve':'\u011E','Gcedil':'\u0122','gcirc':'\u011D','Gcirc':'\u011C','gcy':'\u0433','Gcy':'\u0413','gdot':'\u0121','Gdot':'\u0120','ge':'\u2265','gE':'\u2267','gel':'\u22DB','gEl':'\u2A8C','geq':'\u2265','geqq':'\u2267','geqslant':'\u2A7E','ges':'\u2A7E','gescc':'\u2AA9','gesdot':'\u2A80','gesdoto':'\u2A82','gesdotol':'\u2A84','gesl':'\u22DB\uFE00','gesles':'\u2A94','gfr':'\uD835\uDD24','Gfr':'\uD835\uDD0A','gg':'\u226B','Gg':'\u22D9','ggg':'\u22D9','gimel':'\u2137','gjcy':'\u0453','GJcy':'\u0403','gl':'\u2277','gla':'\u2AA5','glE':'\u2A92','glj':'\u2AA4','gnap':'\u2A8A','gnapprox':'\u2A8A','gne':'\u2A88','gnE':'\u2269','gneq':'\u2A88','gneqq':'\u2269','gnsim':'\u22E7','gopf':'\uD835\uDD58','Gopf':'\uD835\uDD3E','grave':'`','GreaterEqual':'\u2265','GreaterEqualLess':'\u22DB','GreaterFullEqual':'\u2267','GreaterGreater':'\u2AA2','GreaterLess':'\u2277','GreaterSlantEqual':'\u2A7E','GreaterTilde':'\u2273','gscr':'\u210A','Gscr':'\uD835\uDCA2','gsim':'\u2273','gsime':'\u2A8E','gsiml':'\u2A90','gt':'>','Gt':'\u226B','GT':'>','gtcc':'\u2AA7','gtcir':'\u2A7A','gtdot':'\u22D7','gtlPar':'\u2995','gtquest':'\u2A7C','gtrapprox':'\u2A86','gtrarr':'\u2978','gtrdot':'\u22D7','gtreqless':'\u22DB','gtreqqless':'\u2A8C','gtrless':'\u2277','gtrsim':'\u2273','gvertneqq':'\u2269\uFE00','gvnE':'\u2269\uFE00','Hacek':'\u02C7','hairsp':'\u200A','half':'\xBD','hamilt':'\u210B','hardcy':'\u044A','HARDcy':'\u042A','harr':'\u2194','hArr':'\u21D4','harrcir':'\u2948','harrw':'\u21AD','Hat':'^','hbar':'\u210F','hcirc':'\u0125','Hcirc':'\u0124','hearts':'\u2665','heartsuit':'\u2665','hellip':'\u2026','hercon':'\u22B9','hfr':'\uD835\uDD25','Hfr':'\u210C','HilbertSpace':'\u210B','hksearow':'\u2925','hkswarow':'\u2926','hoarr':'\u21FF','homtht':'\u223B','hookleftarrow':'\u21A9','hookrightarrow':'\u21AA','hopf':'\uD835\uDD59','Hopf':'\u210D','horbar':'\u2015','HorizontalLine':'\u2500','hscr':'\uD835\uDCBD','Hscr':'\u210B','hslash':'\u210F','hstrok':'\u0127','Hstrok':'\u0126','HumpDownHump':'\u224E','HumpEqual':'\u224F','hybull':'\u2043','hyphen':'\u2010','iacute':'\xED','Iacute':'\xCD','ic':'\u2063','icirc':'\xEE','Icirc':'\xCE','icy':'\u0438','Icy':'\u0418','Idot':'\u0130','iecy':'\u0435','IEcy':'\u0415','iexcl':'\xA1','iff':'\u21D4','ifr':'\uD835\uDD26','Ifr':'\u2111','igrave':'\xEC','Igrave':'\xCC','ii':'\u2148','iiiint':'\u2A0C','iiint':'\u222D','iinfin':'\u29DC','iiota':'\u2129','ijlig':'\u0133','IJlig':'\u0132','Im':'\u2111','imacr':'\u012B','Imacr':'\u012A','image':'\u2111','ImaginaryI':'\u2148','imagline':'\u2110','imagpart':'\u2111','imath':'\u0131','imof':'\u22B7','imped':'\u01B5','Implies':'\u21D2','in':'\u2208','incare':'\u2105','infin':'\u221E','infintie':'\u29DD','inodot':'\u0131','int':'\u222B','Int':'\u222C','intcal':'\u22BA','integers':'\u2124','Integral':'\u222B','intercal':'\u22BA','Intersection':'\u22C2','intlarhk':'\u2A17','intprod':'\u2A3C','InvisibleComma':'\u2063','InvisibleTimes':'\u2062','iocy':'\u0451','IOcy':'\u0401','iogon':'\u012F','Iogon':'\u012E','iopf':'\uD835\uDD5A','Iopf':'\uD835\uDD40','iota':'\u03B9','Iota':'\u0399','iprod':'\u2A3C','iquest':'\xBF','iscr':'\uD835\uDCBE','Iscr':'\u2110','isin':'\u2208','isindot':'\u22F5','isinE':'\u22F9','isins':'\u22F4','isinsv':'\u22F3','isinv':'\u2208','it':'\u2062','itilde':'\u0129','Itilde':'\u0128','iukcy':'\u0456','Iukcy':'\u0406','iuml':'\xEF','Iuml':'\xCF','jcirc':'\u0135','Jcirc':'\u0134','jcy':'\u0439','Jcy':'\u0419','jfr':'\uD835\uDD27','Jfr':'\uD835\uDD0D','jmath':'\u0237','jopf':'\uD835\uDD5B','Jopf':'\uD835\uDD41','jscr':'\uD835\uDCBF','Jscr':'\uD835\uDCA5','jsercy':'\u0458','Jsercy':'\u0408','jukcy':'\u0454','Jukcy':'\u0404','kappa':'\u03BA','Kappa':'\u039A','kappav':'\u03F0','kcedil':'\u0137','Kcedil':'\u0136','kcy':'\u043A','Kcy':'\u041A','kfr':'\uD835\uDD28','Kfr':'\uD835\uDD0E','kgreen':'\u0138','khcy':'\u0445','KHcy':'\u0425','kjcy':'\u045C','KJcy':'\u040C','kopf':'\uD835\uDD5C','Kopf':'\uD835\uDD42','kscr':'\uD835\uDCC0','Kscr':'\uD835\uDCA6','lAarr':'\u21DA','lacute':'\u013A','Lacute':'\u0139','laemptyv':'\u29B4','lagran':'\u2112','lambda':'\u03BB','Lambda':'\u039B','lang':'\u27E8','Lang':'\u27EA','langd':'\u2991','langle':'\u27E8','lap':'\u2A85','Laplacetrf':'\u2112','laquo':'\xAB','larr':'\u2190','lArr':'\u21D0','Larr':'\u219E','larrb':'\u21E4','larrbfs':'\u291F','larrfs':'\u291D','larrhk':'\u21A9','larrlp':'\u21AB','larrpl':'\u2939','larrsim':'\u2973','larrtl':'\u21A2','lat':'\u2AAB','latail':'\u2919','lAtail':'\u291B','late':'\u2AAD','lates':'\u2AAD\uFE00','lbarr':'\u290C','lBarr':'\u290E','lbbrk':'\u2772','lbrace':'{','lbrack':'[','lbrke':'\u298B','lbrksld':'\u298F','lbrkslu':'\u298D','lcaron':'\u013E','Lcaron':'\u013D','lcedil':'\u013C','Lcedil':'\u013B','lceil':'\u2308','lcub':'{','lcy':'\u043B','Lcy':'\u041B','ldca':'\u2936','ldquo':'\u201C','ldquor':'\u201E','ldrdhar':'\u2967','ldrushar':'\u294B','ldsh':'\u21B2','le':'\u2264','lE':'\u2266','LeftAngleBracket':'\u27E8','leftarrow':'\u2190','Leftarrow':'\u21D0','LeftArrow':'\u2190','LeftArrowBar':'\u21E4','LeftArrowRightArrow':'\u21C6','leftarrowtail':'\u21A2','LeftCeiling':'\u2308','LeftDoubleBracket':'\u27E6','LeftDownTeeVector':'\u2961','LeftDownVector':'\u21C3','LeftDownVectorBar':'\u2959','LeftFloor':'\u230A','leftharpoondown':'\u21BD','leftharpoonup':'\u21BC','leftleftarrows':'\u21C7','leftrightarrow':'\u2194','Leftrightarrow':'\u21D4','LeftRightArrow':'\u2194','leftrightarrows':'\u21C6','leftrightharpoons':'\u21CB','leftrightsquigarrow':'\u21AD','LeftRightVector':'\u294E','LeftTee':'\u22A3','LeftTeeArrow':'\u21A4','LeftTeeVector':'\u295A','leftthreetimes':'\u22CB','LeftTriangle':'\u22B2','LeftTriangleBar':'\u29CF','LeftTriangleEqual':'\u22B4','LeftUpDownVector':'\u2951','LeftUpTeeVector':'\u2960','LeftUpVector':'\u21BF','LeftUpVectorBar':'\u2958','LeftVector':'\u21BC','LeftVectorBar':'\u2952','leg':'\u22DA','lEg':'\u2A8B','leq':'\u2264','leqq':'\u2266','leqslant':'\u2A7D','les':'\u2A7D','lescc':'\u2AA8','lesdot':'\u2A7F','lesdoto':'\u2A81','lesdotor':'\u2A83','lesg':'\u22DA\uFE00','lesges':'\u2A93','lessapprox':'\u2A85','lessdot':'\u22D6','lesseqgtr':'\u22DA','lesseqqgtr':'\u2A8B','LessEqualGreater':'\u22DA','LessFullEqual':'\u2266','LessGreater':'\u2276','lessgtr':'\u2276','LessLess':'\u2AA1','lesssim':'\u2272','LessSlantEqual':'\u2A7D','LessTilde':'\u2272','lfisht':'\u297C','lfloor':'\u230A','lfr':'\uD835\uDD29','Lfr':'\uD835\uDD0F','lg':'\u2276','lgE':'\u2A91','lHar':'\u2962','lhard':'\u21BD','lharu':'\u21BC','lharul':'\u296A','lhblk':'\u2584','ljcy':'\u0459','LJcy':'\u0409','ll':'\u226A','Ll':'\u22D8','llarr':'\u21C7','llcorner':'\u231E','Lleftarrow':'\u21DA','llhard':'\u296B','lltri':'\u25FA','lmidot':'\u0140','Lmidot':'\u013F','lmoust':'\u23B0','lmoustache':'\u23B0','lnap':'\u2A89','lnapprox':'\u2A89','lne':'\u2A87','lnE':'\u2268','lneq':'\u2A87','lneqq':'\u2268','lnsim':'\u22E6','loang':'\u27EC','loarr':'\u21FD','lobrk':'\u27E6','longleftarrow':'\u27F5','Longleftarrow':'\u27F8','LongLeftArrow':'\u27F5','longleftrightarrow':'\u27F7','Longleftrightarrow':'\u27FA','LongLeftRightArrow':'\u27F7','longmapsto':'\u27FC','longrightarrow':'\u27F6','Longrightarrow':'\u27F9','LongRightArrow':'\u27F6','looparrowleft':'\u21AB','looparrowright':'\u21AC','lopar':'\u2985','lopf':'\uD835\uDD5D','Lopf':'\uD835\uDD43','loplus':'\u2A2D','lotimes':'\u2A34','lowast':'\u2217','lowbar':'_','LowerLeftArrow':'\u2199','LowerRightArrow':'\u2198','loz':'\u25CA','lozenge':'\u25CA','lozf':'\u29EB','lpar':'(','lparlt':'\u2993','lrarr':'\u21C6','lrcorner':'\u231F','lrhar':'\u21CB','lrhard':'\u296D','lrm':'\u200E','lrtri':'\u22BF','lsaquo':'\u2039','lscr':'\uD835\uDCC1','Lscr':'\u2112','lsh':'\u21B0','Lsh':'\u21B0','lsim':'\u2272','lsime':'\u2A8D','lsimg':'\u2A8F','lsqb':'[','lsquo':'\u2018','lsquor':'\u201A','lstrok':'\u0142','Lstrok':'\u0141','lt':'<','Lt':'\u226A','LT':'<','ltcc':'\u2AA6','ltcir':'\u2A79','ltdot':'\u22D6','lthree':'\u22CB','ltimes':'\u22C9','ltlarr':'\u2976','ltquest':'\u2A7B','ltri':'\u25C3','ltrie':'\u22B4','ltrif':'\u25C2','ltrPar':'\u2996','lurdshar':'\u294A','luruhar':'\u2966','lvertneqq':'\u2268\uFE00','lvnE':'\u2268\uFE00','macr':'\xAF','male':'\u2642','malt':'\u2720','maltese':'\u2720','map':'\u21A6','Map':'\u2905','mapsto':'\u21A6','mapstodown':'\u21A7','mapstoleft':'\u21A4','mapstoup':'\u21A5','marker':'\u25AE','mcomma':'\u2A29','mcy':'\u043C','Mcy':'\u041C','mdash':'\u2014','mDDot':'\u223A','measuredangle':'\u2221','MediumSpace':'\u205F','Mellintrf':'\u2133','mfr':'\uD835\uDD2A','Mfr':'\uD835\uDD10','mho':'\u2127','micro':'\xB5','mid':'\u2223','midast':'*','midcir':'\u2AF0','middot':'\xB7','minus':'\u2212','minusb':'\u229F','minusd':'\u2238','minusdu':'\u2A2A','MinusPlus':'\u2213','mlcp':'\u2ADB','mldr':'\u2026','mnplus':'\u2213','models':'\u22A7','mopf':'\uD835\uDD5E','Mopf':'\uD835\uDD44','mp':'\u2213','mscr':'\uD835\uDCC2','Mscr':'\u2133','mstpos':'\u223E','mu':'\u03BC','Mu':'\u039C','multimap':'\u22B8','mumap':'\u22B8','nabla':'\u2207','nacute':'\u0144','Nacute':'\u0143','nang':'\u2220\u20D2','nap':'\u2249','napE':'\u2A70\u0338','napid':'\u224B\u0338','napos':'\u0149','napprox':'\u2249','natur':'\u266E','natural':'\u266E','naturals':'\u2115','nbsp':'\xA0','nbump':'\u224E\u0338','nbumpe':'\u224F\u0338','ncap':'\u2A43','ncaron':'\u0148','Ncaron':'\u0147','ncedil':'\u0146','Ncedil':'\u0145','ncong':'\u2247','ncongdot':'\u2A6D\u0338','ncup':'\u2A42','ncy':'\u043D','Ncy':'\u041D','ndash':'\u2013','ne':'\u2260','nearhk':'\u2924','nearr':'\u2197','neArr':'\u21D7','nearrow':'\u2197','nedot':'\u2250\u0338','NegativeMediumSpace':'\u200B','NegativeThickSpace':'\u200B','NegativeThinSpace':'\u200B','NegativeVeryThinSpace':'\u200B','nequiv':'\u2262','nesear':'\u2928','nesim':'\u2242\u0338','NestedGreaterGreater':'\u226B','NestedLessLess':'\u226A','NewLine':'\n','nexist':'\u2204','nexists':'\u2204','nfr':'\uD835\uDD2B','Nfr':'\uD835\uDD11','nge':'\u2271','ngE':'\u2267\u0338','ngeq':'\u2271','ngeqq':'\u2267\u0338','ngeqslant':'\u2A7E\u0338','nges':'\u2A7E\u0338','nGg':'\u22D9\u0338','ngsim':'\u2275','ngt':'\u226F','nGt':'\u226B\u20D2','ngtr':'\u226F','nGtv':'\u226B\u0338','nharr':'\u21AE','nhArr':'\u21CE','nhpar':'\u2AF2','ni':'\u220B','nis':'\u22FC','nisd':'\u22FA','niv':'\u220B','njcy':'\u045A','NJcy':'\u040A','nlarr':'\u219A','nlArr':'\u21CD','nldr':'\u2025','nle':'\u2270','nlE':'\u2266\u0338','nleftarrow':'\u219A','nLeftarrow':'\u21CD','nleftrightarrow':'\u21AE','nLeftrightarrow':'\u21CE','nleq':'\u2270','nleqq':'\u2266\u0338','nleqslant':'\u2A7D\u0338','nles':'\u2A7D\u0338','nless':'\u226E','nLl':'\u22D8\u0338','nlsim':'\u2274','nlt':'\u226E','nLt':'\u226A\u20D2','nltri':'\u22EA','nltrie':'\u22EC','nLtv':'\u226A\u0338','nmid':'\u2224','NoBreak':'\u2060','NonBreakingSpace':'\xA0','nopf':'\uD835\uDD5F','Nopf':'\u2115','not':'\xAC','Not':'\u2AEC','NotCongruent':'\u2262','NotCupCap':'\u226D','NotDoubleVerticalBar':'\u2226','NotElement':'\u2209','NotEqual':'\u2260','NotEqualTilde':'\u2242\u0338','NotExists':'\u2204','NotGreater':'\u226F','NotGreaterEqual':'\u2271','NotGreaterFullEqual':'\u2267\u0338','NotGreaterGreater':'\u226B\u0338','NotGreaterLess':'\u2279','NotGreaterSlantEqual':'\u2A7E\u0338','NotGreaterTilde':'\u2275','NotHumpDownHump':'\u224E\u0338','NotHumpEqual':'\u224F\u0338','notin':'\u2209','notindot':'\u22F5\u0338','notinE':'\u22F9\u0338','notinva':'\u2209','notinvb':'\u22F7','notinvc':'\u22F6','NotLeftTriangle':'\u22EA','NotLeftTriangleBar':'\u29CF\u0338','NotLeftTriangleEqual':'\u22EC','NotLess':'\u226E','NotLessEqual':'\u2270','NotLessGreater':'\u2278','NotLessLess':'\u226A\u0338','NotLessSlantEqual':'\u2A7D\u0338','NotLessTilde':'\u2274','NotNestedGreaterGreater':'\u2AA2\u0338','NotNestedLessLess':'\u2AA1\u0338','notni':'\u220C','notniva':'\u220C','notnivb':'\u22FE','notnivc':'\u22FD','NotPrecedes':'\u2280','NotPrecedesEqual':'\u2AAF\u0338','NotPrecedesSlantEqual':'\u22E0','NotReverseElement':'\u220C','NotRightTriangle':'\u22EB','NotRightTriangleBar':'\u29D0\u0338','NotRightTriangleEqual':'\u22ED','NotSquareSubset':'\u228F\u0338','NotSquareSubsetEqual':'\u22E2','NotSquareSuperset':'\u2290\u0338','NotSquareSupersetEqual':'\u22E3','NotSubset':'\u2282\u20D2','NotSubsetEqual':'\u2288','NotSucceeds':'\u2281','NotSucceedsEqual':'\u2AB0\u0338','NotSucceedsSlantEqual':'\u22E1','NotSucceedsTilde':'\u227F\u0338','NotSuperset':'\u2283\u20D2','NotSupersetEqual':'\u2289','NotTilde':'\u2241','NotTildeEqual':'\u2244','NotTildeFullEqual':'\u2247','NotTildeTilde':'\u2249','NotVerticalBar':'\u2224','npar':'\u2226','nparallel':'\u2226','nparsl':'\u2AFD\u20E5','npart':'\u2202\u0338','npolint':'\u2A14','npr':'\u2280','nprcue':'\u22E0','npre':'\u2AAF\u0338','nprec':'\u2280','npreceq':'\u2AAF\u0338','nrarr':'\u219B','nrArr':'\u21CF','nrarrc':'\u2933\u0338','nrarrw':'\u219D\u0338','nrightarrow':'\u219B','nRightarrow':'\u21CF','nrtri':'\u22EB','nrtrie':'\u22ED','nsc':'\u2281','nsccue':'\u22E1','nsce':'\u2AB0\u0338','nscr':'\uD835\uDCC3','Nscr':'\uD835\uDCA9','nshortmid':'\u2224','nshortparallel':'\u2226','nsim':'\u2241','nsime':'\u2244','nsimeq':'\u2244','nsmid':'\u2224','nspar':'\u2226','nsqsube':'\u22E2','nsqsupe':'\u22E3','nsub':'\u2284','nsube':'\u2288','nsubE':'\u2AC5\u0338','nsubset':'\u2282\u20D2','nsubseteq':'\u2288','nsubseteqq':'\u2AC5\u0338','nsucc':'\u2281','nsucceq':'\u2AB0\u0338','nsup':'\u2285','nsupe':'\u2289','nsupE':'\u2AC6\u0338','nsupset':'\u2283\u20D2','nsupseteq':'\u2289','nsupseteqq':'\u2AC6\u0338','ntgl':'\u2279','ntilde':'\xF1','Ntilde':'\xD1','ntlg':'\u2278','ntriangleleft':'\u22EA','ntrianglelefteq':'\u22EC','ntriangleright':'\u22EB','ntrianglerighteq':'\u22ED','nu':'\u03BD','Nu':'\u039D','num':'#','numero':'\u2116','numsp':'\u2007','nvap':'\u224D\u20D2','nvdash':'\u22AC','nvDash':'\u22AD','nVdash':'\u22AE','nVDash':'\u22AF','nvge':'\u2265\u20D2','nvgt':'>\u20D2','nvHarr':'\u2904','nvinfin':'\u29DE','nvlArr':'\u2902','nvle':'\u2264\u20D2','nvlt':'<\u20D2','nvltrie':'\u22B4\u20D2','nvrArr':'\u2903','nvrtrie':'\u22B5\u20D2','nvsim':'\u223C\u20D2','nwarhk':'\u2923','nwarr':'\u2196','nwArr':'\u21D6','nwarrow':'\u2196','nwnear':'\u2927','oacute':'\xF3','Oacute':'\xD3','oast':'\u229B','ocir':'\u229A','ocirc':'\xF4','Ocirc':'\xD4','ocy':'\u043E','Ocy':'\u041E','odash':'\u229D','odblac':'\u0151','Odblac':'\u0150','odiv':'\u2A38','odot':'\u2299','odsold':'\u29BC','oelig':'\u0153','OElig':'\u0152','ofcir':'\u29BF','ofr':'\uD835\uDD2C','Ofr':'\uD835\uDD12','ogon':'\u02DB','ograve':'\xF2','Ograve':'\xD2','ogt':'\u29C1','ohbar':'\u29B5','ohm':'\u03A9','oint':'\u222E','olarr':'\u21BA','olcir':'\u29BE','olcross':'\u29BB','oline':'\u203E','olt':'\u29C0','omacr':'\u014D','Omacr':'\u014C','omega':'\u03C9','Omega':'\u03A9','omicron':'\u03BF','Omicron':'\u039F','omid':'\u29B6','ominus':'\u2296','oopf':'\uD835\uDD60','Oopf':'\uD835\uDD46','opar':'\u29B7','OpenCurlyDoubleQuote':'\u201C','OpenCurlyQuote':'\u2018','operp':'\u29B9','oplus':'\u2295','or':'\u2228','Or':'\u2A54','orarr':'\u21BB','ord':'\u2A5D','order':'\u2134','orderof':'\u2134','ordf':'\xAA','ordm':'\xBA','origof':'\u22B6','oror':'\u2A56','orslope':'\u2A57','orv':'\u2A5B','oS':'\u24C8','oscr':'\u2134','Oscr':'\uD835\uDCAA','oslash':'\xF8','Oslash':'\xD8','osol':'\u2298','otilde':'\xF5','Otilde':'\xD5','otimes':'\u2297','Otimes':'\u2A37','otimesas':'\u2A36','ouml':'\xF6','Ouml':'\xD6','ovbar':'\u233D','OverBar':'\u203E','OverBrace':'\u23DE','OverBracket':'\u23B4','OverParenthesis':'\u23DC','par':'\u2225','para':'\xB6','parallel':'\u2225','parsim':'\u2AF3','parsl':'\u2AFD','part':'\u2202','PartialD':'\u2202','pcy':'\u043F','Pcy':'\u041F','percnt':'%','period':'.','permil':'\u2030','perp':'\u22A5','pertenk':'\u2031','pfr':'\uD835\uDD2D','Pfr':'\uD835\uDD13','phi':'\u03C6','Phi':'\u03A6','phiv':'\u03D5','phmmat':'\u2133','phone':'\u260E','pi':'\u03C0','Pi':'\u03A0','pitchfork':'\u22D4','piv':'\u03D6','planck':'\u210F','planckh':'\u210E','plankv':'\u210F','plus':'+','plusacir':'\u2A23','plusb':'\u229E','pluscir':'\u2A22','plusdo':'\u2214','plusdu':'\u2A25','pluse':'\u2A72','PlusMinus':'\xB1','plusmn':'\xB1','plussim':'\u2A26','plustwo':'\u2A27','pm':'\xB1','Poincareplane':'\u210C','pointint':'\u2A15','popf':'\uD835\uDD61','Popf':'\u2119','pound':'\xA3','pr':'\u227A','Pr':'\u2ABB','prap':'\u2AB7','prcue':'\u227C','pre':'\u2AAF','prE':'\u2AB3','prec':'\u227A','precapprox':'\u2AB7','preccurlyeq':'\u227C','Precedes':'\u227A','PrecedesEqual':'\u2AAF','PrecedesSlantEqual':'\u227C','PrecedesTilde':'\u227E','preceq':'\u2AAF','precnapprox':'\u2AB9','precneqq':'\u2AB5','precnsim':'\u22E8','precsim':'\u227E','prime':'\u2032','Prime':'\u2033','primes':'\u2119','prnap':'\u2AB9','prnE':'\u2AB5','prnsim':'\u22E8','prod':'\u220F','Product':'\u220F','profalar':'\u232E','profline':'\u2312','profsurf':'\u2313','prop':'\u221D','Proportion':'\u2237','Proportional':'\u221D','propto':'\u221D','prsim':'\u227E','prurel':'\u22B0','pscr':'\uD835\uDCC5','Pscr':'\uD835\uDCAB','psi':'\u03C8','Psi':'\u03A8','puncsp':'\u2008','qfr':'\uD835\uDD2E','Qfr':'\uD835\uDD14','qint':'\u2A0C','qopf':'\uD835\uDD62','Qopf':'\u211A','qprime':'\u2057','qscr':'\uD835\uDCC6','Qscr':'\uD835\uDCAC','quaternions':'\u210D','quatint':'\u2A16','quest':'?','questeq':'\u225F','quot':'"','QUOT':'"','rAarr':'\u21DB','race':'\u223D\u0331','racute':'\u0155','Racute':'\u0154','radic':'\u221A','raemptyv':'\u29B3','rang':'\u27E9','Rang':'\u27EB','rangd':'\u2992','range':'\u29A5','rangle':'\u27E9','raquo':'\xBB','rarr':'\u2192','rArr':'\u21D2','Rarr':'\u21A0','rarrap':'\u2975','rarrb':'\u21E5','rarrbfs':'\u2920','rarrc':'\u2933','rarrfs':'\u291E','rarrhk':'\u21AA','rarrlp':'\u21AC','rarrpl':'\u2945','rarrsim':'\u2974','rarrtl':'\u21A3','Rarrtl':'\u2916','rarrw':'\u219D','ratail':'\u291A','rAtail':'\u291C','ratio':'\u2236','rationals':'\u211A','rbarr':'\u290D','rBarr':'\u290F','RBarr':'\u2910','rbbrk':'\u2773','rbrace':'}','rbrack':']','rbrke':'\u298C','rbrksld':'\u298E','rbrkslu':'\u2990','rcaron':'\u0159','Rcaron':'\u0158','rcedil':'\u0157','Rcedil':'\u0156','rceil':'\u2309','rcub':'}','rcy':'\u0440','Rcy':'\u0420','rdca':'\u2937','rdldhar':'\u2969','rdquo':'\u201D','rdquor':'\u201D','rdsh':'\u21B3','Re':'\u211C','real':'\u211C','realine':'\u211B','realpart':'\u211C','reals':'\u211D','rect':'\u25AD','reg':'\xAE','REG':'\xAE','ReverseElement':'\u220B','ReverseEquilibrium':'\u21CB','ReverseUpEquilibrium':'\u296F','rfisht':'\u297D','rfloor':'\u230B','rfr':'\uD835\uDD2F','Rfr':'\u211C','rHar':'\u2964','rhard':'\u21C1','rharu':'\u21C0','rharul':'\u296C','rho':'\u03C1','Rho':'\u03A1','rhov':'\u03F1','RightAngleBracket':'\u27E9','rightarrow':'\u2192','Rightarrow':'\u21D2','RightArrow':'\u2192','RightArrowBar':'\u21E5','RightArrowLeftArrow':'\u21C4','rightarrowtail':'\u21A3','RightCeiling':'\u2309','RightDoubleBracket':'\u27E7','RightDownTeeVector':'\u295D','RightDownVector':'\u21C2','RightDownVectorBar':'\u2955','RightFloor':'\u230B','rightharpoondown':'\u21C1','rightharpoonup':'\u21C0','rightleftarrows':'\u21C4','rightleftharpoons':'\u21CC','rightrightarrows':'\u21C9','rightsquigarrow':'\u219D','RightTee':'\u22A2','RightTeeArrow':'\u21A6','RightTeeVector':'\u295B','rightthreetimes':'\u22CC','RightTriangle':'\u22B3','RightTriangleBar':'\u29D0','RightTriangleEqual':'\u22B5','RightUpDownVector':'\u294F','RightUpTeeVector':'\u295C','RightUpVector':'\u21BE','RightUpVectorBar':'\u2954','RightVector':'\u21C0','RightVectorBar':'\u2953','ring':'\u02DA','risingdotseq':'\u2253','rlarr':'\u21C4','rlhar':'\u21CC','rlm':'\u200F','rmoust':'\u23B1','rmoustache':'\u23B1','rnmid':'\u2AEE','roang':'\u27ED','roarr':'\u21FE','robrk':'\u27E7','ropar':'\u2986','ropf':'\uD835\uDD63','Ropf':'\u211D','roplus':'\u2A2E','rotimes':'\u2A35','RoundImplies':'\u2970','rpar':')','rpargt':'\u2994','rppolint':'\u2A12','rrarr':'\u21C9','Rrightarrow':'\u21DB','rsaquo':'\u203A','rscr':'\uD835\uDCC7','Rscr':'\u211B','rsh':'\u21B1','Rsh':'\u21B1','rsqb':']','rsquo':'\u2019','rsquor':'\u2019','rthree':'\u22CC','rtimes':'\u22CA','rtri':'\u25B9','rtrie':'\u22B5','rtrif':'\u25B8','rtriltri':'\u29CE','RuleDelayed':'\u29F4','ruluhar':'\u2968','rx':'\u211E','sacute':'\u015B','Sacute':'\u015A','sbquo':'\u201A','sc':'\u227B','Sc':'\u2ABC','scap':'\u2AB8','scaron':'\u0161','Scaron':'\u0160','sccue':'\u227D','sce':'\u2AB0','scE':'\u2AB4','scedil':'\u015F','Scedil':'\u015E','scirc':'\u015D','Scirc':'\u015C','scnap':'\u2ABA','scnE':'\u2AB6','scnsim':'\u22E9','scpolint':'\u2A13','scsim':'\u227F','scy':'\u0441','Scy':'\u0421','sdot':'\u22C5','sdotb':'\u22A1','sdote':'\u2A66','searhk':'\u2925','searr':'\u2198','seArr':'\u21D8','searrow':'\u2198','sect':'\xA7','semi':';','seswar':'\u2929','setminus':'\u2216','setmn':'\u2216','sext':'\u2736','sfr':'\uD835\uDD30','Sfr':'\uD835\uDD16','sfrown':'\u2322','sharp':'\u266F','shchcy':'\u0449','SHCHcy':'\u0429','shcy':'\u0448','SHcy':'\u0428','ShortDownArrow':'\u2193','ShortLeftArrow':'\u2190','shortmid':'\u2223','shortparallel':'\u2225','ShortRightArrow':'\u2192','ShortUpArrow':'\u2191','shy':'\xAD','sigma':'\u03C3','Sigma':'\u03A3','sigmaf':'\u03C2','sigmav':'\u03C2','sim':'\u223C','simdot':'\u2A6A','sime':'\u2243','simeq':'\u2243','simg':'\u2A9E','simgE':'\u2AA0','siml':'\u2A9D','simlE':'\u2A9F','simne':'\u2246','simplus':'\u2A24','simrarr':'\u2972','slarr':'\u2190','SmallCircle':'\u2218','smallsetminus':'\u2216','smashp':'\u2A33','smeparsl':'\u29E4','smid':'\u2223','smile':'\u2323','smt':'\u2AAA','smte':'\u2AAC','smtes':'\u2AAC\uFE00','softcy':'\u044C','SOFTcy':'\u042C','sol':'/','solb':'\u29C4','solbar':'\u233F','sopf':'\uD835\uDD64','Sopf':'\uD835\uDD4A','spades':'\u2660','spadesuit':'\u2660','spar':'\u2225','sqcap':'\u2293','sqcaps':'\u2293\uFE00','sqcup':'\u2294','sqcups':'\u2294\uFE00','Sqrt':'\u221A','sqsub':'\u228F','sqsube':'\u2291','sqsubset':'\u228F','sqsubseteq':'\u2291','sqsup':'\u2290','sqsupe':'\u2292','sqsupset':'\u2290','sqsupseteq':'\u2292','squ':'\u25A1','square':'\u25A1','Square':'\u25A1','SquareIntersection':'\u2293','SquareSubset':'\u228F','SquareSubsetEqual':'\u2291','SquareSuperset':'\u2290','SquareSupersetEqual':'\u2292','SquareUnion':'\u2294','squarf':'\u25AA','squf':'\u25AA','srarr':'\u2192','sscr':'\uD835\uDCC8','Sscr':'\uD835\uDCAE','ssetmn':'\u2216','ssmile':'\u2323','sstarf':'\u22C6','star':'\u2606','Star':'\u22C6','starf':'\u2605','straightepsilon':'\u03F5','straightphi':'\u03D5','strns':'\xAF','sub':'\u2282','Sub':'\u22D0','subdot':'\u2ABD','sube':'\u2286','subE':'\u2AC5','subedot':'\u2AC3','submult':'\u2AC1','subne':'\u228A','subnE':'\u2ACB','subplus':'\u2ABF','subrarr':'\u2979','subset':'\u2282','Subset':'\u22D0','subseteq':'\u2286','subseteqq':'\u2AC5','SubsetEqual':'\u2286','subsetneq':'\u228A','subsetneqq':'\u2ACB','subsim':'\u2AC7','subsub':'\u2AD5','subsup':'\u2AD3','succ':'\u227B','succapprox':'\u2AB8','succcurlyeq':'\u227D','Succeeds':'\u227B','SucceedsEqual':'\u2AB0','SucceedsSlantEqual':'\u227D','SucceedsTilde':'\u227F','succeq':'\u2AB0','succnapprox':'\u2ABA','succneqq':'\u2AB6','succnsim':'\u22E9','succsim':'\u227F','SuchThat':'\u220B','sum':'\u2211','Sum':'\u2211','sung':'\u266A','sup':'\u2283','Sup':'\u22D1','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','supdot':'\u2ABE','supdsub':'\u2AD8','supe':'\u2287','supE':'\u2AC6','supedot':'\u2AC4','Superset':'\u2283','SupersetEqual':'\u2287','suphsol':'\u27C9','suphsub':'\u2AD7','suplarr':'\u297B','supmult':'\u2AC2','supne':'\u228B','supnE':'\u2ACC','supplus':'\u2AC0','supset':'\u2283','Supset':'\u22D1','supseteq':'\u2287','supseteqq':'\u2AC6','supsetneq':'\u228B','supsetneqq':'\u2ACC','supsim':'\u2AC8','supsub':'\u2AD4','supsup':'\u2AD6','swarhk':'\u2926','swarr':'\u2199','swArr':'\u21D9','swarrow':'\u2199','swnwar':'\u292A','szlig':'\xDF','Tab':'\t','target':'\u2316','tau':'\u03C4','Tau':'\u03A4','tbrk':'\u23B4','tcaron':'\u0165','Tcaron':'\u0164','tcedil':'\u0163','Tcedil':'\u0162','tcy':'\u0442','Tcy':'\u0422','tdot':'\u20DB','telrec':'\u2315','tfr':'\uD835\uDD31','Tfr':'\uD835\uDD17','there4':'\u2234','therefore':'\u2234','Therefore':'\u2234','theta':'\u03B8','Theta':'\u0398','thetasym':'\u03D1','thetav':'\u03D1','thickapprox':'\u2248','thicksim':'\u223C','ThickSpace':'\u205F\u200A','thinsp':'\u2009','ThinSpace':'\u2009','thkap':'\u2248','thksim':'\u223C','thorn':'\xFE','THORN':'\xDE','tilde':'\u02DC','Tilde':'\u223C','TildeEqual':'\u2243','TildeFullEqual':'\u2245','TildeTilde':'\u2248','times':'\xD7','timesb':'\u22A0','timesbar':'\u2A31','timesd':'\u2A30','tint':'\u222D','toea':'\u2928','top':'\u22A4','topbot':'\u2336','topcir':'\u2AF1','topf':'\uD835\uDD65','Topf':'\uD835\uDD4B','topfork':'\u2ADA','tosa':'\u2929','tprime':'\u2034','trade':'\u2122','TRADE':'\u2122','triangle':'\u25B5','triangledown':'\u25BF','triangleleft':'\u25C3','trianglelefteq':'\u22B4','triangleq':'\u225C','triangleright':'\u25B9','trianglerighteq':'\u22B5','tridot':'\u25EC','trie':'\u225C','triminus':'\u2A3A','TripleDot':'\u20DB','triplus':'\u2A39','trisb':'\u29CD','tritime':'\u2A3B','trpezium':'\u23E2','tscr':'\uD835\uDCC9','Tscr':'\uD835\uDCAF','tscy':'\u0446','TScy':'\u0426','tshcy':'\u045B','TSHcy':'\u040B','tstrok':'\u0167','Tstrok':'\u0166','twixt':'\u226C','twoheadleftarrow':'\u219E','twoheadrightarrow':'\u21A0','uacute':'\xFA','Uacute':'\xDA','uarr':'\u2191','uArr':'\u21D1','Uarr':'\u219F','Uarrocir':'\u2949','ubrcy':'\u045E','Ubrcy':'\u040E','ubreve':'\u016D','Ubreve':'\u016C','ucirc':'\xFB','Ucirc':'\xDB','ucy':'\u0443','Ucy':'\u0423','udarr':'\u21C5','udblac':'\u0171','Udblac':'\u0170','udhar':'\u296E','ufisht':'\u297E','ufr':'\uD835\uDD32','Ufr':'\uD835\uDD18','ugrave':'\xF9','Ugrave':'\xD9','uHar':'\u2963','uharl':'\u21BF','uharr':'\u21BE','uhblk':'\u2580','ulcorn':'\u231C','ulcorner':'\u231C','ulcrop':'\u230F','ultri':'\u25F8','umacr':'\u016B','Umacr':'\u016A','uml':'\xA8','UnderBar':'_','UnderBrace':'\u23DF','UnderBracket':'\u23B5','UnderParenthesis':'\u23DD','Union':'\u22C3','UnionPlus':'\u228E','uogon':'\u0173','Uogon':'\u0172','uopf':'\uD835\uDD66','Uopf':'\uD835\uDD4C','uparrow':'\u2191','Uparrow':'\u21D1','UpArrow':'\u2191','UpArrowBar':'\u2912','UpArrowDownArrow':'\u21C5','updownarrow':'\u2195','Updownarrow':'\u21D5','UpDownArrow':'\u2195','UpEquilibrium':'\u296E','upharpoonleft':'\u21BF','upharpoonright':'\u21BE','uplus':'\u228E','UpperLeftArrow':'\u2196','UpperRightArrow':'\u2197','upsi':'\u03C5','Upsi':'\u03D2','upsih':'\u03D2','upsilon':'\u03C5','Upsilon':'\u03A5','UpTee':'\u22A5','UpTeeArrow':'\u21A5','upuparrows':'\u21C8','urcorn':'\u231D','urcorner':'\u231D','urcrop':'\u230E','uring':'\u016F','Uring':'\u016E','urtri':'\u25F9','uscr':'\uD835\uDCCA','Uscr':'\uD835\uDCB0','utdot':'\u22F0','utilde':'\u0169','Utilde':'\u0168','utri':'\u25B5','utrif':'\u25B4','uuarr':'\u21C8','uuml':'\xFC','Uuml':'\xDC','uwangle':'\u29A7','vangrt':'\u299C','varepsilon':'\u03F5','varkappa':'\u03F0','varnothing':'\u2205','varphi':'\u03D5','varpi':'\u03D6','varpropto':'\u221D','varr':'\u2195','vArr':'\u21D5','varrho':'\u03F1','varsigma':'\u03C2','varsubsetneq':'\u228A\uFE00','varsubsetneqq':'\u2ACB\uFE00','varsupsetneq':'\u228B\uFE00','varsupsetneqq':'\u2ACC\uFE00','vartheta':'\u03D1','vartriangleleft':'\u22B2','vartriangleright':'\u22B3','vBar':'\u2AE8','Vbar':'\u2AEB','vBarv':'\u2AE9','vcy':'\u0432','Vcy':'\u0412','vdash':'\u22A2','vDash':'\u22A8','Vdash':'\u22A9','VDash':'\u22AB','Vdashl':'\u2AE6','vee':'\u2228','Vee':'\u22C1','veebar':'\u22BB','veeeq':'\u225A','vellip':'\u22EE','verbar':'|','Verbar':'\u2016','vert':'|','Vert':'\u2016','VerticalBar':'\u2223','VerticalLine':'|','VerticalSeparator':'\u2758','VerticalTilde':'\u2240','VeryThinSpace':'\u200A','vfr':'\uD835\uDD33','Vfr':'\uD835\uDD19','vltri':'\u22B2','vnsub':'\u2282\u20D2','vnsup':'\u2283\u20D2','vopf':'\uD835\uDD67','Vopf':'\uD835\uDD4D','vprop':'\u221D','vrtri':'\u22B3','vscr':'\uD835\uDCCB','Vscr':'\uD835\uDCB1','vsubne':'\u228A\uFE00','vsubnE':'\u2ACB\uFE00','vsupne':'\u228B\uFE00','vsupnE':'\u2ACC\uFE00','Vvdash':'\u22AA','vzigzag':'\u299A','wcirc':'\u0175','Wcirc':'\u0174','wedbar':'\u2A5F','wedge':'\u2227','Wedge':'\u22C0','wedgeq':'\u2259','weierp':'\u2118','wfr':'\uD835\uDD34','Wfr':'\uD835\uDD1A','wopf':'\uD835\uDD68','Wopf':'\uD835\uDD4E','wp':'\u2118','wr':'\u2240','wreath':'\u2240','wscr':'\uD835\uDCCC','Wscr':'\uD835\uDCB2','xcap':'\u22C2','xcirc':'\u25EF','xcup':'\u22C3','xdtri':'\u25BD','xfr':'\uD835\uDD35','Xfr':'\uD835\uDD1B','xharr':'\u27F7','xhArr':'\u27FA','xi':'\u03BE','Xi':'\u039E','xlarr':'\u27F5','xlArr':'\u27F8','xmap':'\u27FC','xnis':'\u22FB','xodot':'\u2A00','xopf':'\uD835\uDD69','Xopf':'\uD835\uDD4F','xoplus':'\u2A01','xotime':'\u2A02','xrarr':'\u27F6','xrArr':'\u27F9','xscr':'\uD835\uDCCD','Xscr':'\uD835\uDCB3','xsqcup':'\u2A06','xuplus':'\u2A04','xutri':'\u25B3','xvee':'\u22C1','xwedge':'\u22C0','yacute':'\xFD','Yacute':'\xDD','yacy':'\u044F','YAcy':'\u042F','ycirc':'\u0177','Ycirc':'\u0176','ycy':'\u044B','Ycy':'\u042B','yen':'\xA5','yfr':'\uD835\uDD36','Yfr':'\uD835\uDD1C','yicy':'\u0457','YIcy':'\u0407','yopf':'\uD835\uDD6A','Yopf':'\uD835\uDD50','yscr':'\uD835\uDCCE','Yscr':'\uD835\uDCB4','yucy':'\u044E','YUcy':'\u042E','yuml':'\xFF','Yuml':'\u0178','zacute':'\u017A','Zacute':'\u0179','zcaron':'\u017E','Zcaron':'\u017D','zcy':'\u0437','Zcy':'\u0417','zdot':'\u017C','Zdot':'\u017B','zeetrf':'\u2128','ZeroWidthSpace':'\u200B','zeta':'\u03B6','Zeta':'\u0396','zfr':'\uD835\uDD37','Zfr':'\u2128','zhcy':'\u0436','ZHcy':'\u0416','zigrarr':'\u21DD','zopf':'\uD835\uDD6B','Zopf':'\u2124','zscr':'\uD835\uDCCF','Zscr':'\uD835\uDCB5','zwj':'\u200D','zwnj':'\u200C'}; 1056 var decodeMapLegacy = {'aacute':'\xE1','Aacute':'\xC1','acirc':'\xE2','Acirc':'\xC2','acute':'\xB4','aelig':'\xE6','AElig':'\xC6','agrave':'\xE0','Agrave':'\xC0','amp':'&','AMP':'&','aring':'\xE5','Aring':'\xC5','atilde':'\xE3','Atilde':'\xC3','auml':'\xE4','Auml':'\xC4','brvbar':'\xA6','ccedil':'\xE7','Ccedil':'\xC7','cedil':'\xB8','cent':'\xA2','copy':'\xA9','COPY':'\xA9','curren':'\xA4','deg':'\xB0','divide':'\xF7','eacute':'\xE9','Eacute':'\xC9','ecirc':'\xEA','Ecirc':'\xCA','egrave':'\xE8','Egrave':'\xC8','eth':'\xF0','ETH':'\xD0','euml':'\xEB','Euml':'\xCB','frac12':'\xBD','frac14':'\xBC','frac34':'\xBE','gt':'>','GT':'>','iacute':'\xED','Iacute':'\xCD','icirc':'\xEE','Icirc':'\xCE','iexcl':'\xA1','igrave':'\xEC','Igrave':'\xCC','iquest':'\xBF','iuml':'\xEF','Iuml':'\xCF','laquo':'\xAB','lt':'<','LT':'<','macr':'\xAF','micro':'\xB5','middot':'\xB7','nbsp':'\xA0','not':'\xAC','ntilde':'\xF1','Ntilde':'\xD1','oacute':'\xF3','Oacute':'\xD3','ocirc':'\xF4','Ocirc':'\xD4','ograve':'\xF2','Ograve':'\xD2','ordf':'\xAA','ordm':'\xBA','oslash':'\xF8','Oslash':'\xD8','otilde':'\xF5','Otilde':'\xD5','ouml':'\xF6','Ouml':'\xD6','para':'\xB6','plusmn':'\xB1','pound':'\xA3','quot':'"','QUOT':'"','raquo':'\xBB','reg':'\xAE','REG':'\xAE','sect':'\xA7','shy':'\xAD','sup1':'\xB9','sup2':'\xB2','sup3':'\xB3','szlig':'\xDF','thorn':'\xFE','THORN':'\xDE','times':'\xD7','uacute':'\xFA','Uacute':'\xDA','ucirc':'\xFB','Ucirc':'\xDB','ugrave':'\xF9','Ugrave':'\xD9','uml':'\xA8','uuml':'\xFC','Uuml':'\xDC','yacute':'\xFD','Yacute':'\xDD','yen':'\xA5','yuml':'\xFF'}; 1057 var decodeMapNumeric = {'0':'\uFFFD','128':'\u20AC','130':'\u201A','131':'\u0192','132':'\u201E','133':'\u2026','134':'\u2020','135':'\u2021','136':'\u02C6','137':'\u2030','138':'\u0160','139':'\u2039','140':'\u0152','142':'\u017D','145':'\u2018','146':'\u2019','147':'\u201C','148':'\u201D','149':'\u2022','150':'\u2013','151':'\u2014','152':'\u02DC','153':'\u2122','154':'\u0161','155':'\u203A','156':'\u0153','158':'\u017E','159':'\u0178'}; 1058 var invalidReferenceCodePoints = [1,2,3,4,5,6,7,8,11,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,64976,64977,64978,64979,64980,64981,64982,64983,64984,64985,64986,64987,64988,64989,64990,64991,64992,64993,64994,64995,64996,64997,64998,64999,65000,65001,65002,65003,65004,65005,65006,65007,65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]; 1059 1060 /*--------------------------------------------------------------------------*/ 1061 1062 var stringFromCharCode = String.fromCharCode; 1063 1064 var object = {}; 1065 var hasOwnProperty = object.hasOwnProperty; 1066 var has = function(object, propertyName) { 1067 return hasOwnProperty.call(object, propertyName); 1068 }; 1069 1070 var contains = function(array, value) { 1071 var index = -1; 1072 var length = array.length; 1073 while (++index < length) { 1074 if (array[index] == value) { 1075 return true; 1076 } 1077 } 1078 return false; 1079 }; 1080 1081 var merge = function(options, defaults) { 1082 if (!options) { 1083 return defaults; 1084 } 1085 var result = {}; 1086 var key; 1087 for (key in defaults) { 1088 // A `hasOwnProperty` check is not needed here, since only recognized 1089 // option names are used anyway. Any others are ignored. 1090 result[key] = has(options, key) ? options[key] : defaults[key]; 1091 } 1092 return result; 1093 }; 1094 1095 // Modified version of `ucs2encode`; see https://mths.be/punycode. 1096 var codePointToSymbol = function(codePoint, strict) { 1097 var output = ''; 1098 if ((codePoint >= 0xD800 && codePoint <= 0xDFFF) || codePoint > 0x10FFFF) { 1099 // See issue #4: 1100 // “Otherwise, if the number is in the range 0xD800 to 0xDFFF or is 1101 // greater than 0x10FFFF, then this is a parse error. Return a U+FFFD 1102 // REPLACEMENT CHARACTER.” 1103 if (strict) { 1104 parseError('character reference outside the permissible Unicode range'); 1105 } 1106 return '\uFFFD'; 1107 } 1108 if (has(decodeMapNumeric, codePoint)) { 1109 if (strict) { 1110 parseError('disallowed character reference'); 1111 } 1112 return decodeMapNumeric[codePoint]; 1113 } 1114 if (strict && contains(invalidReferenceCodePoints, codePoint)) { 1115 parseError('disallowed character reference'); 1116 } 1117 if (codePoint > 0xFFFF) { 1118 codePoint -= 0x10000; 1119 output += stringFromCharCode(codePoint >>> 10 & 0x3FF | 0xD800); 1120 codePoint = 0xDC00 | codePoint & 0x3FF; 1121 } 1122 output += stringFromCharCode(codePoint); 1123 return output; 1124 }; 1125 1126 var hexEscape = function(codePoint) { 1127 return '&#x' + codePoint.toString(16).toUpperCase() + ';'; 1128 }; 1129 1130 var decEscape = function(codePoint) { 1131 return '&#' + codePoint + ';'; 1132 }; 1133 1134 var parseError = function(message) { 1135 throw Error('Parse error: ' + message); 1136 }; 1137 1138 /*--------------------------------------------------------------------------*/ 1139 1140 var encode = function(string, options) { 1141 options = merge(options, encode.options); 1142 var strict = options.strict; 1143 if (strict && regexInvalidRawCodePoint.test(string)) { 1144 parseError('forbidden code point'); 1145 } 1146 var encodeEverything = options.encodeEverything; 1147 var useNamedReferences = options.useNamedReferences; 1148 var allowUnsafeSymbols = options.allowUnsafeSymbols; 1149 var escapeCodePoint = options.decimal ? decEscape : hexEscape; 1150 1151 var escapeBmpSymbol = function(symbol) { 1152 return escapeCodePoint(symbol.charCodeAt(0)); 1153 }; 1154 1155 if (encodeEverything) { 1156 // Encode ASCII symbols. 1157 string = string.replace(regexAsciiWhitelist, function(symbol) { 1158 // Use named references if requested & possible. 1159 if (useNamedReferences && has(encodeMap, symbol)) { 1160 return '&' + encodeMap[symbol] + ';'; 1161 } 1162 return escapeBmpSymbol(symbol); 1163 }); 1164 // Shorten a few escapes that represent two symbols, of which at least one 1165 // is within the ASCII range. 1166 if (useNamedReferences) { 1167 string = string 1168 .replace(/>\u20D2/g, '>⃒') 1169 .replace(/<\u20D2/g, '<⃒') 1170 .replace(/fj/g, 'fj'); 1171 } 1172 // Encode non-ASCII symbols. 1173 if (useNamedReferences) { 1174 // Encode non-ASCII symbols that can be replaced with a named reference. 1175 string = string.replace(regexEncodeNonAscii, function(string) { 1176 // Note: there is no need to check `has(encodeMap, string)` here. 1177 return '&' + encodeMap[string] + ';'; 1178 }); 1179 } 1180 // Note: any remaining non-ASCII symbols are handled outside of the `if`. 1181 } else if (useNamedReferences) { 1182 // Apply named character references. 1183 // Encode `<>"'&` using named character references. 1184 if (!allowUnsafeSymbols) { 1185 string = string.replace(regexEscape, function(string) { 1186 return '&' + encodeMap[string] + ';'; // no need to check `has()` here 1187 }); 1188 } 1189 // Shorten escapes that represent two symbols, of which at least one is 1190 // `<>"'&`. 1191 string = string 1192 .replace(/>\u20D2/g, '>⃒') 1193 .replace(/<\u20D2/g, '<⃒'); 1194 // Encode non-ASCII symbols that can be replaced with a named reference. 1195 string = string.replace(regexEncodeNonAscii, function(string) { 1196 // Note: there is no need to check `has(encodeMap, string)` here. 1197 return '&' + encodeMap[string] + ';'; 1198 }); 1199 } else if (!allowUnsafeSymbols) { 1200 // Encode `<>"'&` using hexadecimal escapes, now that they’re not handled 1201 // using named character references. 1202 string = string.replace(regexEscape, escapeBmpSymbol); 1203 } 1204 return string 1205 // Encode astral symbols. 1206 .replace(regexAstralSymbols, function($0) { 1207 // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae 1208 var high = $0.charCodeAt(0); 1209 var low = $0.charCodeAt(1); 1210 var codePoint = (high - 0xD800) * 0x400 + low - 0xDC00 + 0x10000; 1211 return escapeCodePoint(codePoint); 1212 }) 1213 // Encode any remaining BMP symbols that are not printable ASCII symbols 1214 // using a hexadecimal escape. 1215 .replace(regexBmpWhitelist, escapeBmpSymbol); 1216 }; 1217 // Expose default options (so they can be overridden globally). 1218 encode.options = { 1219 'allowUnsafeSymbols': false, 1220 'encodeEverything': false, 1221 'strict': false, 1222 'useNamedReferences': false, 1223 'decimal' : false 1224 }; 1225 1226 var decode = function(html, options) { 1227 options = merge(options, decode.options); 1228 var strict = options.strict; 1229 if (strict && regexInvalidEntity.test(html)) { 1230 parseError('malformed character reference'); 1231 } 1232 return html.replace(regexDecode, function($0, $1, $2, $3, $4, $5, $6, $7) { 1233 var codePoint; 1234 var semicolon; 1235 var decDigits; 1236 var hexDigits; 1237 var reference; 1238 var next; 1239 if ($1) { 1240 // Decode decimal escapes, e.g. `𝌆`. 1241 decDigits = $1; 1242 semicolon = $2; 1243 if (strict && !semicolon) { 1244 parseError('character reference was not terminated by a semicolon'); 1245 } 1246 codePoint = parseInt(decDigits, 10); 1247 return codePointToSymbol(codePoint, strict); 1248 } 1249 if ($3) { 1250 // Decode hexadecimal escapes, e.g. `𝌆`. 1251 hexDigits = $3; 1252 semicolon = $4; 1253 if (strict && !semicolon) { 1254 parseError('character reference was not terminated by a semicolon'); 1255 } 1256 codePoint = parseInt(hexDigits, 16); 1257 return codePointToSymbol(codePoint, strict); 1258 } 1259 if ($5) { 1260 // Decode named character references with trailing `;`, e.g. `©`. 1261 reference = $5; 1262 if (has(decodeMap, reference)) { 1263 return decodeMap[reference]; 1264 } else { 1265 // Ambiguous ampersand. https://mths.be/notes/ambiguous-ampersands 1266 if (strict) { 1267 parseError( 1268 'named character reference was not terminated by a semicolon' 1269 ); 1270 } 1271 return $0; 1272 } 1273 } 1274 // If we’re still here, it’s a legacy reference for sure. No need for an 1275 // extra `if` check. 1276 // Decode named character references without trailing `;`, e.g. `&` 1277 // This is only a parse error if it gets converted to `&`, or if it is 1278 // followed by `=` in an attribute context. 1279 reference = $6; 1280 next = $7; 1281 if (next && options.isAttributeValue) { 1282 if (strict && next == '=') { 1283 parseError('`&` did not start a character reference'); 1284 } 1285 return $0; 1286 } else { 1287 if (strict) { 1288 parseError( 1289 'named character reference was not terminated by a semicolon' 1290 ); 1291 } 1292 // Note: there is no need to check `has(decodeMapLegacy, reference)`. 1293 return decodeMapLegacy[reference] + (next || ''); 1294 } 1295 }); 1296 }; 1297 // Expose default options (so they can be overridden globally). 1298 decode.options = { 1299 'isAttributeValue': false, 1300 'strict': false 1301 }; 1302 1303 var escape = function(string) { 1304 return string.replace(regexEscape, function($0) { 1305 // Note: there is no need to check `has(escapeMap, $0)` here. 1306 return escapeMap[$0]; 1307 }); 1308 }; 1309 1310 /*--------------------------------------------------------------------------*/ 1311 1312 var he = { 1313 'version': '1.1.1', 1314 'encode': encode, 1315 'decode': decode, 1316 'escape': escape, 1317 'unescape': decode 1318 }; 1319 1320 // Some AMD build optimizers, like r.js, check for specific condition patterns 1321 // like the following: 1322 if ( 1323 typeof define == 'function' && 1324 typeof define.amd == 'object' && 1325 define.amd 1326 ) { 1327 define(function() { 1328 return he; 1329 }); 1330 } else if (freeExports && !freeExports.nodeType) { 1331 if (freeModule) { // in Node.js, io.js, or RingoJS v0.8.0+ 1332 freeModule.exports = he; 1333 } else { // in Narwhal or RingoJS v0.7.0- 1334 for (var key in he) { 1335 has(he, key) && (freeExports[key] = he[key]); 1336 } 1337 } 1338 } else { // in Rhino or a web browser 1339 root.he = he; 1340 } 1341 1342 }(this)); 1343 1344 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 1345 },{}],10:[function(require,module,exports){ 1346 module.exports = attributeToProperty 1347 1348 var transform = { 1349 'class': 'className', 1350 'for': 'htmlFor', 1351 'http-equiv': 'httpEquiv' 1352 } 1353 1354 function attributeToProperty (h) { 1355 return function (tagName, attrs, children) { 1356 for (var attr in attrs) { 1357 if (attr in transform) { 1358 attrs[transform[attr]] = attrs[attr] 1359 delete attrs[attr] 1360 } 1361 } 1362 return h(tagName, attrs, children) 1363 } 1364 } 1365 1366 },{}],11:[function(require,module,exports){ 1367 var attrToProp = require('hyperscript-attribute-to-property') 1368 1369 var VAR = 0, TEXT = 1, OPEN = 2, CLOSE = 3, ATTR = 4 1370 var ATTR_KEY = 5, ATTR_KEY_W = 6 1371 var ATTR_VALUE_W = 7, ATTR_VALUE = 8 1372 var ATTR_VALUE_SQ = 9, ATTR_VALUE_DQ = 10 1373 var ATTR_EQ = 11, ATTR_BREAK = 12 1374 var COMMENT = 13 1375 1376 module.exports = function (h, opts) { 1377 if (!opts) opts = {} 1378 var concat = opts.concat || function (a, b) { 1379 return String(a) + String(b) 1380 } 1381 if (opts.attrToProp !== false) { 1382 h = attrToProp(h) 1383 } 1384 1385 return function (strings) { 1386 var state = TEXT, reg = '' 1387 var arglen = arguments.length 1388 var parts = [] 1389 1390 for (var i = 0; i < strings.length; i++) { 1391 if (i < arglen - 1) { 1392 var arg = arguments[i+1] 1393 var p = parse(strings[i]) 1394 var xstate = state 1395 if (xstate === ATTR_VALUE_DQ) xstate = ATTR_VALUE 1396 if (xstate === ATTR_VALUE_SQ) xstate = ATTR_VALUE 1397 if (xstate === ATTR_VALUE_W) xstate = ATTR_VALUE 1398 if (xstate === ATTR) xstate = ATTR_KEY 1399 if (xstate === OPEN) { 1400 if (reg === '/') { 1401 p.push([ OPEN, '/', arg ]) 1402 reg = '' 1403 } else { 1404 p.push([ OPEN, arg ]) 1405 } 1406 } else { 1407 p.push([ VAR, xstate, arg ]) 1408 } 1409 parts.push.apply(parts, p) 1410 } else parts.push.apply(parts, parse(strings[i])) 1411 } 1412 1413 var tree = [null,{},[]] 1414 var stack = [[tree,-1]] 1415 for (var i = 0; i < parts.length; i++) { 1416 var cur = stack[stack.length-1][0] 1417 var p = parts[i], s = p[0] 1418 if (s === OPEN && /^\//.test(p[1])) { 1419 var ix = stack[stack.length-1][1] 1420 if (stack.length > 1) { 1421 stack.pop() 1422 stack[stack.length-1][0][2][ix] = h( 1423 cur[0], cur[1], cur[2].length ? cur[2] : undefined 1424 ) 1425 } 1426 } else if (s === OPEN) { 1427 var c = [p[1],{},[]] 1428 cur[2].push(c) 1429 stack.push([c,cur[2].length-1]) 1430 } else if (s === ATTR_KEY || (s === VAR && p[1] === ATTR_KEY)) { 1431 var key = '' 1432 var copyKey 1433 for (; i < parts.length; i++) { 1434 if (parts[i][0] === ATTR_KEY) { 1435 key = concat(key, parts[i][1]) 1436 } else if (parts[i][0] === VAR && parts[i][1] === ATTR_KEY) { 1437 if (typeof parts[i][2] === 'object' && !key) { 1438 for (copyKey in parts[i][2]) { 1439 if (parts[i][2].hasOwnProperty(copyKey) && !cur[1][copyKey]) { 1440 cur[1][copyKey] = parts[i][2][copyKey] 1441 } 1442 } 1443 } else { 1444 key = concat(key, parts[i][2]) 1445 } 1446 } else break 1447 } 1448 if (parts[i][0] === ATTR_EQ) i++ 1449 var j = i 1450 for (; i < parts.length; i++) { 1451 if (parts[i][0] === ATTR_VALUE || parts[i][0] === ATTR_KEY) { 1452 if (!cur[1][key]) cur[1][key] = strfn(parts[i][1]) 1453 else parts[i][1]==="" || (cur[1][key] = concat(cur[1][key], parts[i][1])); 1454 } else if (parts[i][0] === VAR 1455 && (parts[i][1] === ATTR_VALUE || parts[i][1] === ATTR_KEY)) { 1456 if (!cur[1][key]) cur[1][key] = strfn(parts[i][2]) 1457 else parts[i][2]==="" || (cur[1][key] = concat(cur[1][key], parts[i][2])); 1458 } else { 1459 if (key.length && !cur[1][key] && i === j 1460 && (parts[i][0] === CLOSE || parts[i][0] === ATTR_BREAK)) { 1461 // https://html.spec.whatwg.org/multipage/infrastructure.html#boolean-attributes 1462 // empty string is falsy, not well behaved value in browser 1463 cur[1][key] = key.toLowerCase() 1464 } 1465 if (parts[i][0] === CLOSE) { 1466 i-- 1467 } 1468 break 1469 } 1470 } 1471 } else if (s === ATTR_KEY) { 1472 cur[1][p[1]] = true 1473 } else if (s === VAR && p[1] === ATTR_KEY) { 1474 cur[1][p[2]] = true 1475 } else if (s === CLOSE) { 1476 if (selfClosing(cur[0]) && stack.length) { 1477 var ix = stack[stack.length-1][1] 1478 stack.pop() 1479 stack[stack.length-1][0][2][ix] = h( 1480 cur[0], cur[1], cur[2].length ? cur[2] : undefined 1481 ) 1482 } 1483 } else if (s === VAR && p[1] === TEXT) { 1484 if (p[2] === undefined || p[2] === null) p[2] = '' 1485 else if (!p[2]) p[2] = concat('', p[2]) 1486 if (Array.isArray(p[2][0])) { 1487 cur[2].push.apply(cur[2], p[2]) 1488 } else { 1489 cur[2].push(p[2]) 1490 } 1491 } else if (s === TEXT) { 1492 cur[2].push(p[1]) 1493 } else if (s === ATTR_EQ || s === ATTR_BREAK) { 1494 // no-op 1495 } else { 1496 throw new Error('unhandled: ' + s) 1497 } 1498 } 1499 1500 if (tree[2].length > 1 && /^\s*$/.test(tree[2][0])) { 1501 tree[2].shift() 1502 } 1503 1504 if (tree[2].length > 2 1505 || (tree[2].length === 2 && /\S/.test(tree[2][1]))) { 1506 throw new Error( 1507 'multiple root elements must be wrapped in an enclosing tag' 1508 ) 1509 } 1510 if (Array.isArray(tree[2][0]) && typeof tree[2][0][0] === 'string' 1511 && Array.isArray(tree[2][0][2])) { 1512 tree[2][0] = h(tree[2][0][0], tree[2][0][1], tree[2][0][2]) 1513 } 1514 return tree[2][0] 1515 1516 function parse (str) { 1517 var res = [] 1518 if (state === ATTR_VALUE_W) state = ATTR 1519 for (var i = 0; i < str.length; i++) { 1520 var c = str.charAt(i) 1521 if (state === TEXT && c === '<') { 1522 if (reg.length) res.push([TEXT, reg]) 1523 reg = '' 1524 state = OPEN 1525 } else if (c === '>' && !quot(state) && state !== COMMENT) { 1526 if (state === OPEN && reg.length) { 1527 res.push([OPEN,reg]) 1528 } else if (state === ATTR_KEY) { 1529 res.push([ATTR_KEY,reg]) 1530 } else if (state === ATTR_VALUE && reg.length) { 1531 res.push([ATTR_VALUE,reg]) 1532 } 1533 res.push([CLOSE]) 1534 reg = '' 1535 state = TEXT 1536 } else if (state === COMMENT && /-$/.test(reg) && c === '-') { 1537 if (opts.comments) { 1538 res.push([ATTR_VALUE,reg.substr(0, reg.length - 1)],[CLOSE]) 1539 } 1540 reg = '' 1541 state = TEXT 1542 } else if (state === OPEN && /^!--$/.test(reg)) { 1543 if (opts.comments) { 1544 res.push([OPEN, reg],[ATTR_KEY,'comment'],[ATTR_EQ]) 1545 } 1546 reg = c 1547 state = COMMENT 1548 } else if (state === TEXT || state === COMMENT) { 1549 reg += c 1550 } else if (state === OPEN && c === '/' && reg.length) { 1551 // no-op, self closing tag without a space <br/> 1552 } else if (state === OPEN && /\s/.test(c)) { 1553 if (reg.length) { 1554 res.push([OPEN, reg]) 1555 } 1556 reg = '' 1557 state = ATTR 1558 } else if (state === OPEN) { 1559 reg += c 1560 } else if (state === ATTR && /[^\s"'=/]/.test(c)) { 1561 state = ATTR_KEY 1562 reg = c 1563 } else if (state === ATTR && /\s/.test(c)) { 1564 if (reg.length) res.push([ATTR_KEY,reg]) 1565 res.push([ATTR_BREAK]) 1566 } else if (state === ATTR_KEY && /\s/.test(c)) { 1567 res.push([ATTR_KEY,reg]) 1568 reg = '' 1569 state = ATTR_KEY_W 1570 } else if (state === ATTR_KEY && c === '=') { 1571 res.push([ATTR_KEY,reg],[ATTR_EQ]) 1572 reg = '' 1573 state = ATTR_VALUE_W 1574 } else if (state === ATTR_KEY) { 1575 reg += c 1576 } else if ((state === ATTR_KEY_W || state === ATTR) && c === '=') { 1577 res.push([ATTR_EQ]) 1578 state = ATTR_VALUE_W 1579 } else if ((state === ATTR_KEY_W || state === ATTR) && !/\s/.test(c)) { 1580 res.push([ATTR_BREAK]) 1581 if (/[\w-]/.test(c)) { 1582 reg += c 1583 state = ATTR_KEY 1584 } else state = ATTR 1585 } else if (state === ATTR_VALUE_W && c === '"') { 1586 state = ATTR_VALUE_DQ 1587 } else if (state === ATTR_VALUE_W && c === "'") { 1588 state = ATTR_VALUE_SQ 1589 } else if (state === ATTR_VALUE_DQ && c === '"') { 1590 res.push([ATTR_VALUE,reg],[ATTR_BREAK]) 1591 reg = '' 1592 state = ATTR 1593 } else if (state === ATTR_VALUE_SQ && c === "'") { 1594 res.push([ATTR_VALUE,reg],[ATTR_BREAK]) 1595 reg = '' 1596 state = ATTR 1597 } else if (state === ATTR_VALUE_W && !/\s/.test(c)) { 1598 state = ATTR_VALUE 1599 i-- 1600 } else if (state === ATTR_VALUE && /\s/.test(c)) { 1601 res.push([ATTR_VALUE,reg],[ATTR_BREAK]) 1602 reg = '' 1603 state = ATTR 1604 } else if (state === ATTR_VALUE || state === ATTR_VALUE_SQ 1605 || state === ATTR_VALUE_DQ) { 1606 reg += c 1607 } 1608 } 1609 if (state === TEXT && reg.length) { 1610 res.push([TEXT,reg]) 1611 reg = '' 1612 } else if (state === ATTR_VALUE && reg.length) { 1613 res.push([ATTR_VALUE,reg]) 1614 reg = '' 1615 } else if (state === ATTR_VALUE_DQ && reg.length) { 1616 res.push([ATTR_VALUE,reg]) 1617 reg = '' 1618 } else if (state === ATTR_VALUE_SQ && reg.length) { 1619 res.push([ATTR_VALUE,reg]) 1620 reg = '' 1621 } else if (state === ATTR_KEY) { 1622 res.push([ATTR_KEY,reg]) 1623 reg = '' 1624 } 1625 return res 1626 } 1627 } 1628 1629 function strfn (x) { 1630 if (typeof x === 'function') return x 1631 else if (typeof x === 'string') return x 1632 else if (x && typeof x === 'object') return x 1633 else return concat('', x) 1634 } 1635 } 1636 1637 function quot (state) { 1638 return state === ATTR_VALUE_SQ || state === ATTR_VALUE_DQ 1639 } 1640 1641 var hasOwn = Object.prototype.hasOwnProperty 1642 function has (obj, key) { return hasOwn.call(obj, key) } 1643 1644 var closeRE = RegExp('^(' + [ 1645 'area', 'base', 'basefont', 'bgsound', 'br', 'col', 'command', 'embed', 1646 'frame', 'hr', 'img', 'input', 'isindex', 'keygen', 'link', 'meta', 'param', 1647 'source', 'track', 'wbr', '!--', 1648 // SVG TAGS 1649 'animate', 'animateTransform', 'circle', 'cursor', 'desc', 'ellipse', 1650 'feBlend', 'feColorMatrix', 'feComposite', 1651 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 1652 'feDistantLight', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 1653 'feGaussianBlur', 'feImage', 'feMergeNode', 'feMorphology', 1654 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 1655 'feTurbulence', 'font-face-format', 'font-face-name', 'font-face-uri', 1656 'glyph', 'glyphRef', 'hkern', 'image', 'line', 'missing-glyph', 'mpath', 1657 'path', 'polygon', 'polyline', 'rect', 'set', 'stop', 'tref', 'use', 'view', 1658 'vkern' 1659 ].join('|') + ')(?:[\.#][a-zA-Z0-9\u007F-\uFFFF_:-]+)*$') 1660 function selfClosing (tag) { return closeRE.test(tag) } 1661 1662 },{"hyperscript-attribute-to-property":10}],12:[function(require,module,exports){ 1663 if (typeof Object.create === 'function') { 1664 // implementation from standard node.js 'util' module 1665 module.exports = function inherits(ctor, superCtor) { 1666 ctor.super_ = superCtor 1667 ctor.prototype = Object.create(superCtor.prototype, { 1668 constructor: { 1669 value: ctor, 1670 enumerable: false, 1671 writable: true, 1672 configurable: true 1673 } 1674 }); 1675 }; 1676 } else { 1677 // old school shim for old browsers 1678 module.exports = function inherits(ctor, superCtor) { 1679 ctor.super_ = superCtor 1680 var TempCtor = function () {} 1681 TempCtor.prototype = superCtor.prototype 1682 ctor.prototype = new TempCtor() 1683 ctor.prototype.constructor = ctor 1684 } 1685 } 1686 1687 },{}],13:[function(require,module,exports){ 1688 (function (global){ 1689 /** 1690 * @license 1691 * Lodash <https://lodash.com/> 1692 * Copyright JS Foundation and other contributors <https://js.foundation/> 1693 * Released under MIT license <https://lodash.com/license> 1694 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> 1695 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 1696 */ 1697 ;(function() { 1698 1699 /** Used as a safe reference for `undefined` in pre-ES5 environments. */ 1700 var undefined; 1701 1702 /** Used as the semantic version number. */ 1703 var VERSION = '4.17.10'; 1704 1705 /** Used as the size to enable large array optimizations. */ 1706 var LARGE_ARRAY_SIZE = 200; 1707 1708 /** Error message constants. */ 1709 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', 1710 FUNC_ERROR_TEXT = 'Expected a function'; 1711 1712 /** Used to stand-in for `undefined` hash values. */ 1713 var HASH_UNDEFINED = '__lodash_hash_undefined__'; 1714 1715 /** Used as the maximum memoize cache size. */ 1716 var MAX_MEMOIZE_SIZE = 500; 1717 1718 /** Used as the internal argument placeholder. */ 1719 var PLACEHOLDER = '__lodash_placeholder__'; 1720 1721 /** Used to compose bitmasks for cloning. */ 1722 var CLONE_DEEP_FLAG = 1, 1723 CLONE_FLAT_FLAG = 2, 1724 CLONE_SYMBOLS_FLAG = 4; 1725 1726 /** Used to compose bitmasks for value comparisons. */ 1727 var COMPARE_PARTIAL_FLAG = 1, 1728 COMPARE_UNORDERED_FLAG = 2; 1729 1730 /** Used to compose bitmasks for function metadata. */ 1731 var WRAP_BIND_FLAG = 1, 1732 WRAP_BIND_KEY_FLAG = 2, 1733 WRAP_CURRY_BOUND_FLAG = 4, 1734 WRAP_CURRY_FLAG = 8, 1735 WRAP_CURRY_RIGHT_FLAG = 16, 1736 WRAP_PARTIAL_FLAG = 32, 1737 WRAP_PARTIAL_RIGHT_FLAG = 64, 1738 WRAP_ARY_FLAG = 128, 1739 WRAP_REARG_FLAG = 256, 1740 WRAP_FLIP_FLAG = 512; 1741 1742 /** Used as default options for `_.truncate`. */ 1743 var DEFAULT_TRUNC_LENGTH = 30, 1744 DEFAULT_TRUNC_OMISSION = '...'; 1745 1746 /** Used to detect hot functions by number of calls within a span of milliseconds. */ 1747 var HOT_COUNT = 800, 1748 HOT_SPAN = 16; 1749 1750 /** Used to indicate the type of lazy iteratees. */ 1751 var LAZY_FILTER_FLAG = 1, 1752 LAZY_MAP_FLAG = 2, 1753 LAZY_WHILE_FLAG = 3; 1754 1755 /** Used as references for various `Number` constants. */ 1756 var INFINITY = 1 / 0, 1757 MAX_SAFE_INTEGER = 9007199254740991, 1758 MAX_INTEGER = 1.7976931348623157e+308, 1759 NAN = 0 / 0; 1760 1761 /** Used as references for the maximum length and index of an array. */ 1762 var MAX_ARRAY_LENGTH = 4294967295, 1763 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, 1764 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; 1765 1766 /** Used to associate wrap methods with their bit flags. */ 1767 var wrapFlags = [ 1768 ['ary', WRAP_ARY_FLAG], 1769 ['bind', WRAP_BIND_FLAG], 1770 ['bindKey', WRAP_BIND_KEY_FLAG], 1771 ['curry', WRAP_CURRY_FLAG], 1772 ['curryRight', WRAP_CURRY_RIGHT_FLAG], 1773 ['flip', WRAP_FLIP_FLAG], 1774 ['partial', WRAP_PARTIAL_FLAG], 1775 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], 1776 ['rearg', WRAP_REARG_FLAG] 1777 ]; 1778 1779 /** `Object#toString` result references. */ 1780 var argsTag = '[object Arguments]', 1781 arrayTag = '[object Array]', 1782 asyncTag = '[object AsyncFunction]', 1783 boolTag = '[object Boolean]', 1784 dateTag = '[object Date]', 1785 domExcTag = '[object DOMException]', 1786 errorTag = '[object Error]', 1787 funcTag = '[object Function]', 1788 genTag = '[object GeneratorFunction]', 1789 mapTag = '[object Map]', 1790 numberTag = '[object Number]', 1791 nullTag = '[object Null]', 1792 objectTag = '[object Object]', 1793 promiseTag = '[object Promise]', 1794 proxyTag = '[object Proxy]', 1795 regexpTag = '[object RegExp]', 1796 setTag = '[object Set]', 1797 stringTag = '[object String]', 1798 symbolTag = '[object Symbol]', 1799 undefinedTag = '[object Undefined]', 1800 weakMapTag = '[object WeakMap]', 1801 weakSetTag = '[object WeakSet]'; 1802 1803 var arrayBufferTag = '[object ArrayBuffer]', 1804 dataViewTag = '[object DataView]', 1805 float32Tag = '[object Float32Array]', 1806 float64Tag = '[object Float64Array]', 1807 int8Tag = '[object Int8Array]', 1808 int16Tag = '[object Int16Array]', 1809 int32Tag = '[object Int32Array]', 1810 uint8Tag = '[object Uint8Array]', 1811 uint8ClampedTag = '[object Uint8ClampedArray]', 1812 uint16Tag = '[object Uint16Array]', 1813 uint32Tag = '[object Uint32Array]'; 1814 1815 /** Used to match empty string literals in compiled template source. */ 1816 var reEmptyStringLeading = /\b__p \+= '';/g, 1817 reEmptyStringMiddle = /\b(__p \+=) '' \+/g, 1818 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; 1819 1820 /** Used to match HTML entities and HTML characters. */ 1821 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, 1822 reUnescapedHtml = /[&<>"']/g, 1823 reHasEscapedHtml = RegExp(reEscapedHtml.source), 1824 reHasUnescapedHtml = RegExp(reUnescapedHtml.source); 1825 1826 /** Used to match template delimiters. */ 1827 var reEscape = /<%-([\s\S]+?)%>/g, 1828 reEvaluate = /<%([\s\S]+?)%>/g, 1829 reInterpolate = /<%=([\s\S]+?)%>/g; 1830 1831 /** Used to match property names within property paths. */ 1832 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, 1833 reIsPlainProp = /^\w*$/, 1834 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; 1835 1836 /** 1837 * Used to match `RegExp` 1838 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). 1839 */ 1840 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, 1841 reHasRegExpChar = RegExp(reRegExpChar.source); 1842 1843 /** Used to match leading and trailing whitespace. */ 1844 var reTrim = /^\s+|\s+$/g, 1845 reTrimStart = /^\s+/, 1846 reTrimEnd = /\s+$/; 1847 1848 /** Used to match wrap detail comments. */ 1849 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, 1850 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, 1851 reSplitDetails = /,? & /; 1852 1853 /** Used to match words composed of alphanumeric characters. */ 1854 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; 1855 1856 /** Used to match backslashes in property paths. */ 1857 var reEscapeChar = /\\(\\)?/g; 1858 1859 /** 1860 * Used to match 1861 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). 1862 */ 1863 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; 1864 1865 /** Used to match `RegExp` flags from their coerced string values. */ 1866 var reFlags = /\w*$/; 1867 1868 /** Used to detect bad signed hexadecimal string values. */ 1869 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 1870 1871 /** Used to detect binary string values. */ 1872 var reIsBinary = /^0b[01]+$/i; 1873 1874 /** Used to detect host constructors (Safari). */ 1875 var reIsHostCtor = /^\[object .+?Constructor\]$/; 1876 1877 /** Used to detect octal string values. */ 1878 var reIsOctal = /^0o[0-7]+$/i; 1879 1880 /** Used to detect unsigned integer values. */ 1881 var reIsUint = /^(?:0|[1-9]\d*)$/; 1882 1883 /** Used to match Latin Unicode letters (excluding mathematical operators). */ 1884 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; 1885 1886 /** Used to ensure capturing order of template delimiters. */ 1887 var reNoMatch = /($^)/; 1888 1889 /** Used to match unescaped characters in compiled string literals. */ 1890 var reUnescapedString = /['\n\r\u2028\u2029\\]/g; 1891 1892 /** Used to compose unicode character classes. */ 1893 var rsAstralRange = '\\ud800-\\udfff', 1894 rsComboMarksRange = '\\u0300-\\u036f', 1895 reComboHalfMarksRange = '\\ufe20-\\ufe2f', 1896 rsComboSymbolsRange = '\\u20d0-\\u20ff', 1897 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, 1898 rsDingbatRange = '\\u2700-\\u27bf', 1899 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', 1900 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', 1901 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', 1902 rsPunctuationRange = '\\u2000-\\u206f', 1903 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', 1904 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', 1905 rsVarRange = '\\ufe0e\\ufe0f', 1906 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; 1907 1908 /** Used to compose unicode capture groups. */ 1909 var rsApos = "['\u2019]", 1910 rsAstral = '[' + rsAstralRange + ']', 1911 rsBreak = '[' + rsBreakRange + ']', 1912 rsCombo = '[' + rsComboRange + ']', 1913 rsDigits = '\\d+', 1914 rsDingbat = '[' + rsDingbatRange + ']', 1915 rsLower = '[' + rsLowerRange + ']', 1916 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', 1917 rsFitz = '\\ud83c[\\udffb-\\udfff]', 1918 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', 1919 rsNonAstral = '[^' + rsAstralRange + ']', 1920 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', 1921 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', 1922 rsUpper = '[' + rsUpperRange + ']', 1923 rsZWJ = '\\u200d'; 1924 1925 /** Used to compose unicode regexes. */ 1926 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', 1927 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', 1928 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', 1929 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', 1930 reOptMod = rsModifier + '?', 1931 rsOptVar = '[' + rsVarRange + ']?', 1932 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', 1933 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', 1934 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', 1935 rsSeq = rsOptVar + reOptMod + rsOptJoin, 1936 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, 1937 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; 1938 1939 /** Used to match apostrophes. */ 1940 var reApos = RegExp(rsApos, 'g'); 1941 1942 /** 1943 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and 1944 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). 1945 */ 1946 var reComboMark = RegExp(rsCombo, 'g'); 1947 1948 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ 1949 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); 1950 1951 /** Used to match complex or compound words. */ 1952 var reUnicodeWord = RegExp([ 1953 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', 1954 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', 1955 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, 1956 rsUpper + '+' + rsOptContrUpper, 1957 rsOrdUpper, 1958 rsOrdLower, 1959 rsDigits, 1960 rsEmoji 1961 ].join('|'), 'g'); 1962 1963 /** 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/). */ 1964 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); 1965 1966 /** Used to detect strings that need a more robust regexp to match words. */ 1967 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 ]/; 1968 1969 /** Used to assign default `context` object properties. */ 1970 var contextProps = [ 1971 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 1972 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', 1973 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', 1974 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 1975 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' 1976 ]; 1977 1978 /** Used to make template sourceURLs easier to identify. */ 1979 var templateCounter = -1; 1980 1981 /** Used to identify `toStringTag` values of typed arrays. */ 1982 var typedArrayTags = {}; 1983 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = 1984 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = 1985 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = 1986 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = 1987 typedArrayTags[uint32Tag] = true; 1988 typedArrayTags[argsTag] = typedArrayTags[arrayTag] = 1989 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = 1990 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = 1991 typedArrayTags[errorTag] = typedArrayTags[funcTag] = 1992 typedArrayTags[mapTag] = typedArrayTags[numberTag] = 1993 typedArrayTags[objectTag] = typedArrayTags[regexpTag] = 1994 typedArrayTags[setTag] = typedArrayTags[stringTag] = 1995 typedArrayTags[weakMapTag] = false; 1996 1997 /** Used to identify `toStringTag` values supported by `_.clone`. */ 1998 var cloneableTags = {}; 1999 cloneableTags[argsTag] = cloneableTags[arrayTag] = 2000 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = 2001 cloneableTags[boolTag] = cloneableTags[dateTag] = 2002 cloneableTags[float32Tag] = cloneableTags[float64Tag] = 2003 cloneableTags[int8Tag] = cloneableTags[int16Tag] = 2004 cloneableTags[int32Tag] = cloneableTags[mapTag] = 2005 cloneableTags[numberTag] = cloneableTags[objectTag] = 2006 cloneableTags[regexpTag] = cloneableTags[setTag] = 2007 cloneableTags[stringTag] = cloneableTags[symbolTag] = 2008 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = 2009 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; 2010 cloneableTags[errorTag] = cloneableTags[funcTag] = 2011 cloneableTags[weakMapTag] = false; 2012 2013 /** Used to map Latin Unicode letters to basic Latin letters. */ 2014 var deburredLetters = { 2015 // Latin-1 Supplement block. 2016 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', 2017 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', 2018 '\xc7': 'C', '\xe7': 'c', 2019 '\xd0': 'D', '\xf0': 'd', 2020 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', 2021 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', 2022 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', 2023 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', 2024 '\xd1': 'N', '\xf1': 'n', 2025 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', 2026 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', 2027 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', 2028 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', 2029 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', 2030 '\xc6': 'Ae', '\xe6': 'ae', 2031 '\xde': 'Th', '\xfe': 'th', 2032 '\xdf': 'ss', 2033 // Latin Extended-A block. 2034 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', 2035 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', 2036 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', 2037 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', 2038 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', 2039 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', 2040 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', 2041 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', 2042 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', 2043 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', 2044 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', 2045 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', 2046 '\u0134': 'J', '\u0135': 'j', 2047 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', 2048 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', 2049 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', 2050 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', 2051 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', 2052 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', 2053 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', 2054 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', 2055 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', 2056 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', 2057 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', 2058 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', 2059 '\u0163': 't', '\u0165': 't', '\u0167': 't', 2060 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', 2061 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', 2062 '\u0174': 'W', '\u0175': 'w', 2063 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', 2064 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', 2065 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', 2066 '\u0132': 'IJ', '\u0133': 'ij', 2067 '\u0152': 'Oe', '\u0153': 'oe', 2068 '\u0149': "'n", '\u017f': 's' 2069 }; 2070 2071 /** Used to map characters to HTML entities. */ 2072 var htmlEscapes = { 2073 '&': '&', 2074 '<': '<', 2075 '>': '>', 2076 '"': '"', 2077 "'": ''' 2078 }; 2079 2080 /** Used to map HTML entities to characters. */ 2081 var htmlUnescapes = { 2082 '&': '&', 2083 '<': '<', 2084 '>': '>', 2085 '"': '"', 2086 ''': "'" 2087 }; 2088 2089 /** Used to escape characters for inclusion in compiled string literals. */ 2090 var stringEscapes = { 2091 '\\': '\\', 2092 "'": "'", 2093 '\n': 'n', 2094 '\r': 'r', 2095 '\u2028': 'u2028', 2096 '\u2029': 'u2029' 2097 }; 2098 2099 /** Built-in method references without a dependency on `root`. */ 2100 var freeParseFloat = parseFloat, 2101 freeParseInt = parseInt; 2102 2103 /** Detect free variable `global` from Node.js. */ 2104 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; 2105 2106 /** Detect free variable `self`. */ 2107 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 2108 2109 /** Used as a reference to the global object. */ 2110 var root = freeGlobal || freeSelf || Function('return this')(); 2111 2112 /** Detect free variable `exports`. */ 2113 var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; 2114 2115 /** Detect free variable `module`. */ 2116 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; 2117 2118 /** Detect the popular CommonJS extension `module.exports`. */ 2119 var moduleExports = freeModule && freeModule.exports === freeExports; 2120 2121 /** Detect free variable `process` from Node.js. */ 2122 var freeProcess = moduleExports && freeGlobal.process; 2123 2124 /** Used to access faster Node.js helpers. */ 2125 var nodeUtil = (function() { 2126 try { 2127 // Use `util.types` for Node.js 10+. 2128 var types = freeModule && freeModule.require && freeModule.require('util').types; 2129 2130 if (types) { 2131 return types; 2132 } 2133 2134 // Legacy `process.binding('util')` for Node.js < 10. 2135 return freeProcess && freeProcess.binding && freeProcess.binding('util'); 2136 } catch (e) {} 2137 }()); 2138 2139 /* Node.js helper references. */ 2140 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, 2141 nodeIsDate = nodeUtil && nodeUtil.isDate, 2142 nodeIsMap = nodeUtil && nodeUtil.isMap, 2143 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, 2144 nodeIsSet = nodeUtil && nodeUtil.isSet, 2145 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; 2146 2147 /*--------------------------------------------------------------------------*/ 2148 2149 /** 2150 * A faster alternative to `Function#apply`, this function invokes `func` 2151 * with the `this` binding of `thisArg` and the arguments of `args`. 2152 * 2153 * @private 2154 * @param {Function} func The function to invoke. 2155 * @param {*} thisArg The `this` binding of `func`. 2156 * @param {Array} args The arguments to invoke `func` with. 2157 * @returns {*} Returns the result of `func`. 2158 */ 2159 function apply(func, thisArg, args) { 2160 switch (args.length) { 2161 case 0: return func.call(thisArg); 2162 case 1: return func.call(thisArg, args[0]); 2163 case 2: return func.call(thisArg, args[0], args[1]); 2164 case 3: return func.call(thisArg, args[0], args[1], args[2]); 2165 } 2166 return func.apply(thisArg, args); 2167 } 2168 2169 /** 2170 * A specialized version of `baseAggregator` for arrays. 2171 * 2172 * @private 2173 * @param {Array} [array] The array to iterate over. 2174 * @param {Function} setter The function to set `accumulator` values. 2175 * @param {Function} iteratee The iteratee to transform keys. 2176 * @param {Object} accumulator The initial aggregated object. 2177 * @returns {Function} Returns `accumulator`. 2178 */ 2179 function arrayAggregator(array, setter, iteratee, accumulator) { 2180 var index = -1, 2181 length = array == null ? 0 : array.length; 2182 2183 while (++index < length) { 2184 var value = array[index]; 2185 setter(accumulator, value, iteratee(value), array); 2186 } 2187 return accumulator; 2188 } 2189 2190 /** 2191 * A specialized version of `_.forEach` for arrays without support for 2192 * iteratee shorthands. 2193 * 2194 * @private 2195 * @param {Array} [array] The array to iterate over. 2196 * @param {Function} iteratee The function invoked per iteration. 2197 * @returns {Array} Returns `array`. 2198 */ 2199 function arrayEach(array, iteratee) { 2200 var index = -1, 2201 length = array == null ? 0 : array.length; 2202 2203 while (++index < length) { 2204 if (iteratee(array[index], index, array) === false) { 2205 break; 2206 } 2207 } 2208 return array; 2209 } 2210 2211 /** 2212 * A specialized version of `_.forEachRight` for arrays without support for 2213 * iteratee shorthands. 2214 * 2215 * @private 2216 * @param {Array} [array] The array to iterate over. 2217 * @param {Function} iteratee The function invoked per iteration. 2218 * @returns {Array} Returns `array`. 2219 */ 2220 function arrayEachRight(array, iteratee) { 2221 var length = array == null ? 0 : array.length; 2222 2223 while (length--) { 2224 if (iteratee(array[length], length, array) === false) { 2225 break; 2226 } 2227 } 2228 return array; 2229 } 2230 2231 /** 2232 * A specialized version of `_.every` for arrays without support for 2233 * iteratee shorthands. 2234 * 2235 * @private 2236 * @param {Array} [array] The array to iterate over. 2237 * @param {Function} predicate The function invoked per iteration. 2238 * @returns {boolean} Returns `true` if all elements pass the predicate check, 2239 * else `false`. 2240 */ 2241 function arrayEvery(array, predicate) { 2242 var index = -1, 2243 length = array == null ? 0 : array.length; 2244 2245 while (++index < length) { 2246 if (!predicate(array[index], index, array)) { 2247 return false; 2248 } 2249 } 2250 return true; 2251 } 2252 2253 /** 2254 * A specialized version of `_.filter` for arrays without support for 2255 * iteratee shorthands. 2256 * 2257 * @private 2258 * @param {Array} [array] The array to iterate over. 2259 * @param {Function} predicate The function invoked per iteration. 2260 * @returns {Array} Returns the new filtered array. 2261 */ 2262 function arrayFilter(array, predicate) { 2263 var index = -1, 2264 length = array == null ? 0 : array.length, 2265 resIndex = 0, 2266 result = []; 2267 2268 while (++index < length) { 2269 var value = array[index]; 2270 if (predicate(value, index, array)) { 2271 result[resIndex++] = value; 2272 } 2273 } 2274 return result; 2275 } 2276 2277 /** 2278 * A specialized version of `_.includes` for arrays without support for 2279 * specifying an index to search from. 2280 * 2281 * @private 2282 * @param {Array} [array] The array to inspect. 2283 * @param {*} target The value to search for. 2284 * @returns {boolean} Returns `true` if `target` is found, else `false`. 2285 */ 2286 function arrayIncludes(array, value) { 2287 var length = array == null ? 0 : array.length; 2288 return !!length && baseIndexOf(array, value, 0) > -1; 2289 } 2290 2291 /** 2292 * This function is like `arrayIncludes` except that it accepts a comparator. 2293 * 2294 * @private 2295 * @param {Array} [array] The array to inspect. 2296 * @param {*} target The value to search for. 2297 * @param {Function} comparator The comparator invoked per element. 2298 * @returns {boolean} Returns `true` if `target` is found, else `false`. 2299 */ 2300 function arrayIncludesWith(array, value, comparator) { 2301 var index = -1, 2302 length = array == null ? 0 : array.length; 2303 2304 while (++index < length) { 2305 if (comparator(value, array[index])) { 2306 return true; 2307 } 2308 } 2309 return false; 2310 } 2311 2312 /** 2313 * A specialized version of `_.map` for arrays without support for iteratee 2314 * shorthands. 2315 * 2316 * @private 2317 * @param {Array} [array] The array to iterate over. 2318 * @param {Function} iteratee The function invoked per iteration. 2319 * @returns {Array} Returns the new mapped array. 2320 */ 2321 function arrayMap(array, iteratee) { 2322 var index = -1, 2323 length = array == null ? 0 : array.length, 2324 result = Array(length); 2325 2326 while (++index < length) { 2327 result[index] = iteratee(array[index], index, array); 2328 } 2329 return result; 2330 } 2331 2332 /** 2333 * Appends the elements of `values` to `array`. 2334 * 2335 * @private 2336 * @param {Array} array The array to modify. 2337 * @param {Array} values The values to append. 2338 * @returns {Array} Returns `array`. 2339 */ 2340 function arrayPush(array, values) { 2341 var index = -1, 2342 length = values.length, 2343 offset = array.length; 2344 2345 while (++index < length) { 2346 array[offset + index] = values[index]; 2347 } 2348 return array; 2349 } 2350 2351 /** 2352 * A specialized version of `_.reduce` for arrays without support for 2353 * iteratee shorthands. 2354 * 2355 * @private 2356 * @param {Array} [array] The array to iterate over. 2357 * @param {Function} iteratee The function invoked per iteration. 2358 * @param {*} [accumulator] The initial value. 2359 * @param {boolean} [initAccum] Specify using the first element of `array` as 2360 * the initial value. 2361 * @returns {*} Returns the accumulated value. 2362 */ 2363 function arrayReduce(array, iteratee, accumulator, initAccum) { 2364 var index = -1, 2365 length = array == null ? 0 : array.length; 2366 2367 if (initAccum && length) { 2368 accumulator = array[++index]; 2369 } 2370 while (++index < length) { 2371 accumulator = iteratee(accumulator, array[index], index, array); 2372 } 2373 return accumulator; 2374 } 2375 2376 /** 2377 * A specialized version of `_.reduceRight` for arrays without support for 2378 * iteratee shorthands. 2379 * 2380 * @private 2381 * @param {Array} [array] The array to iterate over. 2382 * @param {Function} iteratee The function invoked per iteration. 2383 * @param {*} [accumulator] The initial value. 2384 * @param {boolean} [initAccum] Specify using the last element of `array` as 2385 * the initial value. 2386 * @returns {*} Returns the accumulated value. 2387 */ 2388 function arrayReduceRight(array, iteratee, accumulator, initAccum) { 2389 var length = array == null ? 0 : array.length; 2390 if (initAccum && length) { 2391 accumulator = array[--length]; 2392 } 2393 while (length--) { 2394 accumulator = iteratee(accumulator, array[length], length, array); 2395 } 2396 return accumulator; 2397 } 2398 2399 /** 2400 * A specialized version of `_.some` for arrays without support for iteratee 2401 * shorthands. 2402 * 2403 * @private 2404 * @param {Array} [array] The array to iterate over. 2405 * @param {Function} predicate The function invoked per iteration. 2406 * @returns {boolean} Returns `true` if any element passes the predicate check, 2407 * else `false`. 2408 */ 2409 function arraySome(array, predicate) { 2410 var index = -1, 2411 length = array == null ? 0 : array.length; 2412 2413 while (++index < length) { 2414 if (predicate(array[index], index, array)) { 2415 return true; 2416 } 2417 } 2418 return false; 2419 } 2420 2421 /** 2422 * Gets the size of an ASCII `string`. 2423 * 2424 * @private 2425 * @param {string} string The string inspect. 2426 * @returns {number} Returns the string size. 2427 */ 2428 var asciiSize = baseProperty('length'); 2429 2430 /** 2431 * Converts an ASCII `string` to an array. 2432 * 2433 * @private 2434 * @param {string} string The string to convert. 2435 * @returns {Array} Returns the converted array. 2436 */ 2437 function asciiToArray(string) { 2438 return string.split(''); 2439 } 2440 2441 /** 2442 * Splits an ASCII `string` into an array of its words. 2443 * 2444 * @private 2445 * @param {string} The string to inspect. 2446 * @returns {Array} Returns the words of `string`. 2447 */ 2448 function asciiWords(string) { 2449 return string.match(reAsciiWord) || []; 2450 } 2451 2452 /** 2453 * The base implementation of methods like `_.findKey` and `_.findLastKey`, 2454 * without support for iteratee shorthands, which iterates over `collection` 2455 * using `eachFunc`. 2456 * 2457 * @private 2458 * @param {Array|Object} collection The collection to inspect. 2459 * @param {Function} predicate The function invoked per iteration. 2460 * @param {Function} eachFunc The function to iterate over `collection`. 2461 * @returns {*} Returns the found element or its key, else `undefined`. 2462 */ 2463 function baseFindKey(collection, predicate, eachFunc) { 2464 var result; 2465 eachFunc(collection, function(value, key, collection) { 2466 if (predicate(value, key, collection)) { 2467 result = key; 2468 return false; 2469 } 2470 }); 2471 return result; 2472 } 2473 2474 /** 2475 * The base implementation of `_.findIndex` and `_.findLastIndex` without 2476 * support for iteratee shorthands. 2477 * 2478 * @private 2479 * @param {Array} array The array to inspect. 2480 * @param {Function} predicate The function invoked per iteration. 2481 * @param {number} fromIndex The index to search from. 2482 * @param {boolean} [fromRight] Specify iterating from right to left. 2483 * @returns {number} Returns the index of the matched value, else `-1`. 2484 */ 2485 function baseFindIndex(array, predicate, fromIndex, fromRight) { 2486 var length = array.length, 2487 index = fromIndex + (fromRight ? 1 : -1); 2488 2489 while ((fromRight ? index-- : ++index < length)) { 2490 if (predicate(array[index], index, array)) { 2491 return index; 2492 } 2493 } 2494 return -1; 2495 } 2496 2497 /** 2498 * The base implementation of `_.indexOf` without `fromIndex` bounds checks. 2499 * 2500 * @private 2501 * @param {Array} array The array to inspect. 2502 * @param {*} value The value to search for. 2503 * @param {number} fromIndex The index to search from. 2504 * @returns {number} Returns the index of the matched value, else `-1`. 2505 */ 2506 function baseIndexOf(array, value, fromIndex) { 2507 return value === value 2508 ? strictIndexOf(array, value, fromIndex) 2509 : baseFindIndex(array, baseIsNaN, fromIndex); 2510 } 2511 2512 /** 2513 * This function is like `baseIndexOf` except that it accepts a comparator. 2514 * 2515 * @private 2516 * @param {Array} array The array to inspect. 2517 * @param {*} value The value to search for. 2518 * @param {number} fromIndex The index to search from. 2519 * @param {Function} comparator The comparator invoked per element. 2520 * @returns {number} Returns the index of the matched value, else `-1`. 2521 */ 2522 function baseIndexOfWith(array, value, fromIndex, comparator) { 2523 var index = fromIndex - 1, 2524 length = array.length; 2525 2526 while (++index < length) { 2527 if (comparator(array[index], value)) { 2528 return index; 2529 } 2530 } 2531 return -1; 2532 } 2533 2534 /** 2535 * The base implementation of `_.isNaN` without support for number objects. 2536 * 2537 * @private 2538 * @param {*} value The value to check. 2539 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 2540 */ 2541 function baseIsNaN(value) { 2542 return value !== value; 2543 } 2544 2545 /** 2546 * The base implementation of `_.mean` and `_.meanBy` without support for 2547 * iteratee shorthands. 2548 * 2549 * @private 2550 * @param {Array} array The array to iterate over. 2551 * @param {Function} iteratee The function invoked per iteration. 2552 * @returns {number} Returns the mean. 2553 */ 2554 function baseMean(array, iteratee) { 2555 var length = array == null ? 0 : array.length; 2556 return length ? (baseSum(array, iteratee) / length) : NAN; 2557 } 2558 2559 /** 2560 * The base implementation of `_.property` without support for deep paths. 2561 * 2562 * @private 2563 * @param {string} key The key of the property to get. 2564 * @returns {Function} Returns the new accessor function. 2565 */ 2566 function baseProperty(key) { 2567 return function(object) { 2568 return object == null ? undefined : object[key]; 2569 }; 2570 } 2571 2572 /** 2573 * The base implementation of `_.propertyOf` without support for deep paths. 2574 * 2575 * @private 2576 * @param {Object} object The object to query. 2577 * @returns {Function} Returns the new accessor function. 2578 */ 2579 function basePropertyOf(object) { 2580 return function(key) { 2581 return object == null ? undefined : object[key]; 2582 }; 2583 } 2584 2585 /** 2586 * The base implementation of `_.reduce` and `_.reduceRight`, without support 2587 * for iteratee shorthands, which iterates over `collection` using `eachFunc`. 2588 * 2589 * @private 2590 * @param {Array|Object} collection The collection to iterate over. 2591 * @param {Function} iteratee The function invoked per iteration. 2592 * @param {*} accumulator The initial value. 2593 * @param {boolean} initAccum Specify using the first or last element of 2594 * `collection` as the initial value. 2595 * @param {Function} eachFunc The function to iterate over `collection`. 2596 * @returns {*} Returns the accumulated value. 2597 */ 2598 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { 2599 eachFunc(collection, function(value, index, collection) { 2600 accumulator = initAccum 2601 ? (initAccum = false, value) 2602 : iteratee(accumulator, value, index, collection); 2603 }); 2604 return accumulator; 2605 } 2606 2607 /** 2608 * The base implementation of `_.sortBy` which uses `comparer` to define the 2609 * sort order of `array` and replaces criteria objects with their corresponding 2610 * values. 2611 * 2612 * @private 2613 * @param {Array} array The array to sort. 2614 * @param {Function} comparer The function to define sort order. 2615 * @returns {Array} Returns `array`. 2616 */ 2617 function baseSortBy(array, comparer) { 2618 var length = array.length; 2619 2620 array.sort(comparer); 2621 while (length--) { 2622 array[length] = array[length].value; 2623 } 2624 return array; 2625 } 2626 2627 /** 2628 * The base implementation of `_.sum` and `_.sumBy` without support for 2629 * iteratee shorthands. 2630 * 2631 * @private 2632 * @param {Array} array The array to iterate over. 2633 * @param {Function} iteratee The function invoked per iteration. 2634 * @returns {number} Returns the sum. 2635 */ 2636 function baseSum(array, iteratee) { 2637 var result, 2638 index = -1, 2639 length = array.length; 2640 2641 while (++index < length) { 2642 var current = iteratee(array[index]); 2643 if (current !== undefined) { 2644 result = result === undefined ? current : (result + current); 2645 } 2646 } 2647 return result; 2648 } 2649 2650 /** 2651 * The base implementation of `_.times` without support for iteratee shorthands 2652 * or max array length checks. 2653 * 2654 * @private 2655 * @param {number} n The number of times to invoke `iteratee`. 2656 * @param {Function} iteratee The function invoked per iteration. 2657 * @returns {Array} Returns the array of results. 2658 */ 2659 function baseTimes(n, iteratee) { 2660 var index = -1, 2661 result = Array(n); 2662 2663 while (++index < n) { 2664 result[index] = iteratee(index); 2665 } 2666 return result; 2667 } 2668 2669 /** 2670 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array 2671 * of key-value pairs for `object` corresponding to the property names of `props`. 2672 * 2673 * @private 2674 * @param {Object} object The object to query. 2675 * @param {Array} props The property names to get values for. 2676 * @returns {Object} Returns the key-value pairs. 2677 */ 2678 function baseToPairs(object, props) { 2679 return arrayMap(props, function(key) { 2680 return [key, object[key]]; 2681 }); 2682 } 2683 2684 /** 2685 * The base implementation of `_.unary` without support for storing metadata. 2686 * 2687 * @private 2688 * @param {Function} func The function to cap arguments for. 2689 * @returns {Function} Returns the new capped function. 2690 */ 2691 function baseUnary(func) { 2692 return function(value) { 2693 return func(value); 2694 }; 2695 } 2696 2697 /** 2698 * The base implementation of `_.values` and `_.valuesIn` which creates an 2699 * array of `object` property values corresponding to the property names 2700 * of `props`. 2701 * 2702 * @private 2703 * @param {Object} object The object to query. 2704 * @param {Array} props The property names to get values for. 2705 * @returns {Object} Returns the array of property values. 2706 */ 2707 function baseValues(object, props) { 2708 return arrayMap(props, function(key) { 2709 return object[key]; 2710 }); 2711 } 2712 2713 /** 2714 * Checks if a `cache` value for `key` exists. 2715 * 2716 * @private 2717 * @param {Object} cache The cache to query. 2718 * @param {string} key The key of the entry to check. 2719 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 2720 */ 2721 function cacheHas(cache, key) { 2722 return cache.has(key); 2723 } 2724 2725 /** 2726 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol 2727 * that is not found in the character symbols. 2728 * 2729 * @private 2730 * @param {Array} strSymbols The string symbols to inspect. 2731 * @param {Array} chrSymbols The character symbols to find. 2732 * @returns {number} Returns the index of the first unmatched string symbol. 2733 */ 2734 function charsStartIndex(strSymbols, chrSymbols) { 2735 var index = -1, 2736 length = strSymbols.length; 2737 2738 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 2739 return index; 2740 } 2741 2742 /** 2743 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol 2744 * that is not found in the character symbols. 2745 * 2746 * @private 2747 * @param {Array} strSymbols The string symbols to inspect. 2748 * @param {Array} chrSymbols The character symbols to find. 2749 * @returns {number} Returns the index of the last unmatched string symbol. 2750 */ 2751 function charsEndIndex(strSymbols, chrSymbols) { 2752 var index = strSymbols.length; 2753 2754 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 2755 return index; 2756 } 2757 2758 /** 2759 * Gets the number of `placeholder` occurrences in `array`. 2760 * 2761 * @private 2762 * @param {Array} array The array to inspect. 2763 * @param {*} placeholder The placeholder to search for. 2764 * @returns {number} Returns the placeholder count. 2765 */ 2766 function countHolders(array, placeholder) { 2767 var length = array.length, 2768 result = 0; 2769 2770 while (length--) { 2771 if (array[length] === placeholder) { 2772 ++result; 2773 } 2774 } 2775 return result; 2776 } 2777 2778 /** 2779 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A 2780 * letters to basic Latin letters. 2781 * 2782 * @private 2783 * @param {string} letter The matched letter to deburr. 2784 * @returns {string} Returns the deburred letter. 2785 */ 2786 var deburrLetter = basePropertyOf(deburredLetters); 2787 2788 /** 2789 * Used by `_.escape` to convert characters to HTML entities. 2790 * 2791 * @private 2792 * @param {string} chr The matched character to escape. 2793 * @returns {string} Returns the escaped character. 2794 */ 2795 var escapeHtmlChar = basePropertyOf(htmlEscapes); 2796 2797 /** 2798 * Used by `_.template` to escape characters for inclusion in compiled string literals. 2799 * 2800 * @private 2801 * @param {string} chr The matched character to escape. 2802 * @returns {string} Returns the escaped character. 2803 */ 2804 function escapeStringChar(chr) { 2805 return '\\' + stringEscapes[chr]; 2806 } 2807 2808 /** 2809 * Gets the value at `key` of `object`. 2810 * 2811 * @private 2812 * @param {Object} [object] The object to query. 2813 * @param {string} key The key of the property to get. 2814 * @returns {*} Returns the property value. 2815 */ 2816 function getValue(object, key) { 2817 return object == null ? undefined : object[key]; 2818 } 2819 2820 /** 2821 * Checks if `string` contains Unicode symbols. 2822 * 2823 * @private 2824 * @param {string} string The string to inspect. 2825 * @returns {boolean} Returns `true` if a symbol is found, else `false`. 2826 */ 2827 function hasUnicode(string) { 2828 return reHasUnicode.test(string); 2829 } 2830 2831 /** 2832 * Checks if `string` contains a word composed of Unicode symbols. 2833 * 2834 * @private 2835 * @param {string} string The string to inspect. 2836 * @returns {boolean} Returns `true` if a word is found, else `false`. 2837 */ 2838 function hasUnicodeWord(string) { 2839 return reHasUnicodeWord.test(string); 2840 } 2841 2842 /** 2843 * Converts `iterator` to an array. 2844 * 2845 * @private 2846 * @param {Object} iterator The iterator to convert. 2847 * @returns {Array} Returns the converted array. 2848 */ 2849 function iteratorToArray(iterator) { 2850 var data, 2851 result = []; 2852 2853 while (!(data = iterator.next()).done) { 2854 result.push(data.value); 2855 } 2856 return result; 2857 } 2858 2859 /** 2860 * Converts `map` to its key-value pairs. 2861 * 2862 * @private 2863 * @param {Object} map The map to convert. 2864 * @returns {Array} Returns the key-value pairs. 2865 */ 2866 function mapToArray(map) { 2867 var index = -1, 2868 result = Array(map.size); 2869 2870 map.forEach(function(value, key) { 2871 result[++index] = [key, value]; 2872 }); 2873 return result; 2874 } 2875 2876 /** 2877 * Creates a unary function that invokes `func` with its argument transformed. 2878 * 2879 * @private 2880 * @param {Function} func The function to wrap. 2881 * @param {Function} transform The argument transform. 2882 * @returns {Function} Returns the new function. 2883 */ 2884 function overArg(func, transform) { 2885 return function(arg) { 2886 return func(transform(arg)); 2887 }; 2888 } 2889 2890 /** 2891 * Replaces all `placeholder` elements in `array` with an internal placeholder 2892 * and returns an array of their indexes. 2893 * 2894 * @private 2895 * @param {Array} array The array to modify. 2896 * @param {*} placeholder The placeholder to replace. 2897 * @returns {Array} Returns the new array of placeholder indexes. 2898 */ 2899 function replaceHolders(array, placeholder) { 2900 var index = -1, 2901 length = array.length, 2902 resIndex = 0, 2903 result = []; 2904 2905 while (++index < length) { 2906 var value = array[index]; 2907 if (value === placeholder || value === PLACEHOLDER) { 2908 array[index] = PLACEHOLDER; 2909 result[resIndex++] = index; 2910 } 2911 } 2912 return result; 2913 } 2914 2915 /** 2916 * Gets the value at `key`, unless `key` is "__proto__". 2917 * 2918 * @private 2919 * @param {Object} object The object to query. 2920 * @param {string} key The key of the property to get. 2921 * @returns {*} Returns the property value. 2922 */ 2923 function safeGet(object, key) { 2924 return key == '__proto__' 2925 ? undefined 2926 : object[key]; 2927 } 2928 2929 /** 2930 * Converts `set` to an array of its values. 2931 * 2932 * @private 2933 * @param {Object} set The set to convert. 2934 * @returns {Array} Returns the values. 2935 */ 2936 function setToArray(set) { 2937 var index = -1, 2938 result = Array(set.size); 2939 2940 set.forEach(function(value) { 2941 result[++index] = value; 2942 }); 2943 return result; 2944 } 2945 2946 /** 2947 * Converts `set` to its value-value pairs. 2948 * 2949 * @private 2950 * @param {Object} set The set to convert. 2951 * @returns {Array} Returns the value-value pairs. 2952 */ 2953 function setToPairs(set) { 2954 var index = -1, 2955 result = Array(set.size); 2956 2957 set.forEach(function(value) { 2958 result[++index] = [value, value]; 2959 }); 2960 return result; 2961 } 2962 2963 /** 2964 * A specialized version of `_.indexOf` which performs strict equality 2965 * comparisons of values, i.e. `===`. 2966 * 2967 * @private 2968 * @param {Array} array The array to inspect. 2969 * @param {*} value The value to search for. 2970 * @param {number} fromIndex The index to search from. 2971 * @returns {number} Returns the index of the matched value, else `-1`. 2972 */ 2973 function strictIndexOf(array, value, fromIndex) { 2974 var index = fromIndex - 1, 2975 length = array.length; 2976 2977 while (++index < length) { 2978 if (array[index] === value) { 2979 return index; 2980 } 2981 } 2982 return -1; 2983 } 2984 2985 /** 2986 * A specialized version of `_.lastIndexOf` which performs strict equality 2987 * comparisons of values, i.e. `===`. 2988 * 2989 * @private 2990 * @param {Array} array The array to inspect. 2991 * @param {*} value The value to search for. 2992 * @param {number} fromIndex The index to search from. 2993 * @returns {number} Returns the index of the matched value, else `-1`. 2994 */ 2995 function strictLastIndexOf(array, value, fromIndex) { 2996 var index = fromIndex + 1; 2997 while (index--) { 2998 if (array[index] === value) { 2999 return index; 3000 } 3001 } 3002 return index; 3003 } 3004 3005 /** 3006 * Gets the number of symbols in `string`. 3007 * 3008 * @private 3009 * @param {string} string The string to inspect. 3010 * @returns {number} Returns the string size. 3011 */ 3012 function stringSize(string) { 3013 return hasUnicode(string) 3014 ? unicodeSize(string) 3015 : asciiSize(string); 3016 } 3017 3018 /** 3019 * Converts `string` to an array. 3020 * 3021 * @private 3022 * @param {string} string The string to convert. 3023 * @returns {Array} Returns the converted array. 3024 */ 3025 function stringToArray(string) { 3026 return hasUnicode(string) 3027 ? unicodeToArray(string) 3028 : asciiToArray(string); 3029 } 3030 3031 /** 3032 * Used by `_.unescape` to convert HTML entities to characters. 3033 * 3034 * @private 3035 * @param {string} chr The matched character to unescape. 3036 * @returns {string} Returns the unescaped character. 3037 */ 3038 var unescapeHtmlChar = basePropertyOf(htmlUnescapes); 3039 3040 /** 3041 * Gets the size of a Unicode `string`. 3042 * 3043 * @private 3044 * @param {string} string The string inspect. 3045 * @returns {number} Returns the string size. 3046 */ 3047 function unicodeSize(string) { 3048 var result = reUnicode.lastIndex = 0; 3049 while (reUnicode.test(string)) { 3050 ++result; 3051 } 3052 return result; 3053 } 3054 3055 /** 3056 * Converts a Unicode `string` to an array. 3057 * 3058 * @private 3059 * @param {string} string The string to convert. 3060 * @returns {Array} Returns the converted array. 3061 */ 3062 function unicodeToArray(string) { 3063 return string.match(reUnicode) || []; 3064 } 3065 3066 /** 3067 * Splits a Unicode `string` into an array of its words. 3068 * 3069 * @private 3070 * @param {string} The string to inspect. 3071 * @returns {Array} Returns the words of `string`. 3072 */ 3073 function unicodeWords(string) { 3074 return string.match(reUnicodeWord) || []; 3075 } 3076 3077 /*--------------------------------------------------------------------------*/ 3078 3079 /** 3080 * Create a new pristine `lodash` function using the `context` object. 3081 * 3082 * @static 3083 * @memberOf _ 3084 * @since 1.1.0 3085 * @category Util 3086 * @param {Object} [context=root] The context object. 3087 * @returns {Function} Returns a new `lodash` function. 3088 * @example 3089 * 3090 * _.mixin({ 'foo': _.constant('foo') }); 3091 * 3092 * var lodash = _.runInContext(); 3093 * lodash.mixin({ 'bar': lodash.constant('bar') }); 3094 * 3095 * _.isFunction(_.foo); 3096 * // => true 3097 * _.isFunction(_.bar); 3098 * // => false 3099 * 3100 * lodash.isFunction(lodash.foo); 3101 * // => false 3102 * lodash.isFunction(lodash.bar); 3103 * // => true 3104 * 3105 * // Create a suped-up `defer` in Node.js. 3106 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; 3107 */ 3108 var runInContext = (function runInContext(context) { 3109 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); 3110 3111 /** Built-in constructor references. */ 3112 var Array = context.Array, 3113 Date = context.Date, 3114 Error = context.Error, 3115 Function = context.Function, 3116 Math = context.Math, 3117 Object = context.Object, 3118 RegExp = context.RegExp, 3119 String = context.String, 3120 TypeError = context.TypeError; 3121 3122 /** Used for built-in method references. */ 3123 var arrayProto = Array.prototype, 3124 funcProto = Function.prototype, 3125 objectProto = Object.prototype; 3126 3127 /** Used to detect overreaching core-js shims. */ 3128 var coreJsData = context['__core-js_shared__']; 3129 3130 /** Used to resolve the decompiled source of functions. */ 3131 var funcToString = funcProto.toString; 3132 3133 /** Used to check objects for own properties. */ 3134 var hasOwnProperty = objectProto.hasOwnProperty; 3135 3136 /** Used to generate unique IDs. */ 3137 var idCounter = 0; 3138 3139 /** Used to detect methods masquerading as native. */ 3140 var maskSrcKey = (function() { 3141 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); 3142 return uid ? ('Symbol(src)_1.' + uid) : ''; 3143 }()); 3144 3145 /** 3146 * Used to resolve the 3147 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 3148 * of values. 3149 */ 3150 var nativeObjectToString = objectProto.toString; 3151 3152 /** Used to infer the `Object` constructor. */ 3153 var objectCtorString = funcToString.call(Object); 3154 3155 /** Used to restore the original `_` reference in `_.noConflict`. */ 3156 var oldDash = root._; 3157 3158 /** Used to detect if a method is native. */ 3159 var reIsNative = RegExp('^' + 3160 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') 3161 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 3162 ); 3163 3164 /** Built-in value references. */ 3165 var Buffer = moduleExports ? context.Buffer : undefined, 3166 Symbol = context.Symbol, 3167 Uint8Array = context.Uint8Array, 3168 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, 3169 getPrototype = overArg(Object.getPrototypeOf, Object), 3170 objectCreate = Object.create, 3171 propertyIsEnumerable = objectProto.propertyIsEnumerable, 3172 splice = arrayProto.splice, 3173 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, 3174 symIterator = Symbol ? Symbol.iterator : undefined, 3175 symToStringTag = Symbol ? Symbol.toStringTag : undefined; 3176 3177 var defineProperty = (function() { 3178 try { 3179 var func = getNative(Object, 'defineProperty'); 3180 func({}, '', {}); 3181 return func; 3182 } catch (e) {} 3183 }()); 3184 3185 /** Mocked built-ins. */ 3186 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, 3187 ctxNow = Date && Date.now !== root.Date.now && Date.now, 3188 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; 3189 3190 /* Built-in method references for those with the same name as other `lodash` methods. */ 3191 var nativeCeil = Math.ceil, 3192 nativeFloor = Math.floor, 3193 nativeGetSymbols = Object.getOwnPropertySymbols, 3194 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, 3195 nativeIsFinite = context.isFinite, 3196 nativeJoin = arrayProto.join, 3197 nativeKeys = overArg(Object.keys, Object), 3198 nativeMax = Math.max, 3199 nativeMin = Math.min, 3200 nativeNow = Date.now, 3201 nativeParseInt = context.parseInt, 3202 nativeRandom = Math.random, 3203 nativeReverse = arrayProto.reverse; 3204 3205 /* Built-in method references that are verified to be native. */ 3206 var DataView = getNative(context, 'DataView'), 3207 Map = getNative(context, 'Map'), 3208 Promise = getNative(context, 'Promise'), 3209 Set = getNative(context, 'Set'), 3210 WeakMap = getNative(context, 'WeakMap'), 3211 nativeCreate = getNative(Object, 'create'); 3212 3213 /** Used to store function metadata. */ 3214 var metaMap = WeakMap && new WeakMap; 3215 3216 /** Used to lookup unminified function names. */ 3217 var realNames = {}; 3218 3219 /** Used to detect maps, sets, and weakmaps. */ 3220 var dataViewCtorString = toSource(DataView), 3221 mapCtorString = toSource(Map), 3222 promiseCtorString = toSource(Promise), 3223 setCtorString = toSource(Set), 3224 weakMapCtorString = toSource(WeakMap); 3225 3226 /** Used to convert symbols to primitives and strings. */ 3227 var symbolProto = Symbol ? Symbol.prototype : undefined, 3228 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, 3229 symbolToString = symbolProto ? symbolProto.toString : undefined; 3230 3231 /*------------------------------------------------------------------------*/ 3232 3233 /** 3234 * Creates a `lodash` object which wraps `value` to enable implicit method 3235 * chain sequences. Methods that operate on and return arrays, collections, 3236 * and functions can be chained together. Methods that retrieve a single value 3237 * or may return a primitive value will automatically end the chain sequence 3238 * and return the unwrapped value. Otherwise, the value must be unwrapped 3239 * with `_#value`. 3240 * 3241 * Explicit chain sequences, which must be unwrapped with `_#value`, may be 3242 * enabled using `_.chain`. 3243 * 3244 * The execution of chained methods is lazy, that is, it's deferred until 3245 * `_#value` is implicitly or explicitly called. 3246 * 3247 * Lazy evaluation allows several methods to support shortcut fusion. 3248 * Shortcut fusion is an optimization to merge iteratee calls; this avoids 3249 * the creation of intermediate arrays and can greatly reduce the number of 3250 * iteratee executions. Sections of a chain sequence qualify for shortcut 3251 * fusion if the section is applied to an array and iteratees accept only 3252 * one argument. The heuristic for whether a section qualifies for shortcut 3253 * fusion is subject to change. 3254 * 3255 * Chaining is supported in custom builds as long as the `_#value` method is 3256 * directly or indirectly included in the build. 3257 * 3258 * In addition to lodash methods, wrappers have `Array` and `String` methods. 3259 * 3260 * The wrapper `Array` methods are: 3261 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` 3262 * 3263 * The wrapper `String` methods are: 3264 * `replace` and `split` 3265 * 3266 * The wrapper methods that support shortcut fusion are: 3267 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, 3268 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, 3269 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` 3270 * 3271 * The chainable wrapper methods are: 3272 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, 3273 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, 3274 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, 3275 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, 3276 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, 3277 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, 3278 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, 3279 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, 3280 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, 3281 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, 3282 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, 3283 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, 3284 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, 3285 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, 3286 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, 3287 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, 3288 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, 3289 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, 3290 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, 3291 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, 3292 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, 3293 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, 3294 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, 3295 * `zipObject`, `zipObjectDeep`, and `zipWith` 3296 * 3297 * The wrapper methods that are **not** chainable by default are: 3298 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, 3299 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, 3300 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, 3301 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, 3302 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, 3303 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, 3304 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, 3305 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, 3306 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, 3307 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, 3308 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, 3309 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, 3310 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, 3311 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, 3312 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, 3313 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, 3314 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, 3315 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, 3316 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, 3317 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, 3318 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, 3319 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, 3320 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, 3321 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, 3322 * `upperFirst`, `value`, and `words` 3323 * 3324 * @name _ 3325 * @constructor 3326 * @category Seq 3327 * @param {*} value The value to wrap in a `lodash` instance. 3328 * @returns {Object} Returns the new `lodash` wrapper instance. 3329 * @example 3330 * 3331 * function square(n) { 3332 * return n * n; 3333 * } 3334 * 3335 * var wrapped = _([1, 2, 3]); 3336 * 3337 * // Returns an unwrapped value. 3338 * wrapped.reduce(_.add); 3339 * // => 6 3340 * 3341 * // Returns a wrapped value. 3342 * var squares = wrapped.map(square); 3343 * 3344 * _.isArray(squares); 3345 * // => false 3346 * 3347 * _.isArray(squares.value()); 3348 * // => true 3349 */ 3350 function lodash(value) { 3351 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { 3352 if (value instanceof LodashWrapper) { 3353 return value; 3354 } 3355 if (hasOwnProperty.call(value, '__wrapped__')) { 3356 return wrapperClone(value); 3357 } 3358 } 3359 return new LodashWrapper(value); 3360 } 3361 3362 /** 3363 * The base implementation of `_.create` without support for assigning 3364 * properties to the created object. 3365 * 3366 * @private 3367 * @param {Object} proto The object to inherit from. 3368 * @returns {Object} Returns the new object. 3369 */ 3370 var baseCreate = (function() { 3371 function object() {} 3372 return function(proto) { 3373 if (!isObject(proto)) { 3374 return {}; 3375 } 3376 if (objectCreate) { 3377 return objectCreate(proto); 3378 } 3379 object.prototype = proto; 3380 var result = new object; 3381 object.prototype = undefined; 3382 return result; 3383 }; 3384 }()); 3385 3386 /** 3387 * The function whose prototype chain sequence wrappers inherit from. 3388 * 3389 * @private 3390 */ 3391 function baseLodash() { 3392 // No operation performed. 3393 } 3394 3395 /** 3396 * The base constructor for creating `lodash` wrapper objects. 3397 * 3398 * @private 3399 * @param {*} value The value to wrap. 3400 * @param {boolean} [chainAll] Enable explicit method chain sequences. 3401 */ 3402 function LodashWrapper(value, chainAll) { 3403 this.__wrapped__ = value; 3404 this.__actions__ = []; 3405 this.__chain__ = !!chainAll; 3406 this.__index__ = 0; 3407 this.__values__ = undefined; 3408 } 3409 3410 /** 3411 * By default, the template delimiters used by lodash are like those in 3412 * embedded Ruby (ERB) as well as ES2015 template strings. Change the 3413 * following template settings to use alternative delimiters. 3414 * 3415 * @static 3416 * @memberOf _ 3417 * @type {Object} 3418 */ 3419 lodash.templateSettings = { 3420 3421 /** 3422 * Used to detect `data` property values to be HTML-escaped. 3423 * 3424 * @memberOf _.templateSettings 3425 * @type {RegExp} 3426 */ 3427 'escape': reEscape, 3428 3429 /** 3430 * Used to detect code to be evaluated. 3431 * 3432 * @memberOf _.templateSettings 3433 * @type {RegExp} 3434 */ 3435 'evaluate': reEvaluate, 3436 3437 /** 3438 * Used to detect `data` property values to inject. 3439 * 3440 * @memberOf _.templateSettings 3441 * @type {RegExp} 3442 */ 3443 'interpolate': reInterpolate, 3444 3445 /** 3446 * Used to reference the data object in the template text. 3447 * 3448 * @memberOf _.templateSettings 3449 * @type {string} 3450 */ 3451 'variable': '', 3452 3453 /** 3454 * Used to import variables into the compiled template. 3455 * 3456 * @memberOf _.templateSettings 3457 * @type {Object} 3458 */ 3459 'imports': { 3460 3461 /** 3462 * A reference to the `lodash` function. 3463 * 3464 * @memberOf _.templateSettings.imports 3465 * @type {Function} 3466 */ 3467 '_': lodash 3468 } 3469 }; 3470 3471 // Ensure wrappers are instances of `baseLodash`. 3472 lodash.prototype = baseLodash.prototype; 3473 lodash.prototype.constructor = lodash; 3474 3475 LodashWrapper.prototype = baseCreate(baseLodash.prototype); 3476 LodashWrapper.prototype.constructor = LodashWrapper; 3477 3478 /*------------------------------------------------------------------------*/ 3479 3480 /** 3481 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. 3482 * 3483 * @private 3484 * @constructor 3485 * @param {*} value The value to wrap. 3486 */ 3487 function LazyWrapper(value) { 3488 this.__wrapped__ = value; 3489 this.__actions__ = []; 3490 this.__dir__ = 1; 3491 this.__filtered__ = false; 3492 this.__iteratees__ = []; 3493 this.__takeCount__ = MAX_ARRAY_LENGTH; 3494 this.__views__ = []; 3495 } 3496 3497 /** 3498 * Creates a clone of the lazy wrapper object. 3499 * 3500 * @private 3501 * @name clone 3502 * @memberOf LazyWrapper 3503 * @returns {Object} Returns the cloned `LazyWrapper` object. 3504 */ 3505 function lazyClone() { 3506 var result = new LazyWrapper(this.__wrapped__); 3507 result.__actions__ = copyArray(this.__actions__); 3508 result.__dir__ = this.__dir__; 3509 result.__filtered__ = this.__filtered__; 3510 result.__iteratees__ = copyArray(this.__iteratees__); 3511 result.__takeCount__ = this.__takeCount__; 3512 result.__views__ = copyArray(this.__views__); 3513 return result; 3514 } 3515 3516 /** 3517 * Reverses the direction of lazy iteration. 3518 * 3519 * @private 3520 * @name reverse 3521 * @memberOf LazyWrapper 3522 * @returns {Object} Returns the new reversed `LazyWrapper` object. 3523 */ 3524 function lazyReverse() { 3525 if (this.__filtered__) { 3526 var result = new LazyWrapper(this); 3527 result.__dir__ = -1; 3528 result.__filtered__ = true; 3529 } else { 3530 result = this.clone(); 3531 result.__dir__ *= -1; 3532 } 3533 return result; 3534 } 3535 3536 /** 3537 * Extracts the unwrapped value from its lazy wrapper. 3538 * 3539 * @private 3540 * @name value 3541 * @memberOf LazyWrapper 3542 * @returns {*} Returns the unwrapped value. 3543 */ 3544 function lazyValue() { 3545 var array = this.__wrapped__.value(), 3546 dir = this.__dir__, 3547 isArr = isArray(array), 3548 isRight = dir < 0, 3549 arrLength = isArr ? array.length : 0, 3550 view = getView(0, arrLength, this.__views__), 3551 start = view.start, 3552 end = view.end, 3553 length = end - start, 3554 index = isRight ? end : (start - 1), 3555 iteratees = this.__iteratees__, 3556 iterLength = iteratees.length, 3557 resIndex = 0, 3558 takeCount = nativeMin(length, this.__takeCount__); 3559 3560 if (!isArr || (!isRight && arrLength == length && takeCount == length)) { 3561 return baseWrapperValue(array, this.__actions__); 3562 } 3563 var result = []; 3564 3565 outer: 3566 while (length-- && resIndex < takeCount) { 3567 index += dir; 3568 3569 var iterIndex = -1, 3570 value = array[index]; 3571 3572 while (++iterIndex < iterLength) { 3573 var data = iteratees[iterIndex], 3574 iteratee = data.iteratee, 3575 type = data.type, 3576 computed = iteratee(value); 3577 3578 if (type == LAZY_MAP_FLAG) { 3579 value = computed; 3580 } else if (!computed) { 3581 if (type == LAZY_FILTER_FLAG) { 3582 continue outer; 3583 } else { 3584 break outer; 3585 } 3586 } 3587 } 3588 result[resIndex++] = value; 3589 } 3590 return result; 3591 } 3592 3593 // Ensure `LazyWrapper` is an instance of `baseLodash`. 3594 LazyWrapper.prototype = baseCreate(baseLodash.prototype); 3595 LazyWrapper.prototype.constructor = LazyWrapper; 3596 3597 /*------------------------------------------------------------------------*/ 3598 3599 /** 3600 * Creates a hash object. 3601 * 3602 * @private 3603 * @constructor 3604 * @param {Array} [entries] The key-value pairs to cache. 3605 */ 3606 function Hash(entries) { 3607 var index = -1, 3608 length = entries == null ? 0 : entries.length; 3609 3610 this.clear(); 3611 while (++index < length) { 3612 var entry = entries[index]; 3613 this.set(entry[0], entry[1]); 3614 } 3615 } 3616 3617 /** 3618 * Removes all key-value entries from the hash. 3619 * 3620 * @private 3621 * @name clear 3622 * @memberOf Hash 3623 */ 3624 function hashClear() { 3625 this.__data__ = nativeCreate ? nativeCreate(null) : {}; 3626 this.size = 0; 3627 } 3628 3629 /** 3630 * Removes `key` and its value from the hash. 3631 * 3632 * @private 3633 * @name delete 3634 * @memberOf Hash 3635 * @param {Object} hash The hash to modify. 3636 * @param {string} key The key of the value to remove. 3637 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 3638 */ 3639 function hashDelete(key) { 3640 var result = this.has(key) && delete this.__data__[key]; 3641 this.size -= result ? 1 : 0; 3642 return result; 3643 } 3644 3645 /** 3646 * Gets the hash value for `key`. 3647 * 3648 * @private 3649 * @name get 3650 * @memberOf Hash 3651 * @param {string} key The key of the value to get. 3652 * @returns {*} Returns the entry value. 3653 */ 3654 function hashGet(key) { 3655 var data = this.__data__; 3656 if (nativeCreate) { 3657 var result = data[key]; 3658 return result === HASH_UNDEFINED ? undefined : result; 3659 } 3660 return hasOwnProperty.call(data, key) ? data[key] : undefined; 3661 } 3662 3663 /** 3664 * Checks if a hash value for `key` exists. 3665 * 3666 * @private 3667 * @name has 3668 * @memberOf Hash 3669 * @param {string} key The key of the entry to check. 3670 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 3671 */ 3672 function hashHas(key) { 3673 var data = this.__data__; 3674 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); 3675 } 3676 3677 /** 3678 * Sets the hash `key` to `value`. 3679 * 3680 * @private 3681 * @name set 3682 * @memberOf Hash 3683 * @param {string} key The key of the value to set. 3684 * @param {*} value The value to set. 3685 * @returns {Object} Returns the hash instance. 3686 */ 3687 function hashSet(key, value) { 3688 var data = this.__data__; 3689 this.size += this.has(key) ? 0 : 1; 3690 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; 3691 return this; 3692 } 3693 3694 // Add methods to `Hash`. 3695 Hash.prototype.clear = hashClear; 3696 Hash.prototype['delete'] = hashDelete; 3697 Hash.prototype.get = hashGet; 3698 Hash.prototype.has = hashHas; 3699 Hash.prototype.set = hashSet; 3700 3701 /*------------------------------------------------------------------------*/ 3702 3703 /** 3704 * Creates an list cache object. 3705 * 3706 * @private 3707 * @constructor 3708 * @param {Array} [entries] The key-value pairs to cache. 3709 */ 3710 function ListCache(entries) { 3711 var index = -1, 3712 length = entries == null ? 0 : entries.length; 3713 3714 this.clear(); 3715 while (++index < length) { 3716 var entry = entries[index]; 3717 this.set(entry[0], entry[1]); 3718 } 3719 } 3720 3721 /** 3722 * Removes all key-value entries from the list cache. 3723 * 3724 * @private 3725 * @name clear 3726 * @memberOf ListCache 3727 */ 3728 function listCacheClear() { 3729 this.__data__ = []; 3730 this.size = 0; 3731 } 3732 3733 /** 3734 * Removes `key` and its value from the list cache. 3735 * 3736 * @private 3737 * @name delete 3738 * @memberOf ListCache 3739 * @param {string} key The key of the value to remove. 3740 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 3741 */ 3742 function listCacheDelete(key) { 3743 var data = this.__data__, 3744 index = assocIndexOf(data, key); 3745 3746 if (index < 0) { 3747 return false; 3748 } 3749 var lastIndex = data.length - 1; 3750 if (index == lastIndex) { 3751 data.pop(); 3752 } else { 3753 splice.call(data, index, 1); 3754 } 3755 --this.size; 3756 return true; 3757 } 3758 3759 /** 3760 * Gets the list cache value for `key`. 3761 * 3762 * @private 3763 * @name get 3764 * @memberOf ListCache 3765 * @param {string} key The key of the value to get. 3766 * @returns {*} Returns the entry value. 3767 */ 3768 function listCacheGet(key) { 3769 var data = this.__data__, 3770 index = assocIndexOf(data, key); 3771 3772 return index < 0 ? undefined : data[index][1]; 3773 } 3774 3775 /** 3776 * Checks if a list cache value for `key` exists. 3777 * 3778 * @private 3779 * @name has 3780 * @memberOf ListCache 3781 * @param {string} key The key of the entry to check. 3782 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 3783 */ 3784 function listCacheHas(key) { 3785 return assocIndexOf(this.__data__, key) > -1; 3786 } 3787 3788 /** 3789 * Sets the list cache `key` to `value`. 3790 * 3791 * @private 3792 * @name set 3793 * @memberOf ListCache 3794 * @param {string} key The key of the value to set. 3795 * @param {*} value The value to set. 3796 * @returns {Object} Returns the list cache instance. 3797 */ 3798 function listCacheSet(key, value) { 3799 var data = this.__data__, 3800 index = assocIndexOf(data, key); 3801 3802 if (index < 0) { 3803 ++this.size; 3804 data.push([key, value]); 3805 } else { 3806 data[index][1] = value; 3807 } 3808 return this; 3809 } 3810 3811 // Add methods to `ListCache`. 3812 ListCache.prototype.clear = listCacheClear; 3813 ListCache.prototype['delete'] = listCacheDelete; 3814 ListCache.prototype.get = listCacheGet; 3815 ListCache.prototype.has = listCacheHas; 3816 ListCache.prototype.set = listCacheSet; 3817 3818 /*------------------------------------------------------------------------*/ 3819 3820 /** 3821 * Creates a map cache object to store key-value pairs. 3822 * 3823 * @private 3824 * @constructor 3825 * @param {Array} [entries] The key-value pairs to cache. 3826 */ 3827 function MapCache(entries) { 3828 var index = -1, 3829 length = entries == null ? 0 : entries.length; 3830 3831 this.clear(); 3832 while (++index < length) { 3833 var entry = entries[index]; 3834 this.set(entry[0], entry[1]); 3835 } 3836 } 3837 3838 /** 3839 * Removes all key-value entries from the map. 3840 * 3841 * @private 3842 * @name clear 3843 * @memberOf MapCache 3844 */ 3845 function mapCacheClear() { 3846 this.size = 0; 3847 this.__data__ = { 3848 'hash': new Hash, 3849 'map': new (Map || ListCache), 3850 'string': new Hash 3851 }; 3852 } 3853 3854 /** 3855 * Removes `key` and its value from the map. 3856 * 3857 * @private 3858 * @name delete 3859 * @memberOf MapCache 3860 * @param {string} key The key of the value to remove. 3861 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 3862 */ 3863 function mapCacheDelete(key) { 3864 var result = getMapData(this, key)['delete'](key); 3865 this.size -= result ? 1 : 0; 3866 return result; 3867 } 3868 3869 /** 3870 * Gets the map value for `key`. 3871 * 3872 * @private 3873 * @name get 3874 * @memberOf MapCache 3875 * @param {string} key The key of the value to get. 3876 * @returns {*} Returns the entry value. 3877 */ 3878 function mapCacheGet(key) { 3879 return getMapData(this, key).get(key); 3880 } 3881 3882 /** 3883 * Checks if a map value for `key` exists. 3884 * 3885 * @private 3886 * @name has 3887 * @memberOf MapCache 3888 * @param {string} key The key of the entry to check. 3889 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 3890 */ 3891 function mapCacheHas(key) { 3892 return getMapData(this, key).has(key); 3893 } 3894 3895 /** 3896 * Sets the map `key` to `value`. 3897 * 3898 * @private 3899 * @name set 3900 * @memberOf MapCache 3901 * @param {string} key The key of the value to set. 3902 * @param {*} value The value to set. 3903 * @returns {Object} Returns the map cache instance. 3904 */ 3905 function mapCacheSet(key, value) { 3906 var data = getMapData(this, key), 3907 size = data.size; 3908 3909 data.set(key, value); 3910 this.size += data.size == size ? 0 : 1; 3911 return this; 3912 } 3913 3914 // Add methods to `MapCache`. 3915 MapCache.prototype.clear = mapCacheClear; 3916 MapCache.prototype['delete'] = mapCacheDelete; 3917 MapCache.prototype.get = mapCacheGet; 3918 MapCache.prototype.has = mapCacheHas; 3919 MapCache.prototype.set = mapCacheSet; 3920 3921 /*------------------------------------------------------------------------*/ 3922 3923 /** 3924 * 3925 * Creates an array cache object to store unique values. 3926 * 3927 * @private 3928 * @constructor 3929 * @param {Array} [values] The values to cache. 3930 */ 3931 function SetCache(values) { 3932 var index = -1, 3933 length = values == null ? 0 : values.length; 3934 3935 this.__data__ = new MapCache; 3936 while (++index < length) { 3937 this.add(values[index]); 3938 } 3939 } 3940 3941 /** 3942 * Adds `value` to the array cache. 3943 * 3944 * @private 3945 * @name add 3946 * @memberOf SetCache 3947 * @alias push 3948 * @param {*} value The value to cache. 3949 * @returns {Object} Returns the cache instance. 3950 */ 3951 function setCacheAdd(value) { 3952 this.__data__.set(value, HASH_UNDEFINED); 3953 return this; 3954 } 3955 3956 /** 3957 * Checks if `value` is in the array cache. 3958 * 3959 * @private 3960 * @name has 3961 * @memberOf SetCache 3962 * @param {*} value The value to search for. 3963 * @returns {number} Returns `true` if `value` is found, else `false`. 3964 */ 3965 function setCacheHas(value) { 3966 return this.__data__.has(value); 3967 } 3968 3969 // Add methods to `SetCache`. 3970 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; 3971 SetCache.prototype.has = setCacheHas; 3972 3973 /*------------------------------------------------------------------------*/ 3974 3975 /** 3976 * Creates a stack cache object to store key-value pairs. 3977 * 3978 * @private 3979 * @constructor 3980 * @param {Array} [entries] The key-value pairs to cache. 3981 */ 3982 function Stack(entries) { 3983 var data = this.__data__ = new ListCache(entries); 3984 this.size = data.size; 3985 } 3986 3987 /** 3988 * Removes all key-value entries from the stack. 3989 * 3990 * @private 3991 * @name clear 3992 * @memberOf Stack 3993 */ 3994 function stackClear() { 3995 this.__data__ = new ListCache; 3996 this.size = 0; 3997 } 3998 3999 /** 4000 * Removes `key` and its value from the stack. 4001 * 4002 * @private 4003 * @name delete 4004 * @memberOf Stack 4005 * @param {string} key The key of the value to remove. 4006 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 4007 */ 4008 function stackDelete(key) { 4009 var data = this.__data__, 4010 result = data['delete'](key); 4011 4012 this.size = data.size; 4013 return result; 4014 } 4015 4016 /** 4017 * Gets the stack value for `key`. 4018 * 4019 * @private 4020 * @name get 4021 * @memberOf Stack 4022 * @param {string} key The key of the value to get. 4023 * @returns {*} Returns the entry value. 4024 */ 4025 function stackGet(key) { 4026 return this.__data__.get(key); 4027 } 4028 4029 /** 4030 * Checks if a stack value for `key` exists. 4031 * 4032 * @private 4033 * @name has 4034 * @memberOf Stack 4035 * @param {string} key The key of the entry to check. 4036 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 4037 */ 4038 function stackHas(key) { 4039 return this.__data__.has(key); 4040 } 4041 4042 /** 4043 * Sets the stack `key` to `value`. 4044 * 4045 * @private 4046 * @name set 4047 * @memberOf Stack 4048 * @param {string} key The key of the value to set. 4049 * @param {*} value The value to set. 4050 * @returns {Object} Returns the stack cache instance. 4051 */ 4052 function stackSet(key, value) { 4053 var data = this.__data__; 4054 if (data instanceof ListCache) { 4055 var pairs = data.__data__; 4056 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { 4057 pairs.push([key, value]); 4058 this.size = ++data.size; 4059 return this; 4060 } 4061 data = this.__data__ = new MapCache(pairs); 4062 } 4063 data.set(key, value); 4064 this.size = data.size; 4065 return this; 4066 } 4067 4068 // Add methods to `Stack`. 4069 Stack.prototype.clear = stackClear; 4070 Stack.prototype['delete'] = stackDelete; 4071 Stack.prototype.get = stackGet; 4072 Stack.prototype.has = stackHas; 4073 Stack.prototype.set = stackSet; 4074 4075 /*------------------------------------------------------------------------*/ 4076 4077 /** 4078 * Creates an array of the enumerable property names of the array-like `value`. 4079 * 4080 * @private 4081 * @param {*} value The value to query. 4082 * @param {boolean} inherited Specify returning inherited property names. 4083 * @returns {Array} Returns the array of property names. 4084 */ 4085 function arrayLikeKeys(value, inherited) { 4086 var isArr = isArray(value), 4087 isArg = !isArr && isArguments(value), 4088 isBuff = !isArr && !isArg && isBuffer(value), 4089 isType = !isArr && !isArg && !isBuff && isTypedArray(value), 4090 skipIndexes = isArr || isArg || isBuff || isType, 4091 result = skipIndexes ? baseTimes(value.length, String) : [], 4092 length = result.length; 4093 4094 for (var key in value) { 4095 if ((inherited || hasOwnProperty.call(value, key)) && 4096 !(skipIndexes && ( 4097 // Safari 9 has enumerable `arguments.length` in strict mode. 4098 key == 'length' || 4099 // Node.js 0.10 has enumerable non-index properties on buffers. 4100 (isBuff && (key == 'offset' || key == 'parent')) || 4101 // PhantomJS 2 has enumerable non-index properties on typed arrays. 4102 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || 4103 // Skip index properties. 4104 isIndex(key, length) 4105 ))) { 4106 result.push(key); 4107 } 4108 } 4109 return result; 4110 } 4111 4112 /** 4113 * A specialized version of `_.sample` for arrays. 4114 * 4115 * @private 4116 * @param {Array} array The array to sample. 4117 * @returns {*} Returns the random element. 4118 */ 4119 function arraySample(array) { 4120 var length = array.length; 4121 return length ? array[baseRandom(0, length - 1)] : undefined; 4122 } 4123 4124 /** 4125 * A specialized version of `_.sampleSize` for arrays. 4126 * 4127 * @private 4128 * @param {Array} array The array to sample. 4129 * @param {number} n The number of elements to sample. 4130 * @returns {Array} Returns the random elements. 4131 */ 4132 function arraySampleSize(array, n) { 4133 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); 4134 } 4135 4136 /** 4137 * A specialized version of `_.shuffle` for arrays. 4138 * 4139 * @private 4140 * @param {Array} array The array to shuffle. 4141 * @returns {Array} Returns the new shuffled array. 4142 */ 4143 function arrayShuffle(array) { 4144 return shuffleSelf(copyArray(array)); 4145 } 4146 4147 /** 4148 * This function is like `assignValue` except that it doesn't assign 4149 * `undefined` values. 4150 * 4151 * @private 4152 * @param {Object} object The object to modify. 4153 * @param {string} key The key of the property to assign. 4154 * @param {*} value The value to assign. 4155 */ 4156 function assignMergeValue(object, key, value) { 4157 if ((value !== undefined && !eq(object[key], value)) || 4158 (value === undefined && !(key in object))) { 4159 baseAssignValue(object, key, value); 4160 } 4161 } 4162 4163 /** 4164 * Assigns `value` to `key` of `object` if the existing value is not equivalent 4165 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 4166 * for equality comparisons. 4167 * 4168 * @private 4169 * @param {Object} object The object to modify. 4170 * @param {string} key The key of the property to assign. 4171 * @param {*} value The value to assign. 4172 */ 4173 function assignValue(object, key, value) { 4174 var objValue = object[key]; 4175 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || 4176 (value === undefined && !(key in object))) { 4177 baseAssignValue(object, key, value); 4178 } 4179 } 4180 4181 /** 4182 * Gets the index at which the `key` is found in `array` of key-value pairs. 4183 * 4184 * @private 4185 * @param {Array} array The array to inspect. 4186 * @param {*} key The key to search for. 4187 * @returns {number} Returns the index of the matched value, else `-1`. 4188 */ 4189 function assocIndexOf(array, key) { 4190 var length = array.length; 4191 while (length--) { 4192 if (eq(array[length][0], key)) { 4193 return length; 4194 } 4195 } 4196 return -1; 4197 } 4198 4199 /** 4200 * Aggregates elements of `collection` on `accumulator` with keys transformed 4201 * by `iteratee` and values set by `setter`. 4202 * 4203 * @private 4204 * @param {Array|Object} collection The collection to iterate over. 4205 * @param {Function} setter The function to set `accumulator` values. 4206 * @param {Function} iteratee The iteratee to transform keys. 4207 * @param {Object} accumulator The initial aggregated object. 4208 * @returns {Function} Returns `accumulator`. 4209 */ 4210 function baseAggregator(collection, setter, iteratee, accumulator) { 4211 baseEach(collection, function(value, key, collection) { 4212 setter(accumulator, value, iteratee(value), collection); 4213 }); 4214 return accumulator; 4215 } 4216 4217 /** 4218 * The base implementation of `_.assign` without support for multiple sources 4219 * or `customizer` functions. 4220 * 4221 * @private 4222 * @param {Object} object The destination object. 4223 * @param {Object} source The source object. 4224 * @returns {Object} Returns `object`. 4225 */ 4226 function baseAssign(object, source) { 4227 return object && copyObject(source, keys(source), object); 4228 } 4229 4230 /** 4231 * The base implementation of `_.assignIn` without support for multiple sources 4232 * or `customizer` functions. 4233 * 4234 * @private 4235 * @param {Object} object The destination object. 4236 * @param {Object} source The source object. 4237 * @returns {Object} Returns `object`. 4238 */ 4239 function baseAssignIn(object, source) { 4240 return object && copyObject(source, keysIn(source), object); 4241 } 4242 4243 /** 4244 * The base implementation of `assignValue` and `assignMergeValue` without 4245 * value checks. 4246 * 4247 * @private 4248 * @param {Object} object The object to modify. 4249 * @param {string} key The key of the property to assign. 4250 * @param {*} value The value to assign. 4251 */ 4252 function baseAssignValue(object, key, value) { 4253 if (key == '__proto__' && defineProperty) { 4254 defineProperty(object, key, { 4255 'configurable': true, 4256 'enumerable': true, 4257 'value': value, 4258 'writable': true 4259 }); 4260 } else { 4261 object[key] = value; 4262 } 4263 } 4264 4265 /** 4266 * The base implementation of `_.at` without support for individual paths. 4267 * 4268 * @private 4269 * @param {Object} object The object to iterate over. 4270 * @param {string[]} paths The property paths to pick. 4271 * @returns {Array} Returns the picked elements. 4272 */ 4273 function baseAt(object, paths) { 4274 var index = -1, 4275 length = paths.length, 4276 result = Array(length), 4277 skip = object == null; 4278 4279 while (++index < length) { 4280 result[index] = skip ? undefined : get(object, paths[index]); 4281 } 4282 return result; 4283 } 4284 4285 /** 4286 * The base implementation of `_.clamp` which doesn't coerce arguments. 4287 * 4288 * @private 4289 * @param {number} number The number to clamp. 4290 * @param {number} [lower] The lower bound. 4291 * @param {number} upper The upper bound. 4292 * @returns {number} Returns the clamped number. 4293 */ 4294 function baseClamp(number, lower, upper) { 4295 if (number === number) { 4296 if (upper !== undefined) { 4297 number = number <= upper ? number : upper; 4298 } 4299 if (lower !== undefined) { 4300 number = number >= lower ? number : lower; 4301 } 4302 } 4303 return number; 4304 } 4305 4306 /** 4307 * The base implementation of `_.clone` and `_.cloneDeep` which tracks 4308 * traversed objects. 4309 * 4310 * @private 4311 * @param {*} value The value to clone. 4312 * @param {boolean} bitmask The bitmask flags. 4313 * 1 - Deep clone 4314 * 2 - Flatten inherited properties 4315 * 4 - Clone symbols 4316 * @param {Function} [customizer] The function to customize cloning. 4317 * @param {string} [key] The key of `value`. 4318 * @param {Object} [object] The parent object of `value`. 4319 * @param {Object} [stack] Tracks traversed objects and their clone counterparts. 4320 * @returns {*} Returns the cloned value. 4321 */ 4322 function baseClone(value, bitmask, customizer, key, object, stack) { 4323 var result, 4324 isDeep = bitmask & CLONE_DEEP_FLAG, 4325 isFlat = bitmask & CLONE_FLAT_FLAG, 4326 isFull = bitmask & CLONE_SYMBOLS_FLAG; 4327 4328 if (customizer) { 4329 result = object ? customizer(value, key, object, stack) : customizer(value); 4330 } 4331 if (result !== undefined) { 4332 return result; 4333 } 4334 if (!isObject(value)) { 4335 return value; 4336 } 4337 var isArr = isArray(value); 4338 if (isArr) { 4339 result = initCloneArray(value); 4340 if (!isDeep) { 4341 return copyArray(value, result); 4342 } 4343 } else { 4344 var tag = getTag(value), 4345 isFunc = tag == funcTag || tag == genTag; 4346 4347 if (isBuffer(value)) { 4348 return cloneBuffer(value, isDeep); 4349 } 4350 if (tag == objectTag || tag == argsTag || (isFunc && !object)) { 4351 result = (isFlat || isFunc) ? {} : initCloneObject(value); 4352 if (!isDeep) { 4353 return isFlat 4354 ? copySymbolsIn(value, baseAssignIn(result, value)) 4355 : copySymbols(value, baseAssign(result, value)); 4356 } 4357 } else { 4358 if (!cloneableTags[tag]) { 4359 return object ? value : {}; 4360 } 4361 result = initCloneByTag(value, tag, isDeep); 4362 } 4363 } 4364 // Check for circular references and return its corresponding clone. 4365 stack || (stack = new Stack); 4366 var stacked = stack.get(value); 4367 if (stacked) { 4368 return stacked; 4369 } 4370 stack.set(value, result); 4371 4372 if (isSet(value)) { 4373 value.forEach(function(subValue) { 4374 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); 4375 }); 4376 4377 return result; 4378 } 4379 4380 if (isMap(value)) { 4381 value.forEach(function(subValue, key) { 4382 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); 4383 }); 4384 4385 return result; 4386 } 4387 4388 var keysFunc = isFull 4389 ? (isFlat ? getAllKeysIn : getAllKeys) 4390 : (isFlat ? keysIn : keys); 4391 4392 var props = isArr ? undefined : keysFunc(value); 4393 arrayEach(props || value, function(subValue, key) { 4394 if (props) { 4395 key = subValue; 4396 subValue = value[key]; 4397 } 4398 // Recursively populate clone (susceptible to call stack limits). 4399 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); 4400 }); 4401 return result; 4402 } 4403 4404 /** 4405 * The base implementation of `_.conforms` which doesn't clone `source`. 4406 * 4407 * @private 4408 * @param {Object} source The object of property predicates to conform to. 4409 * @returns {Function} Returns the new spec function. 4410 */ 4411 function baseConforms(source) { 4412 var props = keys(source); 4413 return function(object) { 4414 return baseConformsTo(object, source, props); 4415 }; 4416 } 4417 4418 /** 4419 * The base implementation of `_.conformsTo` which accepts `props` to check. 4420 * 4421 * @private 4422 * @param {Object} object The object to inspect. 4423 * @param {Object} source The object of property predicates to conform to. 4424 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 4425 */ 4426 function baseConformsTo(object, source, props) { 4427 var length = props.length; 4428 if (object == null) { 4429 return !length; 4430 } 4431 object = Object(object); 4432 while (length--) { 4433 var key = props[length], 4434 predicate = source[key], 4435 value = object[key]; 4436 4437 if ((value === undefined && !(key in object)) || !predicate(value)) { 4438 return false; 4439 } 4440 } 4441 return true; 4442 } 4443 4444 /** 4445 * The base implementation of `_.delay` and `_.defer` which accepts `args` 4446 * to provide to `func`. 4447 * 4448 * @private 4449 * @param {Function} func The function to delay. 4450 * @param {number} wait The number of milliseconds to delay invocation. 4451 * @param {Array} args The arguments to provide to `func`. 4452 * @returns {number|Object} Returns the timer id or timeout object. 4453 */ 4454 function baseDelay(func, wait, args) { 4455 if (typeof func != 'function') { 4456 throw new TypeError(FUNC_ERROR_TEXT); 4457 } 4458 return setTimeout(function() { func.apply(undefined, args); }, wait); 4459 } 4460 4461 /** 4462 * The base implementation of methods like `_.difference` without support 4463 * for excluding multiple arrays or iteratee shorthands. 4464 * 4465 * @private 4466 * @param {Array} array The array to inspect. 4467 * @param {Array} values The values to exclude. 4468 * @param {Function} [iteratee] The iteratee invoked per element. 4469 * @param {Function} [comparator] The comparator invoked per element. 4470 * @returns {Array} Returns the new array of filtered values. 4471 */ 4472 function baseDifference(array, values, iteratee, comparator) { 4473 var index = -1, 4474 includes = arrayIncludes, 4475 isCommon = true, 4476 length = array.length, 4477 result = [], 4478 valuesLength = values.length; 4479 4480 if (!length) { 4481 return result; 4482 } 4483 if (iteratee) { 4484 values = arrayMap(values, baseUnary(iteratee)); 4485 } 4486 if (comparator) { 4487 includes = arrayIncludesWith; 4488 isCommon = false; 4489 } 4490 else if (values.length >= LARGE_ARRAY_SIZE) { 4491 includes = cacheHas; 4492 isCommon = false; 4493 values = new SetCache(values); 4494 } 4495 outer: 4496 while (++index < length) { 4497 var value = array[index], 4498 computed = iteratee == null ? value : iteratee(value); 4499 4500 value = (comparator || value !== 0) ? value : 0; 4501 if (isCommon && computed === computed) { 4502 var valuesIndex = valuesLength; 4503 while (valuesIndex--) { 4504 if (values[valuesIndex] === computed) { 4505 continue outer; 4506 } 4507 } 4508 result.push(value); 4509 } 4510 else if (!includes(values, computed, comparator)) { 4511 result.push(value); 4512 } 4513 } 4514 return result; 4515 } 4516 4517 /** 4518 * The base implementation of `_.forEach` without support for iteratee shorthands. 4519 * 4520 * @private 4521 * @param {Array|Object} collection The collection to iterate over. 4522 * @param {Function} iteratee The function invoked per iteration. 4523 * @returns {Array|Object} Returns `collection`. 4524 */ 4525 var baseEach = createBaseEach(baseForOwn); 4526 4527 /** 4528 * The base implementation of `_.forEachRight` without support for iteratee shorthands. 4529 * 4530 * @private 4531 * @param {Array|Object} collection The collection to iterate over. 4532 * @param {Function} iteratee The function invoked per iteration. 4533 * @returns {Array|Object} Returns `collection`. 4534 */ 4535 var baseEachRight = createBaseEach(baseForOwnRight, true); 4536 4537 /** 4538 * The base implementation of `_.every` without support for iteratee shorthands. 4539 * 4540 * @private 4541 * @param {Array|Object} collection The collection to iterate over. 4542 * @param {Function} predicate The function invoked per iteration. 4543 * @returns {boolean} Returns `true` if all elements pass the predicate check, 4544 * else `false` 4545 */ 4546 function baseEvery(collection, predicate) { 4547 var result = true; 4548 baseEach(collection, function(value, index, collection) { 4549 result = !!predicate(value, index, collection); 4550 return result; 4551 }); 4552 return result; 4553 } 4554 4555 /** 4556 * The base implementation of methods like `_.max` and `_.min` which accepts a 4557 * `comparator` to determine the extremum value. 4558 * 4559 * @private 4560 * @param {Array} array The array to iterate over. 4561 * @param {Function} iteratee The iteratee invoked per iteration. 4562 * @param {Function} comparator The comparator used to compare values. 4563 * @returns {*} Returns the extremum value. 4564 */ 4565 function baseExtremum(array, iteratee, comparator) { 4566 var index = -1, 4567 length = array.length; 4568 4569 while (++index < length) { 4570 var value = array[index], 4571 current = iteratee(value); 4572 4573 if (current != null && (computed === undefined 4574 ? (current === current && !isSymbol(current)) 4575 : comparator(current, computed) 4576 )) { 4577 var computed = current, 4578 result = value; 4579 } 4580 } 4581 return result; 4582 } 4583 4584 /** 4585 * The base implementation of `_.fill` without an iteratee call guard. 4586 * 4587 * @private 4588 * @param {Array} array The array to fill. 4589 * @param {*} value The value to fill `array` with. 4590 * @param {number} [start=0] The start position. 4591 * @param {number} [end=array.length] The end position. 4592 * @returns {Array} Returns `array`. 4593 */ 4594 function baseFill(array, value, start, end) { 4595 var length = array.length; 4596 4597 start = toInteger(start); 4598 if (start < 0) { 4599 start = -start > length ? 0 : (length + start); 4600 } 4601 end = (end === undefined || end > length) ? length : toInteger(end); 4602 if (end < 0) { 4603 end += length; 4604 } 4605 end = start > end ? 0 : toLength(end); 4606 while (start < end) { 4607 array[start++] = value; 4608 } 4609 return array; 4610 } 4611 4612 /** 4613 * The base implementation of `_.filter` without support for iteratee shorthands. 4614 * 4615 * @private 4616 * @param {Array|Object} collection The collection to iterate over. 4617 * @param {Function} predicate The function invoked per iteration. 4618 * @returns {Array} Returns the new filtered array. 4619 */ 4620 function baseFilter(collection, predicate) { 4621 var result = []; 4622 baseEach(collection, function(value, index, collection) { 4623 if (predicate(value, index, collection)) { 4624 result.push(value); 4625 } 4626 }); 4627 return result; 4628 } 4629 4630 /** 4631 * The base implementation of `_.flatten` with support for restricting flattening. 4632 * 4633 * @private 4634 * @param {Array} array The array to flatten. 4635 * @param {number} depth The maximum recursion depth. 4636 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. 4637 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. 4638 * @param {Array} [result=[]] The initial result value. 4639 * @returns {Array} Returns the new flattened array. 4640 */ 4641 function baseFlatten(array, depth, predicate, isStrict, result) { 4642 var index = -1, 4643 length = array.length; 4644 4645 predicate || (predicate = isFlattenable); 4646 result || (result = []); 4647 4648 while (++index < length) { 4649 var value = array[index]; 4650 if (depth > 0 && predicate(value)) { 4651 if (depth > 1) { 4652 // Recursively flatten arrays (susceptible to call stack limits). 4653 baseFlatten(value, depth - 1, predicate, isStrict, result); 4654 } else { 4655 arrayPush(result, value); 4656 } 4657 } else if (!isStrict) { 4658 result[result.length] = value; 4659 } 4660 } 4661 return result; 4662 } 4663 4664 /** 4665 * The base implementation of `baseForOwn` which iterates over `object` 4666 * properties returned by `keysFunc` and invokes `iteratee` for each property. 4667 * Iteratee functions may exit iteration early by explicitly returning `false`. 4668 * 4669 * @private 4670 * @param {Object} object The object to iterate over. 4671 * @param {Function} iteratee The function invoked per iteration. 4672 * @param {Function} keysFunc The function to get the keys of `object`. 4673 * @returns {Object} Returns `object`. 4674 */ 4675 var baseFor = createBaseFor(); 4676 4677 /** 4678 * This function is like `baseFor` except that it iterates over properties 4679 * in the opposite order. 4680 * 4681 * @private 4682 * @param {Object} object The object to iterate over. 4683 * @param {Function} iteratee The function invoked per iteration. 4684 * @param {Function} keysFunc The function to get the keys of `object`. 4685 * @returns {Object} Returns `object`. 4686 */ 4687 var baseForRight = createBaseFor(true); 4688 4689 /** 4690 * The base implementation of `_.forOwn` without support for iteratee shorthands. 4691 * 4692 * @private 4693 * @param {Object} object The object to iterate over. 4694 * @param {Function} iteratee The function invoked per iteration. 4695 * @returns {Object} Returns `object`. 4696 */ 4697 function baseForOwn(object, iteratee) { 4698 return object && baseFor(object, iteratee, keys); 4699 } 4700 4701 /** 4702 * The base implementation of `_.forOwnRight` without support for iteratee shorthands. 4703 * 4704 * @private 4705 * @param {Object} object The object to iterate over. 4706 * @param {Function} iteratee The function invoked per iteration. 4707 * @returns {Object} Returns `object`. 4708 */ 4709 function baseForOwnRight(object, iteratee) { 4710 return object && baseForRight(object, iteratee, keys); 4711 } 4712 4713 /** 4714 * The base implementation of `_.functions` which creates an array of 4715 * `object` function property names filtered from `props`. 4716 * 4717 * @private 4718 * @param {Object} object The object to inspect. 4719 * @param {Array} props The property names to filter. 4720 * @returns {Array} Returns the function names. 4721 */ 4722 function baseFunctions(object, props) { 4723 return arrayFilter(props, function(key) { 4724 return isFunction(object[key]); 4725 }); 4726 } 4727 4728 /** 4729 * The base implementation of `_.get` without support for default values. 4730 * 4731 * @private 4732 * @param {Object} object The object to query. 4733 * @param {Array|string} path The path of the property to get. 4734 * @returns {*} Returns the resolved value. 4735 */ 4736 function baseGet(object, path) { 4737 path = castPath(path, object); 4738 4739 var index = 0, 4740 length = path.length; 4741 4742 while (object != null && index < length) { 4743 object = object[toKey(path[index++])]; 4744 } 4745 return (index && index == length) ? object : undefined; 4746 } 4747 4748 /** 4749 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses 4750 * `keysFunc` and `symbolsFunc` to get the enumerable property names and 4751 * symbols of `object`. 4752 * 4753 * @private 4754 * @param {Object} object The object to query. 4755 * @param {Function} keysFunc The function to get the keys of `object`. 4756 * @param {Function} symbolsFunc The function to get the symbols of `object`. 4757 * @returns {Array} Returns the array of property names and symbols. 4758 */ 4759 function baseGetAllKeys(object, keysFunc, symbolsFunc) { 4760 var result = keysFunc(object); 4761 return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); 4762 } 4763 4764 /** 4765 * The base implementation of `getTag` without fallbacks for buggy environments. 4766 * 4767 * @private 4768 * @param {*} value The value to query. 4769 * @returns {string} Returns the `toStringTag`. 4770 */ 4771 function baseGetTag(value) { 4772 if (value == null) { 4773 return value === undefined ? undefinedTag : nullTag; 4774 } 4775 return (symToStringTag && symToStringTag in Object(value)) 4776 ? getRawTag(value) 4777 : objectToString(value); 4778 } 4779 4780 /** 4781 * The base implementation of `_.gt` which doesn't coerce arguments. 4782 * 4783 * @private 4784 * @param {*} value The value to compare. 4785 * @param {*} other The other value to compare. 4786 * @returns {boolean} Returns `true` if `value` is greater than `other`, 4787 * else `false`. 4788 */ 4789 function baseGt(value, other) { 4790 return value > other; 4791 } 4792 4793 /** 4794 * The base implementation of `_.has` without support for deep paths. 4795 * 4796 * @private 4797 * @param {Object} [object] The object to query. 4798 * @param {Array|string} key The key to check. 4799 * @returns {boolean} Returns `true` if `key` exists, else `false`. 4800 */ 4801 function baseHas(object, key) { 4802 return object != null && hasOwnProperty.call(object, key); 4803 } 4804 4805 /** 4806 * The base implementation of `_.hasIn` without support for deep paths. 4807 * 4808 * @private 4809 * @param {Object} [object] The object to query. 4810 * @param {Array|string} key The key to check. 4811 * @returns {boolean} Returns `true` if `key` exists, else `false`. 4812 */ 4813 function baseHasIn(object, key) { 4814 return object != null && key in Object(object); 4815 } 4816 4817 /** 4818 * The base implementation of `_.inRange` which doesn't coerce arguments. 4819 * 4820 * @private 4821 * @param {number} number The number to check. 4822 * @param {number} start The start of the range. 4823 * @param {number} end The end of the range. 4824 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 4825 */ 4826 function baseInRange(number, start, end) { 4827 return number >= nativeMin(start, end) && number < nativeMax(start, end); 4828 } 4829 4830 /** 4831 * The base implementation of methods like `_.intersection`, without support 4832 * for iteratee shorthands, that accepts an array of arrays to inspect. 4833 * 4834 * @private 4835 * @param {Array} arrays The arrays to inspect. 4836 * @param {Function} [iteratee] The iteratee invoked per element. 4837 * @param {Function} [comparator] The comparator invoked per element. 4838 * @returns {Array} Returns the new array of shared values. 4839 */ 4840 function baseIntersection(arrays, iteratee, comparator) { 4841 var includes = comparator ? arrayIncludesWith : arrayIncludes, 4842 length = arrays[0].length, 4843 othLength = arrays.length, 4844 othIndex = othLength, 4845 caches = Array(othLength), 4846 maxLength = Infinity, 4847 result = []; 4848 4849 while (othIndex--) { 4850 var array = arrays[othIndex]; 4851 if (othIndex && iteratee) { 4852 array = arrayMap(array, baseUnary(iteratee)); 4853 } 4854 maxLength = nativeMin(array.length, maxLength); 4855 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) 4856 ? new SetCache(othIndex && array) 4857 : undefined; 4858 } 4859 array = arrays[0]; 4860 4861 var index = -1, 4862 seen = caches[0]; 4863 4864 outer: 4865 while (++index < length && result.length < maxLength) { 4866 var value = array[index], 4867 computed = iteratee ? iteratee(value) : value; 4868 4869 value = (comparator || value !== 0) ? value : 0; 4870 if (!(seen 4871 ? cacheHas(seen, computed) 4872 : includes(result, computed, comparator) 4873 )) { 4874 othIndex = othLength; 4875 while (--othIndex) { 4876 var cache = caches[othIndex]; 4877 if (!(cache 4878 ? cacheHas(cache, computed) 4879 : includes(arrays[othIndex], computed, comparator)) 4880 ) { 4881 continue outer; 4882 } 4883 } 4884 if (seen) { 4885 seen.push(computed); 4886 } 4887 result.push(value); 4888 } 4889 } 4890 return result; 4891 } 4892 4893 /** 4894 * The base implementation of `_.invert` and `_.invertBy` which inverts 4895 * `object` with values transformed by `iteratee` and set by `setter`. 4896 * 4897 * @private 4898 * @param {Object} object The object to iterate over. 4899 * @param {Function} setter The function to set `accumulator` values. 4900 * @param {Function} iteratee The iteratee to transform values. 4901 * @param {Object} accumulator The initial inverted object. 4902 * @returns {Function} Returns `accumulator`. 4903 */ 4904 function baseInverter(object, setter, iteratee, accumulator) { 4905 baseForOwn(object, function(value, key, object) { 4906 setter(accumulator, iteratee(value), key, object); 4907 }); 4908 return accumulator; 4909 } 4910 4911 /** 4912 * The base implementation of `_.invoke` without support for individual 4913 * method arguments. 4914 * 4915 * @private 4916 * @param {Object} object The object to query. 4917 * @param {Array|string} path The path of the method to invoke. 4918 * @param {Array} args The arguments to invoke the method with. 4919 * @returns {*} Returns the result of the invoked method. 4920 */ 4921 function baseInvoke(object, path, args) { 4922 path = castPath(path, object); 4923 object = parent(object, path); 4924 var func = object == null ? object : object[toKey(last(path))]; 4925 return func == null ? undefined : apply(func, object, args); 4926 } 4927 4928 /** 4929 * The base implementation of `_.isArguments`. 4930 * 4931 * @private 4932 * @param {*} value The value to check. 4933 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 4934 */ 4935 function baseIsArguments(value) { 4936 return isObjectLike(value) && baseGetTag(value) == argsTag; 4937 } 4938 4939 /** 4940 * The base implementation of `_.isArrayBuffer` without Node.js optimizations. 4941 * 4942 * @private 4943 * @param {*} value The value to check. 4944 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 4945 */ 4946 function baseIsArrayBuffer(value) { 4947 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; 4948 } 4949 4950 /** 4951 * The base implementation of `_.isDate` without Node.js optimizations. 4952 * 4953 * @private 4954 * @param {*} value The value to check. 4955 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 4956 */ 4957 function baseIsDate(value) { 4958 return isObjectLike(value) && baseGetTag(value) == dateTag; 4959 } 4960 4961 /** 4962 * The base implementation of `_.isEqual` which supports partial comparisons 4963 * and tracks traversed objects. 4964 * 4965 * @private 4966 * @param {*} value The value to compare. 4967 * @param {*} other The other value to compare. 4968 * @param {boolean} bitmask The bitmask flags. 4969 * 1 - Unordered comparison 4970 * 2 - Partial comparison 4971 * @param {Function} [customizer] The function to customize comparisons. 4972 * @param {Object} [stack] Tracks traversed `value` and `other` objects. 4973 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 4974 */ 4975 function baseIsEqual(value, other, bitmask, customizer, stack) { 4976 if (value === other) { 4977 return true; 4978 } 4979 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { 4980 return value !== value && other !== other; 4981 } 4982 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); 4983 } 4984 4985 /** 4986 * A specialized version of `baseIsEqual` for arrays and objects which performs 4987 * deep comparisons and tracks traversed objects enabling objects with circular 4988 * references to be compared. 4989 * 4990 * @private 4991 * @param {Object} object The object to compare. 4992 * @param {Object} other The other object to compare. 4993 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 4994 * @param {Function} customizer The function to customize comparisons. 4995 * @param {Function} equalFunc The function to determine equivalents of values. 4996 * @param {Object} [stack] Tracks traversed `object` and `other` objects. 4997 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 4998 */ 4999 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { 5000 var objIsArr = isArray(object), 5001 othIsArr = isArray(other), 5002 objTag = objIsArr ? arrayTag : getTag(object), 5003 othTag = othIsArr ? arrayTag : getTag(other); 5004 5005 objTag = objTag == argsTag ? objectTag : objTag; 5006 othTag = othTag == argsTag ? objectTag : othTag; 5007 5008 var objIsObj = objTag == objectTag, 5009 othIsObj = othTag == objectTag, 5010 isSameTag = objTag == othTag; 5011 5012 if (isSameTag && isBuffer(object)) { 5013 if (!isBuffer(other)) { 5014 return false; 5015 } 5016 objIsArr = true; 5017 objIsObj = false; 5018 } 5019 if (isSameTag && !objIsObj) { 5020 stack || (stack = new Stack); 5021 return (objIsArr || isTypedArray(object)) 5022 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) 5023 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); 5024 } 5025 if (!(bitmask & COMPARE_PARTIAL_FLAG)) { 5026 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), 5027 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); 5028 5029 if (objIsWrapped || othIsWrapped) { 5030 var objUnwrapped = objIsWrapped ? object.value() : object, 5031 othUnwrapped = othIsWrapped ? other.value() : other; 5032 5033 stack || (stack = new Stack); 5034 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); 5035 } 5036 } 5037 if (!isSameTag) { 5038 return false; 5039 } 5040 stack || (stack = new Stack); 5041 return equalObjects(object, other, bitmask, customizer, equalFunc, stack); 5042 } 5043 5044 /** 5045 * The base implementation of `_.isMap` without Node.js optimizations. 5046 * 5047 * @private 5048 * @param {*} value The value to check. 5049 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 5050 */ 5051 function baseIsMap(value) { 5052 return isObjectLike(value) && getTag(value) == mapTag; 5053 } 5054 5055 /** 5056 * The base implementation of `_.isMatch` without support for iteratee shorthands. 5057 * 5058 * @private 5059 * @param {Object} object The object to inspect. 5060 * @param {Object} source The object of property values to match. 5061 * @param {Array} matchData The property names, values, and compare flags to match. 5062 * @param {Function} [customizer] The function to customize comparisons. 5063 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 5064 */ 5065 function baseIsMatch(object, source, matchData, customizer) { 5066 var index = matchData.length, 5067 length = index, 5068 noCustomizer = !customizer; 5069 5070 if (object == null) { 5071 return !length; 5072 } 5073 object = Object(object); 5074 while (index--) { 5075 var data = matchData[index]; 5076 if ((noCustomizer && data[2]) 5077 ? data[1] !== object[data[0]] 5078 : !(data[0] in object) 5079 ) { 5080 return false; 5081 } 5082 } 5083 while (++index < length) { 5084 data = matchData[index]; 5085 var key = data[0], 5086 objValue = object[key], 5087 srcValue = data[1]; 5088 5089 if (noCustomizer && data[2]) { 5090 if (objValue === undefined && !(key in object)) { 5091 return false; 5092 } 5093 } else { 5094 var stack = new Stack; 5095 if (customizer) { 5096 var result = customizer(objValue, srcValue, key, object, source, stack); 5097 } 5098 if (!(result === undefined 5099 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) 5100 : result 5101 )) { 5102 return false; 5103 } 5104 } 5105 } 5106 return true; 5107 } 5108 5109 /** 5110 * The base implementation of `_.isNative` without bad shim checks. 5111 * 5112 * @private 5113 * @param {*} value The value to check. 5114 * @returns {boolean} Returns `true` if `value` is a native function, 5115 * else `false`. 5116 */ 5117 function baseIsNative(value) { 5118 if (!isObject(value) || isMasked(value)) { 5119 return false; 5120 } 5121 var pattern = isFunction(value) ? reIsNative : reIsHostCtor; 5122 return pattern.test(toSource(value)); 5123 } 5124 5125 /** 5126 * The base implementation of `_.isRegExp` without Node.js optimizations. 5127 * 5128 * @private 5129 * @param {*} value The value to check. 5130 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 5131 */ 5132 function baseIsRegExp(value) { 5133 return isObjectLike(value) && baseGetTag(value) == regexpTag; 5134 } 5135 5136 /** 5137 * The base implementation of `_.isSet` without Node.js optimizations. 5138 * 5139 * @private 5140 * @param {*} value The value to check. 5141 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 5142 */ 5143 function baseIsSet(value) { 5144 return isObjectLike(value) && getTag(value) == setTag; 5145 } 5146 5147 /** 5148 * The base implementation of `_.isTypedArray` without Node.js optimizations. 5149 * 5150 * @private 5151 * @param {*} value The value to check. 5152 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 5153 */ 5154 function baseIsTypedArray(value) { 5155 return isObjectLike(value) && 5156 isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; 5157 } 5158 5159 /** 5160 * The base implementation of `_.iteratee`. 5161 * 5162 * @private 5163 * @param {*} [value=_.identity] The value to convert to an iteratee. 5164 * @returns {Function} Returns the iteratee. 5165 */ 5166 function baseIteratee(value) { 5167 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. 5168 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. 5169 if (typeof value == 'function') { 5170 return value; 5171 } 5172 if (value == null) { 5173 return identity; 5174 } 5175 if (typeof value == 'object') { 5176 return isArray(value) 5177 ? baseMatchesProperty(value[0], value[1]) 5178 : baseMatches(value); 5179 } 5180 return property(value); 5181 } 5182 5183 /** 5184 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. 5185 * 5186 * @private 5187 * @param {Object} object The object to query. 5188 * @returns {Array} Returns the array of property names. 5189 */ 5190 function baseKeys(object) { 5191 if (!isPrototype(object)) { 5192 return nativeKeys(object); 5193 } 5194 var result = []; 5195 for (var key in Object(object)) { 5196 if (hasOwnProperty.call(object, key) && key != 'constructor') { 5197 result.push(key); 5198 } 5199 } 5200 return result; 5201 } 5202 5203 /** 5204 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. 5205 * 5206 * @private 5207 * @param {Object} object The object to query. 5208 * @returns {Array} Returns the array of property names. 5209 */ 5210 function baseKeysIn(object) { 5211 if (!isObject(object)) { 5212 return nativeKeysIn(object); 5213 } 5214 var isProto = isPrototype(object), 5215 result = []; 5216 5217 for (var key in object) { 5218 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { 5219 result.push(key); 5220 } 5221 } 5222 return result; 5223 } 5224 5225 /** 5226 * The base implementation of `_.lt` which doesn't coerce arguments. 5227 * 5228 * @private 5229 * @param {*} value The value to compare. 5230 * @param {*} other The other value to compare. 5231 * @returns {boolean} Returns `true` if `value` is less than `other`, 5232 * else `false`. 5233 */ 5234 function baseLt(value, other) { 5235 return value < other; 5236 } 5237 5238 /** 5239 * The base implementation of `_.map` without support for iteratee shorthands. 5240 * 5241 * @private 5242 * @param {Array|Object} collection The collection to iterate over. 5243 * @param {Function} iteratee The function invoked per iteration. 5244 * @returns {Array} Returns the new mapped array. 5245 */ 5246 function baseMap(collection, iteratee) { 5247 var index = -1, 5248 result = isArrayLike(collection) ? Array(collection.length) : []; 5249 5250 baseEach(collection, function(value, key, collection) { 5251 result[++index] = iteratee(value, key, collection); 5252 }); 5253 return result; 5254 } 5255 5256 /** 5257 * The base implementation of `_.matches` which doesn't clone `source`. 5258 * 5259 * @private 5260 * @param {Object} source The object of property values to match. 5261 * @returns {Function} Returns the new spec function. 5262 */ 5263 function baseMatches(source) { 5264 var matchData = getMatchData(source); 5265 if (matchData.length == 1 && matchData[0][2]) { 5266 return matchesStrictComparable(matchData[0][0], matchData[0][1]); 5267 } 5268 return function(object) { 5269 return object === source || baseIsMatch(object, source, matchData); 5270 }; 5271 } 5272 5273 /** 5274 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. 5275 * 5276 * @private 5277 * @param {string} path The path of the property to get. 5278 * @param {*} srcValue The value to match. 5279 * @returns {Function} Returns the new spec function. 5280 */ 5281 function baseMatchesProperty(path, srcValue) { 5282 if (isKey(path) && isStrictComparable(srcValue)) { 5283 return matchesStrictComparable(toKey(path), srcValue); 5284 } 5285 return function(object) { 5286 var objValue = get(object, path); 5287 return (objValue === undefined && objValue === srcValue) 5288 ? hasIn(object, path) 5289 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); 5290 }; 5291 } 5292 5293 /** 5294 * The base implementation of `_.merge` without support for multiple sources. 5295 * 5296 * @private 5297 * @param {Object} object The destination object. 5298 * @param {Object} source The source object. 5299 * @param {number} srcIndex The index of `source`. 5300 * @param {Function} [customizer] The function to customize merged values. 5301 * @param {Object} [stack] Tracks traversed source values and their merged 5302 * counterparts. 5303 */ 5304 function baseMerge(object, source, srcIndex, customizer, stack) { 5305 if (object === source) { 5306 return; 5307 } 5308 baseFor(source, function(srcValue, key) { 5309 if (isObject(srcValue)) { 5310 stack || (stack = new Stack); 5311 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); 5312 } 5313 else { 5314 var newValue = customizer 5315 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) 5316 : undefined; 5317 5318 if (newValue === undefined) { 5319 newValue = srcValue; 5320 } 5321 assignMergeValue(object, key, newValue); 5322 } 5323 }, keysIn); 5324 } 5325 5326 /** 5327 * A specialized version of `baseMerge` for arrays and objects which performs 5328 * deep merges and tracks traversed objects enabling objects with circular 5329 * references to be merged. 5330 * 5331 * @private 5332 * @param {Object} object The destination object. 5333 * @param {Object} source The source object. 5334 * @param {string} key The key of the value to merge. 5335 * @param {number} srcIndex The index of `source`. 5336 * @param {Function} mergeFunc The function to merge values. 5337 * @param {Function} [customizer] The function to customize assigned values. 5338 * @param {Object} [stack] Tracks traversed source values and their merged 5339 * counterparts. 5340 */ 5341 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { 5342 var objValue = safeGet(object, key), 5343 srcValue = safeGet(source, key), 5344 stacked = stack.get(srcValue); 5345 5346 if (stacked) { 5347 assignMergeValue(object, key, stacked); 5348 return; 5349 } 5350 var newValue = customizer 5351 ? customizer(objValue, srcValue, (key + ''), object, source, stack) 5352 : undefined; 5353 5354 var isCommon = newValue === undefined; 5355 5356 if (isCommon) { 5357 var isArr = isArray(srcValue), 5358 isBuff = !isArr && isBuffer(srcValue), 5359 isTyped = !isArr && !isBuff && isTypedArray(srcValue); 5360 5361 newValue = srcValue; 5362 if (isArr || isBuff || isTyped) { 5363 if (isArray(objValue)) { 5364 newValue = objValue; 5365 } 5366 else if (isArrayLikeObject(objValue)) { 5367 newValue = copyArray(objValue); 5368 } 5369 else if (isBuff) { 5370 isCommon = false; 5371 newValue = cloneBuffer(srcValue, true); 5372 } 5373 else if (isTyped) { 5374 isCommon = false; 5375 newValue = cloneTypedArray(srcValue, true); 5376 } 5377 else { 5378 newValue = []; 5379 } 5380 } 5381 else if (isPlainObject(srcValue) || isArguments(srcValue)) { 5382 newValue = objValue; 5383 if (isArguments(objValue)) { 5384 newValue = toPlainObject(objValue); 5385 } 5386 else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { 5387 newValue = initCloneObject(srcValue); 5388 } 5389 } 5390 else { 5391 isCommon = false; 5392 } 5393 } 5394 if (isCommon) { 5395 // Recursively merge objects and arrays (susceptible to call stack limits). 5396 stack.set(srcValue, newValue); 5397 mergeFunc(newValue, srcValue, srcIndex, customizer, stack); 5398 stack['delete'](srcValue); 5399 } 5400 assignMergeValue(object, key, newValue); 5401 } 5402 5403 /** 5404 * The base implementation of `_.nth` which doesn't coerce arguments. 5405 * 5406 * @private 5407 * @param {Array} array The array to query. 5408 * @param {number} n The index of the element to return. 5409 * @returns {*} Returns the nth element of `array`. 5410 */ 5411 function baseNth(array, n) { 5412 var length = array.length; 5413 if (!length) { 5414 return; 5415 } 5416 n += n < 0 ? length : 0; 5417 return isIndex(n, length) ? array[n] : undefined; 5418 } 5419 5420 /** 5421 * The base implementation of `_.orderBy` without param guards. 5422 * 5423 * @private 5424 * @param {Array|Object} collection The collection to iterate over. 5425 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. 5426 * @param {string[]} orders The sort orders of `iteratees`. 5427 * @returns {Array} Returns the new sorted array. 5428 */ 5429 function baseOrderBy(collection, iteratees, orders) { 5430 var index = -1; 5431 iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(getIteratee())); 5432 5433 var result = baseMap(collection, function(value, key, collection) { 5434 var criteria = arrayMap(iteratees, function(iteratee) { 5435 return iteratee(value); 5436 }); 5437 return { 'criteria': criteria, 'index': ++index, 'value': value }; 5438 }); 5439 5440 return baseSortBy(result, function(object, other) { 5441 return compareMultiple(object, other, orders); 5442 }); 5443 } 5444 5445 /** 5446 * The base implementation of `_.pick` without support for individual 5447 * property identifiers. 5448 * 5449 * @private 5450 * @param {Object} object The source object. 5451 * @param {string[]} paths The property paths to pick. 5452 * @returns {Object} Returns the new object. 5453 */ 5454 function basePick(object, paths) { 5455 return basePickBy(object, paths, function(value, path) { 5456 return hasIn(object, path); 5457 }); 5458 } 5459 5460 /** 5461 * The base implementation of `_.pickBy` without support for iteratee shorthands. 5462 * 5463 * @private 5464 * @param {Object} object The source object. 5465 * @param {string[]} paths The property paths to pick. 5466 * @param {Function} predicate The function invoked per property. 5467 * @returns {Object} Returns the new object. 5468 */ 5469 function basePickBy(object, paths, predicate) { 5470 var index = -1, 5471 length = paths.length, 5472 result = {}; 5473 5474 while (++index < length) { 5475 var path = paths[index], 5476 value = baseGet(object, path); 5477 5478 if (predicate(value, path)) { 5479 baseSet(result, castPath(path, object), value); 5480 } 5481 } 5482 return result; 5483 } 5484 5485 /** 5486 * A specialized version of `baseProperty` which supports deep paths. 5487 * 5488 * @private 5489 * @param {Array|string} path The path of the property to get. 5490 * @returns {Function} Returns the new accessor function. 5491 */ 5492 function basePropertyDeep(path) { 5493 return function(object) { 5494 return baseGet(object, path); 5495 }; 5496 } 5497 5498 /** 5499 * The base implementation of `_.pullAllBy` without support for iteratee 5500 * shorthands. 5501 * 5502 * @private 5503 * @param {Array} array The array to modify. 5504 * @param {Array} values The values to remove. 5505 * @param {Function} [iteratee] The iteratee invoked per element. 5506 * @param {Function} [comparator] The comparator invoked per element. 5507 * @returns {Array} Returns `array`. 5508 */ 5509 function basePullAll(array, values, iteratee, comparator) { 5510 var indexOf = comparator ? baseIndexOfWith : baseIndexOf, 5511 index = -1, 5512 length = values.length, 5513 seen = array; 5514 5515 if (array === values) { 5516 values = copyArray(values); 5517 } 5518 if (iteratee) { 5519 seen = arrayMap(array, baseUnary(iteratee)); 5520 } 5521 while (++index < length) { 5522 var fromIndex = 0, 5523 value = values[index], 5524 computed = iteratee ? iteratee(value) : value; 5525 5526 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { 5527 if (seen !== array) { 5528 splice.call(seen, fromIndex, 1); 5529 } 5530 splice.call(array, fromIndex, 1); 5531 } 5532 } 5533 return array; 5534 } 5535 5536 /** 5537 * The base implementation of `_.pullAt` without support for individual 5538 * indexes or capturing the removed elements. 5539 * 5540 * @private 5541 * @param {Array} array The array to modify. 5542 * @param {number[]} indexes The indexes of elements to remove. 5543 * @returns {Array} Returns `array`. 5544 */ 5545 function basePullAt(array, indexes) { 5546 var length = array ? indexes.length : 0, 5547 lastIndex = length - 1; 5548 5549 while (length--) { 5550 var index = indexes[length]; 5551 if (length == lastIndex || index !== previous) { 5552 var previous = index; 5553 if (isIndex(index)) { 5554 splice.call(array, index, 1); 5555 } else { 5556 baseUnset(array, index); 5557 } 5558 } 5559 } 5560 return array; 5561 } 5562 5563 /** 5564 * The base implementation of `_.random` without support for returning 5565 * floating-point numbers. 5566 * 5567 * @private 5568 * @param {number} lower The lower bound. 5569 * @param {number} upper The upper bound. 5570 * @returns {number} Returns the random number. 5571 */ 5572 function baseRandom(lower, upper) { 5573 return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); 5574 } 5575 5576 /** 5577 * The base implementation of `_.range` and `_.rangeRight` which doesn't 5578 * coerce arguments. 5579 * 5580 * @private 5581 * @param {number} start The start of the range. 5582 * @param {number} end The end of the range. 5583 * @param {number} step The value to increment or decrement by. 5584 * @param {boolean} [fromRight] Specify iterating from right to left. 5585 * @returns {Array} Returns the range of numbers. 5586 */ 5587 function baseRange(start, end, step, fromRight) { 5588 var index = -1, 5589 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), 5590 result = Array(length); 5591 5592 while (length--) { 5593 result[fromRight ? length : ++index] = start; 5594 start += step; 5595 } 5596 return result; 5597 } 5598 5599 /** 5600 * The base implementation of `_.repeat` which doesn't coerce arguments. 5601 * 5602 * @private 5603 * @param {string} string The string to repeat. 5604 * @param {number} n The number of times to repeat the string. 5605 * @returns {string} Returns the repeated string. 5606 */ 5607 function baseRepeat(string, n) { 5608 var result = ''; 5609 if (!string || n < 1 || n > MAX_SAFE_INTEGER) { 5610 return result; 5611 } 5612 // Leverage the exponentiation by squaring algorithm for a faster repeat. 5613 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. 5614 do { 5615 if (n % 2) { 5616 result += string; 5617 } 5618 n = nativeFloor(n / 2); 5619 if (n) { 5620 string += string; 5621 } 5622 } while (n); 5623 5624 return result; 5625 } 5626 5627 /** 5628 * The base implementation of `_.rest` which doesn't validate or coerce arguments. 5629 * 5630 * @private 5631 * @param {Function} func The function to apply a rest parameter to. 5632 * @param {number} [start=func.length-1] The start position of the rest parameter. 5633 * @returns {Function} Returns the new function. 5634 */ 5635 function baseRest(func, start) { 5636 return setToString(overRest(func, start, identity), func + ''); 5637 } 5638 5639 /** 5640 * The base implementation of `_.sample`. 5641 * 5642 * @private 5643 * @param {Array|Object} collection The collection to sample. 5644 * @returns {*} Returns the random element. 5645 */ 5646 function baseSample(collection) { 5647 return arraySample(values(collection)); 5648 } 5649 5650 /** 5651 * The base implementation of `_.sampleSize` without param guards. 5652 * 5653 * @private 5654 * @param {Array|Object} collection The collection to sample. 5655 * @param {number} n The number of elements to sample. 5656 * @returns {Array} Returns the random elements. 5657 */ 5658 function baseSampleSize(collection, n) { 5659 var array = values(collection); 5660 return shuffleSelf(array, baseClamp(n, 0, array.length)); 5661 } 5662 5663 /** 5664 * The base implementation of `_.set`. 5665 * 5666 * @private 5667 * @param {Object} object The object to modify. 5668 * @param {Array|string} path The path of the property to set. 5669 * @param {*} value The value to set. 5670 * @param {Function} [customizer] The function to customize path creation. 5671 * @returns {Object} Returns `object`. 5672 */ 5673 function baseSet(object, path, value, customizer) { 5674 if (!isObject(object)) { 5675 return object; 5676 } 5677 path = castPath(path, object); 5678 5679 var index = -1, 5680 length = path.length, 5681 lastIndex = length - 1, 5682 nested = object; 5683 5684 while (nested != null && ++index < length) { 5685 var key = toKey(path[index]), 5686 newValue = value; 5687 5688 if (index != lastIndex) { 5689 var objValue = nested[key]; 5690 newValue = customizer ? customizer(objValue, key, nested) : undefined; 5691 if (newValue === undefined) { 5692 newValue = isObject(objValue) 5693 ? objValue 5694 : (isIndex(path[index + 1]) ? [] : {}); 5695 } 5696 } 5697 assignValue(nested, key, newValue); 5698 nested = nested[key]; 5699 } 5700 return object; 5701 } 5702 5703 /** 5704 * The base implementation of `setData` without support for hot loop shorting. 5705 * 5706 * @private 5707 * @param {Function} func The function to associate metadata with. 5708 * @param {*} data The metadata. 5709 * @returns {Function} Returns `func`. 5710 */ 5711 var baseSetData = !metaMap ? identity : function(func, data) { 5712 metaMap.set(func, data); 5713 return func; 5714 }; 5715 5716 /** 5717 * The base implementation of `setToString` without support for hot loop shorting. 5718 * 5719 * @private 5720 * @param {Function} func The function to modify. 5721 * @param {Function} string The `toString` result. 5722 * @returns {Function} Returns `func`. 5723 */ 5724 var baseSetToString = !defineProperty ? identity : function(func, string) { 5725 return defineProperty(func, 'toString', { 5726 'configurable': true, 5727 'enumerable': false, 5728 'value': constant(string), 5729 'writable': true 5730 }); 5731 }; 5732 5733 /** 5734 * The base implementation of `_.shuffle`. 5735 * 5736 * @private 5737 * @param {Array|Object} collection The collection to shuffle. 5738 * @returns {Array} Returns the new shuffled array. 5739 */ 5740 function baseShuffle(collection) { 5741 return shuffleSelf(values(collection)); 5742 } 5743 5744 /** 5745 * The base implementation of `_.slice` without an iteratee call guard. 5746 * 5747 * @private 5748 * @param {Array} array The array to slice. 5749 * @param {number} [start=0] The start position. 5750 * @param {number} [end=array.length] The end position. 5751 * @returns {Array} Returns the slice of `array`. 5752 */ 5753 function baseSlice(array, start, end) { 5754 var index = -1, 5755 length = array.length; 5756 5757 if (start < 0) { 5758 start = -start > length ? 0 : (length + start); 5759 } 5760 end = end > length ? length : end; 5761 if (end < 0) { 5762 end += length; 5763 } 5764 length = start > end ? 0 : ((end - start) >>> 0); 5765 start >>>= 0; 5766 5767 var result = Array(length); 5768 while (++index < length) { 5769 result[index] = array[index + start]; 5770 } 5771 return result; 5772 } 5773 5774 /** 5775 * The base implementation of `_.some` without support for iteratee shorthands. 5776 * 5777 * @private 5778 * @param {Array|Object} collection The collection to iterate over. 5779 * @param {Function} predicate The function invoked per iteration. 5780 * @returns {boolean} Returns `true` if any element passes the predicate check, 5781 * else `false`. 5782 */ 5783 function baseSome(collection, predicate) { 5784 var result; 5785 5786 baseEach(collection, function(value, index, collection) { 5787 result = predicate(value, index, collection); 5788 return !result; 5789 }); 5790 return !!result; 5791 } 5792 5793 /** 5794 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which 5795 * performs a binary search of `array` to determine the index at which `value` 5796 * should be inserted into `array` in order to maintain its sort order. 5797 * 5798 * @private 5799 * @param {Array} array The sorted array to inspect. 5800 * @param {*} value The value to evaluate. 5801 * @param {boolean} [retHighest] Specify returning the highest qualified index. 5802 * @returns {number} Returns the index at which `value` should be inserted 5803 * into `array`. 5804 */ 5805 function baseSortedIndex(array, value, retHighest) { 5806 var low = 0, 5807 high = array == null ? low : array.length; 5808 5809 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { 5810 while (low < high) { 5811 var mid = (low + high) >>> 1, 5812 computed = array[mid]; 5813 5814 if (computed !== null && !isSymbol(computed) && 5815 (retHighest ? (computed <= value) : (computed < value))) { 5816 low = mid + 1; 5817 } else { 5818 high = mid; 5819 } 5820 } 5821 return high; 5822 } 5823 return baseSortedIndexBy(array, value, identity, retHighest); 5824 } 5825 5826 /** 5827 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` 5828 * which invokes `iteratee` for `value` and each element of `array` to compute 5829 * their sort ranking. The iteratee is invoked with one argument; (value). 5830 * 5831 * @private 5832 * @param {Array} array The sorted array to inspect. 5833 * @param {*} value The value to evaluate. 5834 * @param {Function} iteratee The iteratee invoked per element. 5835 * @param {boolean} [retHighest] Specify returning the highest qualified index. 5836 * @returns {number} Returns the index at which `value` should be inserted 5837 * into `array`. 5838 */ 5839 function baseSortedIndexBy(array, value, iteratee, retHighest) { 5840 value = iteratee(value); 5841 5842 var low = 0, 5843 high = array == null ? 0 : array.length, 5844 valIsNaN = value !== value, 5845 valIsNull = value === null, 5846 valIsSymbol = isSymbol(value), 5847 valIsUndefined = value === undefined; 5848 5849 while (low < high) { 5850 var mid = nativeFloor((low + high) / 2), 5851 computed = iteratee(array[mid]), 5852 othIsDefined = computed !== undefined, 5853 othIsNull = computed === null, 5854 othIsReflexive = computed === computed, 5855 othIsSymbol = isSymbol(computed); 5856 5857 if (valIsNaN) { 5858 var setLow = retHighest || othIsReflexive; 5859 } else if (valIsUndefined) { 5860 setLow = othIsReflexive && (retHighest || othIsDefined); 5861 } else if (valIsNull) { 5862 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); 5863 } else if (valIsSymbol) { 5864 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); 5865 } else if (othIsNull || othIsSymbol) { 5866 setLow = false; 5867 } else { 5868 setLow = retHighest ? (computed <= value) : (computed < value); 5869 } 5870 if (setLow) { 5871 low = mid + 1; 5872 } else { 5873 high = mid; 5874 } 5875 } 5876 return nativeMin(high, MAX_ARRAY_INDEX); 5877 } 5878 5879 /** 5880 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without 5881 * support for iteratee shorthands. 5882 * 5883 * @private 5884 * @param {Array} array The array to inspect. 5885 * @param {Function} [iteratee] The iteratee invoked per element. 5886 * @returns {Array} Returns the new duplicate free array. 5887 */ 5888 function baseSortedUniq(array, iteratee) { 5889 var index = -1, 5890 length = array.length, 5891 resIndex = 0, 5892 result = []; 5893 5894 while (++index < length) { 5895 var value = array[index], 5896 computed = iteratee ? iteratee(value) : value; 5897 5898 if (!index || !eq(computed, seen)) { 5899 var seen = computed; 5900 result[resIndex++] = value === 0 ? 0 : value; 5901 } 5902 } 5903 return result; 5904 } 5905 5906 /** 5907 * The base implementation of `_.toNumber` which doesn't ensure correct 5908 * conversions of binary, hexadecimal, or octal string values. 5909 * 5910 * @private 5911 * @param {*} value The value to process. 5912 * @returns {number} Returns the number. 5913 */ 5914 function baseToNumber(value) { 5915 if (typeof value == 'number') { 5916 return value; 5917 } 5918 if (isSymbol(value)) { 5919 return NAN; 5920 } 5921 return +value; 5922 } 5923 5924 /** 5925 * The base implementation of `_.toString` which doesn't convert nullish 5926 * values to empty strings. 5927 * 5928 * @private 5929 * @param {*} value The value to process. 5930 * @returns {string} Returns the string. 5931 */ 5932 function baseToString(value) { 5933 // Exit early for strings to avoid a performance hit in some environments. 5934 if (typeof value == 'string') { 5935 return value; 5936 } 5937 if (isArray(value)) { 5938 // Recursively convert values (susceptible to call stack limits). 5939 return arrayMap(value, baseToString) + ''; 5940 } 5941 if (isSymbol(value)) { 5942 return symbolToString ? symbolToString.call(value) : ''; 5943 } 5944 var result = (value + ''); 5945 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 5946 } 5947 5948 /** 5949 * The base implementation of `_.uniqBy` without support for iteratee shorthands. 5950 * 5951 * @private 5952 * @param {Array} array The array to inspect. 5953 * @param {Function} [iteratee] The iteratee invoked per element. 5954 * @param {Function} [comparator] The comparator invoked per element. 5955 * @returns {Array} Returns the new duplicate free array. 5956 */ 5957 function baseUniq(array, iteratee, comparator) { 5958 var index = -1, 5959 includes = arrayIncludes, 5960 length = array.length, 5961 isCommon = true, 5962 result = [], 5963 seen = result; 5964 5965 if (comparator) { 5966 isCommon = false; 5967 includes = arrayIncludesWith; 5968 } 5969 else if (length >= LARGE_ARRAY_SIZE) { 5970 var set = iteratee ? null : createSet(array); 5971 if (set) { 5972 return setToArray(set); 5973 } 5974 isCommon = false; 5975 includes = cacheHas; 5976 seen = new SetCache; 5977 } 5978 else { 5979 seen = iteratee ? [] : result; 5980 } 5981 outer: 5982 while (++index < length) { 5983 var value = array[index], 5984 computed = iteratee ? iteratee(value) : value; 5985 5986 value = (comparator || value !== 0) ? value : 0; 5987 if (isCommon && computed === computed) { 5988 var seenIndex = seen.length; 5989 while (seenIndex--) { 5990 if (seen[seenIndex] === computed) { 5991 continue outer; 5992 } 5993 } 5994 if (iteratee) { 5995 seen.push(computed); 5996 } 5997 result.push(value); 5998 } 5999 else if (!includes(seen, computed, comparator)) { 6000 if (seen !== result) { 6001 seen.push(computed); 6002 } 6003 result.push(value); 6004 } 6005 } 6006 return result; 6007 } 6008 6009 /** 6010 * The base implementation of `_.unset`. 6011 * 6012 * @private 6013 * @param {Object} object The object to modify. 6014 * @param {Array|string} path The property path to unset. 6015 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 6016 */ 6017 function baseUnset(object, path) { 6018 path = castPath(path, object); 6019 object = parent(object, path); 6020 return object == null || delete object[toKey(last(path))]; 6021 } 6022 6023 /** 6024 * The base implementation of `_.update`. 6025 * 6026 * @private 6027 * @param {Object} object The object to modify. 6028 * @param {Array|string} path The path of the property to update. 6029 * @param {Function} updater The function to produce the updated value. 6030 * @param {Function} [customizer] The function to customize path creation. 6031 * @returns {Object} Returns `object`. 6032 */ 6033 function baseUpdate(object, path, updater, customizer) { 6034 return baseSet(object, path, updater(baseGet(object, path)), customizer); 6035 } 6036 6037 /** 6038 * The base implementation of methods like `_.dropWhile` and `_.takeWhile` 6039 * without support for iteratee shorthands. 6040 * 6041 * @private 6042 * @param {Array} array The array to query. 6043 * @param {Function} predicate The function invoked per iteration. 6044 * @param {boolean} [isDrop] Specify dropping elements instead of taking them. 6045 * @param {boolean} [fromRight] Specify iterating from right to left. 6046 * @returns {Array} Returns the slice of `array`. 6047 */ 6048 function baseWhile(array, predicate, isDrop, fromRight) { 6049 var length = array.length, 6050 index = fromRight ? length : -1; 6051 6052 while ((fromRight ? index-- : ++index < length) && 6053 predicate(array[index], index, array)) {} 6054 6055 return isDrop 6056 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) 6057 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); 6058 } 6059 6060 /** 6061 * The base implementation of `wrapperValue` which returns the result of 6062 * performing a sequence of actions on the unwrapped `value`, where each 6063 * successive action is supplied the return value of the previous. 6064 * 6065 * @private 6066 * @param {*} value The unwrapped value. 6067 * @param {Array} actions Actions to perform to resolve the unwrapped value. 6068 * @returns {*} Returns the resolved value. 6069 */ 6070 function baseWrapperValue(value, actions) { 6071 var result = value; 6072 if (result instanceof LazyWrapper) { 6073 result = result.value(); 6074 } 6075 return arrayReduce(actions, function(result, action) { 6076 return action.func.apply(action.thisArg, arrayPush([result], action.args)); 6077 }, result); 6078 } 6079 6080 /** 6081 * The base implementation of methods like `_.xor`, without support for 6082 * iteratee shorthands, that accepts an array of arrays to inspect. 6083 * 6084 * @private 6085 * @param {Array} arrays The arrays to inspect. 6086 * @param {Function} [iteratee] The iteratee invoked per element. 6087 * @param {Function} [comparator] The comparator invoked per element. 6088 * @returns {Array} Returns the new array of values. 6089 */ 6090 function baseXor(arrays, iteratee, comparator) { 6091 var length = arrays.length; 6092 if (length < 2) { 6093 return length ? baseUniq(arrays[0]) : []; 6094 } 6095 var index = -1, 6096 result = Array(length); 6097 6098 while (++index < length) { 6099 var array = arrays[index], 6100 othIndex = -1; 6101 6102 while (++othIndex < length) { 6103 if (othIndex != index) { 6104 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); 6105 } 6106 } 6107 } 6108 return baseUniq(baseFlatten(result, 1), iteratee, comparator); 6109 } 6110 6111 /** 6112 * This base implementation of `_.zipObject` which assigns values using `assignFunc`. 6113 * 6114 * @private 6115 * @param {Array} props The property identifiers. 6116 * @param {Array} values The property values. 6117 * @param {Function} assignFunc The function to assign values. 6118 * @returns {Object} Returns the new object. 6119 */ 6120 function baseZipObject(props, values, assignFunc) { 6121 var index = -1, 6122 length = props.length, 6123 valsLength = values.length, 6124 result = {}; 6125 6126 while (++index < length) { 6127 var value = index < valsLength ? values[index] : undefined; 6128 assignFunc(result, props[index], value); 6129 } 6130 return result; 6131 } 6132 6133 /** 6134 * Casts `value` to an empty array if it's not an array like object. 6135 * 6136 * @private 6137 * @param {*} value The value to inspect. 6138 * @returns {Array|Object} Returns the cast array-like object. 6139 */ 6140 function castArrayLikeObject(value) { 6141 return isArrayLikeObject(value) ? value : []; 6142 } 6143 6144 /** 6145 * Casts `value` to `identity` if it's not a function. 6146 * 6147 * @private 6148 * @param {*} value The value to inspect. 6149 * @returns {Function} Returns cast function. 6150 */ 6151 function castFunction(value) { 6152 return typeof value == 'function' ? value : identity; 6153 } 6154 6155 /** 6156 * Casts `value` to a path array if it's not one. 6157 * 6158 * @private 6159 * @param {*} value The value to inspect. 6160 * @param {Object} [object] The object to query keys on. 6161 * @returns {Array} Returns the cast property path array. 6162 */ 6163 function castPath(value, object) { 6164 if (isArray(value)) { 6165 return value; 6166 } 6167 return isKey(value, object) ? [value] : stringToPath(toString(value)); 6168 } 6169 6170 /** 6171 * A `baseRest` alias which can be replaced with `identity` by module 6172 * replacement plugins. 6173 * 6174 * @private 6175 * @type {Function} 6176 * @param {Function} func The function to apply a rest parameter to. 6177 * @returns {Function} Returns the new function. 6178 */ 6179 var castRest = baseRest; 6180 6181 /** 6182 * Casts `array` to a slice if it's needed. 6183 * 6184 * @private 6185 * @param {Array} array The array to inspect. 6186 * @param {number} start The start position. 6187 * @param {number} [end=array.length] The end position. 6188 * @returns {Array} Returns the cast slice. 6189 */ 6190 function castSlice(array, start, end) { 6191 var length = array.length; 6192 end = end === undefined ? length : end; 6193 return (!start && end >= length) ? array : baseSlice(array, start, end); 6194 } 6195 6196 /** 6197 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). 6198 * 6199 * @private 6200 * @param {number|Object} id The timer id or timeout object of the timer to clear. 6201 */ 6202 var clearTimeout = ctxClearTimeout || function(id) { 6203 return root.clearTimeout(id); 6204 }; 6205 6206 /** 6207 * Creates a clone of `buffer`. 6208 * 6209 * @private 6210 * @param {Buffer} buffer The buffer to clone. 6211 * @param {boolean} [isDeep] Specify a deep clone. 6212 * @returns {Buffer} Returns the cloned buffer. 6213 */ 6214 function cloneBuffer(buffer, isDeep) { 6215 if (isDeep) { 6216 return buffer.slice(); 6217 } 6218 var length = buffer.length, 6219 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); 6220 6221 buffer.copy(result); 6222 return result; 6223 } 6224 6225 /** 6226 * Creates a clone of `arrayBuffer`. 6227 * 6228 * @private 6229 * @param {ArrayBuffer} arrayBuffer The array buffer to clone. 6230 * @returns {ArrayBuffer} Returns the cloned array buffer. 6231 */ 6232 function cloneArrayBuffer(arrayBuffer) { 6233 var result = new arrayBuffer.constructor(arrayBuffer.byteLength); 6234 new Uint8Array(result).set(new Uint8Array(arrayBuffer)); 6235 return result; 6236 } 6237 6238 /** 6239 * Creates a clone of `dataView`. 6240 * 6241 * @private 6242 * @param {Object} dataView The data view to clone. 6243 * @param {boolean} [isDeep] Specify a deep clone. 6244 * @returns {Object} Returns the cloned data view. 6245 */ 6246 function cloneDataView(dataView, isDeep) { 6247 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; 6248 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); 6249 } 6250 6251 /** 6252 * Creates a clone of `regexp`. 6253 * 6254 * @private 6255 * @param {Object} regexp The regexp to clone. 6256 * @returns {Object} Returns the cloned regexp. 6257 */ 6258 function cloneRegExp(regexp) { 6259 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); 6260 result.lastIndex = regexp.lastIndex; 6261 return result; 6262 } 6263 6264 /** 6265 * Creates a clone of the `symbol` object. 6266 * 6267 * @private 6268 * @param {Object} symbol The symbol object to clone. 6269 * @returns {Object} Returns the cloned symbol object. 6270 */ 6271 function cloneSymbol(symbol) { 6272 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; 6273 } 6274 6275 /** 6276 * Creates a clone of `typedArray`. 6277 * 6278 * @private 6279 * @param {Object} typedArray The typed array to clone. 6280 * @param {boolean} [isDeep] Specify a deep clone. 6281 * @returns {Object} Returns the cloned typed array. 6282 */ 6283 function cloneTypedArray(typedArray, isDeep) { 6284 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; 6285 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); 6286 } 6287 6288 /** 6289 * Compares values to sort them in ascending order. 6290 * 6291 * @private 6292 * @param {*} value The value to compare. 6293 * @param {*} other The other value to compare. 6294 * @returns {number} Returns the sort order indicator for `value`. 6295 */ 6296 function compareAscending(value, other) { 6297 if (value !== other) { 6298 var valIsDefined = value !== undefined, 6299 valIsNull = value === null, 6300 valIsReflexive = value === value, 6301 valIsSymbol = isSymbol(value); 6302 6303 var othIsDefined = other !== undefined, 6304 othIsNull = other === null, 6305 othIsReflexive = other === other, 6306 othIsSymbol = isSymbol(other); 6307 6308 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || 6309 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || 6310 (valIsNull && othIsDefined && othIsReflexive) || 6311 (!valIsDefined && othIsReflexive) || 6312 !valIsReflexive) { 6313 return 1; 6314 } 6315 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || 6316 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || 6317 (othIsNull && valIsDefined && valIsReflexive) || 6318 (!othIsDefined && valIsReflexive) || 6319 !othIsReflexive) { 6320 return -1; 6321 } 6322 } 6323 return 0; 6324 } 6325 6326 /** 6327 * Used by `_.orderBy` to compare multiple properties of a value to another 6328 * and stable sort them. 6329 * 6330 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, 6331 * specify an order of "desc" for descending or "asc" for ascending sort order 6332 * of corresponding values. 6333 * 6334 * @private 6335 * @param {Object} object The object to compare. 6336 * @param {Object} other The other object to compare. 6337 * @param {boolean[]|string[]} orders The order to sort by for each property. 6338 * @returns {number} Returns the sort order indicator for `object`. 6339 */ 6340 function compareMultiple(object, other, orders) { 6341 var index = -1, 6342 objCriteria = object.criteria, 6343 othCriteria = other.criteria, 6344 length = objCriteria.length, 6345 ordersLength = orders.length; 6346 6347 while (++index < length) { 6348 var result = compareAscending(objCriteria[index], othCriteria[index]); 6349 if (result) { 6350 if (index >= ordersLength) { 6351 return result; 6352 } 6353 var order = orders[index]; 6354 return result * (order == 'desc' ? -1 : 1); 6355 } 6356 } 6357 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications 6358 // that causes it, under certain circumstances, to provide the same value for 6359 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 6360 // for more details. 6361 // 6362 // This also ensures a stable sort in V8 and other engines. 6363 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. 6364 return object.index - other.index; 6365 } 6366 6367 /** 6368 * Creates an array that is the composition of partially applied arguments, 6369 * placeholders, and provided arguments into a single array of arguments. 6370 * 6371 * @private 6372 * @param {Array} args The provided arguments. 6373 * @param {Array} partials The arguments to prepend to those provided. 6374 * @param {Array} holders The `partials` placeholder indexes. 6375 * @params {boolean} [isCurried] Specify composing for a curried function. 6376 * @returns {Array} Returns the new array of composed arguments. 6377 */ 6378 function composeArgs(args, partials, holders, isCurried) { 6379 var argsIndex = -1, 6380 argsLength = args.length, 6381 holdersLength = holders.length, 6382 leftIndex = -1, 6383 leftLength = partials.length, 6384 rangeLength = nativeMax(argsLength - holdersLength, 0), 6385 result = Array(leftLength + rangeLength), 6386 isUncurried = !isCurried; 6387 6388 while (++leftIndex < leftLength) { 6389 result[leftIndex] = partials[leftIndex]; 6390 } 6391 while (++argsIndex < holdersLength) { 6392 if (isUncurried || argsIndex < argsLength) { 6393 result[holders[argsIndex]] = args[argsIndex]; 6394 } 6395 } 6396 while (rangeLength--) { 6397 result[leftIndex++] = args[argsIndex++]; 6398 } 6399 return result; 6400 } 6401 6402 /** 6403 * This function is like `composeArgs` except that the arguments composition 6404 * is tailored for `_.partialRight`. 6405 * 6406 * @private 6407 * @param {Array} args The provided arguments. 6408 * @param {Array} partials The arguments to append to those provided. 6409 * @param {Array} holders The `partials` placeholder indexes. 6410 * @params {boolean} [isCurried] Specify composing for a curried function. 6411 * @returns {Array} Returns the new array of composed arguments. 6412 */ 6413 function composeArgsRight(args, partials, holders, isCurried) { 6414 var argsIndex = -1, 6415 argsLength = args.length, 6416 holdersIndex = -1, 6417 holdersLength = holders.length, 6418 rightIndex = -1, 6419 rightLength = partials.length, 6420 rangeLength = nativeMax(argsLength - holdersLength, 0), 6421 result = Array(rangeLength + rightLength), 6422 isUncurried = !isCurried; 6423 6424 while (++argsIndex < rangeLength) { 6425 result[argsIndex] = args[argsIndex]; 6426 } 6427 var offset = argsIndex; 6428 while (++rightIndex < rightLength) { 6429 result[offset + rightIndex] = partials[rightIndex]; 6430 } 6431 while (++holdersIndex < holdersLength) { 6432 if (isUncurried || argsIndex < argsLength) { 6433 result[offset + holders[holdersIndex]] = args[argsIndex++]; 6434 } 6435 } 6436 return result; 6437 } 6438 6439 /** 6440 * Copies the values of `source` to `array`. 6441 * 6442 * @private 6443 * @param {Array} source The array to copy values from. 6444 * @param {Array} [array=[]] The array to copy values to. 6445 * @returns {Array} Returns `array`. 6446 */ 6447 function copyArray(source, array) { 6448 var index = -1, 6449 length = source.length; 6450 6451 array || (array = Array(length)); 6452 while (++index < length) { 6453 array[index] = source[index]; 6454 } 6455 return array; 6456 } 6457 6458 /** 6459 * Copies properties of `source` to `object`. 6460 * 6461 * @private 6462 * @param {Object} source The object to copy properties from. 6463 * @param {Array} props The property identifiers to copy. 6464 * @param {Object} [object={}] The object to copy properties to. 6465 * @param {Function} [customizer] The function to customize copied values. 6466 * @returns {Object} Returns `object`. 6467 */ 6468 function copyObject(source, props, object, customizer) { 6469 var isNew = !object; 6470 object || (object = {}); 6471 6472 var index = -1, 6473 length = props.length; 6474 6475 while (++index < length) { 6476 var key = props[index]; 6477 6478 var newValue = customizer 6479 ? customizer(object[key], source[key], key, object, source) 6480 : undefined; 6481 6482 if (newValue === undefined) { 6483 newValue = source[key]; 6484 } 6485 if (isNew) { 6486 baseAssignValue(object, key, newValue); 6487 } else { 6488 assignValue(object, key, newValue); 6489 } 6490 } 6491 return object; 6492 } 6493 6494 /** 6495 * Copies own symbols of `source` to `object`. 6496 * 6497 * @private 6498 * @param {Object} source The object to copy symbols from. 6499 * @param {Object} [object={}] The object to copy symbols to. 6500 * @returns {Object} Returns `object`. 6501 */ 6502 function copySymbols(source, object) { 6503 return copyObject(source, getSymbols(source), object); 6504 } 6505 6506 /** 6507 * Copies own and inherited symbols of `source` to `object`. 6508 * 6509 * @private 6510 * @param {Object} source The object to copy symbols from. 6511 * @param {Object} [object={}] The object to copy symbols to. 6512 * @returns {Object} Returns `object`. 6513 */ 6514 function copySymbolsIn(source, object) { 6515 return copyObject(source, getSymbolsIn(source), object); 6516 } 6517 6518 /** 6519 * Creates a function like `_.groupBy`. 6520 * 6521 * @private 6522 * @param {Function} setter The function to set accumulator values. 6523 * @param {Function} [initializer] The accumulator object initializer. 6524 * @returns {Function} Returns the new aggregator function. 6525 */ 6526 function createAggregator(setter, initializer) { 6527 return function(collection, iteratee) { 6528 var func = isArray(collection) ? arrayAggregator : baseAggregator, 6529 accumulator = initializer ? initializer() : {}; 6530 6531 return func(collection, setter, getIteratee(iteratee, 2), accumulator); 6532 }; 6533 } 6534 6535 /** 6536 * Creates a function like `_.assign`. 6537 * 6538 * @private 6539 * @param {Function} assigner The function to assign values. 6540 * @returns {Function} Returns the new assigner function. 6541 */ 6542 function createAssigner(assigner) { 6543 return baseRest(function(object, sources) { 6544 var index = -1, 6545 length = sources.length, 6546 customizer = length > 1 ? sources[length - 1] : undefined, 6547 guard = length > 2 ? sources[2] : undefined; 6548 6549 customizer = (assigner.length > 3 && typeof customizer == 'function') 6550 ? (length--, customizer) 6551 : undefined; 6552 6553 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 6554 customizer = length < 3 ? undefined : customizer; 6555 length = 1; 6556 } 6557 object = Object(object); 6558 while (++index < length) { 6559 var source = sources[index]; 6560 if (source) { 6561 assigner(object, source, index, customizer); 6562 } 6563 } 6564 return object; 6565 }); 6566 } 6567 6568 /** 6569 * Creates a `baseEach` or `baseEachRight` function. 6570 * 6571 * @private 6572 * @param {Function} eachFunc The function to iterate over a collection. 6573 * @param {boolean} [fromRight] Specify iterating from right to left. 6574 * @returns {Function} Returns the new base function. 6575 */ 6576 function createBaseEach(eachFunc, fromRight) { 6577 return function(collection, iteratee) { 6578 if (collection == null) { 6579 return collection; 6580 } 6581 if (!isArrayLike(collection)) { 6582 return eachFunc(collection, iteratee); 6583 } 6584 var length = collection.length, 6585 index = fromRight ? length : -1, 6586 iterable = Object(collection); 6587 6588 while ((fromRight ? index-- : ++index < length)) { 6589 if (iteratee(iterable[index], index, iterable) === false) { 6590 break; 6591 } 6592 } 6593 return collection; 6594 }; 6595 } 6596 6597 /** 6598 * Creates a base function for methods like `_.forIn` and `_.forOwn`. 6599 * 6600 * @private 6601 * @param {boolean} [fromRight] Specify iterating from right to left. 6602 * @returns {Function} Returns the new base function. 6603 */ 6604 function createBaseFor(fromRight) { 6605 return function(object, iteratee, keysFunc) { 6606 var index = -1, 6607 iterable = Object(object), 6608 props = keysFunc(object), 6609 length = props.length; 6610 6611 while (length--) { 6612 var key = props[fromRight ? length : ++index]; 6613 if (iteratee(iterable[key], key, iterable) === false) { 6614 break; 6615 } 6616 } 6617 return object; 6618 }; 6619 } 6620 6621 /** 6622 * Creates a function that wraps `func` to invoke it with the optional `this` 6623 * binding of `thisArg`. 6624 * 6625 * @private 6626 * @param {Function} func The function to wrap. 6627 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 6628 * @param {*} [thisArg] The `this` binding of `func`. 6629 * @returns {Function} Returns the new wrapped function. 6630 */ 6631 function createBind(func, bitmask, thisArg) { 6632 var isBind = bitmask & WRAP_BIND_FLAG, 6633 Ctor = createCtor(func); 6634 6635 function wrapper() { 6636 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 6637 return fn.apply(isBind ? thisArg : this, arguments); 6638 } 6639 return wrapper; 6640 } 6641 6642 /** 6643 * Creates a function like `_.lowerFirst`. 6644 * 6645 * @private 6646 * @param {string} methodName The name of the `String` case method to use. 6647 * @returns {Function} Returns the new case function. 6648 */ 6649 function createCaseFirst(methodName) { 6650 return function(string) { 6651 string = toString(string); 6652 6653 var strSymbols = hasUnicode(string) 6654 ? stringToArray(string) 6655 : undefined; 6656 6657 var chr = strSymbols 6658 ? strSymbols[0] 6659 : string.charAt(0); 6660 6661 var trailing = strSymbols 6662 ? castSlice(strSymbols, 1).join('') 6663 : string.slice(1); 6664 6665 return chr[methodName]() + trailing; 6666 }; 6667 } 6668 6669 /** 6670 * Creates a function like `_.camelCase`. 6671 * 6672 * @private 6673 * @param {Function} callback The function to combine each word. 6674 * @returns {Function} Returns the new compounder function. 6675 */ 6676 function createCompounder(callback) { 6677 return function(string) { 6678 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); 6679 }; 6680 } 6681 6682 /** 6683 * Creates a function that produces an instance of `Ctor` regardless of 6684 * whether it was invoked as part of a `new` expression or by `call` or `apply`. 6685 * 6686 * @private 6687 * @param {Function} Ctor The constructor to wrap. 6688 * @returns {Function} Returns the new wrapped function. 6689 */ 6690 function createCtor(Ctor) { 6691 return function() { 6692 // Use a `switch` statement to work with class constructors. See 6693 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist 6694 // for more details. 6695 var args = arguments; 6696 switch (args.length) { 6697 case 0: return new Ctor; 6698 case 1: return new Ctor(args[0]); 6699 case 2: return new Ctor(args[0], args[1]); 6700 case 3: return new Ctor(args[0], args[1], args[2]); 6701 case 4: return new Ctor(args[0], args[1], args[2], args[3]); 6702 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); 6703 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); 6704 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); 6705 } 6706 var thisBinding = baseCreate(Ctor.prototype), 6707 result = Ctor.apply(thisBinding, args); 6708 6709 // Mimic the constructor's `return` behavior. 6710 // See https://es5.github.io/#x13.2.2 for more details. 6711 return isObject(result) ? result : thisBinding; 6712 }; 6713 } 6714 6715 /** 6716 * Creates a function that wraps `func` to enable currying. 6717 * 6718 * @private 6719 * @param {Function} func The function to wrap. 6720 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 6721 * @param {number} arity The arity of `func`. 6722 * @returns {Function} Returns the new wrapped function. 6723 */ 6724 function createCurry(func, bitmask, arity) { 6725 var Ctor = createCtor(func); 6726 6727 function wrapper() { 6728 var length = arguments.length, 6729 args = Array(length), 6730 index = length, 6731 placeholder = getHolder(wrapper); 6732 6733 while (index--) { 6734 args[index] = arguments[index]; 6735 } 6736 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) 6737 ? [] 6738 : replaceHolders(args, placeholder); 6739 6740 length -= holders.length; 6741 if (length < arity) { 6742 return createRecurry( 6743 func, bitmask, createHybrid, wrapper.placeholder, undefined, 6744 args, holders, undefined, undefined, arity - length); 6745 } 6746 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 6747 return apply(fn, this, args); 6748 } 6749 return wrapper; 6750 } 6751 6752 /** 6753 * Creates a `_.find` or `_.findLast` function. 6754 * 6755 * @private 6756 * @param {Function} findIndexFunc The function to find the collection index. 6757 * @returns {Function} Returns the new find function. 6758 */ 6759 function createFind(findIndexFunc) { 6760 return function(collection, predicate, fromIndex) { 6761 var iterable = Object(collection); 6762 if (!isArrayLike(collection)) { 6763 var iteratee = getIteratee(predicate, 3); 6764 collection = keys(collection); 6765 predicate = function(key) { return iteratee(iterable[key], key, iterable); }; 6766 } 6767 var index = findIndexFunc(collection, predicate, fromIndex); 6768 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; 6769 }; 6770 } 6771 6772 /** 6773 * Creates a `_.flow` or `_.flowRight` function. 6774 * 6775 * @private 6776 * @param {boolean} [fromRight] Specify iterating from right to left. 6777 * @returns {Function} Returns the new flow function. 6778 */ 6779 function createFlow(fromRight) { 6780 return flatRest(function(funcs) { 6781 var length = funcs.length, 6782 index = length, 6783 prereq = LodashWrapper.prototype.thru; 6784 6785 if (fromRight) { 6786 funcs.reverse(); 6787 } 6788 while (index--) { 6789 var func = funcs[index]; 6790 if (typeof func != 'function') { 6791 throw new TypeError(FUNC_ERROR_TEXT); 6792 } 6793 if (prereq && !wrapper && getFuncName(func) == 'wrapper') { 6794 var wrapper = new LodashWrapper([], true); 6795 } 6796 } 6797 index = wrapper ? index : length; 6798 while (++index < length) { 6799 func = funcs[index]; 6800 6801 var funcName = getFuncName(func), 6802 data = funcName == 'wrapper' ? getData(func) : undefined; 6803 6804 if (data && isLaziable(data[0]) && 6805 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && 6806 !data[4].length && data[9] == 1 6807 ) { 6808 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); 6809 } else { 6810 wrapper = (func.length == 1 && isLaziable(func)) 6811 ? wrapper[funcName]() 6812 : wrapper.thru(func); 6813 } 6814 } 6815 return function() { 6816 var args = arguments, 6817 value = args[0]; 6818 6819 if (wrapper && args.length == 1 && isArray(value)) { 6820 return wrapper.plant(value).value(); 6821 } 6822 var index = 0, 6823 result = length ? funcs[index].apply(this, args) : value; 6824 6825 while (++index < length) { 6826 result = funcs[index].call(this, result); 6827 } 6828 return result; 6829 }; 6830 }); 6831 } 6832 6833 /** 6834 * Creates a function that wraps `func` to invoke it with optional `this` 6835 * binding of `thisArg`, partial application, and currying. 6836 * 6837 * @private 6838 * @param {Function|string} func The function or method name to wrap. 6839 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 6840 * @param {*} [thisArg] The `this` binding of `func`. 6841 * @param {Array} [partials] The arguments to prepend to those provided to 6842 * the new function. 6843 * @param {Array} [holders] The `partials` placeholder indexes. 6844 * @param {Array} [partialsRight] The arguments to append to those provided 6845 * to the new function. 6846 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. 6847 * @param {Array} [argPos] The argument positions of the new function. 6848 * @param {number} [ary] The arity cap of `func`. 6849 * @param {number} [arity] The arity of `func`. 6850 * @returns {Function} Returns the new wrapped function. 6851 */ 6852 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { 6853 var isAry = bitmask & WRAP_ARY_FLAG, 6854 isBind = bitmask & WRAP_BIND_FLAG, 6855 isBindKey = bitmask & WRAP_BIND_KEY_FLAG, 6856 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), 6857 isFlip = bitmask & WRAP_FLIP_FLAG, 6858 Ctor = isBindKey ? undefined : createCtor(func); 6859 6860 function wrapper() { 6861 var length = arguments.length, 6862 args = Array(length), 6863 index = length; 6864 6865 while (index--) { 6866 args[index] = arguments[index]; 6867 } 6868 if (isCurried) { 6869 var placeholder = getHolder(wrapper), 6870 holdersCount = countHolders(args, placeholder); 6871 } 6872 if (partials) { 6873 args = composeArgs(args, partials, holders, isCurried); 6874 } 6875 if (partialsRight) { 6876 args = composeArgsRight(args, partialsRight, holdersRight, isCurried); 6877 } 6878 length -= holdersCount; 6879 if (isCurried && length < arity) { 6880 var newHolders = replaceHolders(args, placeholder); 6881 return createRecurry( 6882 func, bitmask, createHybrid, wrapper.placeholder, thisArg, 6883 args, newHolders, argPos, ary, arity - length 6884 ); 6885 } 6886 var thisBinding = isBind ? thisArg : this, 6887 fn = isBindKey ? thisBinding[func] : func; 6888 6889 length = args.length; 6890 if (argPos) { 6891 args = reorder(args, argPos); 6892 } else if (isFlip && length > 1) { 6893 args.reverse(); 6894 } 6895 if (isAry && ary < length) { 6896 args.length = ary; 6897 } 6898 if (this && this !== root && this instanceof wrapper) { 6899 fn = Ctor || createCtor(fn); 6900 } 6901 return fn.apply(thisBinding, args); 6902 } 6903 return wrapper; 6904 } 6905 6906 /** 6907 * Creates a function like `_.invertBy`. 6908 * 6909 * @private 6910 * @param {Function} setter The function to set accumulator values. 6911 * @param {Function} toIteratee The function to resolve iteratees. 6912 * @returns {Function} Returns the new inverter function. 6913 */ 6914 function createInverter(setter, toIteratee) { 6915 return function(object, iteratee) { 6916 return baseInverter(object, setter, toIteratee(iteratee), {}); 6917 }; 6918 } 6919 6920 /** 6921 * Creates a function that performs a mathematical operation on two values. 6922 * 6923 * @private 6924 * @param {Function} operator The function to perform the operation. 6925 * @param {number} [defaultValue] The value used for `undefined` arguments. 6926 * @returns {Function} Returns the new mathematical operation function. 6927 */ 6928 function createMathOperation(operator, defaultValue) { 6929 return function(value, other) { 6930 var result; 6931 if (value === undefined && other === undefined) { 6932 return defaultValue; 6933 } 6934 if (value !== undefined) { 6935 result = value; 6936 } 6937 if (other !== undefined) { 6938 if (result === undefined) { 6939 return other; 6940 } 6941 if (typeof value == 'string' || typeof other == 'string') { 6942 value = baseToString(value); 6943 other = baseToString(other); 6944 } else { 6945 value = baseToNumber(value); 6946 other = baseToNumber(other); 6947 } 6948 result = operator(value, other); 6949 } 6950 return result; 6951 }; 6952 } 6953 6954 /** 6955 * Creates a function like `_.over`. 6956 * 6957 * @private 6958 * @param {Function} arrayFunc The function to iterate over iteratees. 6959 * @returns {Function} Returns the new over function. 6960 */ 6961 function createOver(arrayFunc) { 6962 return flatRest(function(iteratees) { 6963 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 6964 return baseRest(function(args) { 6965 var thisArg = this; 6966 return arrayFunc(iteratees, function(iteratee) { 6967 return apply(iteratee, thisArg, args); 6968 }); 6969 }); 6970 }); 6971 } 6972 6973 /** 6974 * Creates the padding for `string` based on `length`. The `chars` string 6975 * is truncated if the number of characters exceeds `length`. 6976 * 6977 * @private 6978 * @param {number} length The padding length. 6979 * @param {string} [chars=' '] The string used as padding. 6980 * @returns {string} Returns the padding for `string`. 6981 */ 6982 function createPadding(length, chars) { 6983 chars = chars === undefined ? ' ' : baseToString(chars); 6984 6985 var charsLength = chars.length; 6986 if (charsLength < 2) { 6987 return charsLength ? baseRepeat(chars, length) : chars; 6988 } 6989 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); 6990 return hasUnicode(chars) 6991 ? castSlice(stringToArray(result), 0, length).join('') 6992 : result.slice(0, length); 6993 } 6994 6995 /** 6996 * Creates a function that wraps `func` to invoke it with the `this` binding 6997 * of `thisArg` and `partials` prepended to the arguments it receives. 6998 * 6999 * @private 7000 * @param {Function} func The function to wrap. 7001 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7002 * @param {*} thisArg The `this` binding of `func`. 7003 * @param {Array} partials The arguments to prepend to those provided to 7004 * the new function. 7005 * @returns {Function} Returns the new wrapped function. 7006 */ 7007 function createPartial(func, bitmask, thisArg, partials) { 7008 var isBind = bitmask & WRAP_BIND_FLAG, 7009 Ctor = createCtor(func); 7010 7011 function wrapper() { 7012 var argsIndex = -1, 7013 argsLength = arguments.length, 7014 leftIndex = -1, 7015 leftLength = partials.length, 7016 args = Array(leftLength + argsLength), 7017 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 7018 7019 while (++leftIndex < leftLength) { 7020 args[leftIndex] = partials[leftIndex]; 7021 } 7022 while (argsLength--) { 7023 args[leftIndex++] = arguments[++argsIndex]; 7024 } 7025 return apply(fn, isBind ? thisArg : this, args); 7026 } 7027 return wrapper; 7028 } 7029 7030 /** 7031 * Creates a `_.range` or `_.rangeRight` function. 7032 * 7033 * @private 7034 * @param {boolean} [fromRight] Specify iterating from right to left. 7035 * @returns {Function} Returns the new range function. 7036 */ 7037 function createRange(fromRight) { 7038 return function(start, end, step) { 7039 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { 7040 end = step = undefined; 7041 } 7042 // Ensure the sign of `-0` is preserved. 7043 start = toFinite(start); 7044 if (end === undefined) { 7045 end = start; 7046 start = 0; 7047 } else { 7048 end = toFinite(end); 7049 } 7050 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); 7051 return baseRange(start, end, step, fromRight); 7052 }; 7053 } 7054 7055 /** 7056 * Creates a function that performs a relational operation on two values. 7057 * 7058 * @private 7059 * @param {Function} operator The function to perform the operation. 7060 * @returns {Function} Returns the new relational operation function. 7061 */ 7062 function createRelationalOperation(operator) { 7063 return function(value, other) { 7064 if (!(typeof value == 'string' && typeof other == 'string')) { 7065 value = toNumber(value); 7066 other = toNumber(other); 7067 } 7068 return operator(value, other); 7069 }; 7070 } 7071 7072 /** 7073 * Creates a function that wraps `func` to continue currying. 7074 * 7075 * @private 7076 * @param {Function} func The function to wrap. 7077 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7078 * @param {Function} wrapFunc The function to create the `func` wrapper. 7079 * @param {*} placeholder The placeholder value. 7080 * @param {*} [thisArg] The `this` binding of `func`. 7081 * @param {Array} [partials] The arguments to prepend to those provided to 7082 * the new function. 7083 * @param {Array} [holders] The `partials` placeholder indexes. 7084 * @param {Array} [argPos] The argument positions of the new function. 7085 * @param {number} [ary] The arity cap of `func`. 7086 * @param {number} [arity] The arity of `func`. 7087 * @returns {Function} Returns the new wrapped function. 7088 */ 7089 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { 7090 var isCurry = bitmask & WRAP_CURRY_FLAG, 7091 newHolders = isCurry ? holders : undefined, 7092 newHoldersRight = isCurry ? undefined : holders, 7093 newPartials = isCurry ? partials : undefined, 7094 newPartialsRight = isCurry ? undefined : partials; 7095 7096 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); 7097 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); 7098 7099 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { 7100 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); 7101 } 7102 var newData = [ 7103 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, 7104 newHoldersRight, argPos, ary, arity 7105 ]; 7106 7107 var result = wrapFunc.apply(undefined, newData); 7108 if (isLaziable(func)) { 7109 setData(result, newData); 7110 } 7111 result.placeholder = placeholder; 7112 return setWrapToString(result, func, bitmask); 7113 } 7114 7115 /** 7116 * Creates a function like `_.round`. 7117 * 7118 * @private 7119 * @param {string} methodName The name of the `Math` method to use when rounding. 7120 * @returns {Function} Returns the new round function. 7121 */ 7122 function createRound(methodName) { 7123 var func = Math[methodName]; 7124 return function(number, precision) { 7125 number = toNumber(number); 7126 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); 7127 if (precision) { 7128 // Shift with exponential notation to avoid floating-point issues. 7129 // See [MDN](https://mdn.io/round#Examples) for more details. 7130 var pair = (toString(number) + 'e').split('e'), 7131 value = func(pair[0] + 'e' + (+pair[1] + precision)); 7132 7133 pair = (toString(value) + 'e').split('e'); 7134 return +(pair[0] + 'e' + (+pair[1] - precision)); 7135 } 7136 return func(number); 7137 }; 7138 } 7139 7140 /** 7141 * Creates a set object of `values`. 7142 * 7143 * @private 7144 * @param {Array} values The values to add to the set. 7145 * @returns {Object} Returns the new set. 7146 */ 7147 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { 7148 return new Set(values); 7149 }; 7150 7151 /** 7152 * Creates a `_.toPairs` or `_.toPairsIn` function. 7153 * 7154 * @private 7155 * @param {Function} keysFunc The function to get the keys of a given object. 7156 * @returns {Function} Returns the new pairs function. 7157 */ 7158 function createToPairs(keysFunc) { 7159 return function(object) { 7160 var tag = getTag(object); 7161 if (tag == mapTag) { 7162 return mapToArray(object); 7163 } 7164 if (tag == setTag) { 7165 return setToPairs(object); 7166 } 7167 return baseToPairs(object, keysFunc(object)); 7168 }; 7169 } 7170 7171 /** 7172 * Creates a function that either curries or invokes `func` with optional 7173 * `this` binding and partially applied arguments. 7174 * 7175 * @private 7176 * @param {Function|string} func The function or method name to wrap. 7177 * @param {number} bitmask The bitmask flags. 7178 * 1 - `_.bind` 7179 * 2 - `_.bindKey` 7180 * 4 - `_.curry` or `_.curryRight` of a bound function 7181 * 8 - `_.curry` 7182 * 16 - `_.curryRight` 7183 * 32 - `_.partial` 7184 * 64 - `_.partialRight` 7185 * 128 - `_.rearg` 7186 * 256 - `_.ary` 7187 * 512 - `_.flip` 7188 * @param {*} [thisArg] The `this` binding of `func`. 7189 * @param {Array} [partials] The arguments to be partially applied. 7190 * @param {Array} [holders] The `partials` placeholder indexes. 7191 * @param {Array} [argPos] The argument positions of the new function. 7192 * @param {number} [ary] The arity cap of `func`. 7193 * @param {number} [arity] The arity of `func`. 7194 * @returns {Function} Returns the new wrapped function. 7195 */ 7196 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { 7197 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; 7198 if (!isBindKey && typeof func != 'function') { 7199 throw new TypeError(FUNC_ERROR_TEXT); 7200 } 7201 var length = partials ? partials.length : 0; 7202 if (!length) { 7203 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); 7204 partials = holders = undefined; 7205 } 7206 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); 7207 arity = arity === undefined ? arity : toInteger(arity); 7208 length -= holders ? holders.length : 0; 7209 7210 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { 7211 var partialsRight = partials, 7212 holdersRight = holders; 7213 7214 partials = holders = undefined; 7215 } 7216 var data = isBindKey ? undefined : getData(func); 7217 7218 var newData = [ 7219 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, 7220 argPos, ary, arity 7221 ]; 7222 7223 if (data) { 7224 mergeData(newData, data); 7225 } 7226 func = newData[0]; 7227 bitmask = newData[1]; 7228 thisArg = newData[2]; 7229 partials = newData[3]; 7230 holders = newData[4]; 7231 arity = newData[9] = newData[9] === undefined 7232 ? (isBindKey ? 0 : func.length) 7233 : nativeMax(newData[9] - length, 0); 7234 7235 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { 7236 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); 7237 } 7238 if (!bitmask || bitmask == WRAP_BIND_FLAG) { 7239 var result = createBind(func, bitmask, thisArg); 7240 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { 7241 result = createCurry(func, bitmask, arity); 7242 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { 7243 result = createPartial(func, bitmask, thisArg, partials); 7244 } else { 7245 result = createHybrid.apply(undefined, newData); 7246 } 7247 var setter = data ? baseSetData : setData; 7248 return setWrapToString(setter(result, newData), func, bitmask); 7249 } 7250 7251 /** 7252 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties 7253 * of source objects to the destination object for all destination properties 7254 * that resolve to `undefined`. 7255 * 7256 * @private 7257 * @param {*} objValue The destination value. 7258 * @param {*} srcValue The source value. 7259 * @param {string} key The key of the property to assign. 7260 * @param {Object} object The parent object of `objValue`. 7261 * @returns {*} Returns the value to assign. 7262 */ 7263 function customDefaultsAssignIn(objValue, srcValue, key, object) { 7264 if (objValue === undefined || 7265 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { 7266 return srcValue; 7267 } 7268 return objValue; 7269 } 7270 7271 /** 7272 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source 7273 * objects into destination objects that are passed thru. 7274 * 7275 * @private 7276 * @param {*} objValue The destination value. 7277 * @param {*} srcValue The source value. 7278 * @param {string} key The key of the property to merge. 7279 * @param {Object} object The parent object of `objValue`. 7280 * @param {Object} source The parent object of `srcValue`. 7281 * @param {Object} [stack] Tracks traversed source values and their merged 7282 * counterparts. 7283 * @returns {*} Returns the value to assign. 7284 */ 7285 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { 7286 if (isObject(objValue) && isObject(srcValue)) { 7287 // Recursively merge objects and arrays (susceptible to call stack limits). 7288 stack.set(srcValue, objValue); 7289 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); 7290 stack['delete'](srcValue); 7291 } 7292 return objValue; 7293 } 7294 7295 /** 7296 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain 7297 * objects. 7298 * 7299 * @private 7300 * @param {*} value The value to inspect. 7301 * @param {string} key The key of the property to inspect. 7302 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. 7303 */ 7304 function customOmitClone(value) { 7305 return isPlainObject(value) ? undefined : value; 7306 } 7307 7308 /** 7309 * A specialized version of `baseIsEqualDeep` for arrays with support for 7310 * partial deep comparisons. 7311 * 7312 * @private 7313 * @param {Array} array The array to compare. 7314 * @param {Array} other The other array to compare. 7315 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 7316 * @param {Function} customizer The function to customize comparisons. 7317 * @param {Function} equalFunc The function to determine equivalents of values. 7318 * @param {Object} stack Tracks traversed `array` and `other` objects. 7319 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 7320 */ 7321 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { 7322 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 7323 arrLength = array.length, 7324 othLength = other.length; 7325 7326 if (arrLength != othLength && !(isPartial && othLength > arrLength)) { 7327 return false; 7328 } 7329 // Assume cyclic values are equal. 7330 var stacked = stack.get(array); 7331 if (stacked && stack.get(other)) { 7332 return stacked == other; 7333 } 7334 var index = -1, 7335 result = true, 7336 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; 7337 7338 stack.set(array, other); 7339 stack.set(other, array); 7340 7341 // Ignore non-index properties. 7342 while (++index < arrLength) { 7343 var arrValue = array[index], 7344 othValue = other[index]; 7345 7346 if (customizer) { 7347 var compared = isPartial 7348 ? customizer(othValue, arrValue, index, other, array, stack) 7349 : customizer(arrValue, othValue, index, array, other, stack); 7350 } 7351 if (compared !== undefined) { 7352 if (compared) { 7353 continue; 7354 } 7355 result = false; 7356 break; 7357 } 7358 // Recursively compare arrays (susceptible to call stack limits). 7359 if (seen) { 7360 if (!arraySome(other, function(othValue, othIndex) { 7361 if (!cacheHas(seen, othIndex) && 7362 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { 7363 return seen.push(othIndex); 7364 } 7365 })) { 7366 result = false; 7367 break; 7368 } 7369 } else if (!( 7370 arrValue === othValue || 7371 equalFunc(arrValue, othValue, bitmask, customizer, stack) 7372 )) { 7373 result = false; 7374 break; 7375 } 7376 } 7377 stack['delete'](array); 7378 stack['delete'](other); 7379 return result; 7380 } 7381 7382 /** 7383 * A specialized version of `baseIsEqualDeep` for comparing objects of 7384 * the same `toStringTag`. 7385 * 7386 * **Note:** This function only supports comparing values with tags of 7387 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 7388 * 7389 * @private 7390 * @param {Object} object The object to compare. 7391 * @param {Object} other The other object to compare. 7392 * @param {string} tag The `toStringTag` of the objects to compare. 7393 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 7394 * @param {Function} customizer The function to customize comparisons. 7395 * @param {Function} equalFunc The function to determine equivalents of values. 7396 * @param {Object} stack Tracks traversed `object` and `other` objects. 7397 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 7398 */ 7399 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { 7400 switch (tag) { 7401 case dataViewTag: 7402 if ((object.byteLength != other.byteLength) || 7403 (object.byteOffset != other.byteOffset)) { 7404 return false; 7405 } 7406 object = object.buffer; 7407 other = other.buffer; 7408 7409 case arrayBufferTag: 7410 if ((object.byteLength != other.byteLength) || 7411 !equalFunc(new Uint8Array(object), new Uint8Array(other))) { 7412 return false; 7413 } 7414 return true; 7415 7416 case boolTag: 7417 case dateTag: 7418 case numberTag: 7419 // Coerce booleans to `1` or `0` and dates to milliseconds. 7420 // Invalid dates are coerced to `NaN`. 7421 return eq(+object, +other); 7422 7423 case errorTag: 7424 return object.name == other.name && object.message == other.message; 7425 7426 case regexpTag: 7427 case stringTag: 7428 // Coerce regexes to strings and treat strings, primitives and objects, 7429 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring 7430 // for more details. 7431 return object == (other + ''); 7432 7433 case mapTag: 7434 var convert = mapToArray; 7435 7436 case setTag: 7437 var isPartial = bitmask & COMPARE_PARTIAL_FLAG; 7438 convert || (convert = setToArray); 7439 7440 if (object.size != other.size && !isPartial) { 7441 return false; 7442 } 7443 // Assume cyclic values are equal. 7444 var stacked = stack.get(object); 7445 if (stacked) { 7446 return stacked == other; 7447 } 7448 bitmask |= COMPARE_UNORDERED_FLAG; 7449 7450 // Recursively compare objects (susceptible to call stack limits). 7451 stack.set(object, other); 7452 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); 7453 stack['delete'](object); 7454 return result; 7455 7456 case symbolTag: 7457 if (symbolValueOf) { 7458 return symbolValueOf.call(object) == symbolValueOf.call(other); 7459 } 7460 } 7461 return false; 7462 } 7463 7464 /** 7465 * A specialized version of `baseIsEqualDeep` for objects with support for 7466 * partial deep comparisons. 7467 * 7468 * @private 7469 * @param {Object} object The object to compare. 7470 * @param {Object} other The other object to compare. 7471 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 7472 * @param {Function} customizer The function to customize comparisons. 7473 * @param {Function} equalFunc The function to determine equivalents of values. 7474 * @param {Object} stack Tracks traversed `object` and `other` objects. 7475 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 7476 */ 7477 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { 7478 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 7479 objProps = getAllKeys(object), 7480 objLength = objProps.length, 7481 othProps = getAllKeys(other), 7482 othLength = othProps.length; 7483 7484 if (objLength != othLength && !isPartial) { 7485 return false; 7486 } 7487 var index = objLength; 7488 while (index--) { 7489 var key = objProps[index]; 7490 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { 7491 return false; 7492 } 7493 } 7494 // Assume cyclic values are equal. 7495 var stacked = stack.get(object); 7496 if (stacked && stack.get(other)) { 7497 return stacked == other; 7498 } 7499 var result = true; 7500 stack.set(object, other); 7501 stack.set(other, object); 7502 7503 var skipCtor = isPartial; 7504 while (++index < objLength) { 7505 key = objProps[index]; 7506 var objValue = object[key], 7507 othValue = other[key]; 7508 7509 if (customizer) { 7510 var compared = isPartial 7511 ? customizer(othValue, objValue, key, other, object, stack) 7512 : customizer(objValue, othValue, key, object, other, stack); 7513 } 7514 // Recursively compare objects (susceptible to call stack limits). 7515 if (!(compared === undefined 7516 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) 7517 : compared 7518 )) { 7519 result = false; 7520 break; 7521 } 7522 skipCtor || (skipCtor = key == 'constructor'); 7523 } 7524 if (result && !skipCtor) { 7525 var objCtor = object.constructor, 7526 othCtor = other.constructor; 7527 7528 // Non `Object` object instances with different constructors are not equal. 7529 if (objCtor != othCtor && 7530 ('constructor' in object && 'constructor' in other) && 7531 !(typeof objCtor == 'function' && objCtor instanceof objCtor && 7532 typeof othCtor == 'function' && othCtor instanceof othCtor)) { 7533 result = false; 7534 } 7535 } 7536 stack['delete'](object); 7537 stack['delete'](other); 7538 return result; 7539 } 7540 7541 /** 7542 * A specialized version of `baseRest` which flattens the rest array. 7543 * 7544 * @private 7545 * @param {Function} func The function to apply a rest parameter to. 7546 * @returns {Function} Returns the new function. 7547 */ 7548 function flatRest(func) { 7549 return setToString(overRest(func, undefined, flatten), func + ''); 7550 } 7551 7552 /** 7553 * Creates an array of own enumerable property names and symbols of `object`. 7554 * 7555 * @private 7556 * @param {Object} object The object to query. 7557 * @returns {Array} Returns the array of property names and symbols. 7558 */ 7559 function getAllKeys(object) { 7560 return baseGetAllKeys(object, keys, getSymbols); 7561 } 7562 7563 /** 7564 * Creates an array of own and inherited enumerable property names and 7565 * symbols of `object`. 7566 * 7567 * @private 7568 * @param {Object} object The object to query. 7569 * @returns {Array} Returns the array of property names and symbols. 7570 */ 7571 function getAllKeysIn(object) { 7572 return baseGetAllKeys(object, keysIn, getSymbolsIn); 7573 } 7574 7575 /** 7576 * Gets metadata for `func`. 7577 * 7578 * @private 7579 * @param {Function} func The function to query. 7580 * @returns {*} Returns the metadata for `func`. 7581 */ 7582 var getData = !metaMap ? noop : function(func) { 7583 return metaMap.get(func); 7584 }; 7585 7586 /** 7587 * Gets the name of `func`. 7588 * 7589 * @private 7590 * @param {Function} func The function to query. 7591 * @returns {string} Returns the function name. 7592 */ 7593 function getFuncName(func) { 7594 var result = (func.name + ''), 7595 array = realNames[result], 7596 length = hasOwnProperty.call(realNames, result) ? array.length : 0; 7597 7598 while (length--) { 7599 var data = array[length], 7600 otherFunc = data.func; 7601 if (otherFunc == null || otherFunc == func) { 7602 return data.name; 7603 } 7604 } 7605 return result; 7606 } 7607 7608 /** 7609 * Gets the argument placeholder value for `func`. 7610 * 7611 * @private 7612 * @param {Function} func The function to inspect. 7613 * @returns {*} Returns the placeholder value. 7614 */ 7615 function getHolder(func) { 7616 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; 7617 return object.placeholder; 7618 } 7619 7620 /** 7621 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, 7622 * this function returns the custom method, otherwise it returns `baseIteratee`. 7623 * If arguments are provided, the chosen function is invoked with them and 7624 * its result is returned. 7625 * 7626 * @private 7627 * @param {*} [value] The value to convert to an iteratee. 7628 * @param {number} [arity] The arity of the created iteratee. 7629 * @returns {Function} Returns the chosen function or its result. 7630 */ 7631 function getIteratee() { 7632 var result = lodash.iteratee || iteratee; 7633 result = result === iteratee ? baseIteratee : result; 7634 return arguments.length ? result(arguments[0], arguments[1]) : result; 7635 } 7636 7637 /** 7638 * Gets the data for `map`. 7639 * 7640 * @private 7641 * @param {Object} map The map to query. 7642 * @param {string} key The reference key. 7643 * @returns {*} Returns the map data. 7644 */ 7645 function getMapData(map, key) { 7646 var data = map.__data__; 7647 return isKeyable(key) 7648 ? data[typeof key == 'string' ? 'string' : 'hash'] 7649 : data.map; 7650 } 7651 7652 /** 7653 * Gets the property names, values, and compare flags of `object`. 7654 * 7655 * @private 7656 * @param {Object} object The object to query. 7657 * @returns {Array} Returns the match data of `object`. 7658 */ 7659 function getMatchData(object) { 7660 var result = keys(object), 7661 length = result.length; 7662 7663 while (length--) { 7664 var key = result[length], 7665 value = object[key]; 7666 7667 result[length] = [key, value, isStrictComparable(value)]; 7668 } 7669 return result; 7670 } 7671 7672 /** 7673 * Gets the native function at `key` of `object`. 7674 * 7675 * @private 7676 * @param {Object} object The object to query. 7677 * @param {string} key The key of the method to get. 7678 * @returns {*} Returns the function if it's native, else `undefined`. 7679 */ 7680 function getNative(object, key) { 7681 var value = getValue(object, key); 7682 return baseIsNative(value) ? value : undefined; 7683 } 7684 7685 /** 7686 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 7687 * 7688 * @private 7689 * @param {*} value The value to query. 7690 * @returns {string} Returns the raw `toStringTag`. 7691 */ 7692 function getRawTag(value) { 7693 var isOwn = hasOwnProperty.call(value, symToStringTag), 7694 tag = value[symToStringTag]; 7695 7696 try { 7697 value[symToStringTag] = undefined; 7698 var unmasked = true; 7699 } catch (e) {} 7700 7701 var result = nativeObjectToString.call(value); 7702 if (unmasked) { 7703 if (isOwn) { 7704 value[symToStringTag] = tag; 7705 } else { 7706 delete value[symToStringTag]; 7707 } 7708 } 7709 return result; 7710 } 7711 7712 /** 7713 * Creates an array of the own enumerable symbols of `object`. 7714 * 7715 * @private 7716 * @param {Object} object The object to query. 7717 * @returns {Array} Returns the array of symbols. 7718 */ 7719 var getSymbols = !nativeGetSymbols ? stubArray : function(object) { 7720 if (object == null) { 7721 return []; 7722 } 7723 object = Object(object); 7724 return arrayFilter(nativeGetSymbols(object), function(symbol) { 7725 return propertyIsEnumerable.call(object, symbol); 7726 }); 7727 }; 7728 7729 /** 7730 * Creates an array of the own and inherited enumerable symbols of `object`. 7731 * 7732 * @private 7733 * @param {Object} object The object to query. 7734 * @returns {Array} Returns the array of symbols. 7735 */ 7736 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { 7737 var result = []; 7738 while (object) { 7739 arrayPush(result, getSymbols(object)); 7740 object = getPrototype(object); 7741 } 7742 return result; 7743 }; 7744 7745 /** 7746 * Gets the `toStringTag` of `value`. 7747 * 7748 * @private 7749 * @param {*} value The value to query. 7750 * @returns {string} Returns the `toStringTag`. 7751 */ 7752 var getTag = baseGetTag; 7753 7754 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. 7755 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || 7756 (Map && getTag(new Map) != mapTag) || 7757 (Promise && getTag(Promise.resolve()) != promiseTag) || 7758 (Set && getTag(new Set) != setTag) || 7759 (WeakMap && getTag(new WeakMap) != weakMapTag)) { 7760 getTag = function(value) { 7761 var result = baseGetTag(value), 7762 Ctor = result == objectTag ? value.constructor : undefined, 7763 ctorString = Ctor ? toSource(Ctor) : ''; 7764 7765 if (ctorString) { 7766 switch (ctorString) { 7767 case dataViewCtorString: return dataViewTag; 7768 case mapCtorString: return mapTag; 7769 case promiseCtorString: return promiseTag; 7770 case setCtorString: return setTag; 7771 case weakMapCtorString: return weakMapTag; 7772 } 7773 } 7774 return result; 7775 }; 7776 } 7777 7778 /** 7779 * Gets the view, applying any `transforms` to the `start` and `end` positions. 7780 * 7781 * @private 7782 * @param {number} start The start of the view. 7783 * @param {number} end The end of the view. 7784 * @param {Array} transforms The transformations to apply to the view. 7785 * @returns {Object} Returns an object containing the `start` and `end` 7786 * positions of the view. 7787 */ 7788 function getView(start, end, transforms) { 7789 var index = -1, 7790 length = transforms.length; 7791 7792 while (++index < length) { 7793 var data = transforms[index], 7794 size = data.size; 7795 7796 switch (data.type) { 7797 case 'drop': start += size; break; 7798 case 'dropRight': end -= size; break; 7799 case 'take': end = nativeMin(end, start + size); break; 7800 case 'takeRight': start = nativeMax(start, end - size); break; 7801 } 7802 } 7803 return { 'start': start, 'end': end }; 7804 } 7805 7806 /** 7807 * Extracts wrapper details from the `source` body comment. 7808 * 7809 * @private 7810 * @param {string} source The source to inspect. 7811 * @returns {Array} Returns the wrapper details. 7812 */ 7813 function getWrapDetails(source) { 7814 var match = source.match(reWrapDetails); 7815 return match ? match[1].split(reSplitDetails) : []; 7816 } 7817 7818 /** 7819 * Checks if `path` exists on `object`. 7820 * 7821 * @private 7822 * @param {Object} object The object to query. 7823 * @param {Array|string} path The path to check. 7824 * @param {Function} hasFunc The function to check properties. 7825 * @returns {boolean} Returns `true` if `path` exists, else `false`. 7826 */ 7827 function hasPath(object, path, hasFunc) { 7828 path = castPath(path, object); 7829 7830 var index = -1, 7831 length = path.length, 7832 result = false; 7833 7834 while (++index < length) { 7835 var key = toKey(path[index]); 7836 if (!(result = object != null && hasFunc(object, key))) { 7837 break; 7838 } 7839 object = object[key]; 7840 } 7841 if (result || ++index != length) { 7842 return result; 7843 } 7844 length = object == null ? 0 : object.length; 7845 return !!length && isLength(length) && isIndex(key, length) && 7846 (isArray(object) || isArguments(object)); 7847 } 7848 7849 /** 7850 * Initializes an array clone. 7851 * 7852 * @private 7853 * @param {Array} array The array to clone. 7854 * @returns {Array} Returns the initialized clone. 7855 */ 7856 function initCloneArray(array) { 7857 var length = array.length, 7858 result = new array.constructor(length); 7859 7860 // Add properties assigned by `RegExp#exec`. 7861 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { 7862 result.index = array.index; 7863 result.input = array.input; 7864 } 7865 return result; 7866 } 7867 7868 /** 7869 * Initializes an object clone. 7870 * 7871 * @private 7872 * @param {Object} object The object to clone. 7873 * @returns {Object} Returns the initialized clone. 7874 */ 7875 function initCloneObject(object) { 7876 return (typeof object.constructor == 'function' && !isPrototype(object)) 7877 ? baseCreate(getPrototype(object)) 7878 : {}; 7879 } 7880 7881 /** 7882 * Initializes an object clone based on its `toStringTag`. 7883 * 7884 * **Note:** This function only supports cloning values with tags of 7885 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. 7886 * 7887 * @private 7888 * @param {Object} object The object to clone. 7889 * @param {string} tag The `toStringTag` of the object to clone. 7890 * @param {boolean} [isDeep] Specify a deep clone. 7891 * @returns {Object} Returns the initialized clone. 7892 */ 7893 function initCloneByTag(object, tag, isDeep) { 7894 var Ctor = object.constructor; 7895 switch (tag) { 7896 case arrayBufferTag: 7897 return cloneArrayBuffer(object); 7898 7899 case boolTag: 7900 case dateTag: 7901 return new Ctor(+object); 7902 7903 case dataViewTag: 7904 return cloneDataView(object, isDeep); 7905 7906 case float32Tag: case float64Tag: 7907 case int8Tag: case int16Tag: case int32Tag: 7908 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: 7909 return cloneTypedArray(object, isDeep); 7910 7911 case mapTag: 7912 return new Ctor; 7913 7914 case numberTag: 7915 case stringTag: 7916 return new Ctor(object); 7917 7918 case regexpTag: 7919 return cloneRegExp(object); 7920 7921 case setTag: 7922 return new Ctor; 7923 7924 case symbolTag: 7925 return cloneSymbol(object); 7926 } 7927 } 7928 7929 /** 7930 * Inserts wrapper `details` in a comment at the top of the `source` body. 7931 * 7932 * @private 7933 * @param {string} source The source to modify. 7934 * @returns {Array} details The details to insert. 7935 * @returns {string} Returns the modified source. 7936 */ 7937 function insertWrapDetails(source, details) { 7938 var length = details.length; 7939 if (!length) { 7940 return source; 7941 } 7942 var lastIndex = length - 1; 7943 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; 7944 details = details.join(length > 2 ? ', ' : ' '); 7945 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); 7946 } 7947 7948 /** 7949 * Checks if `value` is a flattenable `arguments` object or array. 7950 * 7951 * @private 7952 * @param {*} value The value to check. 7953 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. 7954 */ 7955 function isFlattenable(value) { 7956 return isArray(value) || isArguments(value) || 7957 !!(spreadableSymbol && value && value[spreadableSymbol]); 7958 } 7959 7960 /** 7961 * Checks if `value` is a valid array-like index. 7962 * 7963 * @private 7964 * @param {*} value The value to check. 7965 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 7966 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 7967 */ 7968 function isIndex(value, length) { 7969 var type = typeof value; 7970 length = length == null ? MAX_SAFE_INTEGER : length; 7971 7972 return !!length && 7973 (type == 'number' || 7974 (type != 'symbol' && reIsUint.test(value))) && 7975 (value > -1 && value % 1 == 0 && value < length); 7976 } 7977 7978 /** 7979 * Checks if the given arguments are from an iteratee call. 7980 * 7981 * @private 7982 * @param {*} value The potential iteratee value argument. 7983 * @param {*} index The potential iteratee index or key argument. 7984 * @param {*} object The potential iteratee object argument. 7985 * @returns {boolean} Returns `true` if the arguments are from an iteratee call, 7986 * else `false`. 7987 */ 7988 function isIterateeCall(value, index, object) { 7989 if (!isObject(object)) { 7990 return false; 7991 } 7992 var type = typeof index; 7993 if (type == 'number' 7994 ? (isArrayLike(object) && isIndex(index, object.length)) 7995 : (type == 'string' && index in object) 7996 ) { 7997 return eq(object[index], value); 7998 } 7999 return false; 8000 } 8001 8002 /** 8003 * Checks if `value` is a property name and not a property path. 8004 * 8005 * @private 8006 * @param {*} value The value to check. 8007 * @param {Object} [object] The object to query keys on. 8008 * @returns {boolean} Returns `true` if `value` is a property name, else `false`. 8009 */ 8010 function isKey(value, object) { 8011 if (isArray(value)) { 8012 return false; 8013 } 8014 var type = typeof value; 8015 if (type == 'number' || type == 'symbol' || type == 'boolean' || 8016 value == null || isSymbol(value)) { 8017 return true; 8018 } 8019 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || 8020 (object != null && value in Object(object)); 8021 } 8022 8023 /** 8024 * Checks if `value` is suitable for use as unique object key. 8025 * 8026 * @private 8027 * @param {*} value The value to check. 8028 * @returns {boolean} Returns `true` if `value` is suitable, else `false`. 8029 */ 8030 function isKeyable(value) { 8031 var type = typeof value; 8032 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 8033 ? (value !== '__proto__') 8034 : (value === null); 8035 } 8036 8037 /** 8038 * Checks if `func` has a lazy counterpart. 8039 * 8040 * @private 8041 * @param {Function} func The function to check. 8042 * @returns {boolean} Returns `true` if `func` has a lazy counterpart, 8043 * else `false`. 8044 */ 8045 function isLaziable(func) { 8046 var funcName = getFuncName(func), 8047 other = lodash[funcName]; 8048 8049 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { 8050 return false; 8051 } 8052 if (func === other) { 8053 return true; 8054 } 8055 var data = getData(other); 8056 return !!data && func === data[0]; 8057 } 8058 8059 /** 8060 * Checks if `func` has its source masked. 8061 * 8062 * @private 8063 * @param {Function} func The function to check. 8064 * @returns {boolean} Returns `true` if `func` is masked, else `false`. 8065 */ 8066 function isMasked(func) { 8067 return !!maskSrcKey && (maskSrcKey in func); 8068 } 8069 8070 /** 8071 * Checks if `func` is capable of being masked. 8072 * 8073 * @private 8074 * @param {*} value The value to check. 8075 * @returns {boolean} Returns `true` if `func` is maskable, else `false`. 8076 */ 8077 var isMaskable = coreJsData ? isFunction : stubFalse; 8078 8079 /** 8080 * Checks if `value` is likely a prototype object. 8081 * 8082 * @private 8083 * @param {*} value The value to check. 8084 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. 8085 */ 8086 function isPrototype(value) { 8087 var Ctor = value && value.constructor, 8088 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; 8089 8090 return value === proto; 8091 } 8092 8093 /** 8094 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. 8095 * 8096 * @private 8097 * @param {*} value The value to check. 8098 * @returns {boolean} Returns `true` if `value` if suitable for strict 8099 * equality comparisons, else `false`. 8100 */ 8101 function isStrictComparable(value) { 8102 return value === value && !isObject(value); 8103 } 8104 8105 /** 8106 * A specialized version of `matchesProperty` for source values suitable 8107 * for strict equality comparisons, i.e. `===`. 8108 * 8109 * @private 8110 * @param {string} key The key of the property to get. 8111 * @param {*} srcValue The value to match. 8112 * @returns {Function} Returns the new spec function. 8113 */ 8114 function matchesStrictComparable(key, srcValue) { 8115 return function(object) { 8116 if (object == null) { 8117 return false; 8118 } 8119 return object[key] === srcValue && 8120 (srcValue !== undefined || (key in Object(object))); 8121 }; 8122 } 8123 8124 /** 8125 * A specialized version of `_.memoize` which clears the memoized function's 8126 * cache when it exceeds `MAX_MEMOIZE_SIZE`. 8127 * 8128 * @private 8129 * @param {Function} func The function to have its output memoized. 8130 * @returns {Function} Returns the new memoized function. 8131 */ 8132 function memoizeCapped(func) { 8133 var result = memoize(func, function(key) { 8134 if (cache.size === MAX_MEMOIZE_SIZE) { 8135 cache.clear(); 8136 } 8137 return key; 8138 }); 8139 8140 var cache = result.cache; 8141 return result; 8142 } 8143 8144 /** 8145 * Merges the function metadata of `source` into `data`. 8146 * 8147 * Merging metadata reduces the number of wrappers used to invoke a function. 8148 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` 8149 * may be applied regardless of execution order. Methods like `_.ary` and 8150 * `_.rearg` modify function arguments, making the order in which they are 8151 * executed important, preventing the merging of metadata. However, we make 8152 * an exception for a safe combined case where curried functions have `_.ary` 8153 * and or `_.rearg` applied. 8154 * 8155 * @private 8156 * @param {Array} data The destination metadata. 8157 * @param {Array} source The source metadata. 8158 * @returns {Array} Returns `data`. 8159 */ 8160 function mergeData(data, source) { 8161 var bitmask = data[1], 8162 srcBitmask = source[1], 8163 newBitmask = bitmask | srcBitmask, 8164 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); 8165 8166 var isCombo = 8167 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || 8168 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || 8169 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); 8170 8171 // Exit early if metadata can't be merged. 8172 if (!(isCommon || isCombo)) { 8173 return data; 8174 } 8175 // Use source `thisArg` if available. 8176 if (srcBitmask & WRAP_BIND_FLAG) { 8177 data[2] = source[2]; 8178 // Set when currying a bound function. 8179 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; 8180 } 8181 // Compose partial arguments. 8182 var value = source[3]; 8183 if (value) { 8184 var partials = data[3]; 8185 data[3] = partials ? composeArgs(partials, value, source[4]) : value; 8186 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; 8187 } 8188 // Compose partial right arguments. 8189 value = source[5]; 8190 if (value) { 8191 partials = data[5]; 8192 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; 8193 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; 8194 } 8195 // Use source `argPos` if available. 8196 value = source[7]; 8197 if (value) { 8198 data[7] = value; 8199 } 8200 // Use source `ary` if it's smaller. 8201 if (srcBitmask & WRAP_ARY_FLAG) { 8202 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); 8203 } 8204 // Use source `arity` if one is not provided. 8205 if (data[9] == null) { 8206 data[9] = source[9]; 8207 } 8208 // Use source `func` and merge bitmasks. 8209 data[0] = source[0]; 8210 data[1] = newBitmask; 8211 8212 return data; 8213 } 8214 8215 /** 8216 * This function is like 8217 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 8218 * except that it includes inherited enumerable properties. 8219 * 8220 * @private 8221 * @param {Object} object The object to query. 8222 * @returns {Array} Returns the array of property names. 8223 */ 8224 function nativeKeysIn(object) { 8225 var result = []; 8226 if (object != null) { 8227 for (var key in Object(object)) { 8228 result.push(key); 8229 } 8230 } 8231 return result; 8232 } 8233 8234 /** 8235 * Converts `value` to a string using `Object.prototype.toString`. 8236 * 8237 * @private 8238 * @param {*} value The value to convert. 8239 * @returns {string} Returns the converted string. 8240 */ 8241 function objectToString(value) { 8242 return nativeObjectToString.call(value); 8243 } 8244 8245 /** 8246 * A specialized version of `baseRest` which transforms the rest array. 8247 * 8248 * @private 8249 * @param {Function} func The function to apply a rest parameter to. 8250 * @param {number} [start=func.length-1] The start position of the rest parameter. 8251 * @param {Function} transform The rest array transform. 8252 * @returns {Function} Returns the new function. 8253 */ 8254 function overRest(func, start, transform) { 8255 start = nativeMax(start === undefined ? (func.length - 1) : start, 0); 8256 return function() { 8257 var args = arguments, 8258 index = -1, 8259 length = nativeMax(args.length - start, 0), 8260 array = Array(length); 8261 8262 while (++index < length) { 8263 array[index] = args[start + index]; 8264 } 8265 index = -1; 8266 var otherArgs = Array(start + 1); 8267 while (++index < start) { 8268 otherArgs[index] = args[index]; 8269 } 8270 otherArgs[start] = transform(array); 8271 return apply(func, this, otherArgs); 8272 }; 8273 } 8274 8275 /** 8276 * Gets the parent value at `path` of `object`. 8277 * 8278 * @private 8279 * @param {Object} object The object to query. 8280 * @param {Array} path The path to get the parent value of. 8281 * @returns {*} Returns the parent value. 8282 */ 8283 function parent(object, path) { 8284 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); 8285 } 8286 8287 /** 8288 * Reorder `array` according to the specified indexes where the element at 8289 * the first index is assigned as the first element, the element at 8290 * the second index is assigned as the second element, and so on. 8291 * 8292 * @private 8293 * @param {Array} array The array to reorder. 8294 * @param {Array} indexes The arranged array indexes. 8295 * @returns {Array} Returns `array`. 8296 */ 8297 function reorder(array, indexes) { 8298 var arrLength = array.length, 8299 length = nativeMin(indexes.length, arrLength), 8300 oldArray = copyArray(array); 8301 8302 while (length--) { 8303 var index = indexes[length]; 8304 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; 8305 } 8306 return array; 8307 } 8308 8309 /** 8310 * Sets metadata for `func`. 8311 * 8312 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short 8313 * period of time, it will trip its breaker and transition to an identity 8314 * function to avoid garbage collection pauses in V8. See 8315 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) 8316 * for more details. 8317 * 8318 * @private 8319 * @param {Function} func The function to associate metadata with. 8320 * @param {*} data The metadata. 8321 * @returns {Function} Returns `func`. 8322 */ 8323 var setData = shortOut(baseSetData); 8324 8325 /** 8326 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). 8327 * 8328 * @private 8329 * @param {Function} func The function to delay. 8330 * @param {number} wait The number of milliseconds to delay invocation. 8331 * @returns {number|Object} Returns the timer id or timeout object. 8332 */ 8333 var setTimeout = ctxSetTimeout || function(func, wait) { 8334 return root.setTimeout(func, wait); 8335 }; 8336 8337 /** 8338 * Sets the `toString` method of `func` to return `string`. 8339 * 8340 * @private 8341 * @param {Function} func The function to modify. 8342 * @param {Function} string The `toString` result. 8343 * @returns {Function} Returns `func`. 8344 */ 8345 var setToString = shortOut(baseSetToString); 8346 8347 /** 8348 * Sets the `toString` method of `wrapper` to mimic the source of `reference` 8349 * with wrapper details in a comment at the top of the source body. 8350 * 8351 * @private 8352 * @param {Function} wrapper The function to modify. 8353 * @param {Function} reference The reference function. 8354 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 8355 * @returns {Function} Returns `wrapper`. 8356 */ 8357 function setWrapToString(wrapper, reference, bitmask) { 8358 var source = (reference + ''); 8359 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); 8360 } 8361 8362 /** 8363 * Creates a function that'll short out and invoke `identity` instead 8364 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` 8365 * milliseconds. 8366 * 8367 * @private 8368 * @param {Function} func The function to restrict. 8369 * @returns {Function} Returns the new shortable function. 8370 */ 8371 function shortOut(func) { 8372 var count = 0, 8373 lastCalled = 0; 8374 8375 return function() { 8376 var stamp = nativeNow(), 8377 remaining = HOT_SPAN - (stamp - lastCalled); 8378 8379 lastCalled = stamp; 8380 if (remaining > 0) { 8381 if (++count >= HOT_COUNT) { 8382 return arguments[0]; 8383 } 8384 } else { 8385 count = 0; 8386 } 8387 return func.apply(undefined, arguments); 8388 }; 8389 } 8390 8391 /** 8392 * A specialized version of `_.shuffle` which mutates and sets the size of `array`. 8393 * 8394 * @private 8395 * @param {Array} array The array to shuffle. 8396 * @param {number} [size=array.length] The size of `array`. 8397 * @returns {Array} Returns `array`. 8398 */ 8399 function shuffleSelf(array, size) { 8400 var index = -1, 8401 length = array.length, 8402 lastIndex = length - 1; 8403 8404 size = size === undefined ? length : size; 8405 while (++index < size) { 8406 var rand = baseRandom(index, lastIndex), 8407 value = array[rand]; 8408 8409 array[rand] = array[index]; 8410 array[index] = value; 8411 } 8412 array.length = size; 8413 return array; 8414 } 8415 8416 /** 8417 * Converts `string` to a property path array. 8418 * 8419 * @private 8420 * @param {string} string The string to convert. 8421 * @returns {Array} Returns the property path array. 8422 */ 8423 var stringToPath = memoizeCapped(function(string) { 8424 var result = []; 8425 if (string.charCodeAt(0) === 46 /* . */) { 8426 result.push(''); 8427 } 8428 string.replace(rePropName, function(match, number, quote, subString) { 8429 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); 8430 }); 8431 return result; 8432 }); 8433 8434 /** 8435 * Converts `value` to a string key if it's not a string or symbol. 8436 * 8437 * @private 8438 * @param {*} value The value to inspect. 8439 * @returns {string|symbol} Returns the key. 8440 */ 8441 function toKey(value) { 8442 if (typeof value == 'string' || isSymbol(value)) { 8443 return value; 8444 } 8445 var result = (value + ''); 8446 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 8447 } 8448 8449 /** 8450 * Converts `func` to its source code. 8451 * 8452 * @private 8453 * @param {Function} func The function to convert. 8454 * @returns {string} Returns the source code. 8455 */ 8456 function toSource(func) { 8457 if (func != null) { 8458 try { 8459 return funcToString.call(func); 8460 } catch (e) {} 8461 try { 8462 return (func + ''); 8463 } catch (e) {} 8464 } 8465 return ''; 8466 } 8467 8468 /** 8469 * Updates wrapper `details` based on `bitmask` flags. 8470 * 8471 * @private 8472 * @returns {Array} details The details to modify. 8473 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 8474 * @returns {Array} Returns `details`. 8475 */ 8476 function updateWrapDetails(details, bitmask) { 8477 arrayEach(wrapFlags, function(pair) { 8478 var value = '_.' + pair[0]; 8479 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { 8480 details.push(value); 8481 } 8482 }); 8483 return details.sort(); 8484 } 8485 8486 /** 8487 * Creates a clone of `wrapper`. 8488 * 8489 * @private 8490 * @param {Object} wrapper The wrapper to clone. 8491 * @returns {Object} Returns the cloned wrapper. 8492 */ 8493 function wrapperClone(wrapper) { 8494 if (wrapper instanceof LazyWrapper) { 8495 return wrapper.clone(); 8496 } 8497 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); 8498 result.__actions__ = copyArray(wrapper.__actions__); 8499 result.__index__ = wrapper.__index__; 8500 result.__values__ = wrapper.__values__; 8501 return result; 8502 } 8503 8504 /*------------------------------------------------------------------------*/ 8505 8506 /** 8507 * Creates an array of elements split into groups the length of `size`. 8508 * If `array` can't be split evenly, the final chunk will be the remaining 8509 * elements. 8510 * 8511 * @static 8512 * @memberOf _ 8513 * @since 3.0.0 8514 * @category Array 8515 * @param {Array} array The array to process. 8516 * @param {number} [size=1] The length of each chunk 8517 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 8518 * @returns {Array} Returns the new array of chunks. 8519 * @example 8520 * 8521 * _.chunk(['a', 'b', 'c', 'd'], 2); 8522 * // => [['a', 'b'], ['c', 'd']] 8523 * 8524 * _.chunk(['a', 'b', 'c', 'd'], 3); 8525 * // => [['a', 'b', 'c'], ['d']] 8526 */ 8527 function chunk(array, size, guard) { 8528 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { 8529 size = 1; 8530 } else { 8531 size = nativeMax(toInteger(size), 0); 8532 } 8533 var length = array == null ? 0 : array.length; 8534 if (!length || size < 1) { 8535 return []; 8536 } 8537 var index = 0, 8538 resIndex = 0, 8539 result = Array(nativeCeil(length / size)); 8540 8541 while (index < length) { 8542 result[resIndex++] = baseSlice(array, index, (index += size)); 8543 } 8544 return result; 8545 } 8546 8547 /** 8548 * Creates an array with all falsey values removed. The values `false`, `null`, 8549 * `0`, `""`, `undefined`, and `NaN` are falsey. 8550 * 8551 * @static 8552 * @memberOf _ 8553 * @since 0.1.0 8554 * @category Array 8555 * @param {Array} array The array to compact. 8556 * @returns {Array} Returns the new array of filtered values. 8557 * @example 8558 * 8559 * _.compact([0, 1, false, 2, '', 3]); 8560 * // => [1, 2, 3] 8561 */ 8562 function compact(array) { 8563 var index = -1, 8564 length = array == null ? 0 : array.length, 8565 resIndex = 0, 8566 result = []; 8567 8568 while (++index < length) { 8569 var value = array[index]; 8570 if (value) { 8571 result[resIndex++] = value; 8572 } 8573 } 8574 return result; 8575 } 8576 8577 /** 8578 * Creates a new array concatenating `array` with any additional arrays 8579 * and/or values. 8580 * 8581 * @static 8582 * @memberOf _ 8583 * @since 4.0.0 8584 * @category Array 8585 * @param {Array} array The array to concatenate. 8586 * @param {...*} [values] The values to concatenate. 8587 * @returns {Array} Returns the new concatenated array. 8588 * @example 8589 * 8590 * var array = [1]; 8591 * var other = _.concat(array, 2, [3], [[4]]); 8592 * 8593 * console.log(other); 8594 * // => [1, 2, 3, [4]] 8595 * 8596 * console.log(array); 8597 * // => [1] 8598 */ 8599 function concat() { 8600 var length = arguments.length; 8601 if (!length) { 8602 return []; 8603 } 8604 var args = Array(length - 1), 8605 array = arguments[0], 8606 index = length; 8607 8608 while (index--) { 8609 args[index - 1] = arguments[index]; 8610 } 8611 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); 8612 } 8613 8614 /** 8615 * Creates an array of `array` values not included in the other given arrays 8616 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 8617 * for equality comparisons. The order and references of result values are 8618 * determined by the first array. 8619 * 8620 * **Note:** Unlike `_.pullAll`, this method returns a new array. 8621 * 8622 * @static 8623 * @memberOf _ 8624 * @since 0.1.0 8625 * @category Array 8626 * @param {Array} array The array to inspect. 8627 * @param {...Array} [values] The values to exclude. 8628 * @returns {Array} Returns the new array of filtered values. 8629 * @see _.without, _.xor 8630 * @example 8631 * 8632 * _.difference([2, 1], [2, 3]); 8633 * // => [1] 8634 */ 8635 var difference = baseRest(function(array, values) { 8636 return isArrayLikeObject(array) 8637 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) 8638 : []; 8639 }); 8640 8641 /** 8642 * This method is like `_.difference` except that it accepts `iteratee` which 8643 * is invoked for each element of `array` and `values` to generate the criterion 8644 * by which they're compared. The order and references of result values are 8645 * determined by the first array. The iteratee is invoked with one argument: 8646 * (value). 8647 * 8648 * **Note:** Unlike `_.pullAllBy`, this method returns a new array. 8649 * 8650 * @static 8651 * @memberOf _ 8652 * @since 4.0.0 8653 * @category Array 8654 * @param {Array} array The array to inspect. 8655 * @param {...Array} [values] The values to exclude. 8656 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 8657 * @returns {Array} Returns the new array of filtered values. 8658 * @example 8659 * 8660 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); 8661 * // => [1.2] 8662 * 8663 * // The `_.property` iteratee shorthand. 8664 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); 8665 * // => [{ 'x': 2 }] 8666 */ 8667 var differenceBy = baseRest(function(array, values) { 8668 var iteratee = last(values); 8669 if (isArrayLikeObject(iteratee)) { 8670 iteratee = undefined; 8671 } 8672 return isArrayLikeObject(array) 8673 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) 8674 : []; 8675 }); 8676 8677 /** 8678 * This method is like `_.difference` except that it accepts `comparator` 8679 * which is invoked to compare elements of `array` to `values`. The order and 8680 * references of result values are determined by the first array. The comparator 8681 * is invoked with two arguments: (arrVal, othVal). 8682 * 8683 * **Note:** Unlike `_.pullAllWith`, this method returns a new array. 8684 * 8685 * @static 8686 * @memberOf _ 8687 * @since 4.0.0 8688 * @category Array 8689 * @param {Array} array The array to inspect. 8690 * @param {...Array} [values] The values to exclude. 8691 * @param {Function} [comparator] The comparator invoked per element. 8692 * @returns {Array} Returns the new array of filtered values. 8693 * @example 8694 * 8695 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 8696 * 8697 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); 8698 * // => [{ 'x': 2, 'y': 1 }] 8699 */ 8700 var differenceWith = baseRest(function(array, values) { 8701 var comparator = last(values); 8702 if (isArrayLikeObject(comparator)) { 8703 comparator = undefined; 8704 } 8705 return isArrayLikeObject(array) 8706 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) 8707 : []; 8708 }); 8709 8710 /** 8711 * Creates a slice of `array` with `n` elements dropped from the beginning. 8712 * 8713 * @static 8714 * @memberOf _ 8715 * @since 0.5.0 8716 * @category Array 8717 * @param {Array} array The array to query. 8718 * @param {number} [n=1] The number of elements to drop. 8719 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 8720 * @returns {Array} Returns the slice of `array`. 8721 * @example 8722 * 8723 * _.drop([1, 2, 3]); 8724 * // => [2, 3] 8725 * 8726 * _.drop([1, 2, 3], 2); 8727 * // => [3] 8728 * 8729 * _.drop([1, 2, 3], 5); 8730 * // => [] 8731 * 8732 * _.drop([1, 2, 3], 0); 8733 * // => [1, 2, 3] 8734 */ 8735 function drop(array, n, guard) { 8736 var length = array == null ? 0 : array.length; 8737 if (!length) { 8738 return []; 8739 } 8740 n = (guard || n === undefined) ? 1 : toInteger(n); 8741 return baseSlice(array, n < 0 ? 0 : n, length); 8742 } 8743 8744 /** 8745 * Creates a slice of `array` with `n` elements dropped from the end. 8746 * 8747 * @static 8748 * @memberOf _ 8749 * @since 3.0.0 8750 * @category Array 8751 * @param {Array} array The array to query. 8752 * @param {number} [n=1] The number of elements to drop. 8753 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 8754 * @returns {Array} Returns the slice of `array`. 8755 * @example 8756 * 8757 * _.dropRight([1, 2, 3]); 8758 * // => [1, 2] 8759 * 8760 * _.dropRight([1, 2, 3], 2); 8761 * // => [1] 8762 * 8763 * _.dropRight([1, 2, 3], 5); 8764 * // => [] 8765 * 8766 * _.dropRight([1, 2, 3], 0); 8767 * // => [1, 2, 3] 8768 */ 8769 function dropRight(array, n, guard) { 8770 var length = array == null ? 0 : array.length; 8771 if (!length) { 8772 return []; 8773 } 8774 n = (guard || n === undefined) ? 1 : toInteger(n); 8775 n = length - n; 8776 return baseSlice(array, 0, n < 0 ? 0 : n); 8777 } 8778 8779 /** 8780 * Creates a slice of `array` excluding elements dropped from the end. 8781 * Elements are dropped until `predicate` returns falsey. The predicate is 8782 * invoked with three arguments: (value, index, array). 8783 * 8784 * @static 8785 * @memberOf _ 8786 * @since 3.0.0 8787 * @category Array 8788 * @param {Array} array The array to query. 8789 * @param {Function} [predicate=_.identity] The function invoked per iteration. 8790 * @returns {Array} Returns the slice of `array`. 8791 * @example 8792 * 8793 * var users = [ 8794 * { 'user': 'barney', 'active': true }, 8795 * { 'user': 'fred', 'active': false }, 8796 * { 'user': 'pebbles', 'active': false } 8797 * ]; 8798 * 8799 * _.dropRightWhile(users, function(o) { return !o.active; }); 8800 * // => objects for ['barney'] 8801 * 8802 * // The `_.matches` iteratee shorthand. 8803 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); 8804 * // => objects for ['barney', 'fred'] 8805 * 8806 * // The `_.matchesProperty` iteratee shorthand. 8807 * _.dropRightWhile(users, ['active', false]); 8808 * // => objects for ['barney'] 8809 * 8810 * // The `_.property` iteratee shorthand. 8811 * _.dropRightWhile(users, 'active'); 8812 * // => objects for ['barney', 'fred', 'pebbles'] 8813 */ 8814 function dropRightWhile(array, predicate) { 8815 return (array && array.length) 8816 ? baseWhile(array, getIteratee(predicate, 3), true, true) 8817 : []; 8818 } 8819 8820 /** 8821 * Creates a slice of `array` excluding elements dropped from the beginning. 8822 * Elements are dropped until `predicate` returns falsey. The predicate is 8823 * invoked with three arguments: (value, index, array). 8824 * 8825 * @static 8826 * @memberOf _ 8827 * @since 3.0.0 8828 * @category Array 8829 * @param {Array} array The array to query. 8830 * @param {Function} [predicate=_.identity] The function invoked per iteration. 8831 * @returns {Array} Returns the slice of `array`. 8832 * @example 8833 * 8834 * var users = [ 8835 * { 'user': 'barney', 'active': false }, 8836 * { 'user': 'fred', 'active': false }, 8837 * { 'user': 'pebbles', 'active': true } 8838 * ]; 8839 * 8840 * _.dropWhile(users, function(o) { return !o.active; }); 8841 * // => objects for ['pebbles'] 8842 * 8843 * // The `_.matches` iteratee shorthand. 8844 * _.dropWhile(users, { 'user': 'barney', 'active': false }); 8845 * // => objects for ['fred', 'pebbles'] 8846 * 8847 * // The `_.matchesProperty` iteratee shorthand. 8848 * _.dropWhile(users, ['active', false]); 8849 * // => objects for ['pebbles'] 8850 * 8851 * // The `_.property` iteratee shorthand. 8852 * _.dropWhile(users, 'active'); 8853 * // => objects for ['barney', 'fred', 'pebbles'] 8854 */ 8855 function dropWhile(array, predicate) { 8856 return (array && array.length) 8857 ? baseWhile(array, getIteratee(predicate, 3), true) 8858 : []; 8859 } 8860 8861 /** 8862 * Fills elements of `array` with `value` from `start` up to, but not 8863 * including, `end`. 8864 * 8865 * **Note:** This method mutates `array`. 8866 * 8867 * @static 8868 * @memberOf _ 8869 * @since 3.2.0 8870 * @category Array 8871 * @param {Array} array The array to fill. 8872 * @param {*} value The value to fill `array` with. 8873 * @param {number} [start=0] The start position. 8874 * @param {number} [end=array.length] The end position. 8875 * @returns {Array} Returns `array`. 8876 * @example 8877 * 8878 * var array = [1, 2, 3]; 8879 * 8880 * _.fill(array, 'a'); 8881 * console.log(array); 8882 * // => ['a', 'a', 'a'] 8883 * 8884 * _.fill(Array(3), 2); 8885 * // => [2, 2, 2] 8886 * 8887 * _.fill([4, 6, 8, 10], '*', 1, 3); 8888 * // => [4, '*', '*', 10] 8889 */ 8890 function fill(array, value, start, end) { 8891 var length = array == null ? 0 : array.length; 8892 if (!length) { 8893 return []; 8894 } 8895 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { 8896 start = 0; 8897 end = length; 8898 } 8899 return baseFill(array, value, start, end); 8900 } 8901 8902 /** 8903 * This method is like `_.find` except that it returns the index of the first 8904 * element `predicate` returns truthy for instead of the element itself. 8905 * 8906 * @static 8907 * @memberOf _ 8908 * @since 1.1.0 8909 * @category Array 8910 * @param {Array} array The array to inspect. 8911 * @param {Function} [predicate=_.identity] The function invoked per iteration. 8912 * @param {number} [fromIndex=0] The index to search from. 8913 * @returns {number} Returns the index of the found element, else `-1`. 8914 * @example 8915 * 8916 * var users = [ 8917 * { 'user': 'barney', 'active': false }, 8918 * { 'user': 'fred', 'active': false }, 8919 * { 'user': 'pebbles', 'active': true } 8920 * ]; 8921 * 8922 * _.findIndex(users, function(o) { return o.user == 'barney'; }); 8923 * // => 0 8924 * 8925 * // The `_.matches` iteratee shorthand. 8926 * _.findIndex(users, { 'user': 'fred', 'active': false }); 8927 * // => 1 8928 * 8929 * // The `_.matchesProperty` iteratee shorthand. 8930 * _.findIndex(users, ['active', false]); 8931 * // => 0 8932 * 8933 * // The `_.property` iteratee shorthand. 8934 * _.findIndex(users, 'active'); 8935 * // => 2 8936 */ 8937 function findIndex(array, predicate, fromIndex) { 8938 var length = array == null ? 0 : array.length; 8939 if (!length) { 8940 return -1; 8941 } 8942 var index = fromIndex == null ? 0 : toInteger(fromIndex); 8943 if (index < 0) { 8944 index = nativeMax(length + index, 0); 8945 } 8946 return baseFindIndex(array, getIteratee(predicate, 3), index); 8947 } 8948 8949 /** 8950 * This method is like `_.findIndex` except that it iterates over elements 8951 * of `collection` from right to left. 8952 * 8953 * @static 8954 * @memberOf _ 8955 * @since 2.0.0 8956 * @category Array 8957 * @param {Array} array The array to inspect. 8958 * @param {Function} [predicate=_.identity] The function invoked per iteration. 8959 * @param {number} [fromIndex=array.length-1] The index to search from. 8960 * @returns {number} Returns the index of the found element, else `-1`. 8961 * @example 8962 * 8963 * var users = [ 8964 * { 'user': 'barney', 'active': true }, 8965 * { 'user': 'fred', 'active': false }, 8966 * { 'user': 'pebbles', 'active': false } 8967 * ]; 8968 * 8969 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); 8970 * // => 2 8971 * 8972 * // The `_.matches` iteratee shorthand. 8973 * _.findLastIndex(users, { 'user': 'barney', 'active': true }); 8974 * // => 0 8975 * 8976 * // The `_.matchesProperty` iteratee shorthand. 8977 * _.findLastIndex(users, ['active', false]); 8978 * // => 2 8979 * 8980 * // The `_.property` iteratee shorthand. 8981 * _.findLastIndex(users, 'active'); 8982 * // => 0 8983 */ 8984 function findLastIndex(array, predicate, fromIndex) { 8985 var length = array == null ? 0 : array.length; 8986 if (!length) { 8987 return -1; 8988 } 8989 var index = length - 1; 8990 if (fromIndex !== undefined) { 8991 index = toInteger(fromIndex); 8992 index = fromIndex < 0 8993 ? nativeMax(length + index, 0) 8994 : nativeMin(index, length - 1); 8995 } 8996 return baseFindIndex(array, getIteratee(predicate, 3), index, true); 8997 } 8998 8999 /** 9000 * Flattens `array` a single level deep. 9001 * 9002 * @static 9003 * @memberOf _ 9004 * @since 0.1.0 9005 * @category Array 9006 * @param {Array} array The array to flatten. 9007 * @returns {Array} Returns the new flattened array. 9008 * @example 9009 * 9010 * _.flatten([1, [2, [3, [4]], 5]]); 9011 * // => [1, 2, [3, [4]], 5] 9012 */ 9013 function flatten(array) { 9014 var length = array == null ? 0 : array.length; 9015 return length ? baseFlatten(array, 1) : []; 9016 } 9017 9018 /** 9019 * Recursively flattens `array`. 9020 * 9021 * @static 9022 * @memberOf _ 9023 * @since 3.0.0 9024 * @category Array 9025 * @param {Array} array The array to flatten. 9026 * @returns {Array} Returns the new flattened array. 9027 * @example 9028 * 9029 * _.flattenDeep([1, [2, [3, [4]], 5]]); 9030 * // => [1, 2, 3, 4, 5] 9031 */ 9032 function flattenDeep(array) { 9033 var length = array == null ? 0 : array.length; 9034 return length ? baseFlatten(array, INFINITY) : []; 9035 } 9036 9037 /** 9038 * Recursively flatten `array` up to `depth` times. 9039 * 9040 * @static 9041 * @memberOf _ 9042 * @since 4.4.0 9043 * @category Array 9044 * @param {Array} array The array to flatten. 9045 * @param {number} [depth=1] The maximum recursion depth. 9046 * @returns {Array} Returns the new flattened array. 9047 * @example 9048 * 9049 * var array = [1, [2, [3, [4]], 5]]; 9050 * 9051 * _.flattenDepth(array, 1); 9052 * // => [1, 2, [3, [4]], 5] 9053 * 9054 * _.flattenDepth(array, 2); 9055 * // => [1, 2, 3, [4], 5] 9056 */ 9057 function flattenDepth(array, depth) { 9058 var length = array == null ? 0 : array.length; 9059 if (!length) { 9060 return []; 9061 } 9062 depth = depth === undefined ? 1 : toInteger(depth); 9063 return baseFlatten(array, depth); 9064 } 9065 9066 /** 9067 * The inverse of `_.toPairs`; this method returns an object composed 9068 * from key-value `pairs`. 9069 * 9070 * @static 9071 * @memberOf _ 9072 * @since 4.0.0 9073 * @category Array 9074 * @param {Array} pairs The key-value pairs. 9075 * @returns {Object} Returns the new object. 9076 * @example 9077 * 9078 * _.fromPairs([['a', 1], ['b', 2]]); 9079 * // => { 'a': 1, 'b': 2 } 9080 */ 9081 function fromPairs(pairs) { 9082 var index = -1, 9083 length = pairs == null ? 0 : pairs.length, 9084 result = {}; 9085 9086 while (++index < length) { 9087 var pair = pairs[index]; 9088 result[pair[0]] = pair[1]; 9089 } 9090 return result; 9091 } 9092 9093 /** 9094 * Gets the first element of `array`. 9095 * 9096 * @static 9097 * @memberOf _ 9098 * @since 0.1.0 9099 * @alias first 9100 * @category Array 9101 * @param {Array} array The array to query. 9102 * @returns {*} Returns the first element of `array`. 9103 * @example 9104 * 9105 * _.head([1, 2, 3]); 9106 * // => 1 9107 * 9108 * _.head([]); 9109 * // => undefined 9110 */ 9111 function head(array) { 9112 return (array && array.length) ? array[0] : undefined; 9113 } 9114 9115 /** 9116 * Gets the index at which the first occurrence of `value` is found in `array` 9117 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9118 * for equality comparisons. If `fromIndex` is negative, it's used as the 9119 * offset from the end of `array`. 9120 * 9121 * @static 9122 * @memberOf _ 9123 * @since 0.1.0 9124 * @category Array 9125 * @param {Array} array The array to inspect. 9126 * @param {*} value The value to search for. 9127 * @param {number} [fromIndex=0] The index to search from. 9128 * @returns {number} Returns the index of the matched value, else `-1`. 9129 * @example 9130 * 9131 * _.indexOf([1, 2, 1, 2], 2); 9132 * // => 1 9133 * 9134 * // Search from the `fromIndex`. 9135 * _.indexOf([1, 2, 1, 2], 2, 2); 9136 * // => 3 9137 */ 9138 function indexOf(array, value, fromIndex) { 9139 var length = array == null ? 0 : array.length; 9140 if (!length) { 9141 return -1; 9142 } 9143 var index = fromIndex == null ? 0 : toInteger(fromIndex); 9144 if (index < 0) { 9145 index = nativeMax(length + index, 0); 9146 } 9147 return baseIndexOf(array, value, index); 9148 } 9149 9150 /** 9151 * Gets all but the last element of `array`. 9152 * 9153 * @static 9154 * @memberOf _ 9155 * @since 0.1.0 9156 * @category Array 9157 * @param {Array} array The array to query. 9158 * @returns {Array} Returns the slice of `array`. 9159 * @example 9160 * 9161 * _.initial([1, 2, 3]); 9162 * // => [1, 2] 9163 */ 9164 function initial(array) { 9165 var length = array == null ? 0 : array.length; 9166 return length ? baseSlice(array, 0, -1) : []; 9167 } 9168 9169 /** 9170 * Creates an array of unique values that are included in all given arrays 9171 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9172 * for equality comparisons. The order and references of result values are 9173 * determined by the first array. 9174 * 9175 * @static 9176 * @memberOf _ 9177 * @since 0.1.0 9178 * @category Array 9179 * @param {...Array} [arrays] The arrays to inspect. 9180 * @returns {Array} Returns the new array of intersecting values. 9181 * @example 9182 * 9183 * _.intersection([2, 1], [2, 3]); 9184 * // => [2] 9185 */ 9186 var intersection = baseRest(function(arrays) { 9187 var mapped = arrayMap(arrays, castArrayLikeObject); 9188 return (mapped.length && mapped[0] === arrays[0]) 9189 ? baseIntersection(mapped) 9190 : []; 9191 }); 9192 9193 /** 9194 * This method is like `_.intersection` except that it accepts `iteratee` 9195 * which is invoked for each element of each `arrays` to generate the criterion 9196 * by which they're compared. The order and references of result values are 9197 * determined by the first array. The iteratee is invoked with one argument: 9198 * (value). 9199 * 9200 * @static 9201 * @memberOf _ 9202 * @since 4.0.0 9203 * @category Array 9204 * @param {...Array} [arrays] The arrays to inspect. 9205 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 9206 * @returns {Array} Returns the new array of intersecting values. 9207 * @example 9208 * 9209 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); 9210 * // => [2.1] 9211 * 9212 * // The `_.property` iteratee shorthand. 9213 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 9214 * // => [{ 'x': 1 }] 9215 */ 9216 var intersectionBy = baseRest(function(arrays) { 9217 var iteratee = last(arrays), 9218 mapped = arrayMap(arrays, castArrayLikeObject); 9219 9220 if (iteratee === last(mapped)) { 9221 iteratee = undefined; 9222 } else { 9223 mapped.pop(); 9224 } 9225 return (mapped.length && mapped[0] === arrays[0]) 9226 ? baseIntersection(mapped, getIteratee(iteratee, 2)) 9227 : []; 9228 }); 9229 9230 /** 9231 * This method is like `_.intersection` except that it accepts `comparator` 9232 * which is invoked to compare elements of `arrays`. The order and references 9233 * of result values are determined by the first array. The comparator is 9234 * invoked with two arguments: (arrVal, othVal). 9235 * 9236 * @static 9237 * @memberOf _ 9238 * @since 4.0.0 9239 * @category Array 9240 * @param {...Array} [arrays] The arrays to inspect. 9241 * @param {Function} [comparator] The comparator invoked per element. 9242 * @returns {Array} Returns the new array of intersecting values. 9243 * @example 9244 * 9245 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 9246 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 9247 * 9248 * _.intersectionWith(objects, others, _.isEqual); 9249 * // => [{ 'x': 1, 'y': 2 }] 9250 */ 9251 var intersectionWith = baseRest(function(arrays) { 9252 var comparator = last(arrays), 9253 mapped = arrayMap(arrays, castArrayLikeObject); 9254 9255 comparator = typeof comparator == 'function' ? comparator : undefined; 9256 if (comparator) { 9257 mapped.pop(); 9258 } 9259 return (mapped.length && mapped[0] === arrays[0]) 9260 ? baseIntersection(mapped, undefined, comparator) 9261 : []; 9262 }); 9263 9264 /** 9265 * Converts all elements in `array` into a string separated by `separator`. 9266 * 9267 * @static 9268 * @memberOf _ 9269 * @since 4.0.0 9270 * @category Array 9271 * @param {Array} array The array to convert. 9272 * @param {string} [separator=','] The element separator. 9273 * @returns {string} Returns the joined string. 9274 * @example 9275 * 9276 * _.join(['a', 'b', 'c'], '~'); 9277 * // => 'a~b~c' 9278 */ 9279 function join(array, separator) { 9280 return array == null ? '' : nativeJoin.call(array, separator); 9281 } 9282 9283 /** 9284 * Gets the last element of `array`. 9285 * 9286 * @static 9287 * @memberOf _ 9288 * @since 0.1.0 9289 * @category Array 9290 * @param {Array} array The array to query. 9291 * @returns {*} Returns the last element of `array`. 9292 * @example 9293 * 9294 * _.last([1, 2, 3]); 9295 * // => 3 9296 */ 9297 function last(array) { 9298 var length = array == null ? 0 : array.length; 9299 return length ? array[length - 1] : undefined; 9300 } 9301 9302 /** 9303 * This method is like `_.indexOf` except that it iterates over elements of 9304 * `array` from right to left. 9305 * 9306 * @static 9307 * @memberOf _ 9308 * @since 0.1.0 9309 * @category Array 9310 * @param {Array} array The array to inspect. 9311 * @param {*} value The value to search for. 9312 * @param {number} [fromIndex=array.length-1] The index to search from. 9313 * @returns {number} Returns the index of the matched value, else `-1`. 9314 * @example 9315 * 9316 * _.lastIndexOf([1, 2, 1, 2], 2); 9317 * // => 3 9318 * 9319 * // Search from the `fromIndex`. 9320 * _.lastIndexOf([1, 2, 1, 2], 2, 2); 9321 * // => 1 9322 */ 9323 function lastIndexOf(array, value, fromIndex) { 9324 var length = array == null ? 0 : array.length; 9325 if (!length) { 9326 return -1; 9327 } 9328 var index = length; 9329 if (fromIndex !== undefined) { 9330 index = toInteger(fromIndex); 9331 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); 9332 } 9333 return value === value 9334 ? strictLastIndexOf(array, value, index) 9335 : baseFindIndex(array, baseIsNaN, index, true); 9336 } 9337 9338 /** 9339 * Gets the element at index `n` of `array`. If `n` is negative, the nth 9340 * element from the end is returned. 9341 * 9342 * @static 9343 * @memberOf _ 9344 * @since 4.11.0 9345 * @category Array 9346 * @param {Array} array The array to query. 9347 * @param {number} [n=0] The index of the element to return. 9348 * @returns {*} Returns the nth element of `array`. 9349 * @example 9350 * 9351 * var array = ['a', 'b', 'c', 'd']; 9352 * 9353 * _.nth(array, 1); 9354 * // => 'b' 9355 * 9356 * _.nth(array, -2); 9357 * // => 'c'; 9358 */ 9359 function nth(array, n) { 9360 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; 9361 } 9362 9363 /** 9364 * Removes all given values from `array` using 9365 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9366 * for equality comparisons. 9367 * 9368 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` 9369 * to remove elements from an array by predicate. 9370 * 9371 * @static 9372 * @memberOf _ 9373 * @since 2.0.0 9374 * @category Array 9375 * @param {Array} array The array to modify. 9376 * @param {...*} [values] The values to remove. 9377 * @returns {Array} Returns `array`. 9378 * @example 9379 * 9380 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 9381 * 9382 * _.pull(array, 'a', 'c'); 9383 * console.log(array); 9384 * // => ['b', 'b'] 9385 */ 9386 var pull = baseRest(pullAll); 9387 9388 /** 9389 * This method is like `_.pull` except that it accepts an array of values to remove. 9390 * 9391 * **Note:** Unlike `_.difference`, this method mutates `array`. 9392 * 9393 * @static 9394 * @memberOf _ 9395 * @since 4.0.0 9396 * @category Array 9397 * @param {Array} array The array to modify. 9398 * @param {Array} values The values to remove. 9399 * @returns {Array} Returns `array`. 9400 * @example 9401 * 9402 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 9403 * 9404 * _.pullAll(array, ['a', 'c']); 9405 * console.log(array); 9406 * // => ['b', 'b'] 9407 */ 9408 function pullAll(array, values) { 9409 return (array && array.length && values && values.length) 9410 ? basePullAll(array, values) 9411 : array; 9412 } 9413 9414 /** 9415 * This method is like `_.pullAll` except that it accepts `iteratee` which is 9416 * invoked for each element of `array` and `values` to generate the criterion 9417 * by which they're compared. The iteratee is invoked with one argument: (value). 9418 * 9419 * **Note:** Unlike `_.differenceBy`, this method mutates `array`. 9420 * 9421 * @static 9422 * @memberOf _ 9423 * @since 4.0.0 9424 * @category Array 9425 * @param {Array} array The array to modify. 9426 * @param {Array} values The values to remove. 9427 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 9428 * @returns {Array} Returns `array`. 9429 * @example 9430 * 9431 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; 9432 * 9433 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); 9434 * console.log(array); 9435 * // => [{ 'x': 2 }] 9436 */ 9437 function pullAllBy(array, values, iteratee) { 9438 return (array && array.length && values && values.length) 9439 ? basePullAll(array, values, getIteratee(iteratee, 2)) 9440 : array; 9441 } 9442 9443 /** 9444 * This method is like `_.pullAll` except that it accepts `comparator` which 9445 * is invoked to compare elements of `array` to `values`. The comparator is 9446 * invoked with two arguments: (arrVal, othVal). 9447 * 9448 * **Note:** Unlike `_.differenceWith`, this method mutates `array`. 9449 * 9450 * @static 9451 * @memberOf _ 9452 * @since 4.6.0 9453 * @category Array 9454 * @param {Array} array The array to modify. 9455 * @param {Array} values The values to remove. 9456 * @param {Function} [comparator] The comparator invoked per element. 9457 * @returns {Array} Returns `array`. 9458 * @example 9459 * 9460 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; 9461 * 9462 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); 9463 * console.log(array); 9464 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] 9465 */ 9466 function pullAllWith(array, values, comparator) { 9467 return (array && array.length && values && values.length) 9468 ? basePullAll(array, values, undefined, comparator) 9469 : array; 9470 } 9471 9472 /** 9473 * Removes elements from `array` corresponding to `indexes` and returns an 9474 * array of removed elements. 9475 * 9476 * **Note:** Unlike `_.at`, this method mutates `array`. 9477 * 9478 * @static 9479 * @memberOf _ 9480 * @since 3.0.0 9481 * @category Array 9482 * @param {Array} array The array to modify. 9483 * @param {...(number|number[])} [indexes] The indexes of elements to remove. 9484 * @returns {Array} Returns the new array of removed elements. 9485 * @example 9486 * 9487 * var array = ['a', 'b', 'c', 'd']; 9488 * var pulled = _.pullAt(array, [1, 3]); 9489 * 9490 * console.log(array); 9491 * // => ['a', 'c'] 9492 * 9493 * console.log(pulled); 9494 * // => ['b', 'd'] 9495 */ 9496 var pullAt = flatRest(function(array, indexes) { 9497 var length = array == null ? 0 : array.length, 9498 result = baseAt(array, indexes); 9499 9500 basePullAt(array, arrayMap(indexes, function(index) { 9501 return isIndex(index, length) ? +index : index; 9502 }).sort(compareAscending)); 9503 9504 return result; 9505 }); 9506 9507 /** 9508 * Removes all elements from `array` that `predicate` returns truthy for 9509 * and returns an array of the removed elements. The predicate is invoked 9510 * with three arguments: (value, index, array). 9511 * 9512 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` 9513 * to pull elements from an array by value. 9514 * 9515 * @static 9516 * @memberOf _ 9517 * @since 2.0.0 9518 * @category Array 9519 * @param {Array} array The array to modify. 9520 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9521 * @returns {Array} Returns the new array of removed elements. 9522 * @example 9523 * 9524 * var array = [1, 2, 3, 4]; 9525 * var evens = _.remove(array, function(n) { 9526 * return n % 2 == 0; 9527 * }); 9528 * 9529 * console.log(array); 9530 * // => [1, 3] 9531 * 9532 * console.log(evens); 9533 * // => [2, 4] 9534 */ 9535 function remove(array, predicate) { 9536 var result = []; 9537 if (!(array && array.length)) { 9538 return result; 9539 } 9540 var index = -1, 9541 indexes = [], 9542 length = array.length; 9543 9544 predicate = getIteratee(predicate, 3); 9545 while (++index < length) { 9546 var value = array[index]; 9547 if (predicate(value, index, array)) { 9548 result.push(value); 9549 indexes.push(index); 9550 } 9551 } 9552 basePullAt(array, indexes); 9553 return result; 9554 } 9555 9556 /** 9557 * Reverses `array` so that the first element becomes the last, the second 9558 * element becomes the second to last, and so on. 9559 * 9560 * **Note:** This method mutates `array` and is based on 9561 * [`Array#reverse`](https://mdn.io/Array/reverse). 9562 * 9563 * @static 9564 * @memberOf _ 9565 * @since 4.0.0 9566 * @category Array 9567 * @param {Array} array The array to modify. 9568 * @returns {Array} Returns `array`. 9569 * @example 9570 * 9571 * var array = [1, 2, 3]; 9572 * 9573 * _.reverse(array); 9574 * // => [3, 2, 1] 9575 * 9576 * console.log(array); 9577 * // => [3, 2, 1] 9578 */ 9579 function reverse(array) { 9580 return array == null ? array : nativeReverse.call(array); 9581 } 9582 9583 /** 9584 * Creates a slice of `array` from `start` up to, but not including, `end`. 9585 * 9586 * **Note:** This method is used instead of 9587 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are 9588 * returned. 9589 * 9590 * @static 9591 * @memberOf _ 9592 * @since 3.0.0 9593 * @category Array 9594 * @param {Array} array The array to slice. 9595 * @param {number} [start=0] The start position. 9596 * @param {number} [end=array.length] The end position. 9597 * @returns {Array} Returns the slice of `array`. 9598 */ 9599 function slice(array, start, end) { 9600 var length = array == null ? 0 : array.length; 9601 if (!length) { 9602 return []; 9603 } 9604 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { 9605 start = 0; 9606 end = length; 9607 } 9608 else { 9609 start = start == null ? 0 : toInteger(start); 9610 end = end === undefined ? length : toInteger(end); 9611 } 9612 return baseSlice(array, start, end); 9613 } 9614 9615 /** 9616 * Uses a binary search to determine the lowest index at which `value` 9617 * should be inserted into `array` in order to maintain its sort order. 9618 * 9619 * @static 9620 * @memberOf _ 9621 * @since 0.1.0 9622 * @category Array 9623 * @param {Array} array The sorted array to inspect. 9624 * @param {*} value The value to evaluate. 9625 * @returns {number} Returns the index at which `value` should be inserted 9626 * into `array`. 9627 * @example 9628 * 9629 * _.sortedIndex([30, 50], 40); 9630 * // => 1 9631 */ 9632 function sortedIndex(array, value) { 9633 return baseSortedIndex(array, value); 9634 } 9635 9636 /** 9637 * This method is like `_.sortedIndex` except that it accepts `iteratee` 9638 * which is invoked for `value` and each element of `array` to compute their 9639 * sort ranking. The iteratee is invoked with one argument: (value). 9640 * 9641 * @static 9642 * @memberOf _ 9643 * @since 4.0.0 9644 * @category Array 9645 * @param {Array} array The sorted array to inspect. 9646 * @param {*} value The value to evaluate. 9647 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 9648 * @returns {number} Returns the index at which `value` should be inserted 9649 * into `array`. 9650 * @example 9651 * 9652 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 9653 * 9654 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 9655 * // => 0 9656 * 9657 * // The `_.property` iteratee shorthand. 9658 * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); 9659 * // => 0 9660 */ 9661 function sortedIndexBy(array, value, iteratee) { 9662 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); 9663 } 9664 9665 /** 9666 * This method is like `_.indexOf` except that it performs a binary 9667 * search on a sorted `array`. 9668 * 9669 * @static 9670 * @memberOf _ 9671 * @since 4.0.0 9672 * @category Array 9673 * @param {Array} array The array to inspect. 9674 * @param {*} value The value to search for. 9675 * @returns {number} Returns the index of the matched value, else `-1`. 9676 * @example 9677 * 9678 * _.sortedIndexOf([4, 5, 5, 5, 6], 5); 9679 * // => 1 9680 */ 9681 function sortedIndexOf(array, value) { 9682 var length = array == null ? 0 : array.length; 9683 if (length) { 9684 var index = baseSortedIndex(array, value); 9685 if (index < length && eq(array[index], value)) { 9686 return index; 9687 } 9688 } 9689 return -1; 9690 } 9691 9692 /** 9693 * This method is like `_.sortedIndex` except that it returns the highest 9694 * index at which `value` should be inserted into `array` in order to 9695 * maintain its sort order. 9696 * 9697 * @static 9698 * @memberOf _ 9699 * @since 3.0.0 9700 * @category Array 9701 * @param {Array} array The sorted array to inspect. 9702 * @param {*} value The value to evaluate. 9703 * @returns {number} Returns the index at which `value` should be inserted 9704 * into `array`. 9705 * @example 9706 * 9707 * _.sortedLastIndex([4, 5, 5, 5, 6], 5); 9708 * // => 4 9709 */ 9710 function sortedLastIndex(array, value) { 9711 return baseSortedIndex(array, value, true); 9712 } 9713 9714 /** 9715 * This method is like `_.sortedLastIndex` except that it accepts `iteratee` 9716 * which is invoked for `value` and each element of `array` to compute their 9717 * sort ranking. The iteratee is invoked with one argument: (value). 9718 * 9719 * @static 9720 * @memberOf _ 9721 * @since 4.0.0 9722 * @category Array 9723 * @param {Array} array The sorted array to inspect. 9724 * @param {*} value The value to evaluate. 9725 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 9726 * @returns {number} Returns the index at which `value` should be inserted 9727 * into `array`. 9728 * @example 9729 * 9730 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 9731 * 9732 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 9733 * // => 1 9734 * 9735 * // The `_.property` iteratee shorthand. 9736 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); 9737 * // => 1 9738 */ 9739 function sortedLastIndexBy(array, value, iteratee) { 9740 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); 9741 } 9742 9743 /** 9744 * This method is like `_.lastIndexOf` except that it performs a binary 9745 * search on a sorted `array`. 9746 * 9747 * @static 9748 * @memberOf _ 9749 * @since 4.0.0 9750 * @category Array 9751 * @param {Array} array The array to inspect. 9752 * @param {*} value The value to search for. 9753 * @returns {number} Returns the index of the matched value, else `-1`. 9754 * @example 9755 * 9756 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); 9757 * // => 3 9758 */ 9759 function sortedLastIndexOf(array, value) { 9760 var length = array == null ? 0 : array.length; 9761 if (length) { 9762 var index = baseSortedIndex(array, value, true) - 1; 9763 if (eq(array[index], value)) { 9764 return index; 9765 } 9766 } 9767 return -1; 9768 } 9769 9770 /** 9771 * This method is like `_.uniq` except that it's designed and optimized 9772 * for sorted arrays. 9773 * 9774 * @static 9775 * @memberOf _ 9776 * @since 4.0.0 9777 * @category Array 9778 * @param {Array} array The array to inspect. 9779 * @returns {Array} Returns the new duplicate free array. 9780 * @example 9781 * 9782 * _.sortedUniq([1, 1, 2]); 9783 * // => [1, 2] 9784 */ 9785 function sortedUniq(array) { 9786 return (array && array.length) 9787 ? baseSortedUniq(array) 9788 : []; 9789 } 9790 9791 /** 9792 * This method is like `_.uniqBy` except that it's designed and optimized 9793 * for sorted arrays. 9794 * 9795 * @static 9796 * @memberOf _ 9797 * @since 4.0.0 9798 * @category Array 9799 * @param {Array} array The array to inspect. 9800 * @param {Function} [iteratee] The iteratee invoked per element. 9801 * @returns {Array} Returns the new duplicate free array. 9802 * @example 9803 * 9804 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); 9805 * // => [1.1, 2.3] 9806 */ 9807 function sortedUniqBy(array, iteratee) { 9808 return (array && array.length) 9809 ? baseSortedUniq(array, getIteratee(iteratee, 2)) 9810 : []; 9811 } 9812 9813 /** 9814 * Gets all but the first element of `array`. 9815 * 9816 * @static 9817 * @memberOf _ 9818 * @since 4.0.0 9819 * @category Array 9820 * @param {Array} array The array to query. 9821 * @returns {Array} Returns the slice of `array`. 9822 * @example 9823 * 9824 * _.tail([1, 2, 3]); 9825 * // => [2, 3] 9826 */ 9827 function tail(array) { 9828 var length = array == null ? 0 : array.length; 9829 return length ? baseSlice(array, 1, length) : []; 9830 } 9831 9832 /** 9833 * Creates a slice of `array` with `n` elements taken from the beginning. 9834 * 9835 * @static 9836 * @memberOf _ 9837 * @since 0.1.0 9838 * @category Array 9839 * @param {Array} array The array to query. 9840 * @param {number} [n=1] The number of elements to take. 9841 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9842 * @returns {Array} Returns the slice of `array`. 9843 * @example 9844 * 9845 * _.take([1, 2, 3]); 9846 * // => [1] 9847 * 9848 * _.take([1, 2, 3], 2); 9849 * // => [1, 2] 9850 * 9851 * _.take([1, 2, 3], 5); 9852 * // => [1, 2, 3] 9853 * 9854 * _.take([1, 2, 3], 0); 9855 * // => [] 9856 */ 9857 function take(array, n, guard) { 9858 if (!(array && array.length)) { 9859 return []; 9860 } 9861 n = (guard || n === undefined) ? 1 : toInteger(n); 9862 return baseSlice(array, 0, n < 0 ? 0 : n); 9863 } 9864 9865 /** 9866 * Creates a slice of `array` with `n` elements taken from the end. 9867 * 9868 * @static 9869 * @memberOf _ 9870 * @since 3.0.0 9871 * @category Array 9872 * @param {Array} array The array to query. 9873 * @param {number} [n=1] The number of elements to take. 9874 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9875 * @returns {Array} Returns the slice of `array`. 9876 * @example 9877 * 9878 * _.takeRight([1, 2, 3]); 9879 * // => [3] 9880 * 9881 * _.takeRight([1, 2, 3], 2); 9882 * // => [2, 3] 9883 * 9884 * _.takeRight([1, 2, 3], 5); 9885 * // => [1, 2, 3] 9886 * 9887 * _.takeRight([1, 2, 3], 0); 9888 * // => [] 9889 */ 9890 function takeRight(array, n, guard) { 9891 var length = array == null ? 0 : array.length; 9892 if (!length) { 9893 return []; 9894 } 9895 n = (guard || n === undefined) ? 1 : toInteger(n); 9896 n = length - n; 9897 return baseSlice(array, n < 0 ? 0 : n, length); 9898 } 9899 9900 /** 9901 * Creates a slice of `array` with elements taken from the end. Elements are 9902 * taken until `predicate` returns falsey. The predicate is invoked with 9903 * three arguments: (value, index, array). 9904 * 9905 * @static 9906 * @memberOf _ 9907 * @since 3.0.0 9908 * @category Array 9909 * @param {Array} array The array to query. 9910 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9911 * @returns {Array} Returns the slice of `array`. 9912 * @example 9913 * 9914 * var users = [ 9915 * { 'user': 'barney', 'active': true }, 9916 * { 'user': 'fred', 'active': false }, 9917 * { 'user': 'pebbles', 'active': false } 9918 * ]; 9919 * 9920 * _.takeRightWhile(users, function(o) { return !o.active; }); 9921 * // => objects for ['fred', 'pebbles'] 9922 * 9923 * // The `_.matches` iteratee shorthand. 9924 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); 9925 * // => objects for ['pebbles'] 9926 * 9927 * // The `_.matchesProperty` iteratee shorthand. 9928 * _.takeRightWhile(users, ['active', false]); 9929 * // => objects for ['fred', 'pebbles'] 9930 * 9931 * // The `_.property` iteratee shorthand. 9932 * _.takeRightWhile(users, 'active'); 9933 * // => [] 9934 */ 9935 function takeRightWhile(array, predicate) { 9936 return (array && array.length) 9937 ? baseWhile(array, getIteratee(predicate, 3), false, true) 9938 : []; 9939 } 9940 9941 /** 9942 * Creates a slice of `array` with elements taken from the beginning. Elements 9943 * are taken until `predicate` returns falsey. The predicate is invoked with 9944 * three arguments: (value, index, array). 9945 * 9946 * @static 9947 * @memberOf _ 9948 * @since 3.0.0 9949 * @category Array 9950 * @param {Array} array The array to query. 9951 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9952 * @returns {Array} Returns the slice of `array`. 9953 * @example 9954 * 9955 * var users = [ 9956 * { 'user': 'barney', 'active': false }, 9957 * { 'user': 'fred', 'active': false }, 9958 * { 'user': 'pebbles', 'active': true } 9959 * ]; 9960 * 9961 * _.takeWhile(users, function(o) { return !o.active; }); 9962 * // => objects for ['barney', 'fred'] 9963 * 9964 * // The `_.matches` iteratee shorthand. 9965 * _.takeWhile(users, { 'user': 'barney', 'active': false }); 9966 * // => objects for ['barney'] 9967 * 9968 * // The `_.matchesProperty` iteratee shorthand. 9969 * _.takeWhile(users, ['active', false]); 9970 * // => objects for ['barney', 'fred'] 9971 * 9972 * // The `_.property` iteratee shorthand. 9973 * _.takeWhile(users, 'active'); 9974 * // => [] 9975 */ 9976 function takeWhile(array, predicate) { 9977 return (array && array.length) 9978 ? baseWhile(array, getIteratee(predicate, 3)) 9979 : []; 9980 } 9981 9982 /** 9983 * Creates an array of unique values, in order, from all given arrays using 9984 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9985 * for equality comparisons. 9986 * 9987 * @static 9988 * @memberOf _ 9989 * @since 0.1.0 9990 * @category Array 9991 * @param {...Array} [arrays] The arrays to inspect. 9992 * @returns {Array} Returns the new array of combined values. 9993 * @example 9994 * 9995 * _.union([2], [1, 2]); 9996 * // => [2, 1] 9997 */ 9998 var union = baseRest(function(arrays) { 9999 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); 10000 }); 10001 10002 /** 10003 * This method is like `_.union` except that it accepts `iteratee` which is 10004 * invoked for each element of each `arrays` to generate the criterion by 10005 * which uniqueness is computed. Result values are chosen from the first 10006 * array in which the value occurs. The iteratee is invoked with one argument: 10007 * (value). 10008 * 10009 * @static 10010 * @memberOf _ 10011 * @since 4.0.0 10012 * @category Array 10013 * @param {...Array} [arrays] The arrays to inspect. 10014 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10015 * @returns {Array} Returns the new array of combined values. 10016 * @example 10017 * 10018 * _.unionBy([2.1], [1.2, 2.3], Math.floor); 10019 * // => [2.1, 1.2] 10020 * 10021 * // The `_.property` iteratee shorthand. 10022 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 10023 * // => [{ 'x': 1 }, { 'x': 2 }] 10024 */ 10025 var unionBy = baseRest(function(arrays) { 10026 var iteratee = last(arrays); 10027 if (isArrayLikeObject(iteratee)) { 10028 iteratee = undefined; 10029 } 10030 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); 10031 }); 10032 10033 /** 10034 * This method is like `_.union` except that it accepts `comparator` which 10035 * is invoked to compare elements of `arrays`. Result values are chosen from 10036 * the first array in which the value occurs. The comparator is invoked 10037 * with two arguments: (arrVal, othVal). 10038 * 10039 * @static 10040 * @memberOf _ 10041 * @since 4.0.0 10042 * @category Array 10043 * @param {...Array} [arrays] The arrays to inspect. 10044 * @param {Function} [comparator] The comparator invoked per element. 10045 * @returns {Array} Returns the new array of combined values. 10046 * @example 10047 * 10048 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 10049 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 10050 * 10051 * _.unionWith(objects, others, _.isEqual); 10052 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 10053 */ 10054 var unionWith = baseRest(function(arrays) { 10055 var comparator = last(arrays); 10056 comparator = typeof comparator == 'function' ? comparator : undefined; 10057 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); 10058 }); 10059 10060 /** 10061 * Creates a duplicate-free version of an array, using 10062 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 10063 * for equality comparisons, in which only the first occurrence of each element 10064 * is kept. The order of result values is determined by the order they occur 10065 * in the array. 10066 * 10067 * @static 10068 * @memberOf _ 10069 * @since 0.1.0 10070 * @category Array 10071 * @param {Array} array The array to inspect. 10072 * @returns {Array} Returns the new duplicate free array. 10073 * @example 10074 * 10075 * _.uniq([2, 1, 2]); 10076 * // => [2, 1] 10077 */ 10078 function uniq(array) { 10079 return (array && array.length) ? baseUniq(array) : []; 10080 } 10081 10082 /** 10083 * This method is like `_.uniq` except that it accepts `iteratee` which is 10084 * invoked for each element in `array` to generate the criterion by which 10085 * uniqueness is computed. The order of result values is determined by the 10086 * order they occur in the array. The iteratee is invoked with one argument: 10087 * (value). 10088 * 10089 * @static 10090 * @memberOf _ 10091 * @since 4.0.0 10092 * @category Array 10093 * @param {Array} array The array to inspect. 10094 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10095 * @returns {Array} Returns the new duplicate free array. 10096 * @example 10097 * 10098 * _.uniqBy([2.1, 1.2, 2.3], Math.floor); 10099 * // => [2.1, 1.2] 10100 * 10101 * // The `_.property` iteratee shorthand. 10102 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); 10103 * // => [{ 'x': 1 }, { 'x': 2 }] 10104 */ 10105 function uniqBy(array, iteratee) { 10106 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; 10107 } 10108 10109 /** 10110 * This method is like `_.uniq` except that it accepts `comparator` which 10111 * is invoked to compare elements of `array`. The order of result values is 10112 * determined by the order they occur in the array.The comparator is invoked 10113 * with two arguments: (arrVal, othVal). 10114 * 10115 * @static 10116 * @memberOf _ 10117 * @since 4.0.0 10118 * @category Array 10119 * @param {Array} array The array to inspect. 10120 * @param {Function} [comparator] The comparator invoked per element. 10121 * @returns {Array} Returns the new duplicate free array. 10122 * @example 10123 * 10124 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; 10125 * 10126 * _.uniqWith(objects, _.isEqual); 10127 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] 10128 */ 10129 function uniqWith(array, comparator) { 10130 comparator = typeof comparator == 'function' ? comparator : undefined; 10131 return (array && array.length) ? baseUniq(array, undefined, comparator) : []; 10132 } 10133 10134 /** 10135 * This method is like `_.zip` except that it accepts an array of grouped 10136 * elements and creates an array regrouping the elements to their pre-zip 10137 * configuration. 10138 * 10139 * @static 10140 * @memberOf _ 10141 * @since 1.2.0 10142 * @category Array 10143 * @param {Array} array The array of grouped elements to process. 10144 * @returns {Array} Returns the new array of regrouped elements. 10145 * @example 10146 * 10147 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); 10148 * // => [['a', 1, true], ['b', 2, false]] 10149 * 10150 * _.unzip(zipped); 10151 * // => [['a', 'b'], [1, 2], [true, false]] 10152 */ 10153 function unzip(array) { 10154 if (!(array && array.length)) { 10155 return []; 10156 } 10157 var length = 0; 10158 array = arrayFilter(array, function(group) { 10159 if (isArrayLikeObject(group)) { 10160 length = nativeMax(group.length, length); 10161 return true; 10162 } 10163 }); 10164 return baseTimes(length, function(index) { 10165 return arrayMap(array, baseProperty(index)); 10166 }); 10167 } 10168 10169 /** 10170 * This method is like `_.unzip` except that it accepts `iteratee` to specify 10171 * how regrouped values should be combined. The iteratee is invoked with the 10172 * elements of each group: (...group). 10173 * 10174 * @static 10175 * @memberOf _ 10176 * @since 3.8.0 10177 * @category Array 10178 * @param {Array} array The array of grouped elements to process. 10179 * @param {Function} [iteratee=_.identity] The function to combine 10180 * regrouped values. 10181 * @returns {Array} Returns the new array of regrouped elements. 10182 * @example 10183 * 10184 * var zipped = _.zip([1, 2], [10, 20], [100, 200]); 10185 * // => [[1, 10, 100], [2, 20, 200]] 10186 * 10187 * _.unzipWith(zipped, _.add); 10188 * // => [3, 30, 300] 10189 */ 10190 function unzipWith(array, iteratee) { 10191 if (!(array && array.length)) { 10192 return []; 10193 } 10194 var result = unzip(array); 10195 if (iteratee == null) { 10196 return result; 10197 } 10198 return arrayMap(result, function(group) { 10199 return apply(iteratee, undefined, group); 10200 }); 10201 } 10202 10203 /** 10204 * Creates an array excluding all given values using 10205 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 10206 * for equality comparisons. 10207 * 10208 * **Note:** Unlike `_.pull`, this method returns a new array. 10209 * 10210 * @static 10211 * @memberOf _ 10212 * @since 0.1.0 10213 * @category Array 10214 * @param {Array} array The array to inspect. 10215 * @param {...*} [values] The values to exclude. 10216 * @returns {Array} Returns the new array of filtered values. 10217 * @see _.difference, _.xor 10218 * @example 10219 * 10220 * _.without([2, 1, 2, 3], 1, 2); 10221 * // => [3] 10222 */ 10223 var without = baseRest(function(array, values) { 10224 return isArrayLikeObject(array) 10225 ? baseDifference(array, values) 10226 : []; 10227 }); 10228 10229 /** 10230 * Creates an array of unique values that is the 10231 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) 10232 * of the given arrays. The order of result values is determined by the order 10233 * they occur in the arrays. 10234 * 10235 * @static 10236 * @memberOf _ 10237 * @since 2.4.0 10238 * @category Array 10239 * @param {...Array} [arrays] The arrays to inspect. 10240 * @returns {Array} Returns the new array of filtered values. 10241 * @see _.difference, _.without 10242 * @example 10243 * 10244 * _.xor([2, 1], [2, 3]); 10245 * // => [1, 3] 10246 */ 10247 var xor = baseRest(function(arrays) { 10248 return baseXor(arrayFilter(arrays, isArrayLikeObject)); 10249 }); 10250 10251 /** 10252 * This method is like `_.xor` except that it accepts `iteratee` which is 10253 * invoked for each element of each `arrays` to generate the criterion by 10254 * which by which they're compared. The order of result values is determined 10255 * by the order they occur in the arrays. The iteratee is invoked with one 10256 * argument: (value). 10257 * 10258 * @static 10259 * @memberOf _ 10260 * @since 4.0.0 10261 * @category Array 10262 * @param {...Array} [arrays] The arrays to inspect. 10263 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10264 * @returns {Array} Returns the new array of filtered values. 10265 * @example 10266 * 10267 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); 10268 * // => [1.2, 3.4] 10269 * 10270 * // The `_.property` iteratee shorthand. 10271 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 10272 * // => [{ 'x': 2 }] 10273 */ 10274 var xorBy = baseRest(function(arrays) { 10275 var iteratee = last(arrays); 10276 if (isArrayLikeObject(iteratee)) { 10277 iteratee = undefined; 10278 } 10279 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); 10280 }); 10281 10282 /** 10283 * This method is like `_.xor` except that it accepts `comparator` which is 10284 * invoked to compare elements of `arrays`. The order of result values is 10285 * determined by the order they occur in the arrays. The comparator is invoked 10286 * with two arguments: (arrVal, othVal). 10287 * 10288 * @static 10289 * @memberOf _ 10290 * @since 4.0.0 10291 * @category Array 10292 * @param {...Array} [arrays] The arrays to inspect. 10293 * @param {Function} [comparator] The comparator invoked per element. 10294 * @returns {Array} Returns the new array of filtered values. 10295 * @example 10296 * 10297 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 10298 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 10299 * 10300 * _.xorWith(objects, others, _.isEqual); 10301 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 10302 */ 10303 var xorWith = baseRest(function(arrays) { 10304 var comparator = last(arrays); 10305 comparator = typeof comparator == 'function' ? comparator : undefined; 10306 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); 10307 }); 10308 10309 /** 10310 * Creates an array of grouped elements, the first of which contains the 10311 * first elements of the given arrays, the second of which contains the 10312 * second elements of the given arrays, and so on. 10313 * 10314 * @static 10315 * @memberOf _ 10316 * @since 0.1.0 10317 * @category Array 10318 * @param {...Array} [arrays] The arrays to process. 10319 * @returns {Array} Returns the new array of grouped elements. 10320 * @example 10321 * 10322 * _.zip(['a', 'b'], [1, 2], [true, false]); 10323 * // => [['a', 1, true], ['b', 2, false]] 10324 */ 10325 var zip = baseRest(unzip); 10326 10327 /** 10328 * This method is like `_.fromPairs` except that it accepts two arrays, 10329 * one of property identifiers and one of corresponding values. 10330 * 10331 * @static 10332 * @memberOf _ 10333 * @since 0.4.0 10334 * @category Array 10335 * @param {Array} [props=[]] The property identifiers. 10336 * @param {Array} [values=[]] The property values. 10337 * @returns {Object} Returns the new object. 10338 * @example 10339 * 10340 * _.zipObject(['a', 'b'], [1, 2]); 10341 * // => { 'a': 1, 'b': 2 } 10342 */ 10343 function zipObject(props, values) { 10344 return baseZipObject(props || [], values || [], assignValue); 10345 } 10346 10347 /** 10348 * This method is like `_.zipObject` except that it supports property paths. 10349 * 10350 * @static 10351 * @memberOf _ 10352 * @since 4.1.0 10353 * @category Array 10354 * @param {Array} [props=[]] The property identifiers. 10355 * @param {Array} [values=[]] The property values. 10356 * @returns {Object} Returns the new object. 10357 * @example 10358 * 10359 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); 10360 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } 10361 */ 10362 function zipObjectDeep(props, values) { 10363 return baseZipObject(props || [], values || [], baseSet); 10364 } 10365 10366 /** 10367 * This method is like `_.zip` except that it accepts `iteratee` to specify 10368 * how grouped values should be combined. The iteratee is invoked with the 10369 * elements of each group: (...group). 10370 * 10371 * @static 10372 * @memberOf _ 10373 * @since 3.8.0 10374 * @category Array 10375 * @param {...Array} [arrays] The arrays to process. 10376 * @param {Function} [iteratee=_.identity] The function to combine 10377 * grouped values. 10378 * @returns {Array} Returns the new array of grouped elements. 10379 * @example 10380 * 10381 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { 10382 * return a + b + c; 10383 * }); 10384 * // => [111, 222] 10385 */ 10386 var zipWith = baseRest(function(arrays) { 10387 var length = arrays.length, 10388 iteratee = length > 1 ? arrays[length - 1] : undefined; 10389 10390 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; 10391 return unzipWith(arrays, iteratee); 10392 }); 10393 10394 /*------------------------------------------------------------------------*/ 10395 10396 /** 10397 * Creates a `lodash` wrapper instance that wraps `value` with explicit method 10398 * chain sequences enabled. The result of such sequences must be unwrapped 10399 * with `_#value`. 10400 * 10401 * @static 10402 * @memberOf _ 10403 * @since 1.3.0 10404 * @category Seq 10405 * @param {*} value The value to wrap. 10406 * @returns {Object} Returns the new `lodash` wrapper instance. 10407 * @example 10408 * 10409 * var users = [ 10410 * { 'user': 'barney', 'age': 36 }, 10411 * { 'user': 'fred', 'age': 40 }, 10412 * { 'user': 'pebbles', 'age': 1 } 10413 * ]; 10414 * 10415 * var youngest = _ 10416 * .chain(users) 10417 * .sortBy('age') 10418 * .map(function(o) { 10419 * return o.user + ' is ' + o.age; 10420 * }) 10421 * .head() 10422 * .value(); 10423 * // => 'pebbles is 1' 10424 */ 10425 function chain(value) { 10426 var result = lodash(value); 10427 result.__chain__ = true; 10428 return result; 10429 } 10430 10431 /** 10432 * This method invokes `interceptor` and returns `value`. The interceptor 10433 * is invoked with one argument; (value). The purpose of this method is to 10434 * "tap into" a method chain sequence in order to modify intermediate results. 10435 * 10436 * @static 10437 * @memberOf _ 10438 * @since 0.1.0 10439 * @category Seq 10440 * @param {*} value The value to provide to `interceptor`. 10441 * @param {Function} interceptor The function to invoke. 10442 * @returns {*} Returns `value`. 10443 * @example 10444 * 10445 * _([1, 2, 3]) 10446 * .tap(function(array) { 10447 * // Mutate input array. 10448 * array.pop(); 10449 * }) 10450 * .reverse() 10451 * .value(); 10452 * // => [2, 1] 10453 */ 10454 function tap(value, interceptor) { 10455 interceptor(value); 10456 return value; 10457 } 10458 10459 /** 10460 * This method is like `_.tap` except that it returns the result of `interceptor`. 10461 * The purpose of this method is to "pass thru" values replacing intermediate 10462 * results in a method chain sequence. 10463 * 10464 * @static 10465 * @memberOf _ 10466 * @since 3.0.0 10467 * @category Seq 10468 * @param {*} value The value to provide to `interceptor`. 10469 * @param {Function} interceptor The function to invoke. 10470 * @returns {*} Returns the result of `interceptor`. 10471 * @example 10472 * 10473 * _(' abc ') 10474 * .chain() 10475 * .trim() 10476 * .thru(function(value) { 10477 * return [value]; 10478 * }) 10479 * .value(); 10480 * // => ['abc'] 10481 */ 10482 function thru(value, interceptor) { 10483 return interceptor(value); 10484 } 10485 10486 /** 10487 * This method is the wrapper version of `_.at`. 10488 * 10489 * @name at 10490 * @memberOf _ 10491 * @since 1.0.0 10492 * @category Seq 10493 * @param {...(string|string[])} [paths] The property paths to pick. 10494 * @returns {Object} Returns the new `lodash` wrapper instance. 10495 * @example 10496 * 10497 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 10498 * 10499 * _(object).at(['a[0].b.c', 'a[1]']).value(); 10500 * // => [3, 4] 10501 */ 10502 var wrapperAt = flatRest(function(paths) { 10503 var length = paths.length, 10504 start = length ? paths[0] : 0, 10505 value = this.__wrapped__, 10506 interceptor = function(object) { return baseAt(object, paths); }; 10507 10508 if (length > 1 || this.__actions__.length || 10509 !(value instanceof LazyWrapper) || !isIndex(start)) { 10510 return this.thru(interceptor); 10511 } 10512 value = value.slice(start, +start + (length ? 1 : 0)); 10513 value.__actions__.push({ 10514 'func': thru, 10515 'args': [interceptor], 10516 'thisArg': undefined 10517 }); 10518 return new LodashWrapper(value, this.__chain__).thru(function(array) { 10519 if (length && !array.length) { 10520 array.push(undefined); 10521 } 10522 return array; 10523 }); 10524 }); 10525 10526 /** 10527 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. 10528 * 10529 * @name chain 10530 * @memberOf _ 10531 * @since 0.1.0 10532 * @category Seq 10533 * @returns {Object} Returns the new `lodash` wrapper instance. 10534 * @example 10535 * 10536 * var users = [ 10537 * { 'user': 'barney', 'age': 36 }, 10538 * { 'user': 'fred', 'age': 40 } 10539 * ]; 10540 * 10541 * // A sequence without explicit chaining. 10542 * _(users).head(); 10543 * // => { 'user': 'barney', 'age': 36 } 10544 * 10545 * // A sequence with explicit chaining. 10546 * _(users) 10547 * .chain() 10548 * .head() 10549 * .pick('user') 10550 * .value(); 10551 * // => { 'user': 'barney' } 10552 */ 10553 function wrapperChain() { 10554 return chain(this); 10555 } 10556 10557 /** 10558 * Executes the chain sequence and returns the wrapped result. 10559 * 10560 * @name commit 10561 * @memberOf _ 10562 * @since 3.2.0 10563 * @category Seq 10564 * @returns {Object} Returns the new `lodash` wrapper instance. 10565 * @example 10566 * 10567 * var array = [1, 2]; 10568 * var wrapped = _(array).push(3); 10569 * 10570 * console.log(array); 10571 * // => [1, 2] 10572 * 10573 * wrapped = wrapped.commit(); 10574 * console.log(array); 10575 * // => [1, 2, 3] 10576 * 10577 * wrapped.last(); 10578 * // => 3 10579 * 10580 * console.log(array); 10581 * // => [1, 2, 3] 10582 */ 10583 function wrapperCommit() { 10584 return new LodashWrapper(this.value(), this.__chain__); 10585 } 10586 10587 /** 10588 * Gets the next value on a wrapped object following the 10589 * [iterator protocol](https://mdn.io/iteration_protocols#iterator). 10590 * 10591 * @name next 10592 * @memberOf _ 10593 * @since 4.0.0 10594 * @category Seq 10595 * @returns {Object} Returns the next iterator value. 10596 * @example 10597 * 10598 * var wrapped = _([1, 2]); 10599 * 10600 * wrapped.next(); 10601 * // => { 'done': false, 'value': 1 } 10602 * 10603 * wrapped.next(); 10604 * // => { 'done': false, 'value': 2 } 10605 * 10606 * wrapped.next(); 10607 * // => { 'done': true, 'value': undefined } 10608 */ 10609 function wrapperNext() { 10610 if (this.__values__ === undefined) { 10611 this.__values__ = toArray(this.value()); 10612 } 10613 var done = this.__index__ >= this.__values__.length, 10614 value = done ? undefined : this.__values__[this.__index__++]; 10615 10616 return { 'done': done, 'value': value }; 10617 } 10618 10619 /** 10620 * Enables the wrapper to be iterable. 10621 * 10622 * @name Symbol.iterator 10623 * @memberOf _ 10624 * @since 4.0.0 10625 * @category Seq 10626 * @returns {Object} Returns the wrapper object. 10627 * @example 10628 * 10629 * var wrapped = _([1, 2]); 10630 * 10631 * wrapped[Symbol.iterator]() === wrapped; 10632 * // => true 10633 * 10634 * Array.from(wrapped); 10635 * // => [1, 2] 10636 */ 10637 function wrapperToIterator() { 10638 return this; 10639 } 10640 10641 /** 10642 * Creates a clone of the chain sequence planting `value` as the wrapped value. 10643 * 10644 * @name plant 10645 * @memberOf _ 10646 * @since 3.2.0 10647 * @category Seq 10648 * @param {*} value The value to plant. 10649 * @returns {Object} Returns the new `lodash` wrapper instance. 10650 * @example 10651 * 10652 * function square(n) { 10653 * return n * n; 10654 * } 10655 * 10656 * var wrapped = _([1, 2]).map(square); 10657 * var other = wrapped.plant([3, 4]); 10658 * 10659 * other.value(); 10660 * // => [9, 16] 10661 * 10662 * wrapped.value(); 10663 * // => [1, 4] 10664 */ 10665 function wrapperPlant(value) { 10666 var result, 10667 parent = this; 10668 10669 while (parent instanceof baseLodash) { 10670 var clone = wrapperClone(parent); 10671 clone.__index__ = 0; 10672 clone.__values__ = undefined; 10673 if (result) { 10674 previous.__wrapped__ = clone; 10675 } else { 10676 result = clone; 10677 } 10678 var previous = clone; 10679 parent = parent.__wrapped__; 10680 } 10681 previous.__wrapped__ = value; 10682 return result; 10683 } 10684 10685 /** 10686 * This method is the wrapper version of `_.reverse`. 10687 * 10688 * **Note:** This method mutates the wrapped array. 10689 * 10690 * @name reverse 10691 * @memberOf _ 10692 * @since 0.1.0 10693 * @category Seq 10694 * @returns {Object} Returns the new `lodash` wrapper instance. 10695 * @example 10696 * 10697 * var array = [1, 2, 3]; 10698 * 10699 * _(array).reverse().value() 10700 * // => [3, 2, 1] 10701 * 10702 * console.log(array); 10703 * // => [3, 2, 1] 10704 */ 10705 function wrapperReverse() { 10706 var value = this.__wrapped__; 10707 if (value instanceof LazyWrapper) { 10708 var wrapped = value; 10709 if (this.__actions__.length) { 10710 wrapped = new LazyWrapper(this); 10711 } 10712 wrapped = wrapped.reverse(); 10713 wrapped.__actions__.push({ 10714 'func': thru, 10715 'args': [reverse], 10716 'thisArg': undefined 10717 }); 10718 return new LodashWrapper(wrapped, this.__chain__); 10719 } 10720 return this.thru(reverse); 10721 } 10722 10723 /** 10724 * Executes the chain sequence to resolve the unwrapped value. 10725 * 10726 * @name value 10727 * @memberOf _ 10728 * @since 0.1.0 10729 * @alias toJSON, valueOf 10730 * @category Seq 10731 * @returns {*} Returns the resolved unwrapped value. 10732 * @example 10733 * 10734 * _([1, 2, 3]).value(); 10735 * // => [1, 2, 3] 10736 */ 10737 function wrapperValue() { 10738 return baseWrapperValue(this.__wrapped__, this.__actions__); 10739 } 10740 10741 /*------------------------------------------------------------------------*/ 10742 10743 /** 10744 * Creates an object composed of keys generated from the results of running 10745 * each element of `collection` thru `iteratee`. The corresponding value of 10746 * each key is the number of times the key was returned by `iteratee`. The 10747 * iteratee is invoked with one argument: (value). 10748 * 10749 * @static 10750 * @memberOf _ 10751 * @since 0.5.0 10752 * @category Collection 10753 * @param {Array|Object} collection The collection to iterate over. 10754 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 10755 * @returns {Object} Returns the composed aggregate object. 10756 * @example 10757 * 10758 * _.countBy([6.1, 4.2, 6.3], Math.floor); 10759 * // => { '4': 1, '6': 2 } 10760 * 10761 * // The `_.property` iteratee shorthand. 10762 * _.countBy(['one', 'two', 'three'], 'length'); 10763 * // => { '3': 2, '5': 1 } 10764 */ 10765 var countBy = createAggregator(function(result, value, key) { 10766 if (hasOwnProperty.call(result, key)) { 10767 ++result[key]; 10768 } else { 10769 baseAssignValue(result, key, 1); 10770 } 10771 }); 10772 10773 /** 10774 * Checks if `predicate` returns truthy for **all** elements of `collection`. 10775 * Iteration is stopped once `predicate` returns falsey. The predicate is 10776 * invoked with three arguments: (value, index|key, collection). 10777 * 10778 * **Note:** This method returns `true` for 10779 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because 10780 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of 10781 * elements of empty collections. 10782 * 10783 * @static 10784 * @memberOf _ 10785 * @since 0.1.0 10786 * @category Collection 10787 * @param {Array|Object} collection The collection to iterate over. 10788 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10789 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 10790 * @returns {boolean} Returns `true` if all elements pass the predicate check, 10791 * else `false`. 10792 * @example 10793 * 10794 * _.every([true, 1, null, 'yes'], Boolean); 10795 * // => false 10796 * 10797 * var users = [ 10798 * { 'user': 'barney', 'age': 36, 'active': false }, 10799 * { 'user': 'fred', 'age': 40, 'active': false } 10800 * ]; 10801 * 10802 * // The `_.matches` iteratee shorthand. 10803 * _.every(users, { 'user': 'barney', 'active': false }); 10804 * // => false 10805 * 10806 * // The `_.matchesProperty` iteratee shorthand. 10807 * _.every(users, ['active', false]); 10808 * // => true 10809 * 10810 * // The `_.property` iteratee shorthand. 10811 * _.every(users, 'active'); 10812 * // => false 10813 */ 10814 function every(collection, predicate, guard) { 10815 var func = isArray(collection) ? arrayEvery : baseEvery; 10816 if (guard && isIterateeCall(collection, predicate, guard)) { 10817 predicate = undefined; 10818 } 10819 return func(collection, getIteratee(predicate, 3)); 10820 } 10821 10822 /** 10823 * Iterates over elements of `collection`, returning an array of all elements 10824 * `predicate` returns truthy for. The predicate is invoked with three 10825 * arguments: (value, index|key, collection). 10826 * 10827 * **Note:** Unlike `_.remove`, this method returns a new array. 10828 * 10829 * @static 10830 * @memberOf _ 10831 * @since 0.1.0 10832 * @category Collection 10833 * @param {Array|Object} collection The collection to iterate over. 10834 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10835 * @returns {Array} Returns the new filtered array. 10836 * @see _.reject 10837 * @example 10838 * 10839 * var users = [ 10840 * { 'user': 'barney', 'age': 36, 'active': true }, 10841 * { 'user': 'fred', 'age': 40, 'active': false } 10842 * ]; 10843 * 10844 * _.filter(users, function(o) { return !o.active; }); 10845 * // => objects for ['fred'] 10846 * 10847 * // The `_.matches` iteratee shorthand. 10848 * _.filter(users, { 'age': 36, 'active': true }); 10849 * // => objects for ['barney'] 10850 * 10851 * // The `_.matchesProperty` iteratee shorthand. 10852 * _.filter(users, ['active', false]); 10853 * // => objects for ['fred'] 10854 * 10855 * // The `_.property` iteratee shorthand. 10856 * _.filter(users, 'active'); 10857 * // => objects for ['barney'] 10858 */ 10859 function filter(collection, predicate) { 10860 var func = isArray(collection) ? arrayFilter : baseFilter; 10861 return func(collection, getIteratee(predicate, 3)); 10862 } 10863 10864 /** 10865 * Iterates over elements of `collection`, returning the first element 10866 * `predicate` returns truthy for. The predicate is invoked with three 10867 * arguments: (value, index|key, collection). 10868 * 10869 * @static 10870 * @memberOf _ 10871 * @since 0.1.0 10872 * @category Collection 10873 * @param {Array|Object} collection The collection to inspect. 10874 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10875 * @param {number} [fromIndex=0] The index to search from. 10876 * @returns {*} Returns the matched element, else `undefined`. 10877 * @example 10878 * 10879 * var users = [ 10880 * { 'user': 'barney', 'age': 36, 'active': true }, 10881 * { 'user': 'fred', 'age': 40, 'active': false }, 10882 * { 'user': 'pebbles', 'age': 1, 'active': true } 10883 * ]; 10884 * 10885 * _.find(users, function(o) { return o.age < 40; }); 10886 * // => object for 'barney' 10887 * 10888 * // The `_.matches` iteratee shorthand. 10889 * _.find(users, { 'age': 1, 'active': true }); 10890 * // => object for 'pebbles' 10891 * 10892 * // The `_.matchesProperty` iteratee shorthand. 10893 * _.find(users, ['active', false]); 10894 * // => object for 'fred' 10895 * 10896 * // The `_.property` iteratee shorthand. 10897 * _.find(users, 'active'); 10898 * // => object for 'barney' 10899 */ 10900 var find = createFind(findIndex); 10901 10902 /** 10903 * This method is like `_.find` except that it iterates over elements of 10904 * `collection` from right to left. 10905 * 10906 * @static 10907 * @memberOf _ 10908 * @since 2.0.0 10909 * @category Collection 10910 * @param {Array|Object} collection The collection to inspect. 10911 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10912 * @param {number} [fromIndex=collection.length-1] The index to search from. 10913 * @returns {*} Returns the matched element, else `undefined`. 10914 * @example 10915 * 10916 * _.findLast([1, 2, 3, 4], function(n) { 10917 * return n % 2 == 1; 10918 * }); 10919 * // => 3 10920 */ 10921 var findLast = createFind(findLastIndex); 10922 10923 /** 10924 * Creates a flattened array of values by running each element in `collection` 10925 * thru `iteratee` and flattening the mapped results. The iteratee is invoked 10926 * with three arguments: (value, index|key, collection). 10927 * 10928 * @static 10929 * @memberOf _ 10930 * @since 4.0.0 10931 * @category Collection 10932 * @param {Array|Object} collection The collection to iterate over. 10933 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 10934 * @returns {Array} Returns the new flattened array. 10935 * @example 10936 * 10937 * function duplicate(n) { 10938 * return [n, n]; 10939 * } 10940 * 10941 * _.flatMap([1, 2], duplicate); 10942 * // => [1, 1, 2, 2] 10943 */ 10944 function flatMap(collection, iteratee) { 10945 return baseFlatten(map(collection, iteratee), 1); 10946 } 10947 10948 /** 10949 * This method is like `_.flatMap` except that it recursively flattens the 10950 * mapped results. 10951 * 10952 * @static 10953 * @memberOf _ 10954 * @since 4.7.0 10955 * @category Collection 10956 * @param {Array|Object} collection The collection to iterate over. 10957 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 10958 * @returns {Array} Returns the new flattened array. 10959 * @example 10960 * 10961 * function duplicate(n) { 10962 * return [[[n, n]]]; 10963 * } 10964 * 10965 * _.flatMapDeep([1, 2], duplicate); 10966 * // => [1, 1, 2, 2] 10967 */ 10968 function flatMapDeep(collection, iteratee) { 10969 return baseFlatten(map(collection, iteratee), INFINITY); 10970 } 10971 10972 /** 10973 * This method is like `_.flatMap` except that it recursively flattens the 10974 * mapped results up to `depth` times. 10975 * 10976 * @static 10977 * @memberOf _ 10978 * @since 4.7.0 10979 * @category Collection 10980 * @param {Array|Object} collection The collection to iterate over. 10981 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 10982 * @param {number} [depth=1] The maximum recursion depth. 10983 * @returns {Array} Returns the new flattened array. 10984 * @example 10985 * 10986 * function duplicate(n) { 10987 * return [[[n, n]]]; 10988 * } 10989 * 10990 * _.flatMapDepth([1, 2], duplicate, 2); 10991 * // => [[1, 1], [2, 2]] 10992 */ 10993 function flatMapDepth(collection, iteratee, depth) { 10994 depth = depth === undefined ? 1 : toInteger(depth); 10995 return baseFlatten(map(collection, iteratee), depth); 10996 } 10997 10998 /** 10999 * Iterates over elements of `collection` and invokes `iteratee` for each element. 11000 * The iteratee is invoked with three arguments: (value, index|key, collection). 11001 * Iteratee functions may exit iteration early by explicitly returning `false`. 11002 * 11003 * **Note:** As with other "Collections" methods, objects with a "length" 11004 * property are iterated like arrays. To avoid this behavior use `_.forIn` 11005 * or `_.forOwn` for object iteration. 11006 * 11007 * @static 11008 * @memberOf _ 11009 * @since 0.1.0 11010 * @alias each 11011 * @category Collection 11012 * @param {Array|Object} collection The collection to iterate over. 11013 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11014 * @returns {Array|Object} Returns `collection`. 11015 * @see _.forEachRight 11016 * @example 11017 * 11018 * _.forEach([1, 2], function(value) { 11019 * console.log(value); 11020 * }); 11021 * // => Logs `1` then `2`. 11022 * 11023 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 11024 * console.log(key); 11025 * }); 11026 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 11027 */ 11028 function forEach(collection, iteratee) { 11029 var func = isArray(collection) ? arrayEach : baseEach; 11030 return func(collection, getIteratee(iteratee, 3)); 11031 } 11032 11033 /** 11034 * This method is like `_.forEach` except that it iterates over elements of 11035 * `collection` from right to left. 11036 * 11037 * @static 11038 * @memberOf _ 11039 * @since 2.0.0 11040 * @alias eachRight 11041 * @category Collection 11042 * @param {Array|Object} collection The collection to iterate over. 11043 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11044 * @returns {Array|Object} Returns `collection`. 11045 * @see _.forEach 11046 * @example 11047 * 11048 * _.forEachRight([1, 2], function(value) { 11049 * console.log(value); 11050 * }); 11051 * // => Logs `2` then `1`. 11052 */ 11053 function forEachRight(collection, iteratee) { 11054 var func = isArray(collection) ? arrayEachRight : baseEachRight; 11055 return func(collection, getIteratee(iteratee, 3)); 11056 } 11057 11058 /** 11059 * Creates an object composed of keys generated from the results of running 11060 * each element of `collection` thru `iteratee`. The order of grouped values 11061 * is determined by the order they occur in `collection`. The corresponding 11062 * value of each key is an array of elements responsible for generating the 11063 * key. The iteratee is invoked with one argument: (value). 11064 * 11065 * @static 11066 * @memberOf _ 11067 * @since 0.1.0 11068 * @category Collection 11069 * @param {Array|Object} collection The collection to iterate over. 11070 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 11071 * @returns {Object} Returns the composed aggregate object. 11072 * @example 11073 * 11074 * _.groupBy([6.1, 4.2, 6.3], Math.floor); 11075 * // => { '4': [4.2], '6': [6.1, 6.3] } 11076 * 11077 * // The `_.property` iteratee shorthand. 11078 * _.groupBy(['one', 'two', 'three'], 'length'); 11079 * // => { '3': ['one', 'two'], '5': ['three'] } 11080 */ 11081 var groupBy = createAggregator(function(result, value, key) { 11082 if (hasOwnProperty.call(result, key)) { 11083 result[key].push(value); 11084 } else { 11085 baseAssignValue(result, key, [value]); 11086 } 11087 }); 11088 11089 /** 11090 * Checks if `value` is in `collection`. If `collection` is a string, it's 11091 * checked for a substring of `value`, otherwise 11092 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 11093 * is used for equality comparisons. If `fromIndex` is negative, it's used as 11094 * the offset from the end of `collection`. 11095 * 11096 * @static 11097 * @memberOf _ 11098 * @since 0.1.0 11099 * @category Collection 11100 * @param {Array|Object|string} collection The collection to inspect. 11101 * @param {*} value The value to search for. 11102 * @param {number} [fromIndex=0] The index to search from. 11103 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 11104 * @returns {boolean} Returns `true` if `value` is found, else `false`. 11105 * @example 11106 * 11107 * _.includes([1, 2, 3], 1); 11108 * // => true 11109 * 11110 * _.includes([1, 2, 3], 1, 2); 11111 * // => false 11112 * 11113 * _.includes({ 'a': 1, 'b': 2 }, 1); 11114 * // => true 11115 * 11116 * _.includes('abcd', 'bc'); 11117 * // => true 11118 */ 11119 function includes(collection, value, fromIndex, guard) { 11120 collection = isArrayLike(collection) ? collection : values(collection); 11121 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; 11122 11123 var length = collection.length; 11124 if (fromIndex < 0) { 11125 fromIndex = nativeMax(length + fromIndex, 0); 11126 } 11127 return isString(collection) 11128 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) 11129 : (!!length && baseIndexOf(collection, value, fromIndex) > -1); 11130 } 11131 11132 /** 11133 * Invokes the method at `path` of each element in `collection`, returning 11134 * an array of the results of each invoked method. Any additional arguments 11135 * are provided to each invoked method. If `path` is a function, it's invoked 11136 * for, and `this` bound to, each element in `collection`. 11137 * 11138 * @static 11139 * @memberOf _ 11140 * @since 4.0.0 11141 * @category Collection 11142 * @param {Array|Object} collection The collection to iterate over. 11143 * @param {Array|Function|string} path The path of the method to invoke or 11144 * the function invoked per iteration. 11145 * @param {...*} [args] The arguments to invoke each method with. 11146 * @returns {Array} Returns the array of results. 11147 * @example 11148 * 11149 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); 11150 * // => [[1, 5, 7], [1, 2, 3]] 11151 * 11152 * _.invokeMap([123, 456], String.prototype.split, ''); 11153 * // => [['1', '2', '3'], ['4', '5', '6']] 11154 */ 11155 var invokeMap = baseRest(function(collection, path, args) { 11156 var index = -1, 11157 isFunc = typeof path == 'function', 11158 result = isArrayLike(collection) ? Array(collection.length) : []; 11159 11160 baseEach(collection, function(value) { 11161 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); 11162 }); 11163 return result; 11164 }); 11165 11166 /** 11167 * Creates an object composed of keys generated from the results of running 11168 * each element of `collection` thru `iteratee`. The corresponding value of 11169 * each key is the last element responsible for generating the key. The 11170 * iteratee is invoked with one argument: (value). 11171 * 11172 * @static 11173 * @memberOf _ 11174 * @since 4.0.0 11175 * @category Collection 11176 * @param {Array|Object} collection The collection to iterate over. 11177 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 11178 * @returns {Object} Returns the composed aggregate object. 11179 * @example 11180 * 11181 * var array = [ 11182 * { 'dir': 'left', 'code': 97 }, 11183 * { 'dir': 'right', 'code': 100 } 11184 * ]; 11185 * 11186 * _.keyBy(array, function(o) { 11187 * return String.fromCharCode(o.code); 11188 * }); 11189 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } 11190 * 11191 * _.keyBy(array, 'dir'); 11192 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } 11193 */ 11194 var keyBy = createAggregator(function(result, value, key) { 11195 baseAssignValue(result, key, value); 11196 }); 11197 11198 /** 11199 * Creates an array of values by running each element in `collection` thru 11200 * `iteratee`. The iteratee is invoked with three arguments: 11201 * (value, index|key, collection). 11202 * 11203 * Many lodash methods are guarded to work as iteratees for methods like 11204 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. 11205 * 11206 * The guarded methods are: 11207 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, 11208 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, 11209 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, 11210 * `template`, `trim`, `trimEnd`, `trimStart`, and `words` 11211 * 11212 * @static 11213 * @memberOf _ 11214 * @since 0.1.0 11215 * @category Collection 11216 * @param {Array|Object} collection The collection to iterate over. 11217 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11218 * @returns {Array} Returns the new mapped array. 11219 * @example 11220 * 11221 * function square(n) { 11222 * return n * n; 11223 * } 11224 * 11225 * _.map([4, 8], square); 11226 * // => [16, 64] 11227 * 11228 * _.map({ 'a': 4, 'b': 8 }, square); 11229 * // => [16, 64] (iteration order is not guaranteed) 11230 * 11231 * var users = [ 11232 * { 'user': 'barney' }, 11233 * { 'user': 'fred' } 11234 * ]; 11235 * 11236 * // The `_.property` iteratee shorthand. 11237 * _.map(users, 'user'); 11238 * // => ['barney', 'fred'] 11239 */ 11240 function map(collection, iteratee) { 11241 var func = isArray(collection) ? arrayMap : baseMap; 11242 return func(collection, getIteratee(iteratee, 3)); 11243 } 11244 11245 /** 11246 * This method is like `_.sortBy` except that it allows specifying the sort 11247 * orders of the iteratees to sort by. If `orders` is unspecified, all values 11248 * are sorted in ascending order. Otherwise, specify an order of "desc" for 11249 * descending or "asc" for ascending sort order of corresponding values. 11250 * 11251 * @static 11252 * @memberOf _ 11253 * @since 4.0.0 11254 * @category Collection 11255 * @param {Array|Object} collection The collection to iterate over. 11256 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] 11257 * The iteratees to sort by. 11258 * @param {string[]} [orders] The sort orders of `iteratees`. 11259 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 11260 * @returns {Array} Returns the new sorted array. 11261 * @example 11262 * 11263 * var users = [ 11264 * { 'user': 'fred', 'age': 48 }, 11265 * { 'user': 'barney', 'age': 34 }, 11266 * { 'user': 'fred', 'age': 40 }, 11267 * { 'user': 'barney', 'age': 36 } 11268 * ]; 11269 * 11270 * // Sort by `user` in ascending order and by `age` in descending order. 11271 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); 11272 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 11273 */ 11274 function orderBy(collection, iteratees, orders, guard) { 11275 if (collection == null) { 11276 return []; 11277 } 11278 if (!isArray(iteratees)) { 11279 iteratees = iteratees == null ? [] : [iteratees]; 11280 } 11281 orders = guard ? undefined : orders; 11282 if (!isArray(orders)) { 11283 orders = orders == null ? [] : [orders]; 11284 } 11285 return baseOrderBy(collection, iteratees, orders); 11286 } 11287 11288 /** 11289 * Creates an array of elements split into two groups, the first of which 11290 * contains elements `predicate` returns truthy for, the second of which 11291 * contains elements `predicate` returns falsey for. The predicate is 11292 * invoked with one argument: (value). 11293 * 11294 * @static 11295 * @memberOf _ 11296 * @since 3.0.0 11297 * @category Collection 11298 * @param {Array|Object} collection The collection to iterate over. 11299 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11300 * @returns {Array} Returns the array of grouped elements. 11301 * @example 11302 * 11303 * var users = [ 11304 * { 'user': 'barney', 'age': 36, 'active': false }, 11305 * { 'user': 'fred', 'age': 40, 'active': true }, 11306 * { 'user': 'pebbles', 'age': 1, 'active': false } 11307 * ]; 11308 * 11309 * _.partition(users, function(o) { return o.active; }); 11310 * // => objects for [['fred'], ['barney', 'pebbles']] 11311 * 11312 * // The `_.matches` iteratee shorthand. 11313 * _.partition(users, { 'age': 1, 'active': false }); 11314 * // => objects for [['pebbles'], ['barney', 'fred']] 11315 * 11316 * // The `_.matchesProperty` iteratee shorthand. 11317 * _.partition(users, ['active', false]); 11318 * // => objects for [['barney', 'pebbles'], ['fred']] 11319 * 11320 * // The `_.property` iteratee shorthand. 11321 * _.partition(users, 'active'); 11322 * // => objects for [['fred'], ['barney', 'pebbles']] 11323 */ 11324 var partition = createAggregator(function(result, value, key) { 11325 result[key ? 0 : 1].push(value); 11326 }, function() { return [[], []]; }); 11327 11328 /** 11329 * Reduces `collection` to a value which is the accumulated result of running 11330 * each element in `collection` thru `iteratee`, where each successive 11331 * invocation is supplied the return value of the previous. If `accumulator` 11332 * is not given, the first element of `collection` is used as the initial 11333 * value. The iteratee is invoked with four arguments: 11334 * (accumulator, value, index|key, collection). 11335 * 11336 * Many lodash methods are guarded to work as iteratees for methods like 11337 * `_.reduce`, `_.reduceRight`, and `_.transform`. 11338 * 11339 * The guarded methods are: 11340 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, 11341 * and `sortBy` 11342 * 11343 * @static 11344 * @memberOf _ 11345 * @since 0.1.0 11346 * @category Collection 11347 * @param {Array|Object} collection The collection to iterate over. 11348 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11349 * @param {*} [accumulator] The initial value. 11350 * @returns {*} Returns the accumulated value. 11351 * @see _.reduceRight 11352 * @example 11353 * 11354 * _.reduce([1, 2], function(sum, n) { 11355 * return sum + n; 11356 * }, 0); 11357 * // => 3 11358 * 11359 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 11360 * (result[value] || (result[value] = [])).push(key); 11361 * return result; 11362 * }, {}); 11363 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) 11364 */ 11365 function reduce(collection, iteratee, accumulator) { 11366 var func = isArray(collection) ? arrayReduce : baseReduce, 11367 initAccum = arguments.length < 3; 11368 11369 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); 11370 } 11371 11372 /** 11373 * This method is like `_.reduce` except that it iterates over elements of 11374 * `collection` from right to left. 11375 * 11376 * @static 11377 * @memberOf _ 11378 * @since 0.1.0 11379 * @category Collection 11380 * @param {Array|Object} collection The collection to iterate over. 11381 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11382 * @param {*} [accumulator] The initial value. 11383 * @returns {*} Returns the accumulated value. 11384 * @see _.reduce 11385 * @example 11386 * 11387 * var array = [[0, 1], [2, 3], [4, 5]]; 11388 * 11389 * _.reduceRight(array, function(flattened, other) { 11390 * return flattened.concat(other); 11391 * }, []); 11392 * // => [4, 5, 2, 3, 0, 1] 11393 */ 11394 function reduceRight(collection, iteratee, accumulator) { 11395 var func = isArray(collection) ? arrayReduceRight : baseReduce, 11396 initAccum = arguments.length < 3; 11397 11398 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); 11399 } 11400 11401 /** 11402 * The opposite of `_.filter`; this method returns the elements of `collection` 11403 * that `predicate` does **not** return truthy for. 11404 * 11405 * @static 11406 * @memberOf _ 11407 * @since 0.1.0 11408 * @category Collection 11409 * @param {Array|Object} collection The collection to iterate over. 11410 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11411 * @returns {Array} Returns the new filtered array. 11412 * @see _.filter 11413 * @example 11414 * 11415 * var users = [ 11416 * { 'user': 'barney', 'age': 36, 'active': false }, 11417 * { 'user': 'fred', 'age': 40, 'active': true } 11418 * ]; 11419 * 11420 * _.reject(users, function(o) { return !o.active; }); 11421 * // => objects for ['fred'] 11422 * 11423 * // The `_.matches` iteratee shorthand. 11424 * _.reject(users, { 'age': 40, 'active': true }); 11425 * // => objects for ['barney'] 11426 * 11427 * // The `_.matchesProperty` iteratee shorthand. 11428 * _.reject(users, ['active', false]); 11429 * // => objects for ['fred'] 11430 * 11431 * // The `_.property` iteratee shorthand. 11432 * _.reject(users, 'active'); 11433 * // => objects for ['barney'] 11434 */ 11435 function reject(collection, predicate) { 11436 var func = isArray(collection) ? arrayFilter : baseFilter; 11437 return func(collection, negate(getIteratee(predicate, 3))); 11438 } 11439 11440 /** 11441 * Gets a random element from `collection`. 11442 * 11443 * @static 11444 * @memberOf _ 11445 * @since 2.0.0 11446 * @category Collection 11447 * @param {Array|Object} collection The collection to sample. 11448 * @returns {*} Returns the random element. 11449 * @example 11450 * 11451 * _.sample([1, 2, 3, 4]); 11452 * // => 2 11453 */ 11454 function sample(collection) { 11455 var func = isArray(collection) ? arraySample : baseSample; 11456 return func(collection); 11457 } 11458 11459 /** 11460 * Gets `n` random elements at unique keys from `collection` up to the 11461 * size of `collection`. 11462 * 11463 * @static 11464 * @memberOf _ 11465 * @since 4.0.0 11466 * @category Collection 11467 * @param {Array|Object} collection The collection to sample. 11468 * @param {number} [n=1] The number of elements to sample. 11469 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 11470 * @returns {Array} Returns the random elements. 11471 * @example 11472 * 11473 * _.sampleSize([1, 2, 3], 2); 11474 * // => [3, 1] 11475 * 11476 * _.sampleSize([1, 2, 3], 4); 11477 * // => [2, 3, 1] 11478 */ 11479 function sampleSize(collection, n, guard) { 11480 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { 11481 n = 1; 11482 } else { 11483 n = toInteger(n); 11484 } 11485 var func = isArray(collection) ? arraySampleSize : baseSampleSize; 11486 return func(collection, n); 11487 } 11488 11489 /** 11490 * Creates an array of shuffled values, using a version of the 11491 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). 11492 * 11493 * @static 11494 * @memberOf _ 11495 * @since 0.1.0 11496 * @category Collection 11497 * @param {Array|Object} collection The collection to shuffle. 11498 * @returns {Array} Returns the new shuffled array. 11499 * @example 11500 * 11501 * _.shuffle([1, 2, 3, 4]); 11502 * // => [4, 1, 3, 2] 11503 */ 11504 function shuffle(collection) { 11505 var func = isArray(collection) ? arrayShuffle : baseShuffle; 11506 return func(collection); 11507 } 11508 11509 /** 11510 * Gets the size of `collection` by returning its length for array-like 11511 * values or the number of own enumerable string keyed properties for objects. 11512 * 11513 * @static 11514 * @memberOf _ 11515 * @since 0.1.0 11516 * @category Collection 11517 * @param {Array|Object|string} collection The collection to inspect. 11518 * @returns {number} Returns the collection size. 11519 * @example 11520 * 11521 * _.size([1, 2, 3]); 11522 * // => 3 11523 * 11524 * _.size({ 'a': 1, 'b': 2 }); 11525 * // => 2 11526 * 11527 * _.size('pebbles'); 11528 * // => 7 11529 */ 11530 function size(collection) { 11531 if (collection == null) { 11532 return 0; 11533 } 11534 if (isArrayLike(collection)) { 11535 return isString(collection) ? stringSize(collection) : collection.length; 11536 } 11537 var tag = getTag(collection); 11538 if (tag == mapTag || tag == setTag) { 11539 return collection.size; 11540 } 11541 return baseKeys(collection).length; 11542 } 11543 11544 /** 11545 * Checks if `predicate` returns truthy for **any** element of `collection`. 11546 * Iteration is stopped once `predicate` returns truthy. The predicate is 11547 * invoked with three arguments: (value, index|key, collection). 11548 * 11549 * @static 11550 * @memberOf _ 11551 * @since 0.1.0 11552 * @category Collection 11553 * @param {Array|Object} collection The collection to iterate over. 11554 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11555 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 11556 * @returns {boolean} Returns `true` if any element passes the predicate check, 11557 * else `false`. 11558 * @example 11559 * 11560 * _.some([null, 0, 'yes', false], Boolean); 11561 * // => true 11562 * 11563 * var users = [ 11564 * { 'user': 'barney', 'active': true }, 11565 * { 'user': 'fred', 'active': false } 11566 * ]; 11567 * 11568 * // The `_.matches` iteratee shorthand. 11569 * _.some(users, { 'user': 'barney', 'active': false }); 11570 * // => false 11571 * 11572 * // The `_.matchesProperty` iteratee shorthand. 11573 * _.some(users, ['active', false]); 11574 * // => true 11575 * 11576 * // The `_.property` iteratee shorthand. 11577 * _.some(users, 'active'); 11578 * // => true 11579 */ 11580 function some(collection, predicate, guard) { 11581 var func = isArray(collection) ? arraySome : baseSome; 11582 if (guard && isIterateeCall(collection, predicate, guard)) { 11583 predicate = undefined; 11584 } 11585 return func(collection, getIteratee(predicate, 3)); 11586 } 11587 11588 /** 11589 * Creates an array of elements, sorted in ascending order by the results of 11590 * running each element in a collection thru each iteratee. This method 11591 * performs a stable sort, that is, it preserves the original sort order of 11592 * equal elements. The iteratees are invoked with one argument: (value). 11593 * 11594 * @static 11595 * @memberOf _ 11596 * @since 0.1.0 11597 * @category Collection 11598 * @param {Array|Object} collection The collection to iterate over. 11599 * @param {...(Function|Function[])} [iteratees=[_.identity]] 11600 * The iteratees to sort by. 11601 * @returns {Array} Returns the new sorted array. 11602 * @example 11603 * 11604 * var users = [ 11605 * { 'user': 'fred', 'age': 48 }, 11606 * { 'user': 'barney', 'age': 36 }, 11607 * { 'user': 'fred', 'age': 40 }, 11608 * { 'user': 'barney', 'age': 34 } 11609 * ]; 11610 * 11611 * _.sortBy(users, [function(o) { return o.user; }]); 11612 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 11613 * 11614 * _.sortBy(users, ['user', 'age']); 11615 * // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]] 11616 */ 11617 var sortBy = baseRest(function(collection, iteratees) { 11618 if (collection == null) { 11619 return []; 11620 } 11621 var length = iteratees.length; 11622 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { 11623 iteratees = []; 11624 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { 11625 iteratees = [iteratees[0]]; 11626 } 11627 return baseOrderBy(collection, baseFlatten(iteratees, 1), []); 11628 }); 11629 11630 /*------------------------------------------------------------------------*/ 11631 11632 /** 11633 * Gets the timestamp of the number of milliseconds that have elapsed since 11634 * the Unix epoch (1 January 1970 00:00:00 UTC). 11635 * 11636 * @static 11637 * @memberOf _ 11638 * @since 2.4.0 11639 * @category Date 11640 * @returns {number} Returns the timestamp. 11641 * @example 11642 * 11643 * _.defer(function(stamp) { 11644 * console.log(_.now() - stamp); 11645 * }, _.now()); 11646 * // => Logs the number of milliseconds it took for the deferred invocation. 11647 */ 11648 var now = ctxNow || function() { 11649 return root.Date.now(); 11650 }; 11651 11652 /*------------------------------------------------------------------------*/ 11653 11654 /** 11655 * The opposite of `_.before`; this method creates a function that invokes 11656 * `func` once it's called `n` or more times. 11657 * 11658 * @static 11659 * @memberOf _ 11660 * @since 0.1.0 11661 * @category Function 11662 * @param {number} n The number of calls before `func` is invoked. 11663 * @param {Function} func The function to restrict. 11664 * @returns {Function} Returns the new restricted function. 11665 * @example 11666 * 11667 * var saves = ['profile', 'settings']; 11668 * 11669 * var done = _.after(saves.length, function() { 11670 * console.log('done saving!'); 11671 * }); 11672 * 11673 * _.forEach(saves, function(type) { 11674 * asyncSave({ 'type': type, 'complete': done }); 11675 * }); 11676 * // => Logs 'done saving!' after the two async saves have completed. 11677 */ 11678 function after(n, func) { 11679 if (typeof func != 'function') { 11680 throw new TypeError(FUNC_ERROR_TEXT); 11681 } 11682 n = toInteger(n); 11683 return function() { 11684 if (--n < 1) { 11685 return func.apply(this, arguments); 11686 } 11687 }; 11688 } 11689 11690 /** 11691 * Creates a function that invokes `func`, with up to `n` arguments, 11692 * ignoring any additional arguments. 11693 * 11694 * @static 11695 * @memberOf _ 11696 * @since 3.0.0 11697 * @category Function 11698 * @param {Function} func The function to cap arguments for. 11699 * @param {number} [n=func.length] The arity cap. 11700 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 11701 * @returns {Function} Returns the new capped function. 11702 * @example 11703 * 11704 * _.map(['6', '8', '10'], _.ary(parseInt, 1)); 11705 * // => [6, 8, 10] 11706 */ 11707 function ary(func, n, guard) { 11708 n = guard ? undefined : n; 11709 n = (func && n == null) ? func.length : n; 11710 return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); 11711 } 11712 11713 /** 11714 * Creates a function that invokes `func`, with the `this` binding and arguments 11715 * of the created function, while it's called less than `n` times. Subsequent 11716 * calls to the created function return the result of the last `func` invocation. 11717 * 11718 * @static 11719 * @memberOf _ 11720 * @since 3.0.0 11721 * @category Function 11722 * @param {number} n The number of calls at which `func` is no longer invoked. 11723 * @param {Function} func The function to restrict. 11724 * @returns {Function} Returns the new restricted function. 11725 * @example 11726 * 11727 * jQuery(element).on('click', _.before(5, addContactToList)); 11728 * // => Allows adding up to 4 contacts to the list. 11729 */ 11730 function before(n, func) { 11731 var result; 11732 if (typeof func != 'function') { 11733 throw new TypeError(FUNC_ERROR_TEXT); 11734 } 11735 n = toInteger(n); 11736 return function() { 11737 if (--n > 0) { 11738 result = func.apply(this, arguments); 11739 } 11740 if (n <= 1) { 11741 func = undefined; 11742 } 11743 return result; 11744 }; 11745 } 11746 11747 /** 11748 * Creates a function that invokes `func` with the `this` binding of `thisArg` 11749 * and `partials` prepended to the arguments it receives. 11750 * 11751 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, 11752 * may be used as a placeholder for partially applied arguments. 11753 * 11754 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" 11755 * property of bound functions. 11756 * 11757 * @static 11758 * @memberOf _ 11759 * @since 0.1.0 11760 * @category Function 11761 * @param {Function} func The function to bind. 11762 * @param {*} thisArg The `this` binding of `func`. 11763 * @param {...*} [partials] The arguments to be partially applied. 11764 * @returns {Function} Returns the new bound function. 11765 * @example 11766 * 11767 * function greet(greeting, punctuation) { 11768 * return greeting + ' ' + this.user + punctuation; 11769 * } 11770 * 11771 * var object = { 'user': 'fred' }; 11772 * 11773 * var bound = _.bind(greet, object, 'hi'); 11774 * bound('!'); 11775 * // => 'hi fred!' 11776 * 11777 * // Bound with placeholders. 11778 * var bound = _.bind(greet, object, _, '!'); 11779 * bound('hi'); 11780 * // => 'hi fred!' 11781 */ 11782 var bind = baseRest(function(func, thisArg, partials) { 11783 var bitmask = WRAP_BIND_FLAG; 11784 if (partials.length) { 11785 var holders = replaceHolders(partials, getHolder(bind)); 11786 bitmask |= WRAP_PARTIAL_FLAG; 11787 } 11788 return createWrap(func, bitmask, thisArg, partials, holders); 11789 }); 11790 11791 /** 11792 * Creates a function that invokes the method at `object[key]` with `partials` 11793 * prepended to the arguments it receives. 11794 * 11795 * This method differs from `_.bind` by allowing bound functions to reference 11796 * methods that may be redefined or don't yet exist. See 11797 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) 11798 * for more details. 11799 * 11800 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic 11801 * builds, may be used as a placeholder for partially applied arguments. 11802 * 11803 * @static 11804 * @memberOf _ 11805 * @since 0.10.0 11806 * @category Function 11807 * @param {Object} object The object to invoke the method on. 11808 * @param {string} key The key of the method. 11809 * @param {...*} [partials] The arguments to be partially applied. 11810 * @returns {Function} Returns the new bound function. 11811 * @example 11812 * 11813 * var object = { 11814 * 'user': 'fred', 11815 * 'greet': function(greeting, punctuation) { 11816 * return greeting + ' ' + this.user + punctuation; 11817 * } 11818 * }; 11819 * 11820 * var bound = _.bindKey(object, 'greet', 'hi'); 11821 * bound('!'); 11822 * // => 'hi fred!' 11823 * 11824 * object.greet = function(greeting, punctuation) { 11825 * return greeting + 'ya ' + this.user + punctuation; 11826 * }; 11827 * 11828 * bound('!'); 11829 * // => 'hiya fred!' 11830 * 11831 * // Bound with placeholders. 11832 * var bound = _.bindKey(object, 'greet', _, '!'); 11833 * bound('hi'); 11834 * // => 'hiya fred!' 11835 */ 11836 var bindKey = baseRest(function(object, key, partials) { 11837 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; 11838 if (partials.length) { 11839 var holders = replaceHolders(partials, getHolder(bindKey)); 11840 bitmask |= WRAP_PARTIAL_FLAG; 11841 } 11842 return createWrap(key, bitmask, object, partials, holders); 11843 }); 11844 11845 /** 11846 * Creates a function that accepts arguments of `func` and either invokes 11847 * `func` returning its result, if at least `arity` number of arguments have 11848 * been provided, or returns a function that accepts the remaining `func` 11849 * arguments, and so on. The arity of `func` may be specified if `func.length` 11850 * is not sufficient. 11851 * 11852 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, 11853 * may be used as a placeholder for provided arguments. 11854 * 11855 * **Note:** This method doesn't set the "length" property of curried functions. 11856 * 11857 * @static 11858 * @memberOf _ 11859 * @since 2.0.0 11860 * @category Function 11861 * @param {Function} func The function to curry. 11862 * @param {number} [arity=func.length] The arity of `func`. 11863 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 11864 * @returns {Function} Returns the new curried function. 11865 * @example 11866 * 11867 * var abc = function(a, b, c) { 11868 * return [a, b, c]; 11869 * }; 11870 * 11871 * var curried = _.curry(abc); 11872 * 11873 * curried(1)(2)(3); 11874 * // => [1, 2, 3] 11875 * 11876 * curried(1, 2)(3); 11877 * // => [1, 2, 3] 11878 * 11879 * curried(1, 2, 3); 11880 * // => [1, 2, 3] 11881 * 11882 * // Curried with placeholders. 11883 * curried(1)(_, 3)(2); 11884 * // => [1, 2, 3] 11885 */ 11886 function curry(func, arity, guard) { 11887 arity = guard ? undefined : arity; 11888 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 11889 result.placeholder = curry.placeholder; 11890 return result; 11891 } 11892 11893 /** 11894 * This method is like `_.curry` except that arguments are applied to `func` 11895 * in the manner of `_.partialRight` instead of `_.partial`. 11896 * 11897 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic 11898 * builds, may be used as a placeholder for provided arguments. 11899 * 11900 * **Note:** This method doesn't set the "length" property of curried functions. 11901 * 11902 * @static 11903 * @memberOf _ 11904 * @since 3.0.0 11905 * @category Function 11906 * @param {Function} func The function to curry. 11907 * @param {number} [arity=func.length] The arity of `func`. 11908 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 11909 * @returns {Function} Returns the new curried function. 11910 * @example 11911 * 11912 * var abc = function(a, b, c) { 11913 * return [a, b, c]; 11914 * }; 11915 * 11916 * var curried = _.curryRight(abc); 11917 * 11918 * curried(3)(2)(1); 11919 * // => [1, 2, 3] 11920 * 11921 * curried(2, 3)(1); 11922 * // => [1, 2, 3] 11923 * 11924 * curried(1, 2, 3); 11925 * // => [1, 2, 3] 11926 * 11927 * // Curried with placeholders. 11928 * curried(3)(1, _)(2); 11929 * // => [1, 2, 3] 11930 */ 11931 function curryRight(func, arity, guard) { 11932 arity = guard ? undefined : arity; 11933 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 11934 result.placeholder = curryRight.placeholder; 11935 return result; 11936 } 11937 11938 /** 11939 * Creates a debounced function that delays invoking `func` until after `wait` 11940 * milliseconds have elapsed since the last time the debounced function was 11941 * invoked. The debounced function comes with a `cancel` method to cancel 11942 * delayed `func` invocations and a `flush` method to immediately invoke them. 11943 * Provide `options` to indicate whether `func` should be invoked on the 11944 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 11945 * with the last arguments provided to the debounced function. Subsequent 11946 * calls to the debounced function return the result of the last `func` 11947 * invocation. 11948 * 11949 * **Note:** If `leading` and `trailing` options are `true`, `func` is 11950 * invoked on the trailing edge of the timeout only if the debounced function 11951 * is invoked more than once during the `wait` timeout. 11952 * 11953 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 11954 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 11955 * 11956 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 11957 * for details over the differences between `_.debounce` and `_.throttle`. 11958 * 11959 * @static 11960 * @memberOf _ 11961 * @since 0.1.0 11962 * @category Function 11963 * @param {Function} func The function to debounce. 11964 * @param {number} [wait=0] The number of milliseconds to delay. 11965 * @param {Object} [options={}] The options object. 11966 * @param {boolean} [options.leading=false] 11967 * Specify invoking on the leading edge of the timeout. 11968 * @param {number} [options.maxWait] 11969 * The maximum time `func` is allowed to be delayed before it's invoked. 11970 * @param {boolean} [options.trailing=true] 11971 * Specify invoking on the trailing edge of the timeout. 11972 * @returns {Function} Returns the new debounced function. 11973 * @example 11974 * 11975 * // Avoid costly calculations while the window size is in flux. 11976 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 11977 * 11978 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 11979 * jQuery(element).on('click', _.debounce(sendMail, 300, { 11980 * 'leading': true, 11981 * 'trailing': false 11982 * })); 11983 * 11984 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 11985 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 11986 * var source = new EventSource('/stream'); 11987 * jQuery(source).on('message', debounced); 11988 * 11989 * // Cancel the trailing debounced invocation. 11990 * jQuery(window).on('popstate', debounced.cancel); 11991 */ 11992 function debounce(func, wait, options) { 11993 var lastArgs, 11994 lastThis, 11995 maxWait, 11996 result, 11997 timerId, 11998 lastCallTime, 11999 lastInvokeTime = 0, 12000 leading = false, 12001 maxing = false, 12002 trailing = true; 12003 12004 if (typeof func != 'function') { 12005 throw new TypeError(FUNC_ERROR_TEXT); 12006 } 12007 wait = toNumber(wait) || 0; 12008 if (isObject(options)) { 12009 leading = !!options.leading; 12010 maxing = 'maxWait' in options; 12011 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; 12012 trailing = 'trailing' in options ? !!options.trailing : trailing; 12013 } 12014 12015 function invokeFunc(time) { 12016 var args = lastArgs, 12017 thisArg = lastThis; 12018 12019 lastArgs = lastThis = undefined; 12020 lastInvokeTime = time; 12021 result = func.apply(thisArg, args); 12022 return result; 12023 } 12024 12025 function leadingEdge(time) { 12026 // Reset any `maxWait` timer. 12027 lastInvokeTime = time; 12028 // Start the timer for the trailing edge. 12029 timerId = setTimeout(timerExpired, wait); 12030 // Invoke the leading edge. 12031 return leading ? invokeFunc(time) : result; 12032 } 12033 12034 function remainingWait(time) { 12035 var timeSinceLastCall = time - lastCallTime, 12036 timeSinceLastInvoke = time - lastInvokeTime, 12037 timeWaiting = wait - timeSinceLastCall; 12038 12039 return maxing 12040 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) 12041 : timeWaiting; 12042 } 12043 12044 function shouldInvoke(time) { 12045 var timeSinceLastCall = time - lastCallTime, 12046 timeSinceLastInvoke = time - lastInvokeTime; 12047 12048 // Either this is the first call, activity has stopped and we're at the 12049 // trailing edge, the system time has gone backwards and we're treating 12050 // it as the trailing edge, or we've hit the `maxWait` limit. 12051 return (lastCallTime === undefined || (timeSinceLastCall >= wait) || 12052 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 12053 } 12054 12055 function timerExpired() { 12056 var time = now(); 12057 if (shouldInvoke(time)) { 12058 return trailingEdge(time); 12059 } 12060 // Restart the timer. 12061 timerId = setTimeout(timerExpired, remainingWait(time)); 12062 } 12063 12064 function trailingEdge(time) { 12065 timerId = undefined; 12066 12067 // Only invoke if we have `lastArgs` which means `func` has been 12068 // debounced at least once. 12069 if (trailing && lastArgs) { 12070 return invokeFunc(time); 12071 } 12072 lastArgs = lastThis = undefined; 12073 return result; 12074 } 12075 12076 function cancel() { 12077 if (timerId !== undefined) { 12078 clearTimeout(timerId); 12079 } 12080 lastInvokeTime = 0; 12081 lastArgs = lastCallTime = lastThis = timerId = undefined; 12082 } 12083 12084 function flush() { 12085 return timerId === undefined ? result : trailingEdge(now()); 12086 } 12087 12088 function debounced() { 12089 var time = now(), 12090 isInvoking = shouldInvoke(time); 12091 12092 lastArgs = arguments; 12093 lastThis = this; 12094 lastCallTime = time; 12095 12096 if (isInvoking) { 12097 if (timerId === undefined) { 12098 return leadingEdge(lastCallTime); 12099 } 12100 if (maxing) { 12101 // Handle invocations in a tight loop. 12102 timerId = setTimeout(timerExpired, wait); 12103 return invokeFunc(lastCallTime); 12104 } 12105 } 12106 if (timerId === undefined) { 12107 timerId = setTimeout(timerExpired, wait); 12108 } 12109 return result; 12110 } 12111 debounced.cancel = cancel; 12112 debounced.flush = flush; 12113 return debounced; 12114 } 12115 12116 /** 12117 * Defers invoking the `func` until the current call stack has cleared. Any 12118 * additional arguments are provided to `func` when it's invoked. 12119 * 12120 * @static 12121 * @memberOf _ 12122 * @since 0.1.0 12123 * @category Function 12124 * @param {Function} func The function to defer. 12125 * @param {...*} [args] The arguments to invoke `func` with. 12126 * @returns {number} Returns the timer id. 12127 * @example 12128 * 12129 * _.defer(function(text) { 12130 * console.log(text); 12131 * }, 'deferred'); 12132 * // => Logs 'deferred' after one millisecond. 12133 */ 12134 var defer = baseRest(function(func, args) { 12135 return baseDelay(func, 1, args); 12136 }); 12137 12138 /** 12139 * Invokes `func` after `wait` milliseconds. Any additional arguments are 12140 * provided to `func` when it's invoked. 12141 * 12142 * @static 12143 * @memberOf _ 12144 * @since 0.1.0 12145 * @category Function 12146 * @param {Function} func The function to delay. 12147 * @param {number} wait The number of milliseconds to delay invocation. 12148 * @param {...*} [args] The arguments to invoke `func` with. 12149 * @returns {number} Returns the timer id. 12150 * @example 12151 * 12152 * _.delay(function(text) { 12153 * console.log(text); 12154 * }, 1000, 'later'); 12155 * // => Logs 'later' after one second. 12156 */ 12157 var delay = baseRest(function(func, wait, args) { 12158 return baseDelay(func, toNumber(wait) || 0, args); 12159 }); 12160 12161 /** 12162 * Creates a function that invokes `func` with arguments reversed. 12163 * 12164 * @static 12165 * @memberOf _ 12166 * @since 4.0.0 12167 * @category Function 12168 * @param {Function} func The function to flip arguments for. 12169 * @returns {Function} Returns the new flipped function. 12170 * @example 12171 * 12172 * var flipped = _.flip(function() { 12173 * return _.toArray(arguments); 12174 * }); 12175 * 12176 * flipped('a', 'b', 'c', 'd'); 12177 * // => ['d', 'c', 'b', 'a'] 12178 */ 12179 function flip(func) { 12180 return createWrap(func, WRAP_FLIP_FLAG); 12181 } 12182 12183 /** 12184 * Creates a function that memoizes the result of `func`. If `resolver` is 12185 * provided, it determines the cache key for storing the result based on the 12186 * arguments provided to the memoized function. By default, the first argument 12187 * provided to the memoized function is used as the map cache key. The `func` 12188 * is invoked with the `this` binding of the memoized function. 12189 * 12190 * **Note:** The cache is exposed as the `cache` property on the memoized 12191 * function. Its creation may be customized by replacing the `_.memoize.Cache` 12192 * constructor with one whose instances implement the 12193 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) 12194 * method interface of `clear`, `delete`, `get`, `has`, and `set`. 12195 * 12196 * @static 12197 * @memberOf _ 12198 * @since 0.1.0 12199 * @category Function 12200 * @param {Function} func The function to have its output memoized. 12201 * @param {Function} [resolver] The function to resolve the cache key. 12202 * @returns {Function} Returns the new memoized function. 12203 * @example 12204 * 12205 * var object = { 'a': 1, 'b': 2 }; 12206 * var other = { 'c': 3, 'd': 4 }; 12207 * 12208 * var values = _.memoize(_.values); 12209 * values(object); 12210 * // => [1, 2] 12211 * 12212 * values(other); 12213 * // => [3, 4] 12214 * 12215 * object.a = 2; 12216 * values(object); 12217 * // => [1, 2] 12218 * 12219 * // Modify the result cache. 12220 * values.cache.set(object, ['a', 'b']); 12221 * values(object); 12222 * // => ['a', 'b'] 12223 * 12224 * // Replace `_.memoize.Cache`. 12225 * _.memoize.Cache = WeakMap; 12226 */ 12227 function memoize(func, resolver) { 12228 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { 12229 throw new TypeError(FUNC_ERROR_TEXT); 12230 } 12231 var memoized = function() { 12232 var args = arguments, 12233 key = resolver ? resolver.apply(this, args) : args[0], 12234 cache = memoized.cache; 12235 12236 if (cache.has(key)) { 12237 return cache.get(key); 12238 } 12239 var result = func.apply(this, args); 12240 memoized.cache = cache.set(key, result) || cache; 12241 return result; 12242 }; 12243 memoized.cache = new (memoize.Cache || MapCache); 12244 return memoized; 12245 } 12246 12247 // Expose `MapCache`. 12248 memoize.Cache = MapCache; 12249 12250 /** 12251 * Creates a function that negates the result of the predicate `func`. The 12252 * `func` predicate is invoked with the `this` binding and arguments of the 12253 * created function. 12254 * 12255 * @static 12256 * @memberOf _ 12257 * @since 3.0.0 12258 * @category Function 12259 * @param {Function} predicate The predicate to negate. 12260 * @returns {Function} Returns the new negated function. 12261 * @example 12262 * 12263 * function isEven(n) { 12264 * return n % 2 == 0; 12265 * } 12266 * 12267 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); 12268 * // => [1, 3, 5] 12269 */ 12270 function negate(predicate) { 12271 if (typeof predicate != 'function') { 12272 throw new TypeError(FUNC_ERROR_TEXT); 12273 } 12274 return function() { 12275 var args = arguments; 12276 switch (args.length) { 12277 case 0: return !predicate.call(this); 12278 case 1: return !predicate.call(this, args[0]); 12279 case 2: return !predicate.call(this, args[0], args[1]); 12280 case 3: return !predicate.call(this, args[0], args[1], args[2]); 12281 } 12282 return !predicate.apply(this, args); 12283 }; 12284 } 12285 12286 /** 12287 * Creates a function that is restricted to invoking `func` once. Repeat calls 12288 * to the function return the value of the first invocation. The `func` is 12289 * invoked with the `this` binding and arguments of the created function. 12290 * 12291 * @static 12292 * @memberOf _ 12293 * @since 0.1.0 12294 * @category Function 12295 * @param {Function} func The function to restrict. 12296 * @returns {Function} Returns the new restricted function. 12297 * @example 12298 * 12299 * var initialize = _.once(createApplication); 12300 * initialize(); 12301 * initialize(); 12302 * // => `createApplication` is invoked once 12303 */ 12304 function once(func) { 12305 return before(2, func); 12306 } 12307 12308 /** 12309 * Creates a function that invokes `func` with its arguments transformed. 12310 * 12311 * @static 12312 * @since 4.0.0 12313 * @memberOf _ 12314 * @category Function 12315 * @param {Function} func The function to wrap. 12316 * @param {...(Function|Function[])} [transforms=[_.identity]] 12317 * The argument transforms. 12318 * @returns {Function} Returns the new function. 12319 * @example 12320 * 12321 * function doubled(n) { 12322 * return n * 2; 12323 * } 12324 * 12325 * function square(n) { 12326 * return n * n; 12327 * } 12328 * 12329 * var func = _.overArgs(function(x, y) { 12330 * return [x, y]; 12331 * }, [square, doubled]); 12332 * 12333 * func(9, 3); 12334 * // => [81, 6] 12335 * 12336 * func(10, 5); 12337 * // => [100, 10] 12338 */ 12339 var overArgs = castRest(function(func, transforms) { 12340 transforms = (transforms.length == 1 && isArray(transforms[0])) 12341 ? arrayMap(transforms[0], baseUnary(getIteratee())) 12342 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); 12343 12344 var funcsLength = transforms.length; 12345 return baseRest(function(args) { 12346 var index = -1, 12347 length = nativeMin(args.length, funcsLength); 12348 12349 while (++index < length) { 12350 args[index] = transforms[index].call(this, args[index]); 12351 } 12352 return apply(func, this, args); 12353 }); 12354 }); 12355 12356 /** 12357 * Creates a function that invokes `func` with `partials` prepended to the 12358 * arguments it receives. This method is like `_.bind` except it does **not** 12359 * alter the `this` binding. 12360 * 12361 * The `_.partial.placeholder` value, which defaults to `_` in monolithic 12362 * builds, may be used as a placeholder for partially applied arguments. 12363 * 12364 * **Note:** This method doesn't set the "length" property of partially 12365 * applied functions. 12366 * 12367 * @static 12368 * @memberOf _ 12369 * @since 0.2.0 12370 * @category Function 12371 * @param {Function} func The function to partially apply arguments to. 12372 * @param {...*} [partials] The arguments to be partially applied. 12373 * @returns {Function} Returns the new partially applied function. 12374 * @example 12375 * 12376 * function greet(greeting, name) { 12377 * return greeting + ' ' + name; 12378 * } 12379 * 12380 * var sayHelloTo = _.partial(greet, 'hello'); 12381 * sayHelloTo('fred'); 12382 * // => 'hello fred' 12383 * 12384 * // Partially applied with placeholders. 12385 * var greetFred = _.partial(greet, _, 'fred'); 12386 * greetFred('hi'); 12387 * // => 'hi fred' 12388 */ 12389 var partial = baseRest(function(func, partials) { 12390 var holders = replaceHolders(partials, getHolder(partial)); 12391 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); 12392 }); 12393 12394 /** 12395 * This method is like `_.partial` except that partially applied arguments 12396 * are appended to the arguments it receives. 12397 * 12398 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic 12399 * builds, may be used as a placeholder for partially applied arguments. 12400 * 12401 * **Note:** This method doesn't set the "length" property of partially 12402 * applied functions. 12403 * 12404 * @static 12405 * @memberOf _ 12406 * @since 1.0.0 12407 * @category Function 12408 * @param {Function} func The function to partially apply arguments to. 12409 * @param {...*} [partials] The arguments to be partially applied. 12410 * @returns {Function} Returns the new partially applied function. 12411 * @example 12412 * 12413 * function greet(greeting, name) { 12414 * return greeting + ' ' + name; 12415 * } 12416 * 12417 * var greetFred = _.partialRight(greet, 'fred'); 12418 * greetFred('hi'); 12419 * // => 'hi fred' 12420 * 12421 * // Partially applied with placeholders. 12422 * var sayHelloTo = _.partialRight(greet, 'hello', _); 12423 * sayHelloTo('fred'); 12424 * // => 'hello fred' 12425 */ 12426 var partialRight = baseRest(function(func, partials) { 12427 var holders = replaceHolders(partials, getHolder(partialRight)); 12428 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); 12429 }); 12430 12431 /** 12432 * Creates a function that invokes `func` with arguments arranged according 12433 * to the specified `indexes` where the argument value at the first index is 12434 * provided as the first argument, the argument value at the second index is 12435 * provided as the second argument, and so on. 12436 * 12437 * @static 12438 * @memberOf _ 12439 * @since 3.0.0 12440 * @category Function 12441 * @param {Function} func The function to rearrange arguments for. 12442 * @param {...(number|number[])} indexes The arranged argument indexes. 12443 * @returns {Function} Returns the new function. 12444 * @example 12445 * 12446 * var rearged = _.rearg(function(a, b, c) { 12447 * return [a, b, c]; 12448 * }, [2, 0, 1]); 12449 * 12450 * rearged('b', 'c', 'a') 12451 * // => ['a', 'b', 'c'] 12452 */ 12453 var rearg = flatRest(function(func, indexes) { 12454 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); 12455 }); 12456 12457 /** 12458 * Creates a function that invokes `func` with the `this` binding of the 12459 * created function and arguments from `start` and beyond provided as 12460 * an array. 12461 * 12462 * **Note:** This method is based on the 12463 * [rest parameter](https://mdn.io/rest_parameters). 12464 * 12465 * @static 12466 * @memberOf _ 12467 * @since 4.0.0 12468 * @category Function 12469 * @param {Function} func The function to apply a rest parameter to. 12470 * @param {number} [start=func.length-1] The start position of the rest parameter. 12471 * @returns {Function} Returns the new function. 12472 * @example 12473 * 12474 * var say = _.rest(function(what, names) { 12475 * return what + ' ' + _.initial(names).join(', ') + 12476 * (_.size(names) > 1 ? ', & ' : '') + _.last(names); 12477 * }); 12478 * 12479 * say('hello', 'fred', 'barney', 'pebbles'); 12480 * // => 'hello fred, barney, & pebbles' 12481 */ 12482 function rest(func, start) { 12483 if (typeof func != 'function') { 12484 throw new TypeError(FUNC_ERROR_TEXT); 12485 } 12486 start = start === undefined ? start : toInteger(start); 12487 return baseRest(func, start); 12488 } 12489 12490 /** 12491 * Creates a function that invokes `func` with the `this` binding of the 12492 * create function and an array of arguments much like 12493 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). 12494 * 12495 * **Note:** This method is based on the 12496 * [spread operator](https://mdn.io/spread_operator). 12497 * 12498 * @static 12499 * @memberOf _ 12500 * @since 3.2.0 12501 * @category Function 12502 * @param {Function} func The function to spread arguments over. 12503 * @param {number} [start=0] The start position of the spread. 12504 * @returns {Function} Returns the new function. 12505 * @example 12506 * 12507 * var say = _.spread(function(who, what) { 12508 * return who + ' says ' + what; 12509 * }); 12510 * 12511 * say(['fred', 'hello']); 12512 * // => 'fred says hello' 12513 * 12514 * var numbers = Promise.all([ 12515 * Promise.resolve(40), 12516 * Promise.resolve(36) 12517 * ]); 12518 * 12519 * numbers.then(_.spread(function(x, y) { 12520 * return x + y; 12521 * })); 12522 * // => a Promise of 76 12523 */ 12524 function spread(func, start) { 12525 if (typeof func != 'function') { 12526 throw new TypeError(FUNC_ERROR_TEXT); 12527 } 12528 start = start == null ? 0 : nativeMax(toInteger(start), 0); 12529 return baseRest(function(args) { 12530 var array = args[start], 12531 otherArgs = castSlice(args, 0, start); 12532 12533 if (array) { 12534 arrayPush(otherArgs, array); 12535 } 12536 return apply(func, this, otherArgs); 12537 }); 12538 } 12539 12540 /** 12541 * Creates a throttled function that only invokes `func` at most once per 12542 * every `wait` milliseconds. The throttled function comes with a `cancel` 12543 * method to cancel delayed `func` invocations and a `flush` method to 12544 * immediately invoke them. Provide `options` to indicate whether `func` 12545 * should be invoked on the leading and/or trailing edge of the `wait` 12546 * timeout. The `func` is invoked with the last arguments provided to the 12547 * throttled function. Subsequent calls to the throttled function return the 12548 * result of the last `func` invocation. 12549 * 12550 * **Note:** If `leading` and `trailing` options are `true`, `func` is 12551 * invoked on the trailing edge of the timeout only if the throttled function 12552 * is invoked more than once during the `wait` timeout. 12553 * 12554 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 12555 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 12556 * 12557 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 12558 * for details over the differences between `_.throttle` and `_.debounce`. 12559 * 12560 * @static 12561 * @memberOf _ 12562 * @since 0.1.0 12563 * @category Function 12564 * @param {Function} func The function to throttle. 12565 * @param {number} [wait=0] The number of milliseconds to throttle invocations to. 12566 * @param {Object} [options={}] The options object. 12567 * @param {boolean} [options.leading=true] 12568 * Specify invoking on the leading edge of the timeout. 12569 * @param {boolean} [options.trailing=true] 12570 * Specify invoking on the trailing edge of the timeout. 12571 * @returns {Function} Returns the new throttled function. 12572 * @example 12573 * 12574 * // Avoid excessively updating the position while scrolling. 12575 * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); 12576 * 12577 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. 12578 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); 12579 * jQuery(element).on('click', throttled); 12580 * 12581 * // Cancel the trailing throttled invocation. 12582 * jQuery(window).on('popstate', throttled.cancel); 12583 */ 12584 function throttle(func, wait, options) { 12585 var leading = true, 12586 trailing = true; 12587 12588 if (typeof func != 'function') { 12589 throw new TypeError(FUNC_ERROR_TEXT); 12590 } 12591 if (isObject(options)) { 12592 leading = 'leading' in options ? !!options.leading : leading; 12593 trailing = 'trailing' in options ? !!options.trailing : trailing; 12594 } 12595 return debounce(func, wait, { 12596 'leading': leading, 12597 'maxWait': wait, 12598 'trailing': trailing 12599 }); 12600 } 12601 12602 /** 12603 * Creates a function that accepts up to one argument, ignoring any 12604 * additional arguments. 12605 * 12606 * @static 12607 * @memberOf _ 12608 * @since 4.0.0 12609 * @category Function 12610 * @param {Function} func The function to cap arguments for. 12611 * @returns {Function} Returns the new capped function. 12612 * @example 12613 * 12614 * _.map(['6', '8', '10'], _.unary(parseInt)); 12615 * // => [6, 8, 10] 12616 */ 12617 function unary(func) { 12618 return ary(func, 1); 12619 } 12620 12621 /** 12622 * Creates a function that provides `value` to `wrapper` as its first 12623 * argument. Any additional arguments provided to the function are appended 12624 * to those provided to the `wrapper`. The wrapper is invoked with the `this` 12625 * binding of the created function. 12626 * 12627 * @static 12628 * @memberOf _ 12629 * @since 0.1.0 12630 * @category Function 12631 * @param {*} value The value to wrap. 12632 * @param {Function} [wrapper=identity] The wrapper function. 12633 * @returns {Function} Returns the new function. 12634 * @example 12635 * 12636 * var p = _.wrap(_.escape, function(func, text) { 12637 * return '<p>' + func(text) + '</p>'; 12638 * }); 12639 * 12640 * p('fred, barney, & pebbles'); 12641 * // => '<p>fred, barney, & pebbles</p>' 12642 */ 12643 function wrap(value, wrapper) { 12644 return partial(castFunction(wrapper), value); 12645 } 12646 12647 /*------------------------------------------------------------------------*/ 12648 12649 /** 12650 * Casts `value` as an array if it's not one. 12651 * 12652 * @static 12653 * @memberOf _ 12654 * @since 4.4.0 12655 * @category Lang 12656 * @param {*} value The value to inspect. 12657 * @returns {Array} Returns the cast array. 12658 * @example 12659 * 12660 * _.castArray(1); 12661 * // => [1] 12662 * 12663 * _.castArray({ 'a': 1 }); 12664 * // => [{ 'a': 1 }] 12665 * 12666 * _.castArray('abc'); 12667 * // => ['abc'] 12668 * 12669 * _.castArray(null); 12670 * // => [null] 12671 * 12672 * _.castArray(undefined); 12673 * // => [undefined] 12674 * 12675 * _.castArray(); 12676 * // => [] 12677 * 12678 * var array = [1, 2, 3]; 12679 * console.log(_.castArray(array) === array); 12680 * // => true 12681 */ 12682 function castArray() { 12683 if (!arguments.length) { 12684 return []; 12685 } 12686 var value = arguments[0]; 12687 return isArray(value) ? value : [value]; 12688 } 12689 12690 /** 12691 * Creates a shallow clone of `value`. 12692 * 12693 * **Note:** This method is loosely based on the 12694 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) 12695 * and supports cloning arrays, array buffers, booleans, date objects, maps, 12696 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed 12697 * arrays. The own enumerable properties of `arguments` objects are cloned 12698 * as plain objects. An empty object is returned for uncloneable values such 12699 * as error objects, functions, DOM nodes, and WeakMaps. 12700 * 12701 * @static 12702 * @memberOf _ 12703 * @since 0.1.0 12704 * @category Lang 12705 * @param {*} value The value to clone. 12706 * @returns {*} Returns the cloned value. 12707 * @see _.cloneDeep 12708 * @example 12709 * 12710 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 12711 * 12712 * var shallow = _.clone(objects); 12713 * console.log(shallow[0] === objects[0]); 12714 * // => true 12715 */ 12716 function clone(value) { 12717 return baseClone(value, CLONE_SYMBOLS_FLAG); 12718 } 12719 12720 /** 12721 * This method is like `_.clone` except that it accepts `customizer` which 12722 * is invoked to produce the cloned value. If `customizer` returns `undefined`, 12723 * cloning is handled by the method instead. The `customizer` is invoked with 12724 * up to four arguments; (value [, index|key, object, stack]). 12725 * 12726 * @static 12727 * @memberOf _ 12728 * @since 4.0.0 12729 * @category Lang 12730 * @param {*} value The value to clone. 12731 * @param {Function} [customizer] The function to customize cloning. 12732 * @returns {*} Returns the cloned value. 12733 * @see _.cloneDeepWith 12734 * @example 12735 * 12736 * function customizer(value) { 12737 * if (_.isElement(value)) { 12738 * return value.cloneNode(false); 12739 * } 12740 * } 12741 * 12742 * var el = _.cloneWith(document.body, customizer); 12743 * 12744 * console.log(el === document.body); 12745 * // => false 12746 * console.log(el.nodeName); 12747 * // => 'BODY' 12748 * console.log(el.childNodes.length); 12749 * // => 0 12750 */ 12751 function cloneWith(value, customizer) { 12752 customizer = typeof customizer == 'function' ? customizer : undefined; 12753 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); 12754 } 12755 12756 /** 12757 * This method is like `_.clone` except that it recursively clones `value`. 12758 * 12759 * @static 12760 * @memberOf _ 12761 * @since 1.0.0 12762 * @category Lang 12763 * @param {*} value The value to recursively clone. 12764 * @returns {*} Returns the deep cloned value. 12765 * @see _.clone 12766 * @example 12767 * 12768 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 12769 * 12770 * var deep = _.cloneDeep(objects); 12771 * console.log(deep[0] === objects[0]); 12772 * // => false 12773 */ 12774 function cloneDeep(value) { 12775 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); 12776 } 12777 12778 /** 12779 * This method is like `_.cloneWith` except that it recursively clones `value`. 12780 * 12781 * @static 12782 * @memberOf _ 12783 * @since 4.0.0 12784 * @category Lang 12785 * @param {*} value The value to recursively clone. 12786 * @param {Function} [customizer] The function to customize cloning. 12787 * @returns {*} Returns the deep cloned value. 12788 * @see _.cloneWith 12789 * @example 12790 * 12791 * function customizer(value) { 12792 * if (_.isElement(value)) { 12793 * return value.cloneNode(true); 12794 * } 12795 * } 12796 * 12797 * var el = _.cloneDeepWith(document.body, customizer); 12798 * 12799 * console.log(el === document.body); 12800 * // => false 12801 * console.log(el.nodeName); 12802 * // => 'BODY' 12803 * console.log(el.childNodes.length); 12804 * // => 20 12805 */ 12806 function cloneDeepWith(value, customizer) { 12807 customizer = typeof customizer == 'function' ? customizer : undefined; 12808 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); 12809 } 12810 12811 /** 12812 * Checks if `object` conforms to `source` by invoking the predicate 12813 * properties of `source` with the corresponding property values of `object`. 12814 * 12815 * **Note:** This method is equivalent to `_.conforms` when `source` is 12816 * partially applied. 12817 * 12818 * @static 12819 * @memberOf _ 12820 * @since 4.14.0 12821 * @category Lang 12822 * @param {Object} object The object to inspect. 12823 * @param {Object} source The object of property predicates to conform to. 12824 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 12825 * @example 12826 * 12827 * var object = { 'a': 1, 'b': 2 }; 12828 * 12829 * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); 12830 * // => true 12831 * 12832 * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); 12833 * // => false 12834 */ 12835 function conformsTo(object, source) { 12836 return source == null || baseConformsTo(object, source, keys(source)); 12837 } 12838 12839 /** 12840 * Performs a 12841 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 12842 * comparison between two values to determine if they are equivalent. 12843 * 12844 * @static 12845 * @memberOf _ 12846 * @since 4.0.0 12847 * @category Lang 12848 * @param {*} value The value to compare. 12849 * @param {*} other The other value to compare. 12850 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 12851 * @example 12852 * 12853 * var object = { 'a': 1 }; 12854 * var other = { 'a': 1 }; 12855 * 12856 * _.eq(object, object); 12857 * // => true 12858 * 12859 * _.eq(object, other); 12860 * // => false 12861 * 12862 * _.eq('a', 'a'); 12863 * // => true 12864 * 12865 * _.eq('a', Object('a')); 12866 * // => false 12867 * 12868 * _.eq(NaN, NaN); 12869 * // => true 12870 */ 12871 function eq(value, other) { 12872 return value === other || (value !== value && other !== other); 12873 } 12874 12875 /** 12876 * Checks if `value` is greater than `other`. 12877 * 12878 * @static 12879 * @memberOf _ 12880 * @since 3.9.0 12881 * @category Lang 12882 * @param {*} value The value to compare. 12883 * @param {*} other The other value to compare. 12884 * @returns {boolean} Returns `true` if `value` is greater than `other`, 12885 * else `false`. 12886 * @see _.lt 12887 * @example 12888 * 12889 * _.gt(3, 1); 12890 * // => true 12891 * 12892 * _.gt(3, 3); 12893 * // => false 12894 * 12895 * _.gt(1, 3); 12896 * // => false 12897 */ 12898 var gt = createRelationalOperation(baseGt); 12899 12900 /** 12901 * Checks if `value` is greater than or equal to `other`. 12902 * 12903 * @static 12904 * @memberOf _ 12905 * @since 3.9.0 12906 * @category Lang 12907 * @param {*} value The value to compare. 12908 * @param {*} other The other value to compare. 12909 * @returns {boolean} Returns `true` if `value` is greater than or equal to 12910 * `other`, else `false`. 12911 * @see _.lte 12912 * @example 12913 * 12914 * _.gte(3, 1); 12915 * // => true 12916 * 12917 * _.gte(3, 3); 12918 * // => true 12919 * 12920 * _.gte(1, 3); 12921 * // => false 12922 */ 12923 var gte = createRelationalOperation(function(value, other) { 12924 return value >= other; 12925 }); 12926 12927 /** 12928 * Checks if `value` is likely an `arguments` object. 12929 * 12930 * @static 12931 * @memberOf _ 12932 * @since 0.1.0 12933 * @category Lang 12934 * @param {*} value The value to check. 12935 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 12936 * else `false`. 12937 * @example 12938 * 12939 * _.isArguments(function() { return arguments; }()); 12940 * // => true 12941 * 12942 * _.isArguments([1, 2, 3]); 12943 * // => false 12944 */ 12945 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { 12946 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && 12947 !propertyIsEnumerable.call(value, 'callee'); 12948 }; 12949 12950 /** 12951 * Checks if `value` is classified as an `Array` object. 12952 * 12953 * @static 12954 * @memberOf _ 12955 * @since 0.1.0 12956 * @category Lang 12957 * @param {*} value The value to check. 12958 * @returns {boolean} Returns `true` if `value` is an array, else `false`. 12959 * @example 12960 * 12961 * _.isArray([1, 2, 3]); 12962 * // => true 12963 * 12964 * _.isArray(document.body.children); 12965 * // => false 12966 * 12967 * _.isArray('abc'); 12968 * // => false 12969 * 12970 * _.isArray(_.noop); 12971 * // => false 12972 */ 12973 var isArray = Array.isArray; 12974 12975 /** 12976 * Checks if `value` is classified as an `ArrayBuffer` object. 12977 * 12978 * @static 12979 * @memberOf _ 12980 * @since 4.3.0 12981 * @category Lang 12982 * @param {*} value The value to check. 12983 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 12984 * @example 12985 * 12986 * _.isArrayBuffer(new ArrayBuffer(2)); 12987 * // => true 12988 * 12989 * _.isArrayBuffer(new Array(2)); 12990 * // => false 12991 */ 12992 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; 12993 12994 /** 12995 * Checks if `value` is array-like. A value is considered array-like if it's 12996 * not a function and has a `value.length` that's an integer greater than or 12997 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. 12998 * 12999 * @static 13000 * @memberOf _ 13001 * @since 4.0.0 13002 * @category Lang 13003 * @param {*} value The value to check. 13004 * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 13005 * @example 13006 * 13007 * _.isArrayLike([1, 2, 3]); 13008 * // => true 13009 * 13010 * _.isArrayLike(document.body.children); 13011 * // => true 13012 * 13013 * _.isArrayLike('abc'); 13014 * // => true 13015 * 13016 * _.isArrayLike(_.noop); 13017 * // => false 13018 */ 13019 function isArrayLike(value) { 13020 return value != null && isLength(value.length) && !isFunction(value); 13021 } 13022 13023 /** 13024 * This method is like `_.isArrayLike` except that it also checks if `value` 13025 * is an object. 13026 * 13027 * @static 13028 * @memberOf _ 13029 * @since 4.0.0 13030 * @category Lang 13031 * @param {*} value The value to check. 13032 * @returns {boolean} Returns `true` if `value` is an array-like object, 13033 * else `false`. 13034 * @example 13035 * 13036 * _.isArrayLikeObject([1, 2, 3]); 13037 * // => true 13038 * 13039 * _.isArrayLikeObject(document.body.children); 13040 * // => true 13041 * 13042 * _.isArrayLikeObject('abc'); 13043 * // => false 13044 * 13045 * _.isArrayLikeObject(_.noop); 13046 * // => false 13047 */ 13048 function isArrayLikeObject(value) { 13049 return isObjectLike(value) && isArrayLike(value); 13050 } 13051 13052 /** 13053 * Checks if `value` is classified as a boolean primitive or object. 13054 * 13055 * @static 13056 * @memberOf _ 13057 * @since 0.1.0 13058 * @category Lang 13059 * @param {*} value The value to check. 13060 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. 13061 * @example 13062 * 13063 * _.isBoolean(false); 13064 * // => true 13065 * 13066 * _.isBoolean(null); 13067 * // => false 13068 */ 13069 function isBoolean(value) { 13070 return value === true || value === false || 13071 (isObjectLike(value) && baseGetTag(value) == boolTag); 13072 } 13073 13074 /** 13075 * Checks if `value` is a buffer. 13076 * 13077 * @static 13078 * @memberOf _ 13079 * @since 4.3.0 13080 * @category Lang 13081 * @param {*} value The value to check. 13082 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. 13083 * @example 13084 * 13085 * _.isBuffer(new Buffer(2)); 13086 * // => true 13087 * 13088 * _.isBuffer(new Uint8Array(2)); 13089 * // => false 13090 */ 13091 var isBuffer = nativeIsBuffer || stubFalse; 13092 13093 /** 13094 * Checks if `value` is classified as a `Date` object. 13095 * 13096 * @static 13097 * @memberOf _ 13098 * @since 0.1.0 13099 * @category Lang 13100 * @param {*} value The value to check. 13101 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 13102 * @example 13103 * 13104 * _.isDate(new Date); 13105 * // => true 13106 * 13107 * _.isDate('Mon April 23 2012'); 13108 * // => false 13109 */ 13110 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; 13111 13112 /** 13113 * Checks if `value` is likely a DOM element. 13114 * 13115 * @static 13116 * @memberOf _ 13117 * @since 0.1.0 13118 * @category Lang 13119 * @param {*} value The value to check. 13120 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. 13121 * @example 13122 * 13123 * _.isElement(document.body); 13124 * // => true 13125 * 13126 * _.isElement('<body>'); 13127 * // => false 13128 */ 13129 function isElement(value) { 13130 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); 13131 } 13132 13133 /** 13134 * Checks if `value` is an empty object, collection, map, or set. 13135 * 13136 * Objects are considered empty if they have no own enumerable string keyed 13137 * properties. 13138 * 13139 * Array-like values such as `arguments` objects, arrays, buffers, strings, or 13140 * jQuery-like collections are considered empty if they have a `length` of `0`. 13141 * Similarly, maps and sets are considered empty if they have a `size` of `0`. 13142 * 13143 * @static 13144 * @memberOf _ 13145 * @since 0.1.0 13146 * @category Lang 13147 * @param {*} value The value to check. 13148 * @returns {boolean} Returns `true` if `value` is empty, else `false`. 13149 * @example 13150 * 13151 * _.isEmpty(null); 13152 * // => true 13153 * 13154 * _.isEmpty(true); 13155 * // => true 13156 * 13157 * _.isEmpty(1); 13158 * // => true 13159 * 13160 * _.isEmpty([1, 2, 3]); 13161 * // => false 13162 * 13163 * _.isEmpty({ 'a': 1 }); 13164 * // => false 13165 */ 13166 function isEmpty(value) { 13167 if (value == null) { 13168 return true; 13169 } 13170 if (isArrayLike(value) && 13171 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || 13172 isBuffer(value) || isTypedArray(value) || isArguments(value))) { 13173 return !value.length; 13174 } 13175 var tag = getTag(value); 13176 if (tag == mapTag || tag == setTag) { 13177 return !value.size; 13178 } 13179 if (isPrototype(value)) { 13180 return !baseKeys(value).length; 13181 } 13182 for (var key in value) { 13183 if (hasOwnProperty.call(value, key)) { 13184 return false; 13185 } 13186 } 13187 return true; 13188 } 13189 13190 /** 13191 * Performs a deep comparison between two values to determine if they are 13192 * equivalent. 13193 * 13194 * **Note:** This method supports comparing arrays, array buffers, booleans, 13195 * date objects, error objects, maps, numbers, `Object` objects, regexes, 13196 * sets, strings, symbols, and typed arrays. `Object` objects are compared 13197 * by their own, not inherited, enumerable properties. Functions and DOM 13198 * nodes are compared by strict equality, i.e. `===`. 13199 * 13200 * @static 13201 * @memberOf _ 13202 * @since 0.1.0 13203 * @category Lang 13204 * @param {*} value The value to compare. 13205 * @param {*} other The other value to compare. 13206 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 13207 * @example 13208 * 13209 * var object = { 'a': 1 }; 13210 * var other = { 'a': 1 }; 13211 * 13212 * _.isEqual(object, other); 13213 * // => true 13214 * 13215 * object === other; 13216 * // => false 13217 */ 13218 function isEqual(value, other) { 13219 return baseIsEqual(value, other); 13220 } 13221 13222 /** 13223 * This method is like `_.isEqual` except that it accepts `customizer` which 13224 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 13225 * are handled by the method instead. The `customizer` is invoked with up to 13226 * six arguments: (objValue, othValue [, index|key, object, other, stack]). 13227 * 13228 * @static 13229 * @memberOf _ 13230 * @since 4.0.0 13231 * @category Lang 13232 * @param {*} value The value to compare. 13233 * @param {*} other The other value to compare. 13234 * @param {Function} [customizer] The function to customize comparisons. 13235 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 13236 * @example 13237 * 13238 * function isGreeting(value) { 13239 * return /^h(?:i|ello)$/.test(value); 13240 * } 13241 * 13242 * function customizer(objValue, othValue) { 13243 * if (isGreeting(objValue) && isGreeting(othValue)) { 13244 * return true; 13245 * } 13246 * } 13247 * 13248 * var array = ['hello', 'goodbye']; 13249 * var other = ['hi', 'goodbye']; 13250 * 13251 * _.isEqualWith(array, other, customizer); 13252 * // => true 13253 */ 13254 function isEqualWith(value, other, customizer) { 13255 customizer = typeof customizer == 'function' ? customizer : undefined; 13256 var result = customizer ? customizer(value, other) : undefined; 13257 return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; 13258 } 13259 13260 /** 13261 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, 13262 * `SyntaxError`, `TypeError`, or `URIError` object. 13263 * 13264 * @static 13265 * @memberOf _ 13266 * @since 3.0.0 13267 * @category Lang 13268 * @param {*} value The value to check. 13269 * @returns {boolean} Returns `true` if `value` is an error object, else `false`. 13270 * @example 13271 * 13272 * _.isError(new Error); 13273 * // => true 13274 * 13275 * _.isError(Error); 13276 * // => false 13277 */ 13278 function isError(value) { 13279 if (!isObjectLike(value)) { 13280 return false; 13281 } 13282 var tag = baseGetTag(value); 13283 return tag == errorTag || tag == domExcTag || 13284 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); 13285 } 13286 13287 /** 13288 * Checks if `value` is a finite primitive number. 13289 * 13290 * **Note:** This method is based on 13291 * [`Number.isFinite`](https://mdn.io/Number/isFinite). 13292 * 13293 * @static 13294 * @memberOf _ 13295 * @since 0.1.0 13296 * @category Lang 13297 * @param {*} value The value to check. 13298 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. 13299 * @example 13300 * 13301 * _.isFinite(3); 13302 * // => true 13303 * 13304 * _.isFinite(Number.MIN_VALUE); 13305 * // => true 13306 * 13307 * _.isFinite(Infinity); 13308 * // => false 13309 * 13310 * _.isFinite('3'); 13311 * // => false 13312 */ 13313 function isFinite(value) { 13314 return typeof value == 'number' && nativeIsFinite(value); 13315 } 13316 13317 /** 13318 * Checks if `value` is classified as a `Function` object. 13319 * 13320 * @static 13321 * @memberOf _ 13322 * @since 0.1.0 13323 * @category Lang 13324 * @param {*} value The value to check. 13325 * @returns {boolean} Returns `true` if `value` is a function, else `false`. 13326 * @example 13327 * 13328 * _.isFunction(_); 13329 * // => true 13330 * 13331 * _.isFunction(/abc/); 13332 * // => false 13333 */ 13334 function isFunction(value) { 13335 if (!isObject(value)) { 13336 return false; 13337 } 13338 // The use of `Object#toString` avoids issues with the `typeof` operator 13339 // in Safari 9 which returns 'object' for typed arrays and other constructors. 13340 var tag = baseGetTag(value); 13341 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; 13342 } 13343 13344 /** 13345 * Checks if `value` is an integer. 13346 * 13347 * **Note:** This method is based on 13348 * [`Number.isInteger`](https://mdn.io/Number/isInteger). 13349 * 13350 * @static 13351 * @memberOf _ 13352 * @since 4.0.0 13353 * @category Lang 13354 * @param {*} value The value to check. 13355 * @returns {boolean} Returns `true` if `value` is an integer, else `false`. 13356 * @example 13357 * 13358 * _.isInteger(3); 13359 * // => true 13360 * 13361 * _.isInteger(Number.MIN_VALUE); 13362 * // => false 13363 * 13364 * _.isInteger(Infinity); 13365 * // => false 13366 * 13367 * _.isInteger('3'); 13368 * // => false 13369 */ 13370 function isInteger(value) { 13371 return typeof value == 'number' && value == toInteger(value); 13372 } 13373 13374 /** 13375 * Checks if `value` is a valid array-like length. 13376 * 13377 * **Note:** This method is loosely based on 13378 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 13379 * 13380 * @static 13381 * @memberOf _ 13382 * @since 4.0.0 13383 * @category Lang 13384 * @param {*} value The value to check. 13385 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 13386 * @example 13387 * 13388 * _.isLength(3); 13389 * // => true 13390 * 13391 * _.isLength(Number.MIN_VALUE); 13392 * // => false 13393 * 13394 * _.isLength(Infinity); 13395 * // => false 13396 * 13397 * _.isLength('3'); 13398 * // => false 13399 */ 13400 function isLength(value) { 13401 return typeof value == 'number' && 13402 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 13403 } 13404 13405 /** 13406 * Checks if `value` is the 13407 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 13408 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 13409 * 13410 * @static 13411 * @memberOf _ 13412 * @since 0.1.0 13413 * @category Lang 13414 * @param {*} value The value to check. 13415 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 13416 * @example 13417 * 13418 * _.isObject({}); 13419 * // => true 13420 * 13421 * _.isObject([1, 2, 3]); 13422 * // => true 13423 * 13424 * _.isObject(_.noop); 13425 * // => true 13426 * 13427 * _.isObject(null); 13428 * // => false 13429 */ 13430 function isObject(value) { 13431 var type = typeof value; 13432 return value != null && (type == 'object' || type == 'function'); 13433 } 13434 13435 /** 13436 * Checks if `value` is object-like. A value is object-like if it's not `null` 13437 * and has a `typeof` result of "object". 13438 * 13439 * @static 13440 * @memberOf _ 13441 * @since 4.0.0 13442 * @category Lang 13443 * @param {*} value The value to check. 13444 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 13445 * @example 13446 * 13447 * _.isObjectLike({}); 13448 * // => true 13449 * 13450 * _.isObjectLike([1, 2, 3]); 13451 * // => true 13452 * 13453 * _.isObjectLike(_.noop); 13454 * // => false 13455 * 13456 * _.isObjectLike(null); 13457 * // => false 13458 */ 13459 function isObjectLike(value) { 13460 return value != null && typeof value == 'object'; 13461 } 13462 13463 /** 13464 * Checks if `value` is classified as a `Map` object. 13465 * 13466 * @static 13467 * @memberOf _ 13468 * @since 4.3.0 13469 * @category Lang 13470 * @param {*} value The value to check. 13471 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 13472 * @example 13473 * 13474 * _.isMap(new Map); 13475 * // => true 13476 * 13477 * _.isMap(new WeakMap); 13478 * // => false 13479 */ 13480 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; 13481 13482 /** 13483 * Performs a partial deep comparison between `object` and `source` to 13484 * determine if `object` contains equivalent property values. 13485 * 13486 * **Note:** This method is equivalent to `_.matches` when `source` is 13487 * partially applied. 13488 * 13489 * Partial comparisons will match empty array and empty object `source` 13490 * values against any array or object value, respectively. See `_.isEqual` 13491 * for a list of supported value comparisons. 13492 * 13493 * @static 13494 * @memberOf _ 13495 * @since 3.0.0 13496 * @category Lang 13497 * @param {Object} object The object to inspect. 13498 * @param {Object} source The object of property values to match. 13499 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 13500 * @example 13501 * 13502 * var object = { 'a': 1, 'b': 2 }; 13503 * 13504 * _.isMatch(object, { 'b': 2 }); 13505 * // => true 13506 * 13507 * _.isMatch(object, { 'b': 1 }); 13508 * // => false 13509 */ 13510 function isMatch(object, source) { 13511 return object === source || baseIsMatch(object, source, getMatchData(source)); 13512 } 13513 13514 /** 13515 * This method is like `_.isMatch` except that it accepts `customizer` which 13516 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 13517 * are handled by the method instead. The `customizer` is invoked with five 13518 * arguments: (objValue, srcValue, index|key, object, source). 13519 * 13520 * @static 13521 * @memberOf _ 13522 * @since 4.0.0 13523 * @category Lang 13524 * @param {Object} object The object to inspect. 13525 * @param {Object} source The object of property values to match. 13526 * @param {Function} [customizer] The function to customize comparisons. 13527 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 13528 * @example 13529 * 13530 * function isGreeting(value) { 13531 * return /^h(?:i|ello)$/.test(value); 13532 * } 13533 * 13534 * function customizer(objValue, srcValue) { 13535 * if (isGreeting(objValue) && isGreeting(srcValue)) { 13536 * return true; 13537 * } 13538 * } 13539 * 13540 * var object = { 'greeting': 'hello' }; 13541 * var source = { 'greeting': 'hi' }; 13542 * 13543 * _.isMatchWith(object, source, customizer); 13544 * // => true 13545 */ 13546 function isMatchWith(object, source, customizer) { 13547 customizer = typeof customizer == 'function' ? customizer : undefined; 13548 return baseIsMatch(object, source, getMatchData(source), customizer); 13549 } 13550 13551 /** 13552 * Checks if `value` is `NaN`. 13553 * 13554 * **Note:** This method is based on 13555 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as 13556 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for 13557 * `undefined` and other non-number values. 13558 * 13559 * @static 13560 * @memberOf _ 13561 * @since 0.1.0 13562 * @category Lang 13563 * @param {*} value The value to check. 13564 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 13565 * @example 13566 * 13567 * _.isNaN(NaN); 13568 * // => true 13569 * 13570 * _.isNaN(new Number(NaN)); 13571 * // => true 13572 * 13573 * isNaN(undefined); 13574 * // => true 13575 * 13576 * _.isNaN(undefined); 13577 * // => false 13578 */ 13579 function isNaN(value) { 13580 // An `NaN` primitive is the only value that is not equal to itself. 13581 // Perform the `toStringTag` check first to avoid errors with some 13582 // ActiveX objects in IE. 13583 return isNumber(value) && value != +value; 13584 } 13585 13586 /** 13587 * Checks if `value` is a pristine native function. 13588 * 13589 * **Note:** This method can't reliably detect native functions in the presence 13590 * of the core-js package because core-js circumvents this kind of detection. 13591 * Despite multiple requests, the core-js maintainer has made it clear: any 13592 * attempt to fix the detection will be obstructed. As a result, we're left 13593 * with little choice but to throw an error. Unfortunately, this also affects 13594 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), 13595 * which rely on core-js. 13596 * 13597 * @static 13598 * @memberOf _ 13599 * @since 3.0.0 13600 * @category Lang 13601 * @param {*} value The value to check. 13602 * @returns {boolean} Returns `true` if `value` is a native function, 13603 * else `false`. 13604 * @example 13605 * 13606 * _.isNative(Array.prototype.push); 13607 * // => true 13608 * 13609 * _.isNative(_); 13610 * // => false 13611 */ 13612 function isNative(value) { 13613 if (isMaskable(value)) { 13614 throw new Error(CORE_ERROR_TEXT); 13615 } 13616 return baseIsNative(value); 13617 } 13618 13619 /** 13620 * Checks if `value` is `null`. 13621 * 13622 * @static 13623 * @memberOf _ 13624 * @since 0.1.0 13625 * @category Lang 13626 * @param {*} value The value to check. 13627 * @returns {boolean} Returns `true` if `value` is `null`, else `false`. 13628 * @example 13629 * 13630 * _.isNull(null); 13631 * // => true 13632 * 13633 * _.isNull(void 0); 13634 * // => false 13635 */ 13636 function isNull(value) { 13637 return value === null; 13638 } 13639 13640 /** 13641 * Checks if `value` is `null` or `undefined`. 13642 * 13643 * @static 13644 * @memberOf _ 13645 * @since 4.0.0 13646 * @category Lang 13647 * @param {*} value The value to check. 13648 * @returns {boolean} Returns `true` if `value` is nullish, else `false`. 13649 * @example 13650 * 13651 * _.isNil(null); 13652 * // => true 13653 * 13654 * _.isNil(void 0); 13655 * // => true 13656 * 13657 * _.isNil(NaN); 13658 * // => false 13659 */ 13660 function isNil(value) { 13661 return value == null; 13662 } 13663 13664 /** 13665 * Checks if `value` is classified as a `Number` primitive or object. 13666 * 13667 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are 13668 * classified as numbers, use the `_.isFinite` method. 13669 * 13670 * @static 13671 * @memberOf _ 13672 * @since 0.1.0 13673 * @category Lang 13674 * @param {*} value The value to check. 13675 * @returns {boolean} Returns `true` if `value` is a number, else `false`. 13676 * @example 13677 * 13678 * _.isNumber(3); 13679 * // => true 13680 * 13681 * _.isNumber(Number.MIN_VALUE); 13682 * // => true 13683 * 13684 * _.isNumber(Infinity); 13685 * // => true 13686 * 13687 * _.isNumber('3'); 13688 * // => false 13689 */ 13690 function isNumber(value) { 13691 return typeof value == 'number' || 13692 (isObjectLike(value) && baseGetTag(value) == numberTag); 13693 } 13694 13695 /** 13696 * Checks if `value` is a plain object, that is, an object created by the 13697 * `Object` constructor or one with a `[[Prototype]]` of `null`. 13698 * 13699 * @static 13700 * @memberOf _ 13701 * @since 0.8.0 13702 * @category Lang 13703 * @param {*} value The value to check. 13704 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 13705 * @example 13706 * 13707 * function Foo() { 13708 * this.a = 1; 13709 * } 13710 * 13711 * _.isPlainObject(new Foo); 13712 * // => false 13713 * 13714 * _.isPlainObject([1, 2, 3]); 13715 * // => false 13716 * 13717 * _.isPlainObject({ 'x': 0, 'y': 0 }); 13718 * // => true 13719 * 13720 * _.isPlainObject(Object.create(null)); 13721 * // => true 13722 */ 13723 function isPlainObject(value) { 13724 if (!isObjectLike(value) || baseGetTag(value) != objectTag) { 13725 return false; 13726 } 13727 var proto = getPrototype(value); 13728 if (proto === null) { 13729 return true; 13730 } 13731 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 13732 return typeof Ctor == 'function' && Ctor instanceof Ctor && 13733 funcToString.call(Ctor) == objectCtorString; 13734 } 13735 13736 /** 13737 * Checks if `value` is classified as a `RegExp` object. 13738 * 13739 * @static 13740 * @memberOf _ 13741 * @since 0.1.0 13742 * @category Lang 13743 * @param {*} value The value to check. 13744 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 13745 * @example 13746 * 13747 * _.isRegExp(/abc/); 13748 * // => true 13749 * 13750 * _.isRegExp('/abc/'); 13751 * // => false 13752 */ 13753 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; 13754 13755 /** 13756 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 13757 * double precision number which isn't the result of a rounded unsafe integer. 13758 * 13759 * **Note:** This method is based on 13760 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). 13761 * 13762 * @static 13763 * @memberOf _ 13764 * @since 4.0.0 13765 * @category Lang 13766 * @param {*} value The value to check. 13767 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. 13768 * @example 13769 * 13770 * _.isSafeInteger(3); 13771 * // => true 13772 * 13773 * _.isSafeInteger(Number.MIN_VALUE); 13774 * // => false 13775 * 13776 * _.isSafeInteger(Infinity); 13777 * // => false 13778 * 13779 * _.isSafeInteger('3'); 13780 * // => false 13781 */ 13782 function isSafeInteger(value) { 13783 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; 13784 } 13785 13786 /** 13787 * Checks if `value` is classified as a `Set` object. 13788 * 13789 * @static 13790 * @memberOf _ 13791 * @since 4.3.0 13792 * @category Lang 13793 * @param {*} value The value to check. 13794 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 13795 * @example 13796 * 13797 * _.isSet(new Set); 13798 * // => true 13799 * 13800 * _.isSet(new WeakSet); 13801 * // => false 13802 */ 13803 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; 13804 13805 /** 13806 * Checks if `value` is classified as a `String` primitive or object. 13807 * 13808 * @static 13809 * @since 0.1.0 13810 * @memberOf _ 13811 * @category Lang 13812 * @param {*} value The value to check. 13813 * @returns {boolean} Returns `true` if `value` is a string, else `false`. 13814 * @example 13815 * 13816 * _.isString('abc'); 13817 * // => true 13818 * 13819 * _.isString(1); 13820 * // => false 13821 */ 13822 function isString(value) { 13823 return typeof value == 'string' || 13824 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); 13825 } 13826 13827 /** 13828 * Checks if `value` is classified as a `Symbol` primitive or object. 13829 * 13830 * @static 13831 * @memberOf _ 13832 * @since 4.0.0 13833 * @category Lang 13834 * @param {*} value The value to check. 13835 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 13836 * @example 13837 * 13838 * _.isSymbol(Symbol.iterator); 13839 * // => true 13840 * 13841 * _.isSymbol('abc'); 13842 * // => false 13843 */ 13844 function isSymbol(value) { 13845 return typeof value == 'symbol' || 13846 (isObjectLike(value) && baseGetTag(value) == symbolTag); 13847 } 13848 13849 /** 13850 * Checks if `value` is classified as a typed array. 13851 * 13852 * @static 13853 * @memberOf _ 13854 * @since 3.0.0 13855 * @category Lang 13856 * @param {*} value The value to check. 13857 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 13858 * @example 13859 * 13860 * _.isTypedArray(new Uint8Array); 13861 * // => true 13862 * 13863 * _.isTypedArray([]); 13864 * // => false 13865 */ 13866 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; 13867 13868 /** 13869 * Checks if `value` is `undefined`. 13870 * 13871 * @static 13872 * @since 0.1.0 13873 * @memberOf _ 13874 * @category Lang 13875 * @param {*} value The value to check. 13876 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. 13877 * @example 13878 * 13879 * _.isUndefined(void 0); 13880 * // => true 13881 * 13882 * _.isUndefined(null); 13883 * // => false 13884 */ 13885 function isUndefined(value) { 13886 return value === undefined; 13887 } 13888 13889 /** 13890 * Checks if `value` is classified as a `WeakMap` object. 13891 * 13892 * @static 13893 * @memberOf _ 13894 * @since 4.3.0 13895 * @category Lang 13896 * @param {*} value The value to check. 13897 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. 13898 * @example 13899 * 13900 * _.isWeakMap(new WeakMap); 13901 * // => true 13902 * 13903 * _.isWeakMap(new Map); 13904 * // => false 13905 */ 13906 function isWeakMap(value) { 13907 return isObjectLike(value) && getTag(value) == weakMapTag; 13908 } 13909 13910 /** 13911 * Checks if `value` is classified as a `WeakSet` object. 13912 * 13913 * @static 13914 * @memberOf _ 13915 * @since 4.3.0 13916 * @category Lang 13917 * @param {*} value The value to check. 13918 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. 13919 * @example 13920 * 13921 * _.isWeakSet(new WeakSet); 13922 * // => true 13923 * 13924 * _.isWeakSet(new Set); 13925 * // => false 13926 */ 13927 function isWeakSet(value) { 13928 return isObjectLike(value) && baseGetTag(value) == weakSetTag; 13929 } 13930 13931 /** 13932 * Checks if `value` is less than `other`. 13933 * 13934 * @static 13935 * @memberOf _ 13936 * @since 3.9.0 13937 * @category Lang 13938 * @param {*} value The value to compare. 13939 * @param {*} other The other value to compare. 13940 * @returns {boolean} Returns `true` if `value` is less than `other`, 13941 * else `false`. 13942 * @see _.gt 13943 * @example 13944 * 13945 * _.lt(1, 3); 13946 * // => true 13947 * 13948 * _.lt(3, 3); 13949 * // => false 13950 * 13951 * _.lt(3, 1); 13952 * // => false 13953 */ 13954 var lt = createRelationalOperation(baseLt); 13955 13956 /** 13957 * Checks if `value` is less than or equal to `other`. 13958 * 13959 * @static 13960 * @memberOf _ 13961 * @since 3.9.0 13962 * @category Lang 13963 * @param {*} value The value to compare. 13964 * @param {*} other The other value to compare. 13965 * @returns {boolean} Returns `true` if `value` is less than or equal to 13966 * `other`, else `false`. 13967 * @see _.gte 13968 * @example 13969 * 13970 * _.lte(1, 3); 13971 * // => true 13972 * 13973 * _.lte(3, 3); 13974 * // => true 13975 * 13976 * _.lte(3, 1); 13977 * // => false 13978 */ 13979 var lte = createRelationalOperation(function(value, other) { 13980 return value <= other; 13981 }); 13982 13983 /** 13984 * Converts `value` to an array. 13985 * 13986 * @static 13987 * @since 0.1.0 13988 * @memberOf _ 13989 * @category Lang 13990 * @param {*} value The value to convert. 13991 * @returns {Array} Returns the converted array. 13992 * @example 13993 * 13994 * _.toArray({ 'a': 1, 'b': 2 }); 13995 * // => [1, 2] 13996 * 13997 * _.toArray('abc'); 13998 * // => ['a', 'b', 'c'] 13999 * 14000 * _.toArray(1); 14001 * // => [] 14002 * 14003 * _.toArray(null); 14004 * // => [] 14005 */ 14006 function toArray(value) { 14007 if (!value) { 14008 return []; 14009 } 14010 if (isArrayLike(value)) { 14011 return isString(value) ? stringToArray(value) : copyArray(value); 14012 } 14013 if (symIterator && value[symIterator]) { 14014 return iteratorToArray(value[symIterator]()); 14015 } 14016 var tag = getTag(value), 14017 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); 14018 14019 return func(value); 14020 } 14021 14022 /** 14023 * Converts `value` to a finite number. 14024 * 14025 * @static 14026 * @memberOf _ 14027 * @since 4.12.0 14028 * @category Lang 14029 * @param {*} value The value to convert. 14030 * @returns {number} Returns the converted number. 14031 * @example 14032 * 14033 * _.toFinite(3.2); 14034 * // => 3.2 14035 * 14036 * _.toFinite(Number.MIN_VALUE); 14037 * // => 5e-324 14038 * 14039 * _.toFinite(Infinity); 14040 * // => 1.7976931348623157e+308 14041 * 14042 * _.toFinite('3.2'); 14043 * // => 3.2 14044 */ 14045 function toFinite(value) { 14046 if (!value) { 14047 return value === 0 ? value : 0; 14048 } 14049 value = toNumber(value); 14050 if (value === INFINITY || value === -INFINITY) { 14051 var sign = (value < 0 ? -1 : 1); 14052 return sign * MAX_INTEGER; 14053 } 14054 return value === value ? value : 0; 14055 } 14056 14057 /** 14058 * Converts `value` to an integer. 14059 * 14060 * **Note:** This method is loosely based on 14061 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). 14062 * 14063 * @static 14064 * @memberOf _ 14065 * @since 4.0.0 14066 * @category Lang 14067 * @param {*} value The value to convert. 14068 * @returns {number} Returns the converted integer. 14069 * @example 14070 * 14071 * _.toInteger(3.2); 14072 * // => 3 14073 * 14074 * _.toInteger(Number.MIN_VALUE); 14075 * // => 0 14076 * 14077 * _.toInteger(Infinity); 14078 * // => 1.7976931348623157e+308 14079 * 14080 * _.toInteger('3.2'); 14081 * // => 3 14082 */ 14083 function toInteger(value) { 14084 var result = toFinite(value), 14085 remainder = result % 1; 14086 14087 return result === result ? (remainder ? result - remainder : result) : 0; 14088 } 14089 14090 /** 14091 * Converts `value` to an integer suitable for use as the length of an 14092 * array-like object. 14093 * 14094 * **Note:** This method is based on 14095 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 14096 * 14097 * @static 14098 * @memberOf _ 14099 * @since 4.0.0 14100 * @category Lang 14101 * @param {*} value The value to convert. 14102 * @returns {number} Returns the converted integer. 14103 * @example 14104 * 14105 * _.toLength(3.2); 14106 * // => 3 14107 * 14108 * _.toLength(Number.MIN_VALUE); 14109 * // => 0 14110 * 14111 * _.toLength(Infinity); 14112 * // => 4294967295 14113 * 14114 * _.toLength('3.2'); 14115 * // => 3 14116 */ 14117 function toLength(value) { 14118 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; 14119 } 14120 14121 /** 14122 * Converts `value` to a number. 14123 * 14124 * @static 14125 * @memberOf _ 14126 * @since 4.0.0 14127 * @category Lang 14128 * @param {*} value The value to process. 14129 * @returns {number} Returns the number. 14130 * @example 14131 * 14132 * _.toNumber(3.2); 14133 * // => 3.2 14134 * 14135 * _.toNumber(Number.MIN_VALUE); 14136 * // => 5e-324 14137 * 14138 * _.toNumber(Infinity); 14139 * // => Infinity 14140 * 14141 * _.toNumber('3.2'); 14142 * // => 3.2 14143 */ 14144 function toNumber(value) { 14145 if (typeof value == 'number') { 14146 return value; 14147 } 14148 if (isSymbol(value)) { 14149 return NAN; 14150 } 14151 if (isObject(value)) { 14152 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 14153 value = isObject(other) ? (other + '') : other; 14154 } 14155 if (typeof value != 'string') { 14156 return value === 0 ? value : +value; 14157 } 14158 value = value.replace(reTrim, ''); 14159 var isBinary = reIsBinary.test(value); 14160 return (isBinary || reIsOctal.test(value)) 14161 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 14162 : (reIsBadHex.test(value) ? NAN : +value); 14163 } 14164 14165 /** 14166 * Converts `value` to a plain object flattening inherited enumerable string 14167 * keyed properties of `value` to own properties of the plain object. 14168 * 14169 * @static 14170 * @memberOf _ 14171 * @since 3.0.0 14172 * @category Lang 14173 * @param {*} value The value to convert. 14174 * @returns {Object} Returns the converted plain object. 14175 * @example 14176 * 14177 * function Foo() { 14178 * this.b = 2; 14179 * } 14180 * 14181 * Foo.prototype.c = 3; 14182 * 14183 * _.assign({ 'a': 1 }, new Foo); 14184 * // => { 'a': 1, 'b': 2 } 14185 * 14186 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); 14187 * // => { 'a': 1, 'b': 2, 'c': 3 } 14188 */ 14189 function toPlainObject(value) { 14190 return copyObject(value, keysIn(value)); 14191 } 14192 14193 /** 14194 * Converts `value` to a safe integer. A safe integer can be compared and 14195 * represented correctly. 14196 * 14197 * @static 14198 * @memberOf _ 14199 * @since 4.0.0 14200 * @category Lang 14201 * @param {*} value The value to convert. 14202 * @returns {number} Returns the converted integer. 14203 * @example 14204 * 14205 * _.toSafeInteger(3.2); 14206 * // => 3 14207 * 14208 * _.toSafeInteger(Number.MIN_VALUE); 14209 * // => 0 14210 * 14211 * _.toSafeInteger(Infinity); 14212 * // => 9007199254740991 14213 * 14214 * _.toSafeInteger('3.2'); 14215 * // => 3 14216 */ 14217 function toSafeInteger(value) { 14218 return value 14219 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) 14220 : (value === 0 ? value : 0); 14221 } 14222 14223 /** 14224 * Converts `value` to a string. An empty string is returned for `null` 14225 * and `undefined` values. The sign of `-0` is preserved. 14226 * 14227 * @static 14228 * @memberOf _ 14229 * @since 4.0.0 14230 * @category Lang 14231 * @param {*} value The value to convert. 14232 * @returns {string} Returns the converted string. 14233 * @example 14234 * 14235 * _.toString(null); 14236 * // => '' 14237 * 14238 * _.toString(-0); 14239 * // => '-0' 14240 * 14241 * _.toString([1, 2, 3]); 14242 * // => '1,2,3' 14243 */ 14244 function toString(value) { 14245 return value == null ? '' : baseToString(value); 14246 } 14247 14248 /*------------------------------------------------------------------------*/ 14249 14250 /** 14251 * Assigns own enumerable string keyed properties of source objects to the 14252 * destination object. Source objects are applied from left to right. 14253 * Subsequent sources overwrite property assignments of previous sources. 14254 * 14255 * **Note:** This method mutates `object` and is loosely based on 14256 * [`Object.assign`](https://mdn.io/Object/assign). 14257 * 14258 * @static 14259 * @memberOf _ 14260 * @since 0.10.0 14261 * @category Object 14262 * @param {Object} object The destination object. 14263 * @param {...Object} [sources] The source objects. 14264 * @returns {Object} Returns `object`. 14265 * @see _.assignIn 14266 * @example 14267 * 14268 * function Foo() { 14269 * this.a = 1; 14270 * } 14271 * 14272 * function Bar() { 14273 * this.c = 3; 14274 * } 14275 * 14276 * Foo.prototype.b = 2; 14277 * Bar.prototype.d = 4; 14278 * 14279 * _.assign({ 'a': 0 }, new Foo, new Bar); 14280 * // => { 'a': 1, 'c': 3 } 14281 */ 14282 var assign = createAssigner(function(object, source) { 14283 if (isPrototype(source) || isArrayLike(source)) { 14284 copyObject(source, keys(source), object); 14285 return; 14286 } 14287 for (var key in source) { 14288 if (hasOwnProperty.call(source, key)) { 14289 assignValue(object, key, source[key]); 14290 } 14291 } 14292 }); 14293 14294 /** 14295 * This method is like `_.assign` except that it iterates over own and 14296 * inherited source properties. 14297 * 14298 * **Note:** This method mutates `object`. 14299 * 14300 * @static 14301 * @memberOf _ 14302 * @since 4.0.0 14303 * @alias extend 14304 * @category Object 14305 * @param {Object} object The destination object. 14306 * @param {...Object} [sources] The source objects. 14307 * @returns {Object} Returns `object`. 14308 * @see _.assign 14309 * @example 14310 * 14311 * function Foo() { 14312 * this.a = 1; 14313 * } 14314 * 14315 * function Bar() { 14316 * this.c = 3; 14317 * } 14318 * 14319 * Foo.prototype.b = 2; 14320 * Bar.prototype.d = 4; 14321 * 14322 * _.assignIn({ 'a': 0 }, new Foo, new Bar); 14323 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } 14324 */ 14325 var assignIn = createAssigner(function(object, source) { 14326 copyObject(source, keysIn(source), object); 14327 }); 14328 14329 /** 14330 * This method is like `_.assignIn` except that it accepts `customizer` 14331 * which is invoked to produce the assigned values. If `customizer` returns 14332 * `undefined`, assignment is handled by the method instead. The `customizer` 14333 * is invoked with five arguments: (objValue, srcValue, key, object, source). 14334 * 14335 * **Note:** This method mutates `object`. 14336 * 14337 * @static 14338 * @memberOf _ 14339 * @since 4.0.0 14340 * @alias extendWith 14341 * @category Object 14342 * @param {Object} object The destination object. 14343 * @param {...Object} sources The source objects. 14344 * @param {Function} [customizer] The function to customize assigned values. 14345 * @returns {Object} Returns `object`. 14346 * @see _.assignWith 14347 * @example 14348 * 14349 * function customizer(objValue, srcValue) { 14350 * return _.isUndefined(objValue) ? srcValue : objValue; 14351 * } 14352 * 14353 * var defaults = _.partialRight(_.assignInWith, customizer); 14354 * 14355 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 14356 * // => { 'a': 1, 'b': 2 } 14357 */ 14358 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { 14359 copyObject(source, keysIn(source), object, customizer); 14360 }); 14361 14362 /** 14363 * This method is like `_.assign` except that it accepts `customizer` 14364 * which is invoked to produce the assigned values. If `customizer` returns 14365 * `undefined`, assignment is handled by the method instead. The `customizer` 14366 * is invoked with five arguments: (objValue, srcValue, key, object, source). 14367 * 14368 * **Note:** This method mutates `object`. 14369 * 14370 * @static 14371 * @memberOf _ 14372 * @since 4.0.0 14373 * @category Object 14374 * @param {Object} object The destination object. 14375 * @param {...Object} sources The source objects. 14376 * @param {Function} [customizer] The function to customize assigned values. 14377 * @returns {Object} Returns `object`. 14378 * @see _.assignInWith 14379 * @example 14380 * 14381 * function customizer(objValue, srcValue) { 14382 * return _.isUndefined(objValue) ? srcValue : objValue; 14383 * } 14384 * 14385 * var defaults = _.partialRight(_.assignWith, customizer); 14386 * 14387 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 14388 * // => { 'a': 1, 'b': 2 } 14389 */ 14390 var assignWith = createAssigner(function(object, source, srcIndex, customizer) { 14391 copyObject(source, keys(source), object, customizer); 14392 }); 14393 14394 /** 14395 * Creates an array of values corresponding to `paths` of `object`. 14396 * 14397 * @static 14398 * @memberOf _ 14399 * @since 1.0.0 14400 * @category Object 14401 * @param {Object} object The object to iterate over. 14402 * @param {...(string|string[])} [paths] The property paths to pick. 14403 * @returns {Array} Returns the picked values. 14404 * @example 14405 * 14406 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 14407 * 14408 * _.at(object, ['a[0].b.c', 'a[1]']); 14409 * // => [3, 4] 14410 */ 14411 var at = flatRest(baseAt); 14412 14413 /** 14414 * Creates an object that inherits from the `prototype` object. If a 14415 * `properties` object is given, its own enumerable string keyed properties 14416 * are assigned to the created object. 14417 * 14418 * @static 14419 * @memberOf _ 14420 * @since 2.3.0 14421 * @category Object 14422 * @param {Object} prototype The object to inherit from. 14423 * @param {Object} [properties] The properties to assign to the object. 14424 * @returns {Object} Returns the new object. 14425 * @example 14426 * 14427 * function Shape() { 14428 * this.x = 0; 14429 * this.y = 0; 14430 * } 14431 * 14432 * function Circle() { 14433 * Shape.call(this); 14434 * } 14435 * 14436 * Circle.prototype = _.create(Shape.prototype, { 14437 * 'constructor': Circle 14438 * }); 14439 * 14440 * var circle = new Circle; 14441 * circle instanceof Circle; 14442 * // => true 14443 * 14444 * circle instanceof Shape; 14445 * // => true 14446 */ 14447 function create(prototype, properties) { 14448 var result = baseCreate(prototype); 14449 return properties == null ? result : baseAssign(result, properties); 14450 } 14451 14452 /** 14453 * Assigns own and inherited enumerable string keyed properties of source 14454 * objects to the destination object for all destination properties that 14455 * resolve to `undefined`. Source objects are applied from left to right. 14456 * Once a property is set, additional values of the same property are ignored. 14457 * 14458 * **Note:** This method mutates `object`. 14459 * 14460 * @static 14461 * @since 0.1.0 14462 * @memberOf _ 14463 * @category Object 14464 * @param {Object} object The destination object. 14465 * @param {...Object} [sources] The source objects. 14466 * @returns {Object} Returns `object`. 14467 * @see _.defaultsDeep 14468 * @example 14469 * 14470 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 14471 * // => { 'a': 1, 'b': 2 } 14472 */ 14473 var defaults = baseRest(function(object, sources) { 14474 object = Object(object); 14475 14476 var index = -1; 14477 var length = sources.length; 14478 var guard = length > 2 ? sources[2] : undefined; 14479 14480 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 14481 length = 1; 14482 } 14483 14484 while (++index < length) { 14485 var source = sources[index]; 14486 var props = keysIn(source); 14487 var propsIndex = -1; 14488 var propsLength = props.length; 14489 14490 while (++propsIndex < propsLength) { 14491 var key = props[propsIndex]; 14492 var value = object[key]; 14493 14494 if (value === undefined || 14495 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { 14496 object[key] = source[key]; 14497 } 14498 } 14499 } 14500 14501 return object; 14502 }); 14503 14504 /** 14505 * This method is like `_.defaults` except that it recursively assigns 14506 * default properties. 14507 * 14508 * **Note:** This method mutates `object`. 14509 * 14510 * @static 14511 * @memberOf _ 14512 * @since 3.10.0 14513 * @category Object 14514 * @param {Object} object The destination object. 14515 * @param {...Object} [sources] The source objects. 14516 * @returns {Object} Returns `object`. 14517 * @see _.defaults 14518 * @example 14519 * 14520 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); 14521 * // => { 'a': { 'b': 2, 'c': 3 } } 14522 */ 14523 var defaultsDeep = baseRest(function(args) { 14524 args.push(undefined, customDefaultsMerge); 14525 return apply(mergeWith, undefined, args); 14526 }); 14527 14528 /** 14529 * This method is like `_.find` except that it returns the key of the first 14530 * element `predicate` returns truthy for instead of the element itself. 14531 * 14532 * @static 14533 * @memberOf _ 14534 * @since 1.1.0 14535 * @category Object 14536 * @param {Object} object The object to inspect. 14537 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14538 * @returns {string|undefined} Returns the key of the matched element, 14539 * else `undefined`. 14540 * @example 14541 * 14542 * var users = { 14543 * 'barney': { 'age': 36, 'active': true }, 14544 * 'fred': { 'age': 40, 'active': false }, 14545 * 'pebbles': { 'age': 1, 'active': true } 14546 * }; 14547 * 14548 * _.findKey(users, function(o) { return o.age < 40; }); 14549 * // => 'barney' (iteration order is not guaranteed) 14550 * 14551 * // The `_.matches` iteratee shorthand. 14552 * _.findKey(users, { 'age': 1, 'active': true }); 14553 * // => 'pebbles' 14554 * 14555 * // The `_.matchesProperty` iteratee shorthand. 14556 * _.findKey(users, ['active', false]); 14557 * // => 'fred' 14558 * 14559 * // The `_.property` iteratee shorthand. 14560 * _.findKey(users, 'active'); 14561 * // => 'barney' 14562 */ 14563 function findKey(object, predicate) { 14564 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); 14565 } 14566 14567 /** 14568 * This method is like `_.findKey` except that it iterates over elements of 14569 * a collection in the opposite order. 14570 * 14571 * @static 14572 * @memberOf _ 14573 * @since 2.0.0 14574 * @category Object 14575 * @param {Object} object The object to inspect. 14576 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14577 * @returns {string|undefined} Returns the key of the matched element, 14578 * else `undefined`. 14579 * @example 14580 * 14581 * var users = { 14582 * 'barney': { 'age': 36, 'active': true }, 14583 * 'fred': { 'age': 40, 'active': false }, 14584 * 'pebbles': { 'age': 1, 'active': true } 14585 * }; 14586 * 14587 * _.findLastKey(users, function(o) { return o.age < 40; }); 14588 * // => returns 'pebbles' assuming `_.findKey` returns 'barney' 14589 * 14590 * // The `_.matches` iteratee shorthand. 14591 * _.findLastKey(users, { 'age': 36, 'active': true }); 14592 * // => 'barney' 14593 * 14594 * // The `_.matchesProperty` iteratee shorthand. 14595 * _.findLastKey(users, ['active', false]); 14596 * // => 'fred' 14597 * 14598 * // The `_.property` iteratee shorthand. 14599 * _.findLastKey(users, 'active'); 14600 * // => 'pebbles' 14601 */ 14602 function findLastKey(object, predicate) { 14603 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); 14604 } 14605 14606 /** 14607 * Iterates over own and inherited enumerable string keyed properties of an 14608 * object and invokes `iteratee` for each property. The iteratee is invoked 14609 * with three arguments: (value, key, object). Iteratee functions may exit 14610 * iteration early by explicitly returning `false`. 14611 * 14612 * @static 14613 * @memberOf _ 14614 * @since 0.3.0 14615 * @category Object 14616 * @param {Object} object The object to iterate over. 14617 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14618 * @returns {Object} Returns `object`. 14619 * @see _.forInRight 14620 * @example 14621 * 14622 * function Foo() { 14623 * this.a = 1; 14624 * this.b = 2; 14625 * } 14626 * 14627 * Foo.prototype.c = 3; 14628 * 14629 * _.forIn(new Foo, function(value, key) { 14630 * console.log(key); 14631 * }); 14632 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). 14633 */ 14634 function forIn(object, iteratee) { 14635 return object == null 14636 ? object 14637 : baseFor(object, getIteratee(iteratee, 3), keysIn); 14638 } 14639 14640 /** 14641 * This method is like `_.forIn` except that it iterates over properties of 14642 * `object` in the opposite order. 14643 * 14644 * @static 14645 * @memberOf _ 14646 * @since 2.0.0 14647 * @category Object 14648 * @param {Object} object The object to iterate over. 14649 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14650 * @returns {Object} Returns `object`. 14651 * @see _.forIn 14652 * @example 14653 * 14654 * function Foo() { 14655 * this.a = 1; 14656 * this.b = 2; 14657 * } 14658 * 14659 * Foo.prototype.c = 3; 14660 * 14661 * _.forInRight(new Foo, function(value, key) { 14662 * console.log(key); 14663 * }); 14664 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. 14665 */ 14666 function forInRight(object, iteratee) { 14667 return object == null 14668 ? object 14669 : baseForRight(object, getIteratee(iteratee, 3), keysIn); 14670 } 14671 14672 /** 14673 * Iterates over own enumerable string keyed properties of an object and 14674 * invokes `iteratee` for each property. The iteratee is invoked with three 14675 * arguments: (value, key, object). Iteratee functions may exit iteration 14676 * early by explicitly returning `false`. 14677 * 14678 * @static 14679 * @memberOf _ 14680 * @since 0.3.0 14681 * @category Object 14682 * @param {Object} object The object to iterate over. 14683 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14684 * @returns {Object} Returns `object`. 14685 * @see _.forOwnRight 14686 * @example 14687 * 14688 * function Foo() { 14689 * this.a = 1; 14690 * this.b = 2; 14691 * } 14692 * 14693 * Foo.prototype.c = 3; 14694 * 14695 * _.forOwn(new Foo, function(value, key) { 14696 * console.log(key); 14697 * }); 14698 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 14699 */ 14700 function forOwn(object, iteratee) { 14701 return object && baseForOwn(object, getIteratee(iteratee, 3)); 14702 } 14703 14704 /** 14705 * This method is like `_.forOwn` except that it iterates over properties of 14706 * `object` in the opposite order. 14707 * 14708 * @static 14709 * @memberOf _ 14710 * @since 2.0.0 14711 * @category Object 14712 * @param {Object} object The object to iterate over. 14713 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14714 * @returns {Object} Returns `object`. 14715 * @see _.forOwn 14716 * @example 14717 * 14718 * function Foo() { 14719 * this.a = 1; 14720 * this.b = 2; 14721 * } 14722 * 14723 * Foo.prototype.c = 3; 14724 * 14725 * _.forOwnRight(new Foo, function(value, key) { 14726 * console.log(key); 14727 * }); 14728 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. 14729 */ 14730 function forOwnRight(object, iteratee) { 14731 return object && baseForOwnRight(object, getIteratee(iteratee, 3)); 14732 } 14733 14734 /** 14735 * Creates an array of function property names from own enumerable properties 14736 * of `object`. 14737 * 14738 * @static 14739 * @since 0.1.0 14740 * @memberOf _ 14741 * @category Object 14742 * @param {Object} object The object to inspect. 14743 * @returns {Array} Returns the function names. 14744 * @see _.functionsIn 14745 * @example 14746 * 14747 * function Foo() { 14748 * this.a = _.constant('a'); 14749 * this.b = _.constant('b'); 14750 * } 14751 * 14752 * Foo.prototype.c = _.constant('c'); 14753 * 14754 * _.functions(new Foo); 14755 * // => ['a', 'b'] 14756 */ 14757 function functions(object) { 14758 return object == null ? [] : baseFunctions(object, keys(object)); 14759 } 14760 14761 /** 14762 * Creates an array of function property names from own and inherited 14763 * enumerable properties of `object`. 14764 * 14765 * @static 14766 * @memberOf _ 14767 * @since 4.0.0 14768 * @category Object 14769 * @param {Object} object The object to inspect. 14770 * @returns {Array} Returns the function names. 14771 * @see _.functions 14772 * @example 14773 * 14774 * function Foo() { 14775 * this.a = _.constant('a'); 14776 * this.b = _.constant('b'); 14777 * } 14778 * 14779 * Foo.prototype.c = _.constant('c'); 14780 * 14781 * _.functionsIn(new Foo); 14782 * // => ['a', 'b', 'c'] 14783 */ 14784 function functionsIn(object) { 14785 return object == null ? [] : baseFunctions(object, keysIn(object)); 14786 } 14787 14788 /** 14789 * Gets the value at `path` of `object`. If the resolved value is 14790 * `undefined`, the `defaultValue` is returned in its place. 14791 * 14792 * @static 14793 * @memberOf _ 14794 * @since 3.7.0 14795 * @category Object 14796 * @param {Object} object The object to query. 14797 * @param {Array|string} path The path of the property to get. 14798 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 14799 * @returns {*} Returns the resolved value. 14800 * @example 14801 * 14802 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 14803 * 14804 * _.get(object, 'a[0].b.c'); 14805 * // => 3 14806 * 14807 * _.get(object, ['a', '0', 'b', 'c']); 14808 * // => 3 14809 * 14810 * _.get(object, 'a.b.c', 'default'); 14811 * // => 'default' 14812 */ 14813 function get(object, path, defaultValue) { 14814 var result = object == null ? undefined : baseGet(object, path); 14815 return result === undefined ? defaultValue : result; 14816 } 14817 14818 /** 14819 * Checks if `path` is a direct property of `object`. 14820 * 14821 * @static 14822 * @since 0.1.0 14823 * @memberOf _ 14824 * @category Object 14825 * @param {Object} object The object to query. 14826 * @param {Array|string} path The path to check. 14827 * @returns {boolean} Returns `true` if `path` exists, else `false`. 14828 * @example 14829 * 14830 * var object = { 'a': { 'b': 2 } }; 14831 * var other = _.create({ 'a': _.create({ 'b': 2 }) }); 14832 * 14833 * _.has(object, 'a'); 14834 * // => true 14835 * 14836 * _.has(object, 'a.b'); 14837 * // => true 14838 * 14839 * _.has(object, ['a', 'b']); 14840 * // => true 14841 * 14842 * _.has(other, 'a'); 14843 * // => false 14844 */ 14845 function has(object, path) { 14846 return object != null && hasPath(object, path, baseHas); 14847 } 14848 14849 /** 14850 * Checks if `path` is a direct or inherited property of `object`. 14851 * 14852 * @static 14853 * @memberOf _ 14854 * @since 4.0.0 14855 * @category Object 14856 * @param {Object} object The object to query. 14857 * @param {Array|string} path The path to check. 14858 * @returns {boolean} Returns `true` if `path` exists, else `false`. 14859 * @example 14860 * 14861 * var object = _.create({ 'a': _.create({ 'b': 2 }) }); 14862 * 14863 * _.hasIn(object, 'a'); 14864 * // => true 14865 * 14866 * _.hasIn(object, 'a.b'); 14867 * // => true 14868 * 14869 * _.hasIn(object, ['a', 'b']); 14870 * // => true 14871 * 14872 * _.hasIn(object, 'b'); 14873 * // => false 14874 */ 14875 function hasIn(object, path) { 14876 return object != null && hasPath(object, path, baseHasIn); 14877 } 14878 14879 /** 14880 * Creates an object composed of the inverted keys and values of `object`. 14881 * If `object` contains duplicate values, subsequent values overwrite 14882 * property assignments of previous values. 14883 * 14884 * @static 14885 * @memberOf _ 14886 * @since 0.7.0 14887 * @category Object 14888 * @param {Object} object The object to invert. 14889 * @returns {Object} Returns the new inverted object. 14890 * @example 14891 * 14892 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 14893 * 14894 * _.invert(object); 14895 * // => { '1': 'c', '2': 'b' } 14896 */ 14897 var invert = createInverter(function(result, value, key) { 14898 if (value != null && 14899 typeof value.toString != 'function') { 14900 value = nativeObjectToString.call(value); 14901 } 14902 14903 result[value] = key; 14904 }, constant(identity)); 14905 14906 /** 14907 * This method is like `_.invert` except that the inverted object is generated 14908 * from the results of running each element of `object` thru `iteratee`. The 14909 * corresponding inverted value of each inverted key is an array of keys 14910 * responsible for generating the inverted value. The iteratee is invoked 14911 * with one argument: (value). 14912 * 14913 * @static 14914 * @memberOf _ 14915 * @since 4.1.0 14916 * @category Object 14917 * @param {Object} object The object to invert. 14918 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 14919 * @returns {Object} Returns the new inverted object. 14920 * @example 14921 * 14922 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 14923 * 14924 * _.invertBy(object); 14925 * // => { '1': ['a', 'c'], '2': ['b'] } 14926 * 14927 * _.invertBy(object, function(value) { 14928 * return 'group' + value; 14929 * }); 14930 * // => { 'group1': ['a', 'c'], 'group2': ['b'] } 14931 */ 14932 var invertBy = createInverter(function(result, value, key) { 14933 if (value != null && 14934 typeof value.toString != 'function') { 14935 value = nativeObjectToString.call(value); 14936 } 14937 14938 if (hasOwnProperty.call(result, value)) { 14939 result[value].push(key); 14940 } else { 14941 result[value] = [key]; 14942 } 14943 }, getIteratee); 14944 14945 /** 14946 * Invokes the method at `path` of `object`. 14947 * 14948 * @static 14949 * @memberOf _ 14950 * @since 4.0.0 14951 * @category Object 14952 * @param {Object} object The object to query. 14953 * @param {Array|string} path The path of the method to invoke. 14954 * @param {...*} [args] The arguments to invoke the method with. 14955 * @returns {*} Returns the result of the invoked method. 14956 * @example 14957 * 14958 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; 14959 * 14960 * _.invoke(object, 'a[0].b.c.slice', 1, 3); 14961 * // => [2, 3] 14962 */ 14963 var invoke = baseRest(baseInvoke); 14964 14965 /** 14966 * Creates an array of the own enumerable property names of `object`. 14967 * 14968 * **Note:** Non-object values are coerced to objects. See the 14969 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 14970 * for more details. 14971 * 14972 * @static 14973 * @since 0.1.0 14974 * @memberOf _ 14975 * @category Object 14976 * @param {Object} object The object to query. 14977 * @returns {Array} Returns the array of property names. 14978 * @example 14979 * 14980 * function Foo() { 14981 * this.a = 1; 14982 * this.b = 2; 14983 * } 14984 * 14985 * Foo.prototype.c = 3; 14986 * 14987 * _.keys(new Foo); 14988 * // => ['a', 'b'] (iteration order is not guaranteed) 14989 * 14990 * _.keys('hi'); 14991 * // => ['0', '1'] 14992 */ 14993 function keys(object) { 14994 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); 14995 } 14996 14997 /** 14998 * Creates an array of the own and inherited enumerable property names of `object`. 14999 * 15000 * **Note:** Non-object values are coerced to objects. 15001 * 15002 * @static 15003 * @memberOf _ 15004 * @since 3.0.0 15005 * @category Object 15006 * @param {Object} object The object to query. 15007 * @returns {Array} Returns the array of property names. 15008 * @example 15009 * 15010 * function Foo() { 15011 * this.a = 1; 15012 * this.b = 2; 15013 * } 15014 * 15015 * Foo.prototype.c = 3; 15016 * 15017 * _.keysIn(new Foo); 15018 * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 15019 */ 15020 function keysIn(object) { 15021 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); 15022 } 15023 15024 /** 15025 * The opposite of `_.mapValues`; this method creates an object with the 15026 * same values as `object` and keys generated by running each own enumerable 15027 * string keyed property of `object` thru `iteratee`. The iteratee is invoked 15028 * with three arguments: (value, key, object). 15029 * 15030 * @static 15031 * @memberOf _ 15032 * @since 3.8.0 15033 * @category Object 15034 * @param {Object} object The object to iterate over. 15035 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15036 * @returns {Object} Returns the new mapped object. 15037 * @see _.mapValues 15038 * @example 15039 * 15040 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { 15041 * return key + value; 15042 * }); 15043 * // => { 'a1': 1, 'b2': 2 } 15044 */ 15045 function mapKeys(object, iteratee) { 15046 var result = {}; 15047 iteratee = getIteratee(iteratee, 3); 15048 15049 baseForOwn(object, function(value, key, object) { 15050 baseAssignValue(result, iteratee(value, key, object), value); 15051 }); 15052 return result; 15053 } 15054 15055 /** 15056 * Creates an object with the same keys as `object` and values generated 15057 * by running each own enumerable string keyed property of `object` thru 15058 * `iteratee`. The iteratee is invoked with three arguments: 15059 * (value, key, object). 15060 * 15061 * @static 15062 * @memberOf _ 15063 * @since 2.4.0 15064 * @category Object 15065 * @param {Object} object The object to iterate over. 15066 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15067 * @returns {Object} Returns the new mapped object. 15068 * @see _.mapKeys 15069 * @example 15070 * 15071 * var users = { 15072 * 'fred': { 'user': 'fred', 'age': 40 }, 15073 * 'pebbles': { 'user': 'pebbles', 'age': 1 } 15074 * }; 15075 * 15076 * _.mapValues(users, function(o) { return o.age; }); 15077 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 15078 * 15079 * // The `_.property` iteratee shorthand. 15080 * _.mapValues(users, 'age'); 15081 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 15082 */ 15083 function mapValues(object, iteratee) { 15084 var result = {}; 15085 iteratee = getIteratee(iteratee, 3); 15086 15087 baseForOwn(object, function(value, key, object) { 15088 baseAssignValue(result, key, iteratee(value, key, object)); 15089 }); 15090 return result; 15091 } 15092 15093 /** 15094 * This method is like `_.assign` except that it recursively merges own and 15095 * inherited enumerable string keyed properties of source objects into the 15096 * destination object. Source properties that resolve to `undefined` are 15097 * skipped if a destination value exists. Array and plain object properties 15098 * are merged recursively. Other objects and value types are overridden by 15099 * assignment. Source objects are applied from left to right. Subsequent 15100 * sources overwrite property assignments of previous sources. 15101 * 15102 * **Note:** This method mutates `object`. 15103 * 15104 * @static 15105 * @memberOf _ 15106 * @since 0.5.0 15107 * @category Object 15108 * @param {Object} object The destination object. 15109 * @param {...Object} [sources] The source objects. 15110 * @returns {Object} Returns `object`. 15111 * @example 15112 * 15113 * var object = { 15114 * 'a': [{ 'b': 2 }, { 'd': 4 }] 15115 * }; 15116 * 15117 * var other = { 15118 * 'a': [{ 'c': 3 }, { 'e': 5 }] 15119 * }; 15120 * 15121 * _.merge(object, other); 15122 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } 15123 */ 15124 var merge = createAssigner(function(object, source, srcIndex) { 15125 baseMerge(object, source, srcIndex); 15126 }); 15127 15128 /** 15129 * This method is like `_.merge` except that it accepts `customizer` which 15130 * is invoked to produce the merged values of the destination and source 15131 * properties. If `customizer` returns `undefined`, merging is handled by the 15132 * method instead. The `customizer` is invoked with six arguments: 15133 * (objValue, srcValue, key, object, source, stack). 15134 * 15135 * **Note:** This method mutates `object`. 15136 * 15137 * @static 15138 * @memberOf _ 15139 * @since 4.0.0 15140 * @category Object 15141 * @param {Object} object The destination object. 15142 * @param {...Object} sources The source objects. 15143 * @param {Function} customizer The function to customize assigned values. 15144 * @returns {Object} Returns `object`. 15145 * @example 15146 * 15147 * function customizer(objValue, srcValue) { 15148 * if (_.isArray(objValue)) { 15149 * return objValue.concat(srcValue); 15150 * } 15151 * } 15152 * 15153 * var object = { 'a': [1], 'b': [2] }; 15154 * var other = { 'a': [3], 'b': [4] }; 15155 * 15156 * _.mergeWith(object, other, customizer); 15157 * // => { 'a': [1, 3], 'b': [2, 4] } 15158 */ 15159 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { 15160 baseMerge(object, source, srcIndex, customizer); 15161 }); 15162 15163 /** 15164 * The opposite of `_.pick`; this method creates an object composed of the 15165 * own and inherited enumerable property paths of `object` that are not omitted. 15166 * 15167 * **Note:** This method is considerably slower than `_.pick`. 15168 * 15169 * @static 15170 * @since 0.1.0 15171 * @memberOf _ 15172 * @category Object 15173 * @param {Object} object The source object. 15174 * @param {...(string|string[])} [paths] The property paths to omit. 15175 * @returns {Object} Returns the new object. 15176 * @example 15177 * 15178 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15179 * 15180 * _.omit(object, ['a', 'c']); 15181 * // => { 'b': '2' } 15182 */ 15183 var omit = flatRest(function(object, paths) { 15184 var result = {}; 15185 if (object == null) { 15186 return result; 15187 } 15188 var isDeep = false; 15189 paths = arrayMap(paths, function(path) { 15190 path = castPath(path, object); 15191 isDeep || (isDeep = path.length > 1); 15192 return path; 15193 }); 15194 copyObject(object, getAllKeysIn(object), result); 15195 if (isDeep) { 15196 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); 15197 } 15198 var length = paths.length; 15199 while (length--) { 15200 baseUnset(result, paths[length]); 15201 } 15202 return result; 15203 }); 15204 15205 /** 15206 * The opposite of `_.pickBy`; this method creates an object composed of 15207 * the own and inherited enumerable string keyed properties of `object` that 15208 * `predicate` doesn't return truthy for. The predicate is invoked with two 15209 * arguments: (value, key). 15210 * 15211 * @static 15212 * @memberOf _ 15213 * @since 4.0.0 15214 * @category Object 15215 * @param {Object} object The source object. 15216 * @param {Function} [predicate=_.identity] The function invoked per property. 15217 * @returns {Object} Returns the new object. 15218 * @example 15219 * 15220 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15221 * 15222 * _.omitBy(object, _.isNumber); 15223 * // => { 'b': '2' } 15224 */ 15225 function omitBy(object, predicate) { 15226 return pickBy(object, negate(getIteratee(predicate))); 15227 } 15228 15229 /** 15230 * Creates an object composed of the picked `object` properties. 15231 * 15232 * @static 15233 * @since 0.1.0 15234 * @memberOf _ 15235 * @category Object 15236 * @param {Object} object The source object. 15237 * @param {...(string|string[])} [paths] The property paths to pick. 15238 * @returns {Object} Returns the new object. 15239 * @example 15240 * 15241 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15242 * 15243 * _.pick(object, ['a', 'c']); 15244 * // => { 'a': 1, 'c': 3 } 15245 */ 15246 var pick = flatRest(function(object, paths) { 15247 return object == null ? {} : basePick(object, paths); 15248 }); 15249 15250 /** 15251 * Creates an object composed of the `object` properties `predicate` returns 15252 * truthy for. The predicate is invoked with two arguments: (value, key). 15253 * 15254 * @static 15255 * @memberOf _ 15256 * @since 4.0.0 15257 * @category Object 15258 * @param {Object} object The source object. 15259 * @param {Function} [predicate=_.identity] The function invoked per property. 15260 * @returns {Object} Returns the new object. 15261 * @example 15262 * 15263 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15264 * 15265 * _.pickBy(object, _.isNumber); 15266 * // => { 'a': 1, 'c': 3 } 15267 */ 15268 function pickBy(object, predicate) { 15269 if (object == null) { 15270 return {}; 15271 } 15272 var props = arrayMap(getAllKeysIn(object), function(prop) { 15273 return [prop]; 15274 }); 15275 predicate = getIteratee(predicate); 15276 return basePickBy(object, props, function(value, path) { 15277 return predicate(value, path[0]); 15278 }); 15279 } 15280 15281 /** 15282 * This method is like `_.get` except that if the resolved value is a 15283 * function it's invoked with the `this` binding of its parent object and 15284 * its result is returned. 15285 * 15286 * @static 15287 * @since 0.1.0 15288 * @memberOf _ 15289 * @category Object 15290 * @param {Object} object The object to query. 15291 * @param {Array|string} path The path of the property to resolve. 15292 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 15293 * @returns {*} Returns the resolved value. 15294 * @example 15295 * 15296 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; 15297 * 15298 * _.result(object, 'a[0].b.c1'); 15299 * // => 3 15300 * 15301 * _.result(object, 'a[0].b.c2'); 15302 * // => 4 15303 * 15304 * _.result(object, 'a[0].b.c3', 'default'); 15305 * // => 'default' 15306 * 15307 * _.result(object, 'a[0].b.c3', _.constant('default')); 15308 * // => 'default' 15309 */ 15310 function result(object, path, defaultValue) { 15311 path = castPath(path, object); 15312 15313 var index = -1, 15314 length = path.length; 15315 15316 // Ensure the loop is entered when path is empty. 15317 if (!length) { 15318 length = 1; 15319 object = undefined; 15320 } 15321 while (++index < length) { 15322 var value = object == null ? undefined : object[toKey(path[index])]; 15323 if (value === undefined) { 15324 index = length; 15325 value = defaultValue; 15326 } 15327 object = isFunction(value) ? value.call(object) : value; 15328 } 15329 return object; 15330 } 15331 15332 /** 15333 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, 15334 * it's created. Arrays are created for missing index properties while objects 15335 * are created for all other missing properties. Use `_.setWith` to customize 15336 * `path` creation. 15337 * 15338 * **Note:** This method mutates `object`. 15339 * 15340 * @static 15341 * @memberOf _ 15342 * @since 3.7.0 15343 * @category Object 15344 * @param {Object} object The object to modify. 15345 * @param {Array|string} path The path of the property to set. 15346 * @param {*} value The value to set. 15347 * @returns {Object} Returns `object`. 15348 * @example 15349 * 15350 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 15351 * 15352 * _.set(object, 'a[0].b.c', 4); 15353 * console.log(object.a[0].b.c); 15354 * // => 4 15355 * 15356 * _.set(object, ['x', '0', 'y', 'z'], 5); 15357 * console.log(object.x[0].y.z); 15358 * // => 5 15359 */ 15360 function set(object, path, value) { 15361 return object == null ? object : baseSet(object, path, value); 15362 } 15363 15364 /** 15365 * This method is like `_.set` except that it accepts `customizer` which is 15366 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 15367 * path creation is handled by the method instead. The `customizer` is invoked 15368 * with three arguments: (nsValue, key, nsObject). 15369 * 15370 * **Note:** This method mutates `object`. 15371 * 15372 * @static 15373 * @memberOf _ 15374 * @since 4.0.0 15375 * @category Object 15376 * @param {Object} object The object to modify. 15377 * @param {Array|string} path The path of the property to set. 15378 * @param {*} value The value to set. 15379 * @param {Function} [customizer] The function to customize assigned values. 15380 * @returns {Object} Returns `object`. 15381 * @example 15382 * 15383 * var object = {}; 15384 * 15385 * _.setWith(object, '[0][1]', 'a', Object); 15386 * // => { '0': { '1': 'a' } } 15387 */ 15388 function setWith(object, path, value, customizer) { 15389 customizer = typeof customizer == 'function' ? customizer : undefined; 15390 return object == null ? object : baseSet(object, path, value, customizer); 15391 } 15392 15393 /** 15394 * Creates an array of own enumerable string keyed-value pairs for `object` 15395 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its 15396 * entries are returned. 15397 * 15398 * @static 15399 * @memberOf _ 15400 * @since 4.0.0 15401 * @alias entries 15402 * @category Object 15403 * @param {Object} object The object to query. 15404 * @returns {Array} Returns the key-value pairs. 15405 * @example 15406 * 15407 * function Foo() { 15408 * this.a = 1; 15409 * this.b = 2; 15410 * } 15411 * 15412 * Foo.prototype.c = 3; 15413 * 15414 * _.toPairs(new Foo); 15415 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) 15416 */ 15417 var toPairs = createToPairs(keys); 15418 15419 /** 15420 * Creates an array of own and inherited enumerable string keyed-value pairs 15421 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map 15422 * or set, its entries are returned. 15423 * 15424 * @static 15425 * @memberOf _ 15426 * @since 4.0.0 15427 * @alias entriesIn 15428 * @category Object 15429 * @param {Object} object The object to query. 15430 * @returns {Array} Returns the key-value pairs. 15431 * @example 15432 * 15433 * function Foo() { 15434 * this.a = 1; 15435 * this.b = 2; 15436 * } 15437 * 15438 * Foo.prototype.c = 3; 15439 * 15440 * _.toPairsIn(new Foo); 15441 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) 15442 */ 15443 var toPairsIn = createToPairs(keysIn); 15444 15445 /** 15446 * An alternative to `_.reduce`; this method transforms `object` to a new 15447 * `accumulator` object which is the result of running each of its own 15448 * enumerable string keyed properties thru `iteratee`, with each invocation 15449 * potentially mutating the `accumulator` object. If `accumulator` is not 15450 * provided, a new object with the same `[[Prototype]]` will be used. The 15451 * iteratee is invoked with four arguments: (accumulator, value, key, object). 15452 * Iteratee functions may exit iteration early by explicitly returning `false`. 15453 * 15454 * @static 15455 * @memberOf _ 15456 * @since 1.3.0 15457 * @category Object 15458 * @param {Object} object The object to iterate over. 15459 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15460 * @param {*} [accumulator] The custom accumulator value. 15461 * @returns {*} Returns the accumulated value. 15462 * @example 15463 * 15464 * _.transform([2, 3, 4], function(result, n) { 15465 * result.push(n *= n); 15466 * return n % 2 == 0; 15467 * }, []); 15468 * // => [4, 9] 15469 * 15470 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 15471 * (result[value] || (result[value] = [])).push(key); 15472 * }, {}); 15473 * // => { '1': ['a', 'c'], '2': ['b'] } 15474 */ 15475 function transform(object, iteratee, accumulator) { 15476 var isArr = isArray(object), 15477 isArrLike = isArr || isBuffer(object) || isTypedArray(object); 15478 15479 iteratee = getIteratee(iteratee, 4); 15480 if (accumulator == null) { 15481 var Ctor = object && object.constructor; 15482 if (isArrLike) { 15483 accumulator = isArr ? new Ctor : []; 15484 } 15485 else if (isObject(object)) { 15486 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; 15487 } 15488 else { 15489 accumulator = {}; 15490 } 15491 } 15492 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { 15493 return iteratee(accumulator, value, index, object); 15494 }); 15495 return accumulator; 15496 } 15497 15498 /** 15499 * Removes the property at `path` of `object`. 15500 * 15501 * **Note:** This method mutates `object`. 15502 * 15503 * @static 15504 * @memberOf _ 15505 * @since 4.0.0 15506 * @category Object 15507 * @param {Object} object The object to modify. 15508 * @param {Array|string} path The path of the property to unset. 15509 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 15510 * @example 15511 * 15512 * var object = { 'a': [{ 'b': { 'c': 7 } }] }; 15513 * _.unset(object, 'a[0].b.c'); 15514 * // => true 15515 * 15516 * console.log(object); 15517 * // => { 'a': [{ 'b': {} }] }; 15518 * 15519 * _.unset(object, ['a', '0', 'b', 'c']); 15520 * // => true 15521 * 15522 * console.log(object); 15523 * // => { 'a': [{ 'b': {} }] }; 15524 */ 15525 function unset(object, path) { 15526 return object == null ? true : baseUnset(object, path); 15527 } 15528 15529 /** 15530 * This method is like `_.set` except that accepts `updater` to produce the 15531 * value to set. Use `_.updateWith` to customize `path` creation. The `updater` 15532 * is invoked with one argument: (value). 15533 * 15534 * **Note:** This method mutates `object`. 15535 * 15536 * @static 15537 * @memberOf _ 15538 * @since 4.6.0 15539 * @category Object 15540 * @param {Object} object The object to modify. 15541 * @param {Array|string} path The path of the property to set. 15542 * @param {Function} updater The function to produce the updated value. 15543 * @returns {Object} Returns `object`. 15544 * @example 15545 * 15546 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 15547 * 15548 * _.update(object, 'a[0].b.c', function(n) { return n * n; }); 15549 * console.log(object.a[0].b.c); 15550 * // => 9 15551 * 15552 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); 15553 * console.log(object.x[0].y.z); 15554 * // => 0 15555 */ 15556 function update(object, path, updater) { 15557 return object == null ? object : baseUpdate(object, path, castFunction(updater)); 15558 } 15559 15560 /** 15561 * This method is like `_.update` except that it accepts `customizer` which is 15562 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 15563 * path creation is handled by the method instead. The `customizer` is invoked 15564 * with three arguments: (nsValue, key, nsObject). 15565 * 15566 * **Note:** This method mutates `object`. 15567 * 15568 * @static 15569 * @memberOf _ 15570 * @since 4.6.0 15571 * @category Object 15572 * @param {Object} object The object to modify. 15573 * @param {Array|string} path The path of the property to set. 15574 * @param {Function} updater The function to produce the updated value. 15575 * @param {Function} [customizer] The function to customize assigned values. 15576 * @returns {Object} Returns `object`. 15577 * @example 15578 * 15579 * var object = {}; 15580 * 15581 * _.updateWith(object, '[0][1]', _.constant('a'), Object); 15582 * // => { '0': { '1': 'a' } } 15583 */ 15584 function updateWith(object, path, updater, customizer) { 15585 customizer = typeof customizer == 'function' ? customizer : undefined; 15586 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); 15587 } 15588 15589 /** 15590 * Creates an array of the own enumerable string keyed property values of `object`. 15591 * 15592 * **Note:** Non-object values are coerced to objects. 15593 * 15594 * @static 15595 * @since 0.1.0 15596 * @memberOf _ 15597 * @category Object 15598 * @param {Object} object The object to query. 15599 * @returns {Array} Returns the array of property values. 15600 * @example 15601 * 15602 * function Foo() { 15603 * this.a = 1; 15604 * this.b = 2; 15605 * } 15606 * 15607 * Foo.prototype.c = 3; 15608 * 15609 * _.values(new Foo); 15610 * // => [1, 2] (iteration order is not guaranteed) 15611 * 15612 * _.values('hi'); 15613 * // => ['h', 'i'] 15614 */ 15615 function values(object) { 15616 return object == null ? [] : baseValues(object, keys(object)); 15617 } 15618 15619 /** 15620 * Creates an array of the own and inherited enumerable string keyed property 15621 * values of `object`. 15622 * 15623 * **Note:** Non-object values are coerced to objects. 15624 * 15625 * @static 15626 * @memberOf _ 15627 * @since 3.0.0 15628 * @category Object 15629 * @param {Object} object The object to query. 15630 * @returns {Array} Returns the array of property values. 15631 * @example 15632 * 15633 * function Foo() { 15634 * this.a = 1; 15635 * this.b = 2; 15636 * } 15637 * 15638 * Foo.prototype.c = 3; 15639 * 15640 * _.valuesIn(new Foo); 15641 * // => [1, 2, 3] (iteration order is not guaranteed) 15642 */ 15643 function valuesIn(object) { 15644 return object == null ? [] : baseValues(object, keysIn(object)); 15645 } 15646 15647 /*------------------------------------------------------------------------*/ 15648 15649 /** 15650 * Clamps `number` within the inclusive `lower` and `upper` bounds. 15651 * 15652 * @static 15653 * @memberOf _ 15654 * @since 4.0.0 15655 * @category Number 15656 * @param {number} number The number to clamp. 15657 * @param {number} [lower] The lower bound. 15658 * @param {number} upper The upper bound. 15659 * @returns {number} Returns the clamped number. 15660 * @example 15661 * 15662 * _.clamp(-10, -5, 5); 15663 * // => -5 15664 * 15665 * _.clamp(10, -5, 5); 15666 * // => 5 15667 */ 15668 function clamp(number, lower, upper) { 15669 if (upper === undefined) { 15670 upper = lower; 15671 lower = undefined; 15672 } 15673 if (upper !== undefined) { 15674 upper = toNumber(upper); 15675 upper = upper === upper ? upper : 0; 15676 } 15677 if (lower !== undefined) { 15678 lower = toNumber(lower); 15679 lower = lower === lower ? lower : 0; 15680 } 15681 return baseClamp(toNumber(number), lower, upper); 15682 } 15683 15684 /** 15685 * Checks if `n` is between `start` and up to, but not including, `end`. If 15686 * `end` is not specified, it's set to `start` with `start` then set to `0`. 15687 * If `start` is greater than `end` the params are swapped to support 15688 * negative ranges. 15689 * 15690 * @static 15691 * @memberOf _ 15692 * @since 3.3.0 15693 * @category Number 15694 * @param {number} number The number to check. 15695 * @param {number} [start=0] The start of the range. 15696 * @param {number} end The end of the range. 15697 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 15698 * @see _.range, _.rangeRight 15699 * @example 15700 * 15701 * _.inRange(3, 2, 4); 15702 * // => true 15703 * 15704 * _.inRange(4, 8); 15705 * // => true 15706 * 15707 * _.inRange(4, 2); 15708 * // => false 15709 * 15710 * _.inRange(2, 2); 15711 * // => false 15712 * 15713 * _.inRange(1.2, 2); 15714 * // => true 15715 * 15716 * _.inRange(5.2, 4); 15717 * // => false 15718 * 15719 * _.inRange(-3, -2, -6); 15720 * // => true 15721 */ 15722 function inRange(number, start, end) { 15723 start = toFinite(start); 15724 if (end === undefined) { 15725 end = start; 15726 start = 0; 15727 } else { 15728 end = toFinite(end); 15729 } 15730 number = toNumber(number); 15731 return baseInRange(number, start, end); 15732 } 15733 15734 /** 15735 * Produces a random number between the inclusive `lower` and `upper` bounds. 15736 * If only one argument is provided a number between `0` and the given number 15737 * is returned. If `floating` is `true`, or either `lower` or `upper` are 15738 * floats, a floating-point number is returned instead of an integer. 15739 * 15740 * **Note:** JavaScript follows the IEEE-754 standard for resolving 15741 * floating-point values which can produce unexpected results. 15742 * 15743 * @static 15744 * @memberOf _ 15745 * @since 0.7.0 15746 * @category Number 15747 * @param {number} [lower=0] The lower bound. 15748 * @param {number} [upper=1] The upper bound. 15749 * @param {boolean} [floating] Specify returning a floating-point number. 15750 * @returns {number} Returns the random number. 15751 * @example 15752 * 15753 * _.random(0, 5); 15754 * // => an integer between 0 and 5 15755 * 15756 * _.random(5); 15757 * // => also an integer between 0 and 5 15758 * 15759 * _.random(5, true); 15760 * // => a floating-point number between 0 and 5 15761 * 15762 * _.random(1.2, 5.2); 15763 * // => a floating-point number between 1.2 and 5.2 15764 */ 15765 function random(lower, upper, floating) { 15766 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { 15767 upper = floating = undefined; 15768 } 15769 if (floating === undefined) { 15770 if (typeof upper == 'boolean') { 15771 floating = upper; 15772 upper = undefined; 15773 } 15774 else if (typeof lower == 'boolean') { 15775 floating = lower; 15776 lower = undefined; 15777 } 15778 } 15779 if (lower === undefined && upper === undefined) { 15780 lower = 0; 15781 upper = 1; 15782 } 15783 else { 15784 lower = toFinite(lower); 15785 if (upper === undefined) { 15786 upper = lower; 15787 lower = 0; 15788 } else { 15789 upper = toFinite(upper); 15790 } 15791 } 15792 if (lower > upper) { 15793 var temp = lower; 15794 lower = upper; 15795 upper = temp; 15796 } 15797 if (floating || lower % 1 || upper % 1) { 15798 var rand = nativeRandom(); 15799 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); 15800 } 15801 return baseRandom(lower, upper); 15802 } 15803 15804 /*------------------------------------------------------------------------*/ 15805 15806 /** 15807 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). 15808 * 15809 * @static 15810 * @memberOf _ 15811 * @since 3.0.0 15812 * @category String 15813 * @param {string} [string=''] The string to convert. 15814 * @returns {string} Returns the camel cased string. 15815 * @example 15816 * 15817 * _.camelCase('Foo Bar'); 15818 * // => 'fooBar' 15819 * 15820 * _.camelCase('--foo-bar--'); 15821 * // => 'fooBar' 15822 * 15823 * _.camelCase('__FOO_BAR__'); 15824 * // => 'fooBar' 15825 */ 15826 var camelCase = createCompounder(function(result, word, index) { 15827 word = word.toLowerCase(); 15828 return result + (index ? capitalize(word) : word); 15829 }); 15830 15831 /** 15832 * Converts the first character of `string` to upper case and the remaining 15833 * to lower case. 15834 * 15835 * @static 15836 * @memberOf _ 15837 * @since 3.0.0 15838 * @category String 15839 * @param {string} [string=''] The string to capitalize. 15840 * @returns {string} Returns the capitalized string. 15841 * @example 15842 * 15843 * _.capitalize('FRED'); 15844 * // => 'Fred' 15845 */ 15846 function capitalize(string) { 15847 return upperFirst(toString(string).toLowerCase()); 15848 } 15849 15850 /** 15851 * Deburrs `string` by converting 15852 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) 15853 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) 15854 * letters to basic Latin letters and removing 15855 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). 15856 * 15857 * @static 15858 * @memberOf _ 15859 * @since 3.0.0 15860 * @category String 15861 * @param {string} [string=''] The string to deburr. 15862 * @returns {string} Returns the deburred string. 15863 * @example 15864 * 15865 * _.deburr('déjà vu'); 15866 * // => 'deja vu' 15867 */ 15868 function deburr(string) { 15869 string = toString(string); 15870 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); 15871 } 15872 15873 /** 15874 * Checks if `string` ends with the given target string. 15875 * 15876 * @static 15877 * @memberOf _ 15878 * @since 3.0.0 15879 * @category String 15880 * @param {string} [string=''] The string to inspect. 15881 * @param {string} [target] The string to search for. 15882 * @param {number} [position=string.length] The position to search up to. 15883 * @returns {boolean} Returns `true` if `string` ends with `target`, 15884 * else `false`. 15885 * @example 15886 * 15887 * _.endsWith('abc', 'c'); 15888 * // => true 15889 * 15890 * _.endsWith('abc', 'b'); 15891 * // => false 15892 * 15893 * _.endsWith('abc', 'b', 2); 15894 * // => true 15895 */ 15896 function endsWith(string, target, position) { 15897 string = toString(string); 15898 target = baseToString(target); 15899 15900 var length = string.length; 15901 position = position === undefined 15902 ? length 15903 : baseClamp(toInteger(position), 0, length); 15904 15905 var end = position; 15906 position -= target.length; 15907 return position >= 0 && string.slice(position, end) == target; 15908 } 15909 15910 /** 15911 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their 15912 * corresponding HTML entities. 15913 * 15914 * **Note:** No other characters are escaped. To escape additional 15915 * characters use a third-party library like [_he_](https://mths.be/he). 15916 * 15917 * Though the ">" character is escaped for symmetry, characters like 15918 * ">" and "/" don't need escaping in HTML and have no special meaning 15919 * unless they're part of a tag or unquoted attribute value. See 15920 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) 15921 * (under "semi-related fun fact") for more details. 15922 * 15923 * When working with HTML you should always 15924 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce 15925 * XSS vectors. 15926 * 15927 * @static 15928 * @since 0.1.0 15929 * @memberOf _ 15930 * @category String 15931 * @param {string} [string=''] The string to escape. 15932 * @returns {string} Returns the escaped string. 15933 * @example 15934 * 15935 * _.escape('fred, barney, & pebbles'); 15936 * // => 'fred, barney, & pebbles' 15937 */ 15938 function escape(string) { 15939 string = toString(string); 15940 return (string && reHasUnescapedHtml.test(string)) 15941 ? string.replace(reUnescapedHtml, escapeHtmlChar) 15942 : string; 15943 } 15944 15945 /** 15946 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", 15947 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. 15948 * 15949 * @static 15950 * @memberOf _ 15951 * @since 3.0.0 15952 * @category String 15953 * @param {string} [string=''] The string to escape. 15954 * @returns {string} Returns the escaped string. 15955 * @example 15956 * 15957 * _.escapeRegExp('[lodash](https://lodash.com/)'); 15958 * // => '\[lodash\]\(https://lodash\.com/\)' 15959 */ 15960 function escapeRegExp(string) { 15961 string = toString(string); 15962 return (string && reHasRegExpChar.test(string)) 15963 ? string.replace(reRegExpChar, '\\$&') 15964 : string; 15965 } 15966 15967 /** 15968 * Converts `string` to 15969 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 15970 * 15971 * @static 15972 * @memberOf _ 15973 * @since 3.0.0 15974 * @category String 15975 * @param {string} [string=''] The string to convert. 15976 * @returns {string} Returns the kebab cased string. 15977 * @example 15978 * 15979 * _.kebabCase('Foo Bar'); 15980 * // => 'foo-bar' 15981 * 15982 * _.kebabCase('fooBar'); 15983 * // => 'foo-bar' 15984 * 15985 * _.kebabCase('__FOO_BAR__'); 15986 * // => 'foo-bar' 15987 */ 15988 var kebabCase = createCompounder(function(result, word, index) { 15989 return result + (index ? '-' : '') + word.toLowerCase(); 15990 }); 15991 15992 /** 15993 * Converts `string`, as space separated words, to lower case. 15994 * 15995 * @static 15996 * @memberOf _ 15997 * @since 4.0.0 15998 * @category String 15999 * @param {string} [string=''] The string to convert. 16000 * @returns {string} Returns the lower cased string. 16001 * @example 16002 * 16003 * _.lowerCase('--Foo-Bar--'); 16004 * // => 'foo bar' 16005 * 16006 * _.lowerCase('fooBar'); 16007 * // => 'foo bar' 16008 * 16009 * _.lowerCase('__FOO_BAR__'); 16010 * // => 'foo bar' 16011 */ 16012 var lowerCase = createCompounder(function(result, word, index) { 16013 return result + (index ? ' ' : '') + word.toLowerCase(); 16014 }); 16015 16016 /** 16017 * Converts the first character of `string` to lower case. 16018 * 16019 * @static 16020 * @memberOf _ 16021 * @since 4.0.0 16022 * @category String 16023 * @param {string} [string=''] The string to convert. 16024 * @returns {string} Returns the converted string. 16025 * @example 16026 * 16027 * _.lowerFirst('Fred'); 16028 * // => 'fred' 16029 * 16030 * _.lowerFirst('FRED'); 16031 * // => 'fRED' 16032 */ 16033 var lowerFirst = createCaseFirst('toLowerCase'); 16034 16035 /** 16036 * Pads `string` on the left and right sides if it's shorter than `length`. 16037 * Padding characters are truncated if they can't be evenly divided by `length`. 16038 * 16039 * @static 16040 * @memberOf _ 16041 * @since 3.0.0 16042 * @category String 16043 * @param {string} [string=''] The string to pad. 16044 * @param {number} [length=0] The padding length. 16045 * @param {string} [chars=' '] The string used as padding. 16046 * @returns {string} Returns the padded string. 16047 * @example 16048 * 16049 * _.pad('abc', 8); 16050 * // => ' abc ' 16051 * 16052 * _.pad('abc', 8, '_-'); 16053 * // => '_-abc_-_' 16054 * 16055 * _.pad('abc', 3); 16056 * // => 'abc' 16057 */ 16058 function pad(string, length, chars) { 16059 string = toString(string); 16060 length = toInteger(length); 16061 16062 var strLength = length ? stringSize(string) : 0; 16063 if (!length || strLength >= length) { 16064 return string; 16065 } 16066 var mid = (length - strLength) / 2; 16067 return ( 16068 createPadding(nativeFloor(mid), chars) + 16069 string + 16070 createPadding(nativeCeil(mid), chars) 16071 ); 16072 } 16073 16074 /** 16075 * Pads `string` on the right side if it's shorter than `length`. Padding 16076 * characters are truncated if they exceed `length`. 16077 * 16078 * @static 16079 * @memberOf _ 16080 * @since 4.0.0 16081 * @category String 16082 * @param {string} [string=''] The string to pad. 16083 * @param {number} [length=0] The padding length. 16084 * @param {string} [chars=' '] The string used as padding. 16085 * @returns {string} Returns the padded string. 16086 * @example 16087 * 16088 * _.padEnd('abc', 6); 16089 * // => 'abc ' 16090 * 16091 * _.padEnd('abc', 6, '_-'); 16092 * // => 'abc_-_' 16093 * 16094 * _.padEnd('abc', 3); 16095 * // => 'abc' 16096 */ 16097 function padEnd(string, length, chars) { 16098 string = toString(string); 16099 length = toInteger(length); 16100 16101 var strLength = length ? stringSize(string) : 0; 16102 return (length && strLength < length) 16103 ? (string + createPadding(length - strLength, chars)) 16104 : string; 16105 } 16106 16107 /** 16108 * Pads `string` on the left side if it's shorter than `length`. Padding 16109 * characters are truncated if they exceed `length`. 16110 * 16111 * @static 16112 * @memberOf _ 16113 * @since 4.0.0 16114 * @category String 16115 * @param {string} [string=''] The string to pad. 16116 * @param {number} [length=0] The padding length. 16117 * @param {string} [chars=' '] The string used as padding. 16118 * @returns {string} Returns the padded string. 16119 * @example 16120 * 16121 * _.padStart('abc', 6); 16122 * // => ' abc' 16123 * 16124 * _.padStart('abc', 6, '_-'); 16125 * // => '_-_abc' 16126 * 16127 * _.padStart('abc', 3); 16128 * // => 'abc' 16129 */ 16130 function padStart(string, length, chars) { 16131 string = toString(string); 16132 length = toInteger(length); 16133 16134 var strLength = length ? stringSize(string) : 0; 16135 return (length && strLength < length) 16136 ? (createPadding(length - strLength, chars) + string) 16137 : string; 16138 } 16139 16140 /** 16141 * Converts `string` to an integer of the specified radix. If `radix` is 16142 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a 16143 * hexadecimal, in which case a `radix` of `16` is used. 16144 * 16145 * **Note:** This method aligns with the 16146 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. 16147 * 16148 * @static 16149 * @memberOf _ 16150 * @since 1.1.0 16151 * @category String 16152 * @param {string} string The string to convert. 16153 * @param {number} [radix=10] The radix to interpret `value` by. 16154 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16155 * @returns {number} Returns the converted integer. 16156 * @example 16157 * 16158 * _.parseInt('08'); 16159 * // => 8 16160 * 16161 * _.map(['6', '08', '10'], _.parseInt); 16162 * // => [6, 8, 10] 16163 */ 16164 function parseInt(string, radix, guard) { 16165 if (guard || radix == null) { 16166 radix = 0; 16167 } else if (radix) { 16168 radix = +radix; 16169 } 16170 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); 16171 } 16172 16173 /** 16174 * Repeats the given string `n` times. 16175 * 16176 * @static 16177 * @memberOf _ 16178 * @since 3.0.0 16179 * @category String 16180 * @param {string} [string=''] The string to repeat. 16181 * @param {number} [n=1] The number of times to repeat the string. 16182 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16183 * @returns {string} Returns the repeated string. 16184 * @example 16185 * 16186 * _.repeat('*', 3); 16187 * // => '***' 16188 * 16189 * _.repeat('abc', 2); 16190 * // => 'abcabc' 16191 * 16192 * _.repeat('abc', 0); 16193 * // => '' 16194 */ 16195 function repeat(string, n, guard) { 16196 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { 16197 n = 1; 16198 } else { 16199 n = toInteger(n); 16200 } 16201 return baseRepeat(toString(string), n); 16202 } 16203 16204 /** 16205 * Replaces matches for `pattern` in `string` with `replacement`. 16206 * 16207 * **Note:** This method is based on 16208 * [`String#replace`](https://mdn.io/String/replace). 16209 * 16210 * @static 16211 * @memberOf _ 16212 * @since 4.0.0 16213 * @category String 16214 * @param {string} [string=''] The string to modify. 16215 * @param {RegExp|string} pattern The pattern to replace. 16216 * @param {Function|string} replacement The match replacement. 16217 * @returns {string} Returns the modified string. 16218 * @example 16219 * 16220 * _.replace('Hi Fred', 'Fred', 'Barney'); 16221 * // => 'Hi Barney' 16222 */ 16223 function replace() { 16224 var args = arguments, 16225 string = toString(args[0]); 16226 16227 return args.length < 3 ? string : string.replace(args[1], args[2]); 16228 } 16229 16230 /** 16231 * Converts `string` to 16232 * [snake case](https://en.wikipedia.org/wiki/Snake_case). 16233 * 16234 * @static 16235 * @memberOf _ 16236 * @since 3.0.0 16237 * @category String 16238 * @param {string} [string=''] The string to convert. 16239 * @returns {string} Returns the snake cased string. 16240 * @example 16241 * 16242 * _.snakeCase('Foo Bar'); 16243 * // => 'foo_bar' 16244 * 16245 * _.snakeCase('fooBar'); 16246 * // => 'foo_bar' 16247 * 16248 * _.snakeCase('--FOO-BAR--'); 16249 * // => 'foo_bar' 16250 */ 16251 var snakeCase = createCompounder(function(result, word, index) { 16252 return result + (index ? '_' : '') + word.toLowerCase(); 16253 }); 16254 16255 /** 16256 * Splits `string` by `separator`. 16257 * 16258 * **Note:** This method is based on 16259 * [`String#split`](https://mdn.io/String/split). 16260 * 16261 * @static 16262 * @memberOf _ 16263 * @since 4.0.0 16264 * @category String 16265 * @param {string} [string=''] The string to split. 16266 * @param {RegExp|string} separator The separator pattern to split by. 16267 * @param {number} [limit] The length to truncate results to. 16268 * @returns {Array} Returns the string segments. 16269 * @example 16270 * 16271 * _.split('a-b-c', '-', 2); 16272 * // => ['a', 'b'] 16273 */ 16274 function split(string, separator, limit) { 16275 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { 16276 separator = limit = undefined; 16277 } 16278 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; 16279 if (!limit) { 16280 return []; 16281 } 16282 string = toString(string); 16283 if (string && ( 16284 typeof separator == 'string' || 16285 (separator != null && !isRegExp(separator)) 16286 )) { 16287 separator = baseToString(separator); 16288 if (!separator && hasUnicode(string)) { 16289 return castSlice(stringToArray(string), 0, limit); 16290 } 16291 } 16292 return string.split(separator, limit); 16293 } 16294 16295 /** 16296 * Converts `string` to 16297 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). 16298 * 16299 * @static 16300 * @memberOf _ 16301 * @since 3.1.0 16302 * @category String 16303 * @param {string} [string=''] The string to convert. 16304 * @returns {string} Returns the start cased string. 16305 * @example 16306 * 16307 * _.startCase('--foo-bar--'); 16308 * // => 'Foo Bar' 16309 * 16310 * _.startCase('fooBar'); 16311 * // => 'Foo Bar' 16312 * 16313 * _.startCase('__FOO_BAR__'); 16314 * // => 'FOO BAR' 16315 */ 16316 var startCase = createCompounder(function(result, word, index) { 16317 return result + (index ? ' ' : '') + upperFirst(word); 16318 }); 16319 16320 /** 16321 * Checks if `string` starts with the given target string. 16322 * 16323 * @static 16324 * @memberOf _ 16325 * @since 3.0.0 16326 * @category String 16327 * @param {string} [string=''] The string to inspect. 16328 * @param {string} [target] The string to search for. 16329 * @param {number} [position=0] The position to search from. 16330 * @returns {boolean} Returns `true` if `string` starts with `target`, 16331 * else `false`. 16332 * @example 16333 * 16334 * _.startsWith('abc', 'a'); 16335 * // => true 16336 * 16337 * _.startsWith('abc', 'b'); 16338 * // => false 16339 * 16340 * _.startsWith('abc', 'b', 1); 16341 * // => true 16342 */ 16343 function startsWith(string, target, position) { 16344 string = toString(string); 16345 position = position == null 16346 ? 0 16347 : baseClamp(toInteger(position), 0, string.length); 16348 16349 target = baseToString(target); 16350 return string.slice(position, position + target.length) == target; 16351 } 16352 16353 /** 16354 * Creates a compiled template function that can interpolate data properties 16355 * in "interpolate" delimiters, HTML-escape interpolated data properties in 16356 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data 16357 * properties may be accessed as free variables in the template. If a setting 16358 * object is given, it takes precedence over `_.templateSettings` values. 16359 * 16360 * **Note:** In the development build `_.template` utilizes 16361 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) 16362 * for easier debugging. 16363 * 16364 * For more information on precompiling templates see 16365 * [lodash's custom builds documentation](https://lodash.com/custom-builds). 16366 * 16367 * For more information on Chrome extension sandboxes see 16368 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). 16369 * 16370 * @static 16371 * @since 0.1.0 16372 * @memberOf _ 16373 * @category String 16374 * @param {string} [string=''] The template string. 16375 * @param {Object} [options={}] The options object. 16376 * @param {RegExp} [options.escape=_.templateSettings.escape] 16377 * The HTML "escape" delimiter. 16378 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] 16379 * The "evaluate" delimiter. 16380 * @param {Object} [options.imports=_.templateSettings.imports] 16381 * An object to import into the template as free variables. 16382 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] 16383 * The "interpolate" delimiter. 16384 * @param {string} [options.sourceURL='lodash.templateSources[n]'] 16385 * The sourceURL of the compiled template. 16386 * @param {string} [options.variable='obj'] 16387 * The data object variable name. 16388 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16389 * @returns {Function} Returns the compiled template function. 16390 * @example 16391 * 16392 * // Use the "interpolate" delimiter to create a compiled template. 16393 * var compiled = _.template('hello <%= user %>!'); 16394 * compiled({ 'user': 'fred' }); 16395 * // => 'hello fred!' 16396 * 16397 * // Use the HTML "escape" delimiter to escape data property values. 16398 * var compiled = _.template('<b><%- value %></b>'); 16399 * compiled({ 'value': '<script>' }); 16400 * // => '<b><script></b>' 16401 * 16402 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. 16403 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); 16404 * compiled({ 'users': ['fred', 'barney'] }); 16405 * // => '<li>fred</li><li>barney</li>' 16406 * 16407 * // Use the internal `print` function in "evaluate" delimiters. 16408 * var compiled = _.template('<% print("hello " + user); %>!'); 16409 * compiled({ 'user': 'barney' }); 16410 * // => 'hello barney!' 16411 * 16412 * // Use the ES template literal delimiter as an "interpolate" delimiter. 16413 * // Disable support by replacing the "interpolate" delimiter. 16414 * var compiled = _.template('hello ${ user }!'); 16415 * compiled({ 'user': 'pebbles' }); 16416 * // => 'hello pebbles!' 16417 * 16418 * // Use backslashes to treat delimiters as plain text. 16419 * var compiled = _.template('<%= "\\<%- value %\\>" %>'); 16420 * compiled({ 'value': 'ignored' }); 16421 * // => '<%- value %>' 16422 * 16423 * // Use the `imports` option to import `jQuery` as `jq`. 16424 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; 16425 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); 16426 * compiled({ 'users': ['fred', 'barney'] }); 16427 * // => '<li>fred</li><li>barney</li>' 16428 * 16429 * // Use the `sourceURL` option to specify a custom sourceURL for the template. 16430 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); 16431 * compiled(data); 16432 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. 16433 * 16434 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. 16435 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); 16436 * compiled.source; 16437 * // => function(data) { 16438 * // var __t, __p = ''; 16439 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; 16440 * // return __p; 16441 * // } 16442 * 16443 * // Use custom template delimiters. 16444 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; 16445 * var compiled = _.template('hello {{ user }}!'); 16446 * compiled({ 'user': 'mustache' }); 16447 * // => 'hello mustache!' 16448 * 16449 * // Use the `source` property to inline compiled templates for meaningful 16450 * // line numbers in error messages and stack traces. 16451 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ 16452 * var JST = {\ 16453 * "main": ' + _.template(mainText).source + '\ 16454 * };\ 16455 * '); 16456 */ 16457 function template(string, options, guard) { 16458 // Based on John Resig's `tmpl` implementation 16459 // (http://ejohn.org/blog/javascript-micro-templating/) 16460 // and Laura Doktorova's doT.js (https://github.com/olado/doT). 16461 var settings = lodash.templateSettings; 16462 16463 if (guard && isIterateeCall(string, options, guard)) { 16464 options = undefined; 16465 } 16466 string = toString(string); 16467 options = assignInWith({}, options, settings, customDefaultsAssignIn); 16468 16469 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), 16470 importsKeys = keys(imports), 16471 importsValues = baseValues(imports, importsKeys); 16472 16473 var isEscaping, 16474 isEvaluating, 16475 index = 0, 16476 interpolate = options.interpolate || reNoMatch, 16477 source = "__p += '"; 16478 16479 // Compile the regexp to match each delimiter. 16480 var reDelimiters = RegExp( 16481 (options.escape || reNoMatch).source + '|' + 16482 interpolate.source + '|' + 16483 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + 16484 (options.evaluate || reNoMatch).source + '|$' 16485 , 'g'); 16486 16487 // Use a sourceURL for easier debugging. 16488 var sourceURL = '//# sourceURL=' + 16489 ('sourceURL' in options 16490 ? options.sourceURL 16491 : ('lodash.templateSources[' + (++templateCounter) + ']') 16492 ) + '\n'; 16493 16494 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { 16495 interpolateValue || (interpolateValue = esTemplateValue); 16496 16497 // Escape characters that can't be included in string literals. 16498 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); 16499 16500 // Replace delimiters with snippets. 16501 if (escapeValue) { 16502 isEscaping = true; 16503 source += "' +\n__e(" + escapeValue + ") +\n'"; 16504 } 16505 if (evaluateValue) { 16506 isEvaluating = true; 16507 source += "';\n" + evaluateValue + ";\n__p += '"; 16508 } 16509 if (interpolateValue) { 16510 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; 16511 } 16512 index = offset + match.length; 16513 16514 // The JS engine embedded in Adobe products needs `match` returned in 16515 // order to produce the correct `offset` value. 16516 return match; 16517 }); 16518 16519 source += "';\n"; 16520 16521 // If `variable` is not specified wrap a with-statement around the generated 16522 // code to add the data object to the top of the scope chain. 16523 var variable = options.variable; 16524 if (!variable) { 16525 source = 'with (obj) {\n' + source + '\n}\n'; 16526 } 16527 // Cleanup code by stripping empty strings. 16528 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) 16529 .replace(reEmptyStringMiddle, '$1') 16530 .replace(reEmptyStringTrailing, '$1;'); 16531 16532 // Frame code as the function body. 16533 source = 'function(' + (variable || 'obj') + ') {\n' + 16534 (variable 16535 ? '' 16536 : 'obj || (obj = {});\n' 16537 ) + 16538 "var __t, __p = ''" + 16539 (isEscaping 16540 ? ', __e = _.escape' 16541 : '' 16542 ) + 16543 (isEvaluating 16544 ? ', __j = Array.prototype.join;\n' + 16545 "function print() { __p += __j.call(arguments, '') }\n" 16546 : ';\n' 16547 ) + 16548 source + 16549 'return __p\n}'; 16550 16551 var result = attempt(function() { 16552 return Function(importsKeys, sourceURL + 'return ' + source) 16553 .apply(undefined, importsValues); 16554 }); 16555 16556 // Provide the compiled function's source by its `toString` method or 16557 // the `source` property as a convenience for inlining compiled templates. 16558 result.source = source; 16559 if (isError(result)) { 16560 throw result; 16561 } 16562 return result; 16563 } 16564 16565 /** 16566 * Converts `string`, as a whole, to lower case just like 16567 * [String#toLowerCase](https://mdn.io/toLowerCase). 16568 * 16569 * @static 16570 * @memberOf _ 16571 * @since 4.0.0 16572 * @category String 16573 * @param {string} [string=''] The string to convert. 16574 * @returns {string} Returns the lower cased string. 16575 * @example 16576 * 16577 * _.toLower('--Foo-Bar--'); 16578 * // => '--foo-bar--' 16579 * 16580 * _.toLower('fooBar'); 16581 * // => 'foobar' 16582 * 16583 * _.toLower('__FOO_BAR__'); 16584 * // => '__foo_bar__' 16585 */ 16586 function toLower(value) { 16587 return toString(value).toLowerCase(); 16588 } 16589 16590 /** 16591 * Converts `string`, as a whole, to upper case just like 16592 * [String#toUpperCase](https://mdn.io/toUpperCase). 16593 * 16594 * @static 16595 * @memberOf _ 16596 * @since 4.0.0 16597 * @category String 16598 * @param {string} [string=''] The string to convert. 16599 * @returns {string} Returns the upper cased string. 16600 * @example 16601 * 16602 * _.toUpper('--foo-bar--'); 16603 * // => '--FOO-BAR--' 16604 * 16605 * _.toUpper('fooBar'); 16606 * // => 'FOOBAR' 16607 * 16608 * _.toUpper('__foo_bar__'); 16609 * // => '__FOO_BAR__' 16610 */ 16611 function toUpper(value) { 16612 return toString(value).toUpperCase(); 16613 } 16614 16615 /** 16616 * Removes leading and trailing whitespace or specified characters from `string`. 16617 * 16618 * @static 16619 * @memberOf _ 16620 * @since 3.0.0 16621 * @category String 16622 * @param {string} [string=''] The string to trim. 16623 * @param {string} [chars=whitespace] The characters to trim. 16624 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16625 * @returns {string} Returns the trimmed string. 16626 * @example 16627 * 16628 * _.trim(' abc '); 16629 * // => 'abc' 16630 * 16631 * _.trim('-_-abc-_-', '_-'); 16632 * // => 'abc' 16633 * 16634 * _.map([' foo ', ' bar '], _.trim); 16635 * // => ['foo', 'bar'] 16636 */ 16637 function trim(string, chars, guard) { 16638 string = toString(string); 16639 if (string && (guard || chars === undefined)) { 16640 return string.replace(reTrim, ''); 16641 } 16642 if (!string || !(chars = baseToString(chars))) { 16643 return string; 16644 } 16645 var strSymbols = stringToArray(string), 16646 chrSymbols = stringToArray(chars), 16647 start = charsStartIndex(strSymbols, chrSymbols), 16648 end = charsEndIndex(strSymbols, chrSymbols) + 1; 16649 16650 return castSlice(strSymbols, start, end).join(''); 16651 } 16652 16653 /** 16654 * Removes trailing whitespace or specified characters from `string`. 16655 * 16656 * @static 16657 * @memberOf _ 16658 * @since 4.0.0 16659 * @category String 16660 * @param {string} [string=''] The string to trim. 16661 * @param {string} [chars=whitespace] The characters to trim. 16662 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16663 * @returns {string} Returns the trimmed string. 16664 * @example 16665 * 16666 * _.trimEnd(' abc '); 16667 * // => ' abc' 16668 * 16669 * _.trimEnd('-_-abc-_-', '_-'); 16670 * // => '-_-abc' 16671 */ 16672 function trimEnd(string, chars, guard) { 16673 string = toString(string); 16674 if (string && (guard || chars === undefined)) { 16675 return string.replace(reTrimEnd, ''); 16676 } 16677 if (!string || !(chars = baseToString(chars))) { 16678 return string; 16679 } 16680 var strSymbols = stringToArray(string), 16681 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; 16682 16683 return castSlice(strSymbols, 0, end).join(''); 16684 } 16685 16686 /** 16687 * Removes leading whitespace or specified characters from `string`. 16688 * 16689 * @static 16690 * @memberOf _ 16691 * @since 4.0.0 16692 * @category String 16693 * @param {string} [string=''] The string to trim. 16694 * @param {string} [chars=whitespace] The characters to trim. 16695 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16696 * @returns {string} Returns the trimmed string. 16697 * @example 16698 * 16699 * _.trimStart(' abc '); 16700 * // => 'abc ' 16701 * 16702 * _.trimStart('-_-abc-_-', '_-'); 16703 * // => 'abc-_-' 16704 */ 16705 function trimStart(string, chars, guard) { 16706 string = toString(string); 16707 if (string && (guard || chars === undefined)) { 16708 return string.replace(reTrimStart, ''); 16709 } 16710 if (!string || !(chars = baseToString(chars))) { 16711 return string; 16712 } 16713 var strSymbols = stringToArray(string), 16714 start = charsStartIndex(strSymbols, stringToArray(chars)); 16715 16716 return castSlice(strSymbols, start).join(''); 16717 } 16718 16719 /** 16720 * Truncates `string` if it's longer than the given maximum string length. 16721 * The last characters of the truncated string are replaced with the omission 16722 * string which defaults to "...". 16723 * 16724 * @static 16725 * @memberOf _ 16726 * @since 4.0.0 16727 * @category String 16728 * @param {string} [string=''] The string to truncate. 16729 * @param {Object} [options={}] The options object. 16730 * @param {number} [options.length=30] The maximum string length. 16731 * @param {string} [options.omission='...'] The string to indicate text is omitted. 16732 * @param {RegExp|string} [options.separator] The separator pattern to truncate to. 16733 * @returns {string} Returns the truncated string. 16734 * @example 16735 * 16736 * _.truncate('hi-diddly-ho there, neighborino'); 16737 * // => 'hi-diddly-ho there, neighbo...' 16738 * 16739 * _.truncate('hi-diddly-ho there, neighborino', { 16740 * 'length': 24, 16741 * 'separator': ' ' 16742 * }); 16743 * // => 'hi-diddly-ho there,...' 16744 * 16745 * _.truncate('hi-diddly-ho there, neighborino', { 16746 * 'length': 24, 16747 * 'separator': /,? +/ 16748 * }); 16749 * // => 'hi-diddly-ho there...' 16750 * 16751 * _.truncate('hi-diddly-ho there, neighborino', { 16752 * 'omission': ' [...]' 16753 * }); 16754 * // => 'hi-diddly-ho there, neig [...]' 16755 */ 16756 function truncate(string, options) { 16757 var length = DEFAULT_TRUNC_LENGTH, 16758 omission = DEFAULT_TRUNC_OMISSION; 16759 16760 if (isObject(options)) { 16761 var separator = 'separator' in options ? options.separator : separator; 16762 length = 'length' in options ? toInteger(options.length) : length; 16763 omission = 'omission' in options ? baseToString(options.omission) : omission; 16764 } 16765 string = toString(string); 16766 16767 var strLength = string.length; 16768 if (hasUnicode(string)) { 16769 var strSymbols = stringToArray(string); 16770 strLength = strSymbols.length; 16771 } 16772 if (length >= strLength) { 16773 return string; 16774 } 16775 var end = length - stringSize(omission); 16776 if (end < 1) { 16777 return omission; 16778 } 16779 var result = strSymbols 16780 ? castSlice(strSymbols, 0, end).join('') 16781 : string.slice(0, end); 16782 16783 if (separator === undefined) { 16784 return result + omission; 16785 } 16786 if (strSymbols) { 16787 end += (result.length - end); 16788 } 16789 if (isRegExp(separator)) { 16790 if (string.slice(end).search(separator)) { 16791 var match, 16792 substring = result; 16793 16794 if (!separator.global) { 16795 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); 16796 } 16797 separator.lastIndex = 0; 16798 while ((match = separator.exec(substring))) { 16799 var newEnd = match.index; 16800 } 16801 result = result.slice(0, newEnd === undefined ? end : newEnd); 16802 } 16803 } else if (string.indexOf(baseToString(separator), end) != end) { 16804 var index = result.lastIndexOf(separator); 16805 if (index > -1) { 16806 result = result.slice(0, index); 16807 } 16808 } 16809 return result + omission; 16810 } 16811 16812 /** 16813 * The inverse of `_.escape`; this method converts the HTML entities 16814 * `&`, `<`, `>`, `"`, and `'` in `string` to 16815 * their corresponding characters. 16816 * 16817 * **Note:** No other HTML entities are unescaped. To unescape additional 16818 * HTML entities use a third-party library like [_he_](https://mths.be/he). 16819 * 16820 * @static 16821 * @memberOf _ 16822 * @since 0.6.0 16823 * @category String 16824 * @param {string} [string=''] The string to unescape. 16825 * @returns {string} Returns the unescaped string. 16826 * @example 16827 * 16828 * _.unescape('fred, barney, & pebbles'); 16829 * // => 'fred, barney, & pebbles' 16830 */ 16831 function unescape(string) { 16832 string = toString(string); 16833 return (string && reHasEscapedHtml.test(string)) 16834 ? string.replace(reEscapedHtml, unescapeHtmlChar) 16835 : string; 16836 } 16837 16838 /** 16839 * Converts `string`, as space separated words, to upper case. 16840 * 16841 * @static 16842 * @memberOf _ 16843 * @since 4.0.0 16844 * @category String 16845 * @param {string} [string=''] The string to convert. 16846 * @returns {string} Returns the upper cased string. 16847 * @example 16848 * 16849 * _.upperCase('--foo-bar'); 16850 * // => 'FOO BAR' 16851 * 16852 * _.upperCase('fooBar'); 16853 * // => 'FOO BAR' 16854 * 16855 * _.upperCase('__foo_bar__'); 16856 * // => 'FOO BAR' 16857 */ 16858 var upperCase = createCompounder(function(result, word, index) { 16859 return result + (index ? ' ' : '') + word.toUpperCase(); 16860 }); 16861 16862 /** 16863 * Converts the first character of `string` to upper case. 16864 * 16865 * @static 16866 * @memberOf _ 16867 * @since 4.0.0 16868 * @category String 16869 * @param {string} [string=''] The string to convert. 16870 * @returns {string} Returns the converted string. 16871 * @example 16872 * 16873 * _.upperFirst('fred'); 16874 * // => 'Fred' 16875 * 16876 * _.upperFirst('FRED'); 16877 * // => 'FRED' 16878 */ 16879 var upperFirst = createCaseFirst('toUpperCase'); 16880 16881 /** 16882 * Splits `string` into an array of its words. 16883 * 16884 * @static 16885 * @memberOf _ 16886 * @since 3.0.0 16887 * @category String 16888 * @param {string} [string=''] The string to inspect. 16889 * @param {RegExp|string} [pattern] The pattern to match words. 16890 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16891 * @returns {Array} Returns the words of `string`. 16892 * @example 16893 * 16894 * _.words('fred, barney, & pebbles'); 16895 * // => ['fred', 'barney', 'pebbles'] 16896 * 16897 * _.words('fred, barney, & pebbles', /[^, ]+/g); 16898 * // => ['fred', 'barney', '&', 'pebbles'] 16899 */ 16900 function words(string, pattern, guard) { 16901 string = toString(string); 16902 pattern = guard ? undefined : pattern; 16903 16904 if (pattern === undefined) { 16905 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); 16906 } 16907 return string.match(pattern) || []; 16908 } 16909 16910 /*------------------------------------------------------------------------*/ 16911 16912 /** 16913 * Attempts to invoke `func`, returning either the result or the caught error 16914 * object. Any additional arguments are provided to `func` when it's invoked. 16915 * 16916 * @static 16917 * @memberOf _ 16918 * @since 3.0.0 16919 * @category Util 16920 * @param {Function} func The function to attempt. 16921 * @param {...*} [args] The arguments to invoke `func` with. 16922 * @returns {*} Returns the `func` result or error object. 16923 * @example 16924 * 16925 * // Avoid throwing errors for invalid selectors. 16926 * var elements = _.attempt(function(selector) { 16927 * return document.querySelectorAll(selector); 16928 * }, '>_>'); 16929 * 16930 * if (_.isError(elements)) { 16931 * elements = []; 16932 * } 16933 */ 16934 var attempt = baseRest(function(func, args) { 16935 try { 16936 return apply(func, undefined, args); 16937 } catch (e) { 16938 return isError(e) ? e : new Error(e); 16939 } 16940 }); 16941 16942 /** 16943 * Binds methods of an object to the object itself, overwriting the existing 16944 * method. 16945 * 16946 * **Note:** This method doesn't set the "length" property of bound functions. 16947 * 16948 * @static 16949 * @since 0.1.0 16950 * @memberOf _ 16951 * @category Util 16952 * @param {Object} object The object to bind and assign the bound methods to. 16953 * @param {...(string|string[])} methodNames The object method names to bind. 16954 * @returns {Object} Returns `object`. 16955 * @example 16956 * 16957 * var view = { 16958 * 'label': 'docs', 16959 * 'click': function() { 16960 * console.log('clicked ' + this.label); 16961 * } 16962 * }; 16963 * 16964 * _.bindAll(view, ['click']); 16965 * jQuery(element).on('click', view.click); 16966 * // => Logs 'clicked docs' when clicked. 16967 */ 16968 var bindAll = flatRest(function(object, methodNames) { 16969 arrayEach(methodNames, function(key) { 16970 key = toKey(key); 16971 baseAssignValue(object, key, bind(object[key], object)); 16972 }); 16973 return object; 16974 }); 16975 16976 /** 16977 * Creates a function that iterates over `pairs` and invokes the corresponding 16978 * function of the first predicate to return truthy. The predicate-function 16979 * pairs are invoked with the `this` binding and arguments of the created 16980 * function. 16981 * 16982 * @static 16983 * @memberOf _ 16984 * @since 4.0.0 16985 * @category Util 16986 * @param {Array} pairs The predicate-function pairs. 16987 * @returns {Function} Returns the new composite function. 16988 * @example 16989 * 16990 * var func = _.cond([ 16991 * [_.matches({ 'a': 1 }), _.constant('matches A')], 16992 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], 16993 * [_.stubTrue, _.constant('no match')] 16994 * ]); 16995 * 16996 * func({ 'a': 1, 'b': 2 }); 16997 * // => 'matches A' 16998 * 16999 * func({ 'a': 0, 'b': 1 }); 17000 * // => 'matches B' 17001 * 17002 * func({ 'a': '1', 'b': '2' }); 17003 * // => 'no match' 17004 */ 17005 function cond(pairs) { 17006 var length = pairs == null ? 0 : pairs.length, 17007 toIteratee = getIteratee(); 17008 17009 pairs = !length ? [] : arrayMap(pairs, function(pair) { 17010 if (typeof pair[1] != 'function') { 17011 throw new TypeError(FUNC_ERROR_TEXT); 17012 } 17013 return [toIteratee(pair[0]), pair[1]]; 17014 }); 17015 17016 return baseRest(function(args) { 17017 var index = -1; 17018 while (++index < length) { 17019 var pair = pairs[index]; 17020 if (apply(pair[0], this, args)) { 17021 return apply(pair[1], this, args); 17022 } 17023 } 17024 }); 17025 } 17026 17027 /** 17028 * Creates a function that invokes the predicate properties of `source` with 17029 * the corresponding property values of a given object, returning `true` if 17030 * all predicates return truthy, else `false`. 17031 * 17032 * **Note:** The created function is equivalent to `_.conformsTo` with 17033 * `source` partially applied. 17034 * 17035 * @static 17036 * @memberOf _ 17037 * @since 4.0.0 17038 * @category Util 17039 * @param {Object} source The object of property predicates to conform to. 17040 * @returns {Function} Returns the new spec function. 17041 * @example 17042 * 17043 * var objects = [ 17044 * { 'a': 2, 'b': 1 }, 17045 * { 'a': 1, 'b': 2 } 17046 * ]; 17047 * 17048 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); 17049 * // => [{ 'a': 1, 'b': 2 }] 17050 */ 17051 function conforms(source) { 17052 return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); 17053 } 17054 17055 /** 17056 * Creates a function that returns `value`. 17057 * 17058 * @static 17059 * @memberOf _ 17060 * @since 2.4.0 17061 * @category Util 17062 * @param {*} value The value to return from the new function. 17063 * @returns {Function} Returns the new constant function. 17064 * @example 17065 * 17066 * var objects = _.times(2, _.constant({ 'a': 1 })); 17067 * 17068 * console.log(objects); 17069 * // => [{ 'a': 1 }, { 'a': 1 }] 17070 * 17071 * console.log(objects[0] === objects[1]); 17072 * // => true 17073 */ 17074 function constant(value) { 17075 return function() { 17076 return value; 17077 }; 17078 } 17079 17080 /** 17081 * Checks `value` to determine whether a default value should be returned in 17082 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, 17083 * or `undefined`. 17084 * 17085 * @static 17086 * @memberOf _ 17087 * @since 4.14.0 17088 * @category Util 17089 * @param {*} value The value to check. 17090 * @param {*} defaultValue The default value. 17091 * @returns {*} Returns the resolved value. 17092 * @example 17093 * 17094 * _.defaultTo(1, 10); 17095 * // => 1 17096 * 17097 * _.defaultTo(undefined, 10); 17098 * // => 10 17099 */ 17100 function defaultTo(value, defaultValue) { 17101 return (value == null || value !== value) ? defaultValue : value; 17102 } 17103 17104 /** 17105 * Creates a function that returns the result of invoking the given functions 17106 * with the `this` binding of the created function, where each successive 17107 * invocation is supplied the return value of the previous. 17108 * 17109 * @static 17110 * @memberOf _ 17111 * @since 3.0.0 17112 * @category Util 17113 * @param {...(Function|Function[])} [funcs] The functions to invoke. 17114 * @returns {Function} Returns the new composite function. 17115 * @see _.flowRight 17116 * @example 17117 * 17118 * function square(n) { 17119 * return n * n; 17120 * } 17121 * 17122 * var addSquare = _.flow([_.add, square]); 17123 * addSquare(1, 2); 17124 * // => 9 17125 */ 17126 var flow = createFlow(); 17127 17128 /** 17129 * This method is like `_.flow` except that it creates a function that 17130 * invokes the given functions from right to left. 17131 * 17132 * @static 17133 * @since 3.0.0 17134 * @memberOf _ 17135 * @category Util 17136 * @param {...(Function|Function[])} [funcs] The functions to invoke. 17137 * @returns {Function} Returns the new composite function. 17138 * @see _.flow 17139 * @example 17140 * 17141 * function square(n) { 17142 * return n * n; 17143 * } 17144 * 17145 * var addSquare = _.flowRight([square, _.add]); 17146 * addSquare(1, 2); 17147 * // => 9 17148 */ 17149 var flowRight = createFlow(true); 17150 17151 /** 17152 * This method returns the first argument it receives. 17153 * 17154 * @static 17155 * @since 0.1.0 17156 * @memberOf _ 17157 * @category Util 17158 * @param {*} value Any value. 17159 * @returns {*} Returns `value`. 17160 * @example 17161 * 17162 * var object = { 'a': 1 }; 17163 * 17164 * console.log(_.identity(object) === object); 17165 * // => true 17166 */ 17167 function identity(value) { 17168 return value; 17169 } 17170 17171 /** 17172 * Creates a function that invokes `func` with the arguments of the created 17173 * function. If `func` is a property name, the created function returns the 17174 * property value for a given element. If `func` is an array or object, the 17175 * created function returns `true` for elements that contain the equivalent 17176 * source properties, otherwise it returns `false`. 17177 * 17178 * @static 17179 * @since 4.0.0 17180 * @memberOf _ 17181 * @category Util 17182 * @param {*} [func=_.identity] The value to convert to a callback. 17183 * @returns {Function} Returns the callback. 17184 * @example 17185 * 17186 * var users = [ 17187 * { 'user': 'barney', 'age': 36, 'active': true }, 17188 * { 'user': 'fred', 'age': 40, 'active': false } 17189 * ]; 17190 * 17191 * // The `_.matches` iteratee shorthand. 17192 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); 17193 * // => [{ 'user': 'barney', 'age': 36, 'active': true }] 17194 * 17195 * // The `_.matchesProperty` iteratee shorthand. 17196 * _.filter(users, _.iteratee(['user', 'fred'])); 17197 * // => [{ 'user': 'fred', 'age': 40 }] 17198 * 17199 * // The `_.property` iteratee shorthand. 17200 * _.map(users, _.iteratee('user')); 17201 * // => ['barney', 'fred'] 17202 * 17203 * // Create custom iteratee shorthands. 17204 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { 17205 * return !_.isRegExp(func) ? iteratee(func) : function(string) { 17206 * return func.test(string); 17207 * }; 17208 * }); 17209 * 17210 * _.filter(['abc', 'def'], /ef/); 17211 * // => ['def'] 17212 */ 17213 function iteratee(func) { 17214 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); 17215 } 17216 17217 /** 17218 * Creates a function that performs a partial deep comparison between a given 17219 * object and `source`, returning `true` if the given object has equivalent 17220 * property values, else `false`. 17221 * 17222 * **Note:** The created function is equivalent to `_.isMatch` with `source` 17223 * partially applied. 17224 * 17225 * Partial comparisons will match empty array and empty object `source` 17226 * values against any array or object value, respectively. See `_.isEqual` 17227 * for a list of supported value comparisons. 17228 * 17229 * @static 17230 * @memberOf _ 17231 * @since 3.0.0 17232 * @category Util 17233 * @param {Object} source The object of property values to match. 17234 * @returns {Function} Returns the new spec function. 17235 * @example 17236 * 17237 * var objects = [ 17238 * { 'a': 1, 'b': 2, 'c': 3 }, 17239 * { 'a': 4, 'b': 5, 'c': 6 } 17240 * ]; 17241 * 17242 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); 17243 * // => [{ 'a': 4, 'b': 5, 'c': 6 }] 17244 */ 17245 function matches(source) { 17246 return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); 17247 } 17248 17249 /** 17250 * Creates a function that performs a partial deep comparison between the 17251 * value at `path` of a given object to `srcValue`, returning `true` if the 17252 * object value is equivalent, else `false`. 17253 * 17254 * **Note:** Partial comparisons will match empty array and empty object 17255 * `srcValue` values against any array or object value, respectively. See 17256 * `_.isEqual` for a list of supported value comparisons. 17257 * 17258 * @static 17259 * @memberOf _ 17260 * @since 3.2.0 17261 * @category Util 17262 * @param {Array|string} path The path of the property to get. 17263 * @param {*} srcValue The value to match. 17264 * @returns {Function} Returns the new spec function. 17265 * @example 17266 * 17267 * var objects = [ 17268 * { 'a': 1, 'b': 2, 'c': 3 }, 17269 * { 'a': 4, 'b': 5, 'c': 6 } 17270 * ]; 17271 * 17272 * _.find(objects, _.matchesProperty('a', 4)); 17273 * // => { 'a': 4, 'b': 5, 'c': 6 } 17274 */ 17275 function matchesProperty(path, srcValue) { 17276 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); 17277 } 17278 17279 /** 17280 * Creates a function that invokes the method at `path` of a given object. 17281 * Any additional arguments are provided to the invoked method. 17282 * 17283 * @static 17284 * @memberOf _ 17285 * @since 3.7.0 17286 * @category Util 17287 * @param {Array|string} path The path of the method to invoke. 17288 * @param {...*} [args] The arguments to invoke the method with. 17289 * @returns {Function} Returns the new invoker function. 17290 * @example 17291 * 17292 * var objects = [ 17293 * { 'a': { 'b': _.constant(2) } }, 17294 * { 'a': { 'b': _.constant(1) } } 17295 * ]; 17296 * 17297 * _.map(objects, _.method('a.b')); 17298 * // => [2, 1] 17299 * 17300 * _.map(objects, _.method(['a', 'b'])); 17301 * // => [2, 1] 17302 */ 17303 var method = baseRest(function(path, args) { 17304 return function(object) { 17305 return baseInvoke(object, path, args); 17306 }; 17307 }); 17308 17309 /** 17310 * The opposite of `_.method`; this method creates a function that invokes 17311 * the method at a given path of `object`. Any additional arguments are 17312 * provided to the invoked method. 17313 * 17314 * @static 17315 * @memberOf _ 17316 * @since 3.7.0 17317 * @category Util 17318 * @param {Object} object The object to query. 17319 * @param {...*} [args] The arguments to invoke the method with. 17320 * @returns {Function} Returns the new invoker function. 17321 * @example 17322 * 17323 * var array = _.times(3, _.constant), 17324 * object = { 'a': array, 'b': array, 'c': array }; 17325 * 17326 * _.map(['a[2]', 'c[0]'], _.methodOf(object)); 17327 * // => [2, 0] 17328 * 17329 * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); 17330 * // => [2, 0] 17331 */ 17332 var methodOf = baseRest(function(object, args) { 17333 return function(path) { 17334 return baseInvoke(object, path, args); 17335 }; 17336 }); 17337 17338 /** 17339 * Adds all own enumerable string keyed function properties of a source 17340 * object to the destination object. If `object` is a function, then methods 17341 * are added to its prototype as well. 17342 * 17343 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to 17344 * avoid conflicts caused by modifying the original. 17345 * 17346 * @static 17347 * @since 0.1.0 17348 * @memberOf _ 17349 * @category Util 17350 * @param {Function|Object} [object=lodash] The destination object. 17351 * @param {Object} source The object of functions to add. 17352 * @param {Object} [options={}] The options object. 17353 * @param {boolean} [options.chain=true] Specify whether mixins are chainable. 17354 * @returns {Function|Object} Returns `object`. 17355 * @example 17356 * 17357 * function vowels(string) { 17358 * return _.filter(string, function(v) { 17359 * return /[aeiou]/i.test(v); 17360 * }); 17361 * } 17362 * 17363 * _.mixin({ 'vowels': vowels }); 17364 * _.vowels('fred'); 17365 * // => ['e'] 17366 * 17367 * _('fred').vowels().value(); 17368 * // => ['e'] 17369 * 17370 * _.mixin({ 'vowels': vowels }, { 'chain': false }); 17371 * _('fred').vowels(); 17372 * // => ['e'] 17373 */ 17374 function mixin(object, source, options) { 17375 var props = keys(source), 17376 methodNames = baseFunctions(source, props); 17377 17378 if (options == null && 17379 !(isObject(source) && (methodNames.length || !props.length))) { 17380 options = source; 17381 source = object; 17382 object = this; 17383 methodNames = baseFunctions(source, keys(source)); 17384 } 17385 var chain = !(isObject(options) && 'chain' in options) || !!options.chain, 17386 isFunc = isFunction(object); 17387 17388 arrayEach(methodNames, function(methodName) { 17389 var func = source[methodName]; 17390 object[methodName] = func; 17391 if (isFunc) { 17392 object.prototype[methodName] = function() { 17393 var chainAll = this.__chain__; 17394 if (chain || chainAll) { 17395 var result = object(this.__wrapped__), 17396 actions = result.__actions__ = copyArray(this.__actions__); 17397 17398 actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); 17399 result.__chain__ = chainAll; 17400 return result; 17401 } 17402 return func.apply(object, arrayPush([this.value()], arguments)); 17403 }; 17404 } 17405 }); 17406 17407 return object; 17408 } 17409 17410 /** 17411 * Reverts the `_` variable to its previous value and returns a reference to 17412 * the `lodash` function. 17413 * 17414 * @static 17415 * @since 0.1.0 17416 * @memberOf _ 17417 * @category Util 17418 * @returns {Function} Returns the `lodash` function. 17419 * @example 17420 * 17421 * var lodash = _.noConflict(); 17422 */ 17423 function noConflict() { 17424 if (root._ === this) { 17425 root._ = oldDash; 17426 } 17427 return this; 17428 } 17429 17430 /** 17431 * This method returns `undefined`. 17432 * 17433 * @static 17434 * @memberOf _ 17435 * @since 2.3.0 17436 * @category Util 17437 * @example 17438 * 17439 * _.times(2, _.noop); 17440 * // => [undefined, undefined] 17441 */ 17442 function noop() { 17443 // No operation performed. 17444 } 17445 17446 /** 17447 * Creates a function that gets the argument at index `n`. If `n` is negative, 17448 * the nth argument from the end is returned. 17449 * 17450 * @static 17451 * @memberOf _ 17452 * @since 4.0.0 17453 * @category Util 17454 * @param {number} [n=0] The index of the argument to return. 17455 * @returns {Function} Returns the new pass-thru function. 17456 * @example 17457 * 17458 * var func = _.nthArg(1); 17459 * func('a', 'b', 'c', 'd'); 17460 * // => 'b' 17461 * 17462 * var func = _.nthArg(-2); 17463 * func('a', 'b', 'c', 'd'); 17464 * // => 'c' 17465 */ 17466 function nthArg(n) { 17467 n = toInteger(n); 17468 return baseRest(function(args) { 17469 return baseNth(args, n); 17470 }); 17471 } 17472 17473 /** 17474 * Creates a function that invokes `iteratees` with the arguments it receives 17475 * and returns their results. 17476 * 17477 * @static 17478 * @memberOf _ 17479 * @since 4.0.0 17480 * @category Util 17481 * @param {...(Function|Function[])} [iteratees=[_.identity]] 17482 * The iteratees to invoke. 17483 * @returns {Function} Returns the new function. 17484 * @example 17485 * 17486 * var func = _.over([Math.max, Math.min]); 17487 * 17488 * func(1, 2, 3, 4); 17489 * // => [4, 1] 17490 */ 17491 var over = createOver(arrayMap); 17492 17493 /** 17494 * Creates a function that checks if **all** of the `predicates` return 17495 * truthy when invoked with the arguments it receives. 17496 * 17497 * @static 17498 * @memberOf _ 17499 * @since 4.0.0 17500 * @category Util 17501 * @param {...(Function|Function[])} [predicates=[_.identity]] 17502 * The predicates to check. 17503 * @returns {Function} Returns the new function. 17504 * @example 17505 * 17506 * var func = _.overEvery([Boolean, isFinite]); 17507 * 17508 * func('1'); 17509 * // => true 17510 * 17511 * func(null); 17512 * // => false 17513 * 17514 * func(NaN); 17515 * // => false 17516 */ 17517 var overEvery = createOver(arrayEvery); 17518 17519 /** 17520 * Creates a function that checks if **any** of the `predicates` return 17521 * truthy when invoked with the arguments it receives. 17522 * 17523 * @static 17524 * @memberOf _ 17525 * @since 4.0.0 17526 * @category Util 17527 * @param {...(Function|Function[])} [predicates=[_.identity]] 17528 * The predicates to check. 17529 * @returns {Function} Returns the new function. 17530 * @example 17531 * 17532 * var func = _.overSome([Boolean, isFinite]); 17533 * 17534 * func('1'); 17535 * // => true 17536 * 17537 * func(null); 17538 * // => true 17539 * 17540 * func(NaN); 17541 * // => false 17542 */ 17543 var overSome = createOver(arraySome); 17544 17545 /** 17546 * Creates a function that returns the value at `path` of a given object. 17547 * 17548 * @static 17549 * @memberOf _ 17550 * @since 2.4.0 17551 * @category Util 17552 * @param {Array|string} path The path of the property to get. 17553 * @returns {Function} Returns the new accessor function. 17554 * @example 17555 * 17556 * var objects = [ 17557 * { 'a': { 'b': 2 } }, 17558 * { 'a': { 'b': 1 } } 17559 * ]; 17560 * 17561 * _.map(objects, _.property('a.b')); 17562 * // => [2, 1] 17563 * 17564 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); 17565 * // => [1, 2] 17566 */ 17567 function property(path) { 17568 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); 17569 } 17570 17571 /** 17572 * The opposite of `_.property`; this method creates a function that returns 17573 * the value at a given path of `object`. 17574 * 17575 * @static 17576 * @memberOf _ 17577 * @since 3.0.0 17578 * @category Util 17579 * @param {Object} object The object to query. 17580 * @returns {Function} Returns the new accessor function. 17581 * @example 17582 * 17583 * var array = [0, 1, 2], 17584 * object = { 'a': array, 'b': array, 'c': array }; 17585 * 17586 * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); 17587 * // => [2, 0] 17588 * 17589 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); 17590 * // => [2, 0] 17591 */ 17592 function propertyOf(object) { 17593 return function(path) { 17594 return object == null ? undefined : baseGet(object, path); 17595 }; 17596 } 17597 17598 /** 17599 * Creates an array of numbers (positive and/or negative) progressing from 17600 * `start` up to, but not including, `end`. A step of `-1` is used if a negative 17601 * `start` is specified without an `end` or `step`. If `end` is not specified, 17602 * it's set to `start` with `start` then set to `0`. 17603 * 17604 * **Note:** JavaScript follows the IEEE-754 standard for resolving 17605 * floating-point values which can produce unexpected results. 17606 * 17607 * @static 17608 * @since 0.1.0 17609 * @memberOf _ 17610 * @category Util 17611 * @param {number} [start=0] The start of the range. 17612 * @param {number} end The end of the range. 17613 * @param {number} [step=1] The value to increment or decrement by. 17614 * @returns {Array} Returns the range of numbers. 17615 * @see _.inRange, _.rangeRight 17616 * @example 17617 * 17618 * _.range(4); 17619 * // => [0, 1, 2, 3] 17620 * 17621 * _.range(-4); 17622 * // => [0, -1, -2, -3] 17623 * 17624 * _.range(1, 5); 17625 * // => [1, 2, 3, 4] 17626 * 17627 * _.range(0, 20, 5); 17628 * // => [0, 5, 10, 15] 17629 * 17630 * _.range(0, -4, -1); 17631 * // => [0, -1, -2, -3] 17632 * 17633 * _.range(1, 4, 0); 17634 * // => [1, 1, 1] 17635 * 17636 * _.range(0); 17637 * // => [] 17638 */ 17639 var range = createRange(); 17640 17641 /** 17642 * This method is like `_.range` except that it populates values in 17643 * descending order. 17644 * 17645 * @static 17646 * @memberOf _ 17647 * @since 4.0.0 17648 * @category Util 17649 * @param {number} [start=0] The start of the range. 17650 * @param {number} end The end of the range. 17651 * @param {number} [step=1] The value to increment or decrement by. 17652 * @returns {Array} Returns the range of numbers. 17653 * @see _.inRange, _.range 17654 * @example 17655 * 17656 * _.rangeRight(4); 17657 * // => [3, 2, 1, 0] 17658 * 17659 * _.rangeRight(-4); 17660 * // => [-3, -2, -1, 0] 17661 * 17662 * _.rangeRight(1, 5); 17663 * // => [4, 3, 2, 1] 17664 * 17665 * _.rangeRight(0, 20, 5); 17666 * // => [15, 10, 5, 0] 17667 * 17668 * _.rangeRight(0, -4, -1); 17669 * // => [-3, -2, -1, 0] 17670 * 17671 * _.rangeRight(1, 4, 0); 17672 * // => [1, 1, 1] 17673 * 17674 * _.rangeRight(0); 17675 * // => [] 17676 */ 17677 var rangeRight = createRange(true); 17678 17679 /** 17680 * This method returns a new empty array. 17681 * 17682 * @static 17683 * @memberOf _ 17684 * @since 4.13.0 17685 * @category Util 17686 * @returns {Array} Returns the new empty array. 17687 * @example 17688 * 17689 * var arrays = _.times(2, _.stubArray); 17690 * 17691 * console.log(arrays); 17692 * // => [[], []] 17693 * 17694 * console.log(arrays[0] === arrays[1]); 17695 * // => false 17696 */ 17697 function stubArray() { 17698 return []; 17699 } 17700 17701 /** 17702 * This method returns `false`. 17703 * 17704 * @static 17705 * @memberOf _ 17706 * @since 4.13.0 17707 * @category Util 17708 * @returns {boolean} Returns `false`. 17709 * @example 17710 * 17711 * _.times(2, _.stubFalse); 17712 * // => [false, false] 17713 */ 17714 function stubFalse() { 17715 return false; 17716 } 17717 17718 /** 17719 * This method returns a new empty object. 17720 * 17721 * @static 17722 * @memberOf _ 17723 * @since 4.13.0 17724 * @category Util 17725 * @returns {Object} Returns the new empty object. 17726 * @example 17727 * 17728 * var objects = _.times(2, _.stubObject); 17729 * 17730 * console.log(objects); 17731 * // => [{}, {}] 17732 * 17733 * console.log(objects[0] === objects[1]); 17734 * // => false 17735 */ 17736 function stubObject() { 17737 return {}; 17738 } 17739 17740 /** 17741 * This method returns an empty string. 17742 * 17743 * @static 17744 * @memberOf _ 17745 * @since 4.13.0 17746 * @category Util 17747 * @returns {string} Returns the empty string. 17748 * @example 17749 * 17750 * _.times(2, _.stubString); 17751 * // => ['', ''] 17752 */ 17753 function stubString() { 17754 return ''; 17755 } 17756 17757 /** 17758 * This method returns `true`. 17759 * 17760 * @static 17761 * @memberOf _ 17762 * @since 4.13.0 17763 * @category Util 17764 * @returns {boolean} Returns `true`. 17765 * @example 17766 * 17767 * _.times(2, _.stubTrue); 17768 * // => [true, true] 17769 */ 17770 function stubTrue() { 17771 return true; 17772 } 17773 17774 /** 17775 * Invokes the iteratee `n` times, returning an array of the results of 17776 * each invocation. The iteratee is invoked with one argument; (index). 17777 * 17778 * @static 17779 * @since 0.1.0 17780 * @memberOf _ 17781 * @category Util 17782 * @param {number} n The number of times to invoke `iteratee`. 17783 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 17784 * @returns {Array} Returns the array of results. 17785 * @example 17786 * 17787 * _.times(3, String); 17788 * // => ['0', '1', '2'] 17789 * 17790 * _.times(4, _.constant(0)); 17791 * // => [0, 0, 0, 0] 17792 */ 17793 function times(n, iteratee) { 17794 n = toInteger(n); 17795 if (n < 1 || n > MAX_SAFE_INTEGER) { 17796 return []; 17797 } 17798 var index = MAX_ARRAY_LENGTH, 17799 length = nativeMin(n, MAX_ARRAY_LENGTH); 17800 17801 iteratee = getIteratee(iteratee); 17802 n -= MAX_ARRAY_LENGTH; 17803 17804 var result = baseTimes(length, iteratee); 17805 while (++index < n) { 17806 iteratee(index); 17807 } 17808 return result; 17809 } 17810 17811 /** 17812 * Converts `value` to a property path array. 17813 * 17814 * @static 17815 * @memberOf _ 17816 * @since 4.0.0 17817 * @category Util 17818 * @param {*} value The value to convert. 17819 * @returns {Array} Returns the new property path array. 17820 * @example 17821 * 17822 * _.toPath('a.b.c'); 17823 * // => ['a', 'b', 'c'] 17824 * 17825 * _.toPath('a[0].b.c'); 17826 * // => ['a', '0', 'b', 'c'] 17827 */ 17828 function toPath(value) { 17829 if (isArray(value)) { 17830 return arrayMap(value, toKey); 17831 } 17832 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); 17833 } 17834 17835 /** 17836 * Generates a unique ID. If `prefix` is given, the ID is appended to it. 17837 * 17838 * @static 17839 * @since 0.1.0 17840 * @memberOf _ 17841 * @category Util 17842 * @param {string} [prefix=''] The value to prefix the ID with. 17843 * @returns {string} Returns the unique ID. 17844 * @example 17845 * 17846 * _.uniqueId('contact_'); 17847 * // => 'contact_104' 17848 * 17849 * _.uniqueId(); 17850 * // => '105' 17851 */ 17852 function uniqueId(prefix) { 17853 var id = ++idCounter; 17854 return toString(prefix) + id; 17855 } 17856 17857 /*------------------------------------------------------------------------*/ 17858 17859 /** 17860 * Adds two numbers. 17861 * 17862 * @static 17863 * @memberOf _ 17864 * @since 3.4.0 17865 * @category Math 17866 * @param {number} augend The first number in an addition. 17867 * @param {number} addend The second number in an addition. 17868 * @returns {number} Returns the total. 17869 * @example 17870 * 17871 * _.add(6, 4); 17872 * // => 10 17873 */ 17874 var add = createMathOperation(function(augend, addend) { 17875 return augend + addend; 17876 }, 0); 17877 17878 /** 17879 * Computes `number` rounded up to `precision`. 17880 * 17881 * @static 17882 * @memberOf _ 17883 * @since 3.10.0 17884 * @category Math 17885 * @param {number} number The number to round up. 17886 * @param {number} [precision=0] The precision to round up to. 17887 * @returns {number} Returns the rounded up number. 17888 * @example 17889 * 17890 * _.ceil(4.006); 17891 * // => 5 17892 * 17893 * _.ceil(6.004, 2); 17894 * // => 6.01 17895 * 17896 * _.ceil(6040, -2); 17897 * // => 6100 17898 */ 17899 var ceil = createRound('ceil'); 17900 17901 /** 17902 * Divide two numbers. 17903 * 17904 * @static 17905 * @memberOf _ 17906 * @since 4.7.0 17907 * @category Math 17908 * @param {number} dividend The first number in a division. 17909 * @param {number} divisor The second number in a division. 17910 * @returns {number} Returns the quotient. 17911 * @example 17912 * 17913 * _.divide(6, 4); 17914 * // => 1.5 17915 */ 17916 var divide = createMathOperation(function(dividend, divisor) { 17917 return dividend / divisor; 17918 }, 1); 17919 17920 /** 17921 * Computes `number` rounded down to `precision`. 17922 * 17923 * @static 17924 * @memberOf _ 17925 * @since 3.10.0 17926 * @category Math 17927 * @param {number} number The number to round down. 17928 * @param {number} [precision=0] The precision to round down to. 17929 * @returns {number} Returns the rounded down number. 17930 * @example 17931 * 17932 * _.floor(4.006); 17933 * // => 4 17934 * 17935 * _.floor(0.046, 2); 17936 * // => 0.04 17937 * 17938 * _.floor(4060, -2); 17939 * // => 4000 17940 */ 17941 var floor = createRound('floor'); 17942 17943 /** 17944 * Computes the maximum value of `array`. If `array` is empty or falsey, 17945 * `undefined` is returned. 17946 * 17947 * @static 17948 * @since 0.1.0 17949 * @memberOf _ 17950 * @category Math 17951 * @param {Array} array The array to iterate over. 17952 * @returns {*} Returns the maximum value. 17953 * @example 17954 * 17955 * _.max([4, 2, 8, 6]); 17956 * // => 8 17957 * 17958 * _.max([]); 17959 * // => undefined 17960 */ 17961 function max(array) { 17962 return (array && array.length) 17963 ? baseExtremum(array, identity, baseGt) 17964 : undefined; 17965 } 17966 17967 /** 17968 * This method is like `_.max` except that it accepts `iteratee` which is 17969 * invoked for each element in `array` to generate the criterion by which 17970 * the value is ranked. The iteratee is invoked with one argument: (value). 17971 * 17972 * @static 17973 * @memberOf _ 17974 * @since 4.0.0 17975 * @category Math 17976 * @param {Array} array The array to iterate over. 17977 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 17978 * @returns {*} Returns the maximum value. 17979 * @example 17980 * 17981 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 17982 * 17983 * _.maxBy(objects, function(o) { return o.n; }); 17984 * // => { 'n': 2 } 17985 * 17986 * // The `_.property` iteratee shorthand. 17987 * _.maxBy(objects, 'n'); 17988 * // => { 'n': 2 } 17989 */ 17990 function maxBy(array, iteratee) { 17991 return (array && array.length) 17992 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) 17993 : undefined; 17994 } 17995 17996 /** 17997 * Computes the mean of the values in `array`. 17998 * 17999 * @static 18000 * @memberOf _ 18001 * @since 4.0.0 18002 * @category Math 18003 * @param {Array} array The array to iterate over. 18004 * @returns {number} Returns the mean. 18005 * @example 18006 * 18007 * _.mean([4, 2, 8, 6]); 18008 * // => 5 18009 */ 18010 function mean(array) { 18011 return baseMean(array, identity); 18012 } 18013 18014 /** 18015 * This method is like `_.mean` except that it accepts `iteratee` which is 18016 * invoked for each element in `array` to generate the value to be averaged. 18017 * The iteratee is invoked with one argument: (value). 18018 * 18019 * @static 18020 * @memberOf _ 18021 * @since 4.7.0 18022 * @category Math 18023 * @param {Array} array The array to iterate over. 18024 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18025 * @returns {number} Returns the mean. 18026 * @example 18027 * 18028 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 18029 * 18030 * _.meanBy(objects, function(o) { return o.n; }); 18031 * // => 5 18032 * 18033 * // The `_.property` iteratee shorthand. 18034 * _.meanBy(objects, 'n'); 18035 * // => 5 18036 */ 18037 function meanBy(array, iteratee) { 18038 return baseMean(array, getIteratee(iteratee, 2)); 18039 } 18040 18041 /** 18042 * Computes the minimum value of `array`. If `array` is empty or falsey, 18043 * `undefined` is returned. 18044 * 18045 * @static 18046 * @since 0.1.0 18047 * @memberOf _ 18048 * @category Math 18049 * @param {Array} array The array to iterate over. 18050 * @returns {*} Returns the minimum value. 18051 * @example 18052 * 18053 * _.min([4, 2, 8, 6]); 18054 * // => 2 18055 * 18056 * _.min([]); 18057 * // => undefined 18058 */ 18059 function min(array) { 18060 return (array && array.length) 18061 ? baseExtremum(array, identity, baseLt) 18062 : undefined; 18063 } 18064 18065 /** 18066 * This method is like `_.min` except that it accepts `iteratee` which is 18067 * invoked for each element in `array` to generate the criterion by which 18068 * the value is ranked. The iteratee is invoked with one argument: (value). 18069 * 18070 * @static 18071 * @memberOf _ 18072 * @since 4.0.0 18073 * @category Math 18074 * @param {Array} array The array to iterate over. 18075 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18076 * @returns {*} Returns the minimum value. 18077 * @example 18078 * 18079 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 18080 * 18081 * _.minBy(objects, function(o) { return o.n; }); 18082 * // => { 'n': 1 } 18083 * 18084 * // The `_.property` iteratee shorthand. 18085 * _.minBy(objects, 'n'); 18086 * // => { 'n': 1 } 18087 */ 18088 function minBy(array, iteratee) { 18089 return (array && array.length) 18090 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) 18091 : undefined; 18092 } 18093 18094 /** 18095 * Multiply two numbers. 18096 * 18097 * @static 18098 * @memberOf _ 18099 * @since 4.7.0 18100 * @category Math 18101 * @param {number} multiplier The first number in a multiplication. 18102 * @param {number} multiplicand The second number in a multiplication. 18103 * @returns {number} Returns the product. 18104 * @example 18105 * 18106 * _.multiply(6, 4); 18107 * // => 24 18108 */ 18109 var multiply = createMathOperation(function(multiplier, multiplicand) { 18110 return multiplier * multiplicand; 18111 }, 1); 18112 18113 /** 18114 * Computes `number` rounded to `precision`. 18115 * 18116 * @static 18117 * @memberOf _ 18118 * @since 3.10.0 18119 * @category Math 18120 * @param {number} number The number to round. 18121 * @param {number} [precision=0] The precision to round to. 18122 * @returns {number} Returns the rounded number. 18123 * @example 18124 * 18125 * _.round(4.006); 18126 * // => 4 18127 * 18128 * _.round(4.006, 2); 18129 * // => 4.01 18130 * 18131 * _.round(4060, -2); 18132 * // => 4100 18133 */ 18134 var round = createRound('round'); 18135 18136 /** 18137 * Subtract two numbers. 18138 * 18139 * @static 18140 * @memberOf _ 18141 * @since 4.0.0 18142 * @category Math 18143 * @param {number} minuend The first number in a subtraction. 18144 * @param {number} subtrahend The second number in a subtraction. 18145 * @returns {number} Returns the difference. 18146 * @example 18147 * 18148 * _.subtract(6, 4); 18149 * // => 2 18150 */ 18151 var subtract = createMathOperation(function(minuend, subtrahend) { 18152 return minuend - subtrahend; 18153 }, 0); 18154 18155 /** 18156 * Computes the sum of the values in `array`. 18157 * 18158 * @static 18159 * @memberOf _ 18160 * @since 3.4.0 18161 * @category Math 18162 * @param {Array} array The array to iterate over. 18163 * @returns {number} Returns the sum. 18164 * @example 18165 * 18166 * _.sum([4, 2, 8, 6]); 18167 * // => 20 18168 */ 18169 function sum(array) { 18170 return (array && array.length) 18171 ? baseSum(array, identity) 18172 : 0; 18173 } 18174 18175 /** 18176 * This method is like `_.sum` except that it accepts `iteratee` which is 18177 * invoked for each element in `array` to generate the value to be summed. 18178 * The iteratee is invoked with one argument: (value). 18179 * 18180 * @static 18181 * @memberOf _ 18182 * @since 4.0.0 18183 * @category Math 18184 * @param {Array} array The array to iterate over. 18185 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18186 * @returns {number} Returns the sum. 18187 * @example 18188 * 18189 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 18190 * 18191 * _.sumBy(objects, function(o) { return o.n; }); 18192 * // => 20 18193 * 18194 * // The `_.property` iteratee shorthand. 18195 * _.sumBy(objects, 'n'); 18196 * // => 20 18197 */ 18198 function sumBy(array, iteratee) { 18199 return (array && array.length) 18200 ? baseSum(array, getIteratee(iteratee, 2)) 18201 : 0; 18202 } 18203 18204 /*------------------------------------------------------------------------*/ 18205 18206 // Add methods that return wrapped values in chain sequences. 18207 lodash.after = after; 18208 lodash.ary = ary; 18209 lodash.assign = assign; 18210 lodash.assignIn = assignIn; 18211 lodash.assignInWith = assignInWith; 18212 lodash.assignWith = assignWith; 18213 lodash.at = at; 18214 lodash.before = before; 18215 lodash.bind = bind; 18216 lodash.bindAll = bindAll; 18217 lodash.bindKey = bindKey; 18218 lodash.castArray = castArray; 18219 lodash.chain = chain; 18220 lodash.chunk = chunk; 18221 lodash.compact = compact; 18222 lodash.concat = concat; 18223 lodash.cond = cond; 18224 lodash.conforms = conforms; 18225 lodash.constant = constant; 18226 lodash.countBy = countBy; 18227 lodash.create = create; 18228 lodash.curry = curry; 18229 lodash.curryRight = curryRight; 18230 lodash.debounce = debounce; 18231 lodash.defaults = defaults; 18232 lodash.defaultsDeep = defaultsDeep; 18233 lodash.defer = defer; 18234 lodash.delay = delay; 18235 lodash.difference = difference; 18236 lodash.differenceBy = differenceBy; 18237 lodash.differenceWith = differenceWith; 18238 lodash.drop = drop; 18239 lodash.dropRight = dropRight; 18240 lodash.dropRightWhile = dropRightWhile; 18241 lodash.dropWhile = dropWhile; 18242 lodash.fill = fill; 18243 lodash.filter = filter; 18244 lodash.flatMap = flatMap; 18245 lodash.flatMapDeep = flatMapDeep; 18246 lodash.flatMapDepth = flatMapDepth; 18247 lodash.flatten = flatten; 18248 lodash.flattenDeep = flattenDeep; 18249 lodash.flattenDepth = flattenDepth; 18250 lodash.flip = flip; 18251 lodash.flow = flow; 18252 lodash.flowRight = flowRight; 18253 lodash.fromPairs = fromPairs; 18254 lodash.functions = functions; 18255 lodash.functionsIn = functionsIn; 18256 lodash.groupBy = groupBy; 18257 lodash.initial = initial; 18258 lodash.intersection = intersection; 18259 lodash.intersectionBy = intersectionBy; 18260 lodash.intersectionWith = intersectionWith; 18261 lodash.invert = invert; 18262 lodash.invertBy = invertBy; 18263 lodash.invokeMap = invokeMap; 18264 lodash.iteratee = iteratee; 18265 lodash.keyBy = keyBy; 18266 lodash.keys = keys; 18267 lodash.keysIn = keysIn; 18268 lodash.map = map; 18269 lodash.mapKeys = mapKeys; 18270 lodash.mapValues = mapValues; 18271 lodash.matches = matches; 18272 lodash.matchesProperty = matchesProperty; 18273 lodash.memoize = memoize; 18274 lodash.merge = merge; 18275 lodash.mergeWith = mergeWith; 18276 lodash.method = method; 18277 lodash.methodOf = methodOf; 18278 lodash.mixin = mixin; 18279 lodash.negate = negate; 18280 lodash.nthArg = nthArg; 18281 lodash.omit = omit; 18282 lodash.omitBy = omitBy; 18283 lodash.once = once; 18284 lodash.orderBy = orderBy; 18285 lodash.over = over; 18286 lodash.overArgs = overArgs; 18287 lodash.overEvery = overEvery; 18288 lodash.overSome = overSome; 18289 lodash.partial = partial; 18290 lodash.partialRight = partialRight; 18291 lodash.partition = partition; 18292 lodash.pick = pick; 18293 lodash.pickBy = pickBy; 18294 lodash.property = property; 18295 lodash.propertyOf = propertyOf; 18296 lodash.pull = pull; 18297 lodash.pullAll = pullAll; 18298 lodash.pullAllBy = pullAllBy; 18299 lodash.pullAllWith = pullAllWith; 18300 lodash.pullAt = pullAt; 18301 lodash.range = range; 18302 lodash.rangeRight = rangeRight; 18303 lodash.rearg = rearg; 18304 lodash.reject = reject; 18305 lodash.remove = remove; 18306 lodash.rest = rest; 18307 lodash.reverse = reverse; 18308 lodash.sampleSize = sampleSize; 18309 lodash.set = set; 18310 lodash.setWith = setWith; 18311 lodash.shuffle = shuffle; 18312 lodash.slice = slice; 18313 lodash.sortBy = sortBy; 18314 lodash.sortedUniq = sortedUniq; 18315 lodash.sortedUniqBy = sortedUniqBy; 18316 lodash.split = split; 18317 lodash.spread = spread; 18318 lodash.tail = tail; 18319 lodash.take = take; 18320 lodash.takeRight = takeRight; 18321 lodash.takeRightWhile = takeRightWhile; 18322 lodash.takeWhile = takeWhile; 18323 lodash.tap = tap; 18324 lodash.throttle = throttle; 18325 lodash.thru = thru; 18326 lodash.toArray = toArray; 18327 lodash.toPairs = toPairs; 18328 lodash.toPairsIn = toPairsIn; 18329 lodash.toPath = toPath; 18330 lodash.toPlainObject = toPlainObject; 18331 lodash.transform = transform; 18332 lodash.unary = unary; 18333 lodash.union = union; 18334 lodash.unionBy = unionBy; 18335 lodash.unionWith = unionWith; 18336 lodash.uniq = uniq; 18337 lodash.uniqBy = uniqBy; 18338 lodash.uniqWith = uniqWith; 18339 lodash.unset = unset; 18340 lodash.unzip = unzip; 18341 lodash.unzipWith = unzipWith; 18342 lodash.update = update; 18343 lodash.updateWith = updateWith; 18344 lodash.values = values; 18345 lodash.valuesIn = valuesIn; 18346 lodash.without = without; 18347 lodash.words = words; 18348 lodash.wrap = wrap; 18349 lodash.xor = xor; 18350 lodash.xorBy = xorBy; 18351 lodash.xorWith = xorWith; 18352 lodash.zip = zip; 18353 lodash.zipObject = zipObject; 18354 lodash.zipObjectDeep = zipObjectDeep; 18355 lodash.zipWith = zipWith; 18356 18357 // Add aliases. 18358 lodash.entries = toPairs; 18359 lodash.entriesIn = toPairsIn; 18360 lodash.extend = assignIn; 18361 lodash.extendWith = assignInWith; 18362 18363 // Add methods to `lodash.prototype`. 18364 mixin(lodash, lodash); 18365 18366 /*------------------------------------------------------------------------*/ 18367 18368 // Add methods that return unwrapped values in chain sequences. 18369 lodash.add = add; 18370 lodash.attempt = attempt; 18371 lodash.camelCase = camelCase; 18372 lodash.capitalize = capitalize; 18373 lodash.ceil = ceil; 18374 lodash.clamp = clamp; 18375 lodash.clone = clone; 18376 lodash.cloneDeep = cloneDeep; 18377 lodash.cloneDeepWith = cloneDeepWith; 18378 lodash.cloneWith = cloneWith; 18379 lodash.conformsTo = conformsTo; 18380 lodash.deburr = deburr; 18381 lodash.defaultTo = defaultTo; 18382 lodash.divide = divide; 18383 lodash.endsWith = endsWith; 18384 lodash.eq = eq; 18385 lodash.escape = escape; 18386 lodash.escapeRegExp = escapeRegExp; 18387 lodash.every = every; 18388 lodash.find = find; 18389 lodash.findIndex = findIndex; 18390 lodash.findKey = findKey; 18391 lodash.findLast = findLast; 18392 lodash.findLastIndex = findLastIndex; 18393 lodash.findLastKey = findLastKey; 18394 lodash.floor = floor; 18395 lodash.forEach = forEach; 18396 lodash.forEachRight = forEachRight; 18397 lodash.forIn = forIn; 18398 lodash.forInRight = forInRight; 18399 lodash.forOwn = forOwn; 18400 lodash.forOwnRight = forOwnRight; 18401 lodash.get = get; 18402 lodash.gt = gt; 18403 lodash.gte = gte; 18404 lodash.has = has; 18405 lodash.hasIn = hasIn; 18406 lodash.head = head; 18407 lodash.identity = identity; 18408 lodash.includes = includes; 18409 lodash.indexOf = indexOf; 18410 lodash.inRange = inRange; 18411 lodash.invoke = invoke; 18412 lodash.isArguments = isArguments; 18413 lodash.isArray = isArray; 18414 lodash.isArrayBuffer = isArrayBuffer; 18415 lodash.isArrayLike = isArrayLike; 18416 lodash.isArrayLikeObject = isArrayLikeObject; 18417 lodash.isBoolean = isBoolean; 18418 lodash.isBuffer = isBuffer; 18419 lodash.isDate = isDate; 18420 lodash.isElement = isElement; 18421 lodash.isEmpty = isEmpty; 18422 lodash.isEqual = isEqual; 18423 lodash.isEqualWith = isEqualWith; 18424 lodash.isError = isError; 18425 lodash.isFinite = isFinite; 18426 lodash.isFunction = isFunction; 18427 lodash.isInteger = isInteger; 18428 lodash.isLength = isLength; 18429 lodash.isMap = isMap; 18430 lodash.isMatch = isMatch; 18431 lodash.isMatchWith = isMatchWith; 18432 lodash.isNaN = isNaN; 18433 lodash.isNative = isNative; 18434 lodash.isNil = isNil; 18435 lodash.isNull = isNull; 18436 lodash.isNumber = isNumber; 18437 lodash.isObject = isObject; 18438 lodash.isObjectLike = isObjectLike; 18439 lodash.isPlainObject = isPlainObject; 18440 lodash.isRegExp = isRegExp; 18441 lodash.isSafeInteger = isSafeInteger; 18442 lodash.isSet = isSet; 18443 lodash.isString = isString; 18444 lodash.isSymbol = isSymbol; 18445 lodash.isTypedArray = isTypedArray; 18446 lodash.isUndefined = isUndefined; 18447 lodash.isWeakMap = isWeakMap; 18448 lodash.isWeakSet = isWeakSet; 18449 lodash.join = join; 18450 lodash.kebabCase = kebabCase; 18451 lodash.last = last; 18452 lodash.lastIndexOf = lastIndexOf; 18453 lodash.lowerCase = lowerCase; 18454 lodash.lowerFirst = lowerFirst; 18455 lodash.lt = lt; 18456 lodash.lte = lte; 18457 lodash.max = max; 18458 lodash.maxBy = maxBy; 18459 lodash.mean = mean; 18460 lodash.meanBy = meanBy; 18461 lodash.min = min; 18462 lodash.minBy = minBy; 18463 lodash.stubArray = stubArray; 18464 lodash.stubFalse = stubFalse; 18465 lodash.stubObject = stubObject; 18466 lodash.stubString = stubString; 18467 lodash.stubTrue = stubTrue; 18468 lodash.multiply = multiply; 18469 lodash.nth = nth; 18470 lodash.noConflict = noConflict; 18471 lodash.noop = noop; 18472 lodash.now = now; 18473 lodash.pad = pad; 18474 lodash.padEnd = padEnd; 18475 lodash.padStart = padStart; 18476 lodash.parseInt = parseInt; 18477 lodash.random = random; 18478 lodash.reduce = reduce; 18479 lodash.reduceRight = reduceRight; 18480 lodash.repeat = repeat; 18481 lodash.replace = replace; 18482 lodash.result = result; 18483 lodash.round = round; 18484 lodash.runInContext = runInContext; 18485 lodash.sample = sample; 18486 lodash.size = size; 18487 lodash.snakeCase = snakeCase; 18488 lodash.some = some; 18489 lodash.sortedIndex = sortedIndex; 18490 lodash.sortedIndexBy = sortedIndexBy; 18491 lodash.sortedIndexOf = sortedIndexOf; 18492 lodash.sortedLastIndex = sortedLastIndex; 18493 lodash.sortedLastIndexBy = sortedLastIndexBy; 18494 lodash.sortedLastIndexOf = sortedLastIndexOf; 18495 lodash.startCase = startCase; 18496 lodash.startsWith = startsWith; 18497 lodash.subtract = subtract; 18498 lodash.sum = sum; 18499 lodash.sumBy = sumBy; 18500 lodash.template = template; 18501 lodash.times = times; 18502 lodash.toFinite = toFinite; 18503 lodash.toInteger = toInteger; 18504 lodash.toLength = toLength; 18505 lodash.toLower = toLower; 18506 lodash.toNumber = toNumber; 18507 lodash.toSafeInteger = toSafeInteger; 18508 lodash.toString = toString; 18509 lodash.toUpper = toUpper; 18510 lodash.trim = trim; 18511 lodash.trimEnd = trimEnd; 18512 lodash.trimStart = trimStart; 18513 lodash.truncate = truncate; 18514 lodash.unescape = unescape; 18515 lodash.uniqueId = uniqueId; 18516 lodash.upperCase = upperCase; 18517 lodash.upperFirst = upperFirst; 18518 18519 // Add aliases. 18520 lodash.each = forEach; 18521 lodash.eachRight = forEachRight; 18522 lodash.first = head; 18523 18524 mixin(lodash, (function() { 18525 var source = {}; 18526 baseForOwn(lodash, function(func, methodName) { 18527 if (!hasOwnProperty.call(lodash.prototype, methodName)) { 18528 source[methodName] = func; 18529 } 18530 }); 18531 return source; 18532 }()), { 'chain': false }); 18533 18534 /*------------------------------------------------------------------------*/ 18535 18536 /** 18537 * The semantic version number. 18538 * 18539 * @static 18540 * @memberOf _ 18541 * @type {string} 18542 */ 18543 lodash.VERSION = VERSION; 18544 18545 // Assign default placeholders. 18546 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { 18547 lodash[methodName].placeholder = lodash; 18548 }); 18549 18550 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. 18551 arrayEach(['drop', 'take'], function(methodName, index) { 18552 LazyWrapper.prototype[methodName] = function(n) { 18553 n = n === undefined ? 1 : nativeMax(toInteger(n), 0); 18554 18555 var result = (this.__filtered__ && !index) 18556 ? new LazyWrapper(this) 18557 : this.clone(); 18558 18559 if (result.__filtered__) { 18560 result.__takeCount__ = nativeMin(n, result.__takeCount__); 18561 } else { 18562 result.__views__.push({ 18563 'size': nativeMin(n, MAX_ARRAY_LENGTH), 18564 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') 18565 }); 18566 } 18567 return result; 18568 }; 18569 18570 LazyWrapper.prototype[methodName + 'Right'] = function(n) { 18571 return this.reverse()[methodName](n).reverse(); 18572 }; 18573 }); 18574 18575 // Add `LazyWrapper` methods that accept an `iteratee` value. 18576 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { 18577 var type = index + 1, 18578 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; 18579 18580 LazyWrapper.prototype[methodName] = function(iteratee) { 18581 var result = this.clone(); 18582 result.__iteratees__.push({ 18583 'iteratee': getIteratee(iteratee, 3), 18584 'type': type 18585 }); 18586 result.__filtered__ = result.__filtered__ || isFilter; 18587 return result; 18588 }; 18589 }); 18590 18591 // Add `LazyWrapper` methods for `_.head` and `_.last`. 18592 arrayEach(['head', 'last'], function(methodName, index) { 18593 var takeName = 'take' + (index ? 'Right' : ''); 18594 18595 LazyWrapper.prototype[methodName] = function() { 18596 return this[takeName](1).value()[0]; 18597 }; 18598 }); 18599 18600 // Add `LazyWrapper` methods for `_.initial` and `_.tail`. 18601 arrayEach(['initial', 'tail'], function(methodName, index) { 18602 var dropName = 'drop' + (index ? '' : 'Right'); 18603 18604 LazyWrapper.prototype[methodName] = function() { 18605 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); 18606 }; 18607 }); 18608 18609 LazyWrapper.prototype.compact = function() { 18610 return this.filter(identity); 18611 }; 18612 18613 LazyWrapper.prototype.find = function(predicate) { 18614 return this.filter(predicate).head(); 18615 }; 18616 18617 LazyWrapper.prototype.findLast = function(predicate) { 18618 return this.reverse().find(predicate); 18619 }; 18620 18621 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { 18622 if (typeof path == 'function') { 18623 return new LazyWrapper(this); 18624 } 18625 return this.map(function(value) { 18626 return baseInvoke(value, path, args); 18627 }); 18628 }); 18629 18630 LazyWrapper.prototype.reject = function(predicate) { 18631 return this.filter(negate(getIteratee(predicate))); 18632 }; 18633 18634 LazyWrapper.prototype.slice = function(start, end) { 18635 start = toInteger(start); 18636 18637 var result = this; 18638 if (result.__filtered__ && (start > 0 || end < 0)) { 18639 return new LazyWrapper(result); 18640 } 18641 if (start < 0) { 18642 result = result.takeRight(-start); 18643 } else if (start) { 18644 result = result.drop(start); 18645 } 18646 if (end !== undefined) { 18647 end = toInteger(end); 18648 result = end < 0 ? result.dropRight(-end) : result.take(end - start); 18649 } 18650 return result; 18651 }; 18652 18653 LazyWrapper.prototype.takeRightWhile = function(predicate) { 18654 return this.reverse().takeWhile(predicate).reverse(); 18655 }; 18656 18657 LazyWrapper.prototype.toArray = function() { 18658 return this.take(MAX_ARRAY_LENGTH); 18659 }; 18660 18661 // Add `LazyWrapper` methods to `lodash.prototype`. 18662 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 18663 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), 18664 isTaker = /^(?:head|last)$/.test(methodName), 18665 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], 18666 retUnwrapped = isTaker || /^find/.test(methodName); 18667 18668 if (!lodashFunc) { 18669 return; 18670 } 18671 lodash.prototype[methodName] = function() { 18672 var value = this.__wrapped__, 18673 args = isTaker ? [1] : arguments, 18674 isLazy = value instanceof LazyWrapper, 18675 iteratee = args[0], 18676 useLazy = isLazy || isArray(value); 18677 18678 var interceptor = function(value) { 18679 var result = lodashFunc.apply(lodash, arrayPush([value], args)); 18680 return (isTaker && chainAll) ? result[0] : result; 18681 }; 18682 18683 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { 18684 // Avoid lazy use if the iteratee has a "length" value other than `1`. 18685 isLazy = useLazy = false; 18686 } 18687 var chainAll = this.__chain__, 18688 isHybrid = !!this.__actions__.length, 18689 isUnwrapped = retUnwrapped && !chainAll, 18690 onlyLazy = isLazy && !isHybrid; 18691 18692 if (!retUnwrapped && useLazy) { 18693 value = onlyLazy ? value : new LazyWrapper(this); 18694 var result = func.apply(value, args); 18695 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); 18696 return new LodashWrapper(result, chainAll); 18697 } 18698 if (isUnwrapped && onlyLazy) { 18699 return func.apply(this, args); 18700 } 18701 result = this.thru(interceptor); 18702 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; 18703 }; 18704 }); 18705 18706 // Add `Array` methods to `lodash.prototype`. 18707 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { 18708 var func = arrayProto[methodName], 18709 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', 18710 retUnwrapped = /^(?:pop|shift)$/.test(methodName); 18711 18712 lodash.prototype[methodName] = function() { 18713 var args = arguments; 18714 if (retUnwrapped && !this.__chain__) { 18715 var value = this.value(); 18716 return func.apply(isArray(value) ? value : [], args); 18717 } 18718 return this[chainName](function(value) { 18719 return func.apply(isArray(value) ? value : [], args); 18720 }); 18721 }; 18722 }); 18723 18724 // Map minified method names to their real names. 18725 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 18726 var lodashFunc = lodash[methodName]; 18727 if (lodashFunc) { 18728 var key = (lodashFunc.name + ''), 18729 names = realNames[key] || (realNames[key] = []); 18730 18731 names.push({ 'name': methodName, 'func': lodashFunc }); 18732 } 18733 }); 18734 18735 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{ 18736 'name': 'wrapper', 18737 'func': undefined 18738 }]; 18739 18740 // Add methods to `LazyWrapper`. 18741 LazyWrapper.prototype.clone = lazyClone; 18742 LazyWrapper.prototype.reverse = lazyReverse; 18743 LazyWrapper.prototype.value = lazyValue; 18744 18745 // Add chain sequence methods to the `lodash` wrapper. 18746 lodash.prototype.at = wrapperAt; 18747 lodash.prototype.chain = wrapperChain; 18748 lodash.prototype.commit = wrapperCommit; 18749 lodash.prototype.next = wrapperNext; 18750 lodash.prototype.plant = wrapperPlant; 18751 lodash.prototype.reverse = wrapperReverse; 18752 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; 18753 18754 // Add lazy aliases. 18755 lodash.prototype.first = lodash.prototype.head; 18756 18757 if (symIterator) { 18758 lodash.prototype[symIterator] = wrapperToIterator; 18759 } 18760 return lodash; 18761 }); 18762 18763 /*--------------------------------------------------------------------------*/ 18764 18765 // Export lodash. 18766 var _ = runInContext(); 18767 18768 // Some AMD build optimizers, like r.js, check for condition patterns like: 18769 if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) { 18770 // Expose Lodash on the global object to prevent errors when Lodash is 18771 // loaded by a script tag in the presence of an AMD loader. 18772 // See http://requirejs.org/docs/errors.html#mismatch for more details. 18773 // Use `_.noConflict` to remove Lodash from the global object. 18774 root._ = _; 18775 18776 // Define as an anonymous module so, through path mapping, it can be 18777 // referenced as the "underscore" module. 18778 define(function() { 18779 return _; 18780 }); 18781 } 18782 // Check for `exports` after `define` in case a build optimizer adds it. 18783 else if (freeModule) { 18784 // Export for Node.js. 18785 (freeModule.exports = _)._ = _; 18786 // Export for CommonJS support. 18787 freeExports._ = _; 18788 } 18789 else { 18790 // Export to the global object. 18791 root._ = _; 18792 } 18793 }.call(this)); 18794 18795 }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 18796 },{}],14:[function(require,module,exports){ 18797 /** 18798 * Helpers. 18799 */ 18800 18801 var s = 1000; 18802 var m = s * 60; 18803 var h = m * 60; 18804 var d = h * 24; 18805 var y = d * 365.25; 18806 18807 /** 18808 * Parse or format the given `val`. 18809 * 18810 * Options: 18811 * 18812 * - `long` verbose formatting [false] 18813 * 18814 * @param {String|Number} val 18815 * @param {Object} [options] 18816 * @throws {Error} throw an error if val is not a non-empty string or a number 18817 * @return {String|Number} 18818 * @api public 18819 */ 18820 18821 module.exports = function(val, options) { 18822 options = options || {}; 18823 var type = typeof val; 18824 if (type === 'string' && val.length > 0) { 18825 return parse(val); 18826 } else if (type === 'number' && isNaN(val) === false) { 18827 return options.long ? fmtLong(val) : fmtShort(val); 18828 } 18829 throw new Error( 18830 'val is not a non-empty string or a valid number. val=' + 18831 JSON.stringify(val) 18832 ); 18833 }; 18834 18835 /** 18836 * Parse the given `str` and return milliseconds. 18837 * 18838 * @param {String} str 18839 * @return {Number} 18840 * @api private 18841 */ 18842 18843 function parse(str) { 18844 str = String(str); 18845 if (str.length > 100) { 18846 return; 18847 } 18848 var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec( 18849 str 18850 ); 18851 if (!match) { 18852 return; 18853 } 18854 var n = parseFloat(match[1]); 18855 var type = (match[2] || 'ms').toLowerCase(); 18856 switch (type) { 18857 case 'years': 18858 case 'year': 18859 case 'yrs': 18860 case 'yr': 18861 case 'y': 18862 return n * y; 18863 case 'days': 18864 case 'day': 18865 case 'd': 18866 return n * d; 18867 case 'hours': 18868 case 'hour': 18869 case 'hrs': 18870 case 'hr': 18871 case 'h': 18872 return n * h; 18873 case 'minutes': 18874 case 'minute': 18875 case 'mins': 18876 case 'min': 18877 case 'm': 18878 return n * m; 18879 case 'seconds': 18880 case 'second': 18881 case 'secs': 18882 case 'sec': 18883 case 's': 18884 return n * s; 18885 case 'milliseconds': 18886 case 'millisecond': 18887 case 'msecs': 18888 case 'msec': 18889 case 'ms': 18890 return n; 18891 default: 18892 return undefined; 18893 } 18894 } 18895 18896 /** 18897 * Short format for `ms`. 18898 * 18899 * @param {Number} ms 18900 * @return {String} 18901 * @api private 18902 */ 18903 18904 function fmtShort(ms) { 18905 if (ms >= d) { 18906 return Math.round(ms / d) + 'd'; 18907 } 18908 if (ms >= h) { 18909 return Math.round(ms / h) + 'h'; 18910 } 18911 if (ms >= m) { 18912 return Math.round(ms / m) + 'm'; 18913 } 18914 if (ms >= s) { 18915 return Math.round(ms / s) + 's'; 18916 } 18917 return ms + 'ms'; 18918 } 18919 18920 /** 18921 * Long format for `ms`. 18922 * 18923 * @param {Number} ms 18924 * @return {String} 18925 * @api private 18926 */ 18927 18928 function fmtLong(ms) { 18929 return plural(ms, d, 'day') || 18930 plural(ms, h, 'hour') || 18931 plural(ms, m, 'minute') || 18932 plural(ms, s, 'second') || 18933 ms + ' ms'; 18934 } 18935 18936 /** 18937 * Pluralization helper. 18938 */ 18939 18940 function plural(ms, n, name) { 18941 if (ms < n) { 18942 return; 18943 } 18944 if (ms < n * 1.5) { 18945 return Math.floor(ms / n) + ' ' + name; 18946 } 18947 return Math.ceil(ms / n) + ' ' + name + 's'; 18948 } 18949 18950 },{}],15:[function(require,module,exports){ 18951 assert.notEqual = notEqual 18952 assert.notOk = notOk 18953 assert.equal = equal 18954 assert.ok = assert 18955 18956 module.exports = assert 18957 18958 function equal (a, b, m) { 18959 assert(a == b, m) // eslint-disable-line eqeqeq 18960 } 18961 18962 function notEqual (a, b, m) { 18963 assert(a != b, m) // eslint-disable-line eqeqeq 18964 } 18965 18966 function notOk (t, m) { 18967 assert(!t, m) 18968 } 18969 18970 function assert (t, m) { 18971 if (!t) throw new Error(m || 'AssertionError') 18972 } 18973 18974 },{}],16:[function(require,module,exports){ 18975 var splice = require('remove-array-items') 18976 var nanotiming = require('nanotiming') 18977 var assert = require('assert') 18978 18979 module.exports = Nanobus 18980 18981 function Nanobus (name) { 18982 if (!(this instanceof Nanobus)) return new Nanobus(name) 18983 18984 this._name = name || 'nanobus' 18985 this._starListeners = [] 18986 this._listeners = {} 18987 } 18988 18989 Nanobus.prototype.emit = function (eventName) { 18990 assert.equal(typeof eventName, 'string', 'nanobus.emit: eventName should be type string') 18991 18992 var data = [] 18993 for (var i = 1, len = arguments.length; i < len; i++) { 18994 data.push(arguments[i]) 18995 } 18996 18997 var emitTiming = nanotiming(this._name + "('" + eventName + "')") 18998 var listeners = this._listeners[eventName] 18999 if (listeners && listeners.length > 0) { 19000 this._emit(this._listeners[eventName], data) 19001 } 19002 19003 if (this._starListeners.length > 0) { 19004 this._emit(this._starListeners, eventName, data, emitTiming.uuid) 19005 } 19006 emitTiming() 19007 19008 return this 19009 } 19010 19011 Nanobus.prototype.on = Nanobus.prototype.addListener = function (eventName, listener) { 19012 assert.equal(typeof eventName, 'string', 'nanobus.on: eventName should be type string') 19013 assert.equal(typeof listener, 'function', 'nanobus.on: listener should be type function') 19014 19015 if (eventName === '*') { 19016 this._starListeners.push(listener) 19017 } else { 19018 if (!this._listeners[eventName]) this._listeners[eventName] = [] 19019 this._listeners[eventName].push(listener) 19020 } 19021 return this 19022 } 19023 19024 Nanobus.prototype.prependListener = function (eventName, listener) { 19025 assert.equal(typeof eventName, 'string', 'nanobus.prependListener: eventName should be type string') 19026 assert.equal(typeof listener, 'function', 'nanobus.prependListener: listener should be type function') 19027 19028 if (eventName === '*') { 19029 this._starListeners.unshift(listener) 19030 } else { 19031 if (!this._listeners[eventName]) this._listeners[eventName] = [] 19032 this._listeners[eventName].unshift(listener) 19033 } 19034 return this 19035 } 19036 19037 Nanobus.prototype.once = function (eventName, listener) { 19038 assert.equal(typeof eventName, 'string', 'nanobus.once: eventName should be type string') 19039 assert.equal(typeof listener, 'function', 'nanobus.once: listener should be type function') 19040 19041 var self = this 19042 this.on(eventName, once) 19043 function once () { 19044 listener.apply(self, arguments) 19045 self.removeListener(eventName, once) 19046 } 19047 return this 19048 } 19049 19050 Nanobus.prototype.prependOnceListener = function (eventName, listener) { 19051 assert.equal(typeof eventName, 'string', 'nanobus.prependOnceListener: eventName should be type string') 19052 assert.equal(typeof listener, 'function', 'nanobus.prependOnceListener: listener should be type function') 19053 19054 var self = this 19055 this.prependListener(eventName, once) 19056 function once () { 19057 listener.apply(self, arguments) 19058 self.removeListener(eventName, once) 19059 } 19060 return this 19061 } 19062 19063 Nanobus.prototype.removeListener = function (eventName, listener) { 19064 assert.equal(typeof eventName, 'string', 'nanobus.removeListener: eventName should be type string') 19065 assert.equal(typeof listener, 'function', 'nanobus.removeListener: listener should be type function') 19066 19067 if (eventName === '*') { 19068 this._starListeners = this._starListeners.slice() 19069 return remove(this._starListeners, listener) 19070 } else { 19071 if (typeof this._listeners[eventName] !== 'undefined') { 19072 this._listeners[eventName] = this._listeners[eventName].slice() 19073 } 19074 19075 return remove(this._listeners[eventName], listener) 19076 } 19077 19078 function remove (arr, listener) { 19079 if (!arr) return 19080 var index = arr.indexOf(listener) 19081 if (index !== -1) { 19082 splice(arr, index, 1) 19083 return true 19084 } 19085 } 19086 } 19087 19088 Nanobus.prototype.removeAllListeners = function (eventName) { 19089 if (eventName) { 19090 if (eventName === '*') { 19091 this._starListeners = [] 19092 } else { 19093 this._listeners[eventName] = [] 19094 } 19095 } else { 19096 this._starListeners = [] 19097 this._listeners = {} 19098 } 19099 return this 19100 } 19101 19102 Nanobus.prototype.listeners = function (eventName) { 19103 var listeners = eventName !== '*' 19104 ? this._listeners[eventName] 19105 : this._starListeners 19106 19107 var ret = [] 19108 if (listeners) { 19109 var ilength = listeners.length 19110 for (var i = 0; i < ilength; i++) ret.push(listeners[i]) 19111 } 19112 return ret 19113 } 19114 19115 Nanobus.prototype._emit = function (arr, eventName, data, uuid) { 19116 if (typeof arr === 'undefined') return 19117 if (arr.length === 0) return 19118 if (data === undefined) { 19119 data = eventName 19120 eventName = null 19121 } 19122 19123 if (eventName) { 19124 if (uuid !== undefined) { 19125 data = [eventName].concat(data, uuid) 19126 } else { 19127 data = [eventName].concat(data) 19128 } 19129 } 19130 19131 var length = arr.length 19132 for (var i = 0; i < length; i++) { 19133 var listener = arr[i] 19134 listener.apply(listener, data) 19135 } 19136 } 19137 19138 },{"assert":2,"nanotiming":32,"remove-array-items":35}],17:[function(require,module,exports){ 19139 var document = require('global/document') 19140 var nanotiming = require('nanotiming') 19141 var morph = require('nanomorph') 19142 var onload = require('on-load') 19143 var OL_KEY_ID = onload.KEY_ID 19144 var OL_ATTR_ID = onload.KEY_ATTR 19145 var assert = require('assert') 19146 19147 module.exports = Nanocomponent 19148 19149 function makeID () { 19150 return 'ncid-' + Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1) 19151 } 19152 19153 function Nanocomponent (name) { 19154 this._hasWindow = typeof window !== 'undefined' 19155 this._id = null // represents the id of the root node 19156 this._ncID = null // internal nanocomponent id 19157 this._olID = null 19158 this._proxy = null 19159 this._loaded = false // Used to debounce on-load when child-reordering 19160 this._rootNodeName = null 19161 this._name = name || 'nanocomponent' 19162 this._rerender = false 19163 19164 this._handleLoad = this._handleLoad.bind(this) 19165 this._handleUnload = this._handleUnload.bind(this) 19166 19167 this._arguments = [] 19168 19169 var self = this 19170 19171 Object.defineProperty(this, 'element', { 19172 get: function () { 19173 var el = document.getElementById(self._id) 19174 if (el) return el.dataset.nanocomponent === self._ncID ? el : undefined 19175 } 19176 }) 19177 } 19178 19179 Nanocomponent.prototype.render = function () { 19180 var renderTiming = nanotiming(this._name + '.render') 19181 var self = this 19182 var args = new Array(arguments.length) 19183 var el 19184 for (var i = 0; i < arguments.length; i++) args[i] = arguments[i] 19185 if (!this._hasWindow) { 19186 var createTiming = nanotiming(this._name + '.create') 19187 el = this.createElement.apply(this, args) 19188 createTiming() 19189 renderTiming() 19190 return el 19191 } else if (this.element) { 19192 el = this.element // retain reference, as the ID might change on render 19193 var updateTiming = nanotiming(this._name + '.update') 19194 var shouldUpdate = this._rerender || this.update.apply(this, args) 19195 updateTiming() 19196 if (this._rerender) this._rerender = false 19197 if (shouldUpdate) { 19198 var desiredHtml = this._handleRender(args) 19199 var morphTiming = nanotiming(this._name + '.morph') 19200 morph(el, desiredHtml) 19201 morphTiming() 19202 if (this.afterupdate) this.afterupdate(el) 19203 } 19204 if (!this._proxy) { this._proxy = this._createProxy() } 19205 renderTiming() 19206 return this._proxy 19207 } else { 19208 this._reset() 19209 el = this._handleRender(args) 19210 if (this.beforerender) this.beforerender(el) 19211 if (this.load || this.unload || this.afterreorder) { 19212 onload(el, self._handleLoad, self._handleUnload, self._ncID) 19213 this._olID = el.dataset[OL_KEY_ID] 19214 } 19215 renderTiming() 19216 return el 19217 } 19218 } 19219 19220 Nanocomponent.prototype.rerender = function () { 19221 assert(this.element, 'nanocomponent: cant rerender on an unmounted dom node') 19222 this._rerender = true 19223 this.render.apply(this, this._arguments) 19224 } 19225 19226 Nanocomponent.prototype._handleRender = function (args) { 19227 var createElementTiming = nanotiming(this._name + '.createElement') 19228 var el = this.createElement.apply(this, args) 19229 createElementTiming() 19230 if (!this._rootNodeName) this._rootNodeName = el.nodeName 19231 assert(el instanceof window.Element, 'nanocomponent: createElement should return a DOM node') 19232 assert.equal(this._rootNodeName, el.nodeName, 'nanocomponent: root node types cannot differ between re-renders') 19233 this._arguments = args 19234 return this._brandNode(this._ensureID(el)) 19235 } 19236 19237 Nanocomponent.prototype._createProxy = function () { 19238 var proxy = document.createElement(this._rootNodeName) 19239 var self = this 19240 this._brandNode(proxy) 19241 proxy.id = this._id 19242 proxy.setAttribute('data-proxy', '') 19243 proxy.isSameNode = function (el) { 19244 return (el && el.dataset.nanocomponent === self._ncID) 19245 } 19246 return proxy 19247 } 19248 19249 Nanocomponent.prototype._reset = function () { 19250 this._ncID = makeID() 19251 this._olID = null 19252 this._id = null 19253 this._proxy = null 19254 this._rootNodeName = null 19255 } 19256 19257 Nanocomponent.prototype._brandNode = function (node) { 19258 node.setAttribute('data-nanocomponent', this._ncID) 19259 if (this._olID) node.setAttribute(OL_ATTR_ID, this._olID) 19260 return node 19261 } 19262 19263 Nanocomponent.prototype._ensureID = function (node) { 19264 if (node.id) this._id = node.id 19265 else node.id = this._id = this._ncID 19266 // Update proxy node ID if it changed 19267 if (this._proxy && this._proxy.id !== this._id) this._proxy.id = this._id 19268 return node 19269 } 19270 19271 Nanocomponent.prototype._handleLoad = function (el) { 19272 if (this._loaded) { 19273 if (this.afterreorder) this.afterreorder(el) 19274 return // Debounce child-reorders 19275 } 19276 this._loaded = true 19277 if (this.load) this.load(el) 19278 } 19279 19280 Nanocomponent.prototype._handleUnload = function (el) { 19281 if (this.element) return // Debounce child-reorders 19282 this._loaded = false 19283 if (this.unload) this.unload(el) 19284 } 19285 19286 Nanocomponent.prototype.createElement = function () { 19287 throw new Error('nanocomponent: createElement should be implemented!') 19288 } 19289 19290 Nanocomponent.prototype.update = function () { 19291 throw new Error('nanocomponent: update should be implemented!') 19292 } 19293 19294 },{"assert":15,"global/document":6,"nanomorph":24,"nanotiming":32,"on-load":33}],18:[function(require,module,exports){ 19295 var trailingNewlineRegex = /\n[\s]+$/ 19296 var leadingNewlineRegex = /^\n[\s]+/ 19297 var trailingSpaceRegex = /[\s]+$/ 19298 var leadingSpaceRegex = /^[\s]+/ 19299 var multiSpaceRegex = /[\n\s]+/g 19300 19301 var TEXT_TAGS = [ 19302 'a', 'abbr', 'b', 'bdi', 'bdo', 'br', 'cite', 'data', 'dfn', 'em', 'i', 19303 'kbd', 'mark', 'q', 'rp', 'rt', 'rtc', 'ruby', 's', 'amp', 'small', 'span', 19304 'strong', 'sub', 'sup', 'time', 'u', 'var', 'wbr' 19305 ] 19306 19307 var VERBATIM_TAGS = [ 19308 'code', 'pre', 'textarea' 19309 ] 19310 19311 module.exports = function appendChild (el, childs) { 19312 if (!Array.isArray(childs)) return 19313 19314 var nodeName = el.nodeName.toLowerCase() 19315 19316 var hadText = false 19317 var value, leader 19318 19319 for (var i = 0, len = childs.length; i < len; i++) { 19320 var node = childs[i] 19321 if (Array.isArray(node)) { 19322 appendChild(el, node) 19323 continue 19324 } 19325 19326 if (typeof node === 'number' || 19327 typeof node === 'boolean' || 19328 typeof node === 'function' || 19329 node instanceof Date || 19330 node instanceof RegExp) { 19331 node = node.toString() 19332 } 19333 19334 var lastChild = el.childNodes[el.childNodes.length - 1] 19335 19336 // Iterate over text nodes 19337 if (typeof node === 'string') { 19338 hadText = true 19339 19340 // If we already had text, append to the existing text 19341 if (lastChild && lastChild.nodeName === '#text') { 19342 lastChild.nodeValue += node 19343 19344 // We didn't have a text node yet, create one 19345 } else { 19346 node = document.createTextNode(node) 19347 el.appendChild(node) 19348 lastChild = node 19349 } 19350 19351 // If this is the last of the child nodes, make sure we close it out 19352 // right 19353 if (i === len - 1) { 19354 hadText = false 19355 // Trim the child text nodes if the current node isn't a 19356 // node where whitespace matters. 19357 if (TEXT_TAGS.indexOf(nodeName) === -1 && 19358 VERBATIM_TAGS.indexOf(nodeName) === -1) { 19359 value = lastChild.nodeValue 19360 .replace(leadingNewlineRegex, '') 19361 .replace(trailingSpaceRegex, '') 19362 .replace(trailingNewlineRegex, '') 19363 .replace(multiSpaceRegex, ' ') 19364 if (value === '') { 19365 el.removeChild(lastChild) 19366 } else { 19367 lastChild.nodeValue = value 19368 } 19369 } else if (VERBATIM_TAGS.indexOf(nodeName) === -1) { 19370 // The very first node in the list should not have leading 19371 // whitespace. Sibling text nodes should have whitespace if there 19372 // was any. 19373 leader = i === 0 ? '' : ' ' 19374 value = lastChild.nodeValue 19375 .replace(leadingNewlineRegex, leader) 19376 .replace(leadingSpaceRegex, ' ') 19377 .replace(trailingSpaceRegex, '') 19378 .replace(trailingNewlineRegex, '') 19379 .replace(multiSpaceRegex, ' ') 19380 lastChild.nodeValue = value 19381 } 19382 } 19383 19384 // Iterate over DOM nodes 19385 } else if (node && node.nodeType) { 19386 // If the last node was a text node, make sure it is properly closed out 19387 if (hadText) { 19388 hadText = false 19389 19390 // Trim the child text nodes if the current node isn't a 19391 // text node or a code node 19392 if (TEXT_TAGS.indexOf(nodeName) === -1 && 19393 VERBATIM_TAGS.indexOf(nodeName) === -1) { 19394 value = lastChild.nodeValue 19395 .replace(leadingNewlineRegex, '') 19396 .replace(trailingNewlineRegex, '') 19397 .replace(multiSpaceRegex, ' ') 19398 19399 // Remove empty text nodes, append otherwise 19400 if (value === '') { 19401 el.removeChild(lastChild) 19402 } else { 19403 lastChild.nodeValue = value 19404 } 19405 // Trim the child nodes if the current node is not a node 19406 // where all whitespace must be preserved 19407 } else if (VERBATIM_TAGS.indexOf(nodeName) === -1) { 19408 value = lastChild.nodeValue 19409 .replace(leadingSpaceRegex, ' ') 19410 .replace(leadingNewlineRegex, '') 19411 .replace(trailingNewlineRegex, '') 19412 .replace(multiSpaceRegex, ' ') 19413 lastChild.nodeValue = value 19414 } 19415 } 19416 19417 // Store the last nodename 19418 var _nodeName = node.nodeName 19419 if (_nodeName) nodeName = _nodeName.toLowerCase() 19420 19421 // Append the node to the DOM 19422 el.appendChild(node) 19423 } 19424 } 19425 } 19426 19427 },{}],19:[function(require,module,exports){ 19428 module.exports = [ 19429 'autofocus', 'checked', 'defaultchecked', 'disabled', 'formnovalidate', 19430 'indeterminate', 'readonly', 'required', 'selected', 'willvalidate' 19431 ] 19432 19433 },{}],20:[function(require,module,exports){ 19434 var hyperx = require('hyperx') 19435 var appendChild = require('./append-child') 19436 var SVG_TAGS = require('./svg-tags') 19437 var BOOL_PROPS = require('./bool-props') 19438 // Props that need to be set directly rather than with el.setAttribute() 19439 var DIRECT_PROPS = require('./direct-props') 19440 19441 var SVGNS = 'http://www.w3.org/2000/svg' 19442 var XLINKNS = 'http://www.w3.org/1999/xlink' 19443 19444 var COMMENT_TAG = '!--' 19445 19446 function nanoHtmlCreateElement (tag, props, children) { 19447 var el 19448 19449 // If an svg tag, it needs a namespace 19450 if (SVG_TAGS.indexOf(tag) !== -1) { 19451 props.namespace = SVGNS 19452 } 19453 19454 // If we are using a namespace 19455 var ns = false 19456 if (props.namespace) { 19457 ns = props.namespace 19458 delete props.namespace 19459 } 19460 19461 // Create the element 19462 if (ns) { 19463 el = document.createElementNS(ns, tag) 19464 } else if (tag === COMMENT_TAG) { 19465 return document.createComment(props.comment) 19466 } else { 19467 el = document.createElement(tag) 19468 } 19469 19470 // Create the properties 19471 for (var p in props) { 19472 if (props.hasOwnProperty(p)) { 19473 var key = p.toLowerCase() 19474 var val = props[p] 19475 // Normalize className 19476 if (key === 'classname') { 19477 key = 'class' 19478 p = 'class' 19479 } 19480 // The for attribute gets transformed to htmlFor, but we just set as for 19481 if (p === 'htmlFor') { 19482 p = 'for' 19483 } 19484 // If a property is boolean, set itself to the key 19485 if (BOOL_PROPS.indexOf(key) !== -1) { 19486 if (val === 'true') val = key 19487 else if (val === 'false') continue 19488 } 19489 // If a property prefers being set directly vs setAttribute 19490 if (key.slice(0, 2) === 'on' || DIRECT_PROPS.indexOf(key) !== -1) { 19491 el[p] = val 19492 } else { 19493 if (ns) { 19494 if (p === 'xlink:href') { 19495 el.setAttributeNS(XLINKNS, p, val) 19496 } else if (/^xmlns($|:)/i.test(p)) { 19497 // skip xmlns definitions 19498 } else { 19499 el.setAttributeNS(null, p, val) 19500 } 19501 } else { 19502 el.setAttribute(p, val) 19503 } 19504 } 19505 } 19506 } 19507 19508 appendChild(el, children) 19509 return el 19510 } 19511 19512 module.exports = hyperx(nanoHtmlCreateElement, {comments: true}) 19513 module.exports.default = module.exports 19514 module.exports.createElement = nanoHtmlCreateElement 19515 19516 },{"./append-child":18,"./bool-props":19,"./direct-props":21,"./svg-tags":23,"hyperx":11}],21:[function(require,module,exports){ 19517 module.exports = [ 19518 'indeterminate' 19519 ] 19520 19521 },{}],22:[function(require,module,exports){ 19522 function nanohtmlRawBrowser (tag) { 19523 var el = document.createElement('div') 19524 el.innerHTML = tag 19525 return toArray(el.childNodes) 19526 } 19527 19528 function toArray (arr) { 19529 return Array.isArray(arr) ? arr : [].slice.call(arr) 19530 } 19531 19532 module.exports = nanohtmlRawBrowser 19533 19534 },{}],23:[function(require,module,exports){ 19535 module.exports = [ 19536 'svg', 'altGlyph', 'altGlyphDef', 'altGlyphItem', 'animate', 'animateColor', 19537 'animateMotion', 'animateTransform', 'circle', 'clipPath', 'color-profile', 19538 'cursor', 'defs', 'desc', 'ellipse', 'feBlend', 'feColorMatrix', 19539 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 19540 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feFlood', 19541 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 19542 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 19543 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence', 'filter', 19544 'font', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 19545 'font-face-uri', 'foreignObject', 'g', 'glyph', 'glyphRef', 'hkern', 'image', 19546 'line', 'linearGradient', 'marker', 'mask', 'metadata', 'missing-glyph', 19547 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 19548 'set', 'stop', 'switch', 'symbol', 'text', 'textPath', 'title', 'tref', 19549 'tspan', 'use', 'view', 'vkern' 19550 ] 19551 19552 },{}],24:[function(require,module,exports){ 19553 var assert = require('assert') 19554 var morph = require('./lib/morph') 19555 19556 var TEXT_NODE = 3 19557 // var DEBUG = false 19558 19559 module.exports = nanomorph 19560 19561 // Morph one tree into another tree 19562 // 19563 // no parent 19564 // -> same: diff and walk children 19565 // -> not same: replace and return 19566 // old node doesn't exist 19567 // -> insert new node 19568 // new node doesn't exist 19569 // -> delete old node 19570 // nodes are not the same 19571 // -> diff nodes and apply patch to old node 19572 // nodes are the same 19573 // -> walk all child nodes and append to old node 19574 function nanomorph (oldTree, newTree) { 19575 // if (DEBUG) { 19576 // console.log( 19577 // 'nanomorph\nold\n %s\nnew\n %s', 19578 // oldTree && oldTree.outerHTML, 19579 // newTree && newTree.outerHTML 19580 // ) 19581 // } 19582 assert.equal(typeof oldTree, 'object', 'nanomorph: oldTree should be an object') 19583 assert.equal(typeof newTree, 'object', 'nanomorph: newTree should be an object') 19584 var tree = walk(newTree, oldTree) 19585 // if (DEBUG) console.log('=> morphed\n %s', tree.outerHTML) 19586 return tree 19587 } 19588 19589 // Walk and morph a dom tree 19590 function walk (newNode, oldNode) { 19591 // if (DEBUG) { 19592 // console.log( 19593 // 'walk\nold\n %s\nnew\n %s', 19594 // oldNode && oldNode.outerHTML, 19595 // newNode && newNode.outerHTML 19596 // ) 19597 // } 19598 if (!oldNode) { 19599 return newNode 19600 } else if (!newNode) { 19601 return null 19602 } else if (newNode.isSameNode && newNode.isSameNode(oldNode)) { 19603 return oldNode 19604 } else if (newNode.tagName !== oldNode.tagName) { 19605 return newNode 19606 } else { 19607 morph(newNode, oldNode) 19608 updateChildren(newNode, oldNode) 19609 return oldNode 19610 } 19611 } 19612 19613 // Update the children of elements 19614 // (obj, obj) -> null 19615 function updateChildren (newNode, oldNode) { 19616 // if (DEBUG) { 19617 // console.log( 19618 // 'updateChildren\nold\n %s\nnew\n %s', 19619 // oldNode && oldNode.outerHTML, 19620 // newNode && newNode.outerHTML 19621 // ) 19622 // } 19623 var oldChild, newChild, morphed, oldMatch 19624 19625 // The offset is only ever increased, and used for [i - offset] in the loop 19626 var offset = 0 19627 19628 for (var i = 0; ; i++) { 19629 oldChild = oldNode.childNodes[i] 19630 newChild = newNode.childNodes[i - offset] 19631 // if (DEBUG) { 19632 // console.log( 19633 // '===\n- old\n %s\n- new\n %s', 19634 // oldChild && oldChild.outerHTML, 19635 // newChild && newChild.outerHTML 19636 // ) 19637 // } 19638 // Both nodes are empty, do nothing 19639 if (!oldChild && !newChild) { 19640 break 19641 19642 // There is no new child, remove old 19643 } else if (!newChild) { 19644 oldNode.removeChild(oldChild) 19645 i-- 19646 19647 // There is no old child, add new 19648 } else if (!oldChild) { 19649 oldNode.appendChild(newChild) 19650 offset++ 19651 19652 // Both nodes are the same, morph 19653 } else if (same(newChild, oldChild)) { 19654 morphed = walk(newChild, oldChild) 19655 if (morphed !== oldChild) { 19656 oldNode.replaceChild(morphed, oldChild) 19657 offset++ 19658 } 19659 19660 // Both nodes do not share an ID or a placeholder, try reorder 19661 } else { 19662 oldMatch = null 19663 19664 // Try and find a similar node somewhere in the tree 19665 for (var j = i; j < oldNode.childNodes.length; j++) { 19666 if (same(oldNode.childNodes[j], newChild)) { 19667 oldMatch = oldNode.childNodes[j] 19668 break 19669 } 19670 } 19671 19672 // If there was a node with the same ID or placeholder in the old list 19673 if (oldMatch) { 19674 morphed = walk(newChild, oldMatch) 19675 if (morphed !== oldMatch) offset++ 19676 oldNode.insertBefore(morphed, oldChild) 19677 19678 // It's safe to morph two nodes in-place if neither has an ID 19679 } else if (!newChild.id && !oldChild.id) { 19680 morphed = walk(newChild, oldChild) 19681 if (morphed !== oldChild) { 19682 oldNode.replaceChild(morphed, oldChild) 19683 offset++ 19684 } 19685 19686 // Insert the node at the index if we couldn't morph or find a matching node 19687 } else { 19688 oldNode.insertBefore(newChild, oldChild) 19689 offset++ 19690 } 19691 } 19692 } 19693 } 19694 19695 function same (a, b) { 19696 if (a.id) return a.id === b.id 19697 if (a.isSameNode) return a.isSameNode(b) 19698 if (a.tagName !== b.tagName) return false 19699 if (a.type === TEXT_NODE) return a.nodeValue === b.nodeValue 19700 return false 19701 } 19702 19703 },{"./lib/morph":26,"assert":15}],25:[function(require,module,exports){ 19704 module.exports = [ 19705 // attribute events (can be set with attributes) 19706 'onclick', 19707 'ondblclick', 19708 'onmousedown', 19709 'onmouseup', 19710 'onmouseover', 19711 'onmousemove', 19712 'onmouseout', 19713 'onmouseenter', 19714 'onmouseleave', 19715 'ontouchcancel', 19716 'ontouchend', 19717 'ontouchmove', 19718 'ontouchstart', 19719 'ondragstart', 19720 'ondrag', 19721 'ondragenter', 19722 'ondragleave', 19723 'ondragover', 19724 'ondrop', 19725 'ondragend', 19726 'onkeydown', 19727 'onkeypress', 19728 'onkeyup', 19729 'onunload', 19730 'onabort', 19731 'onerror', 19732 'onresize', 19733 'onscroll', 19734 'onselect', 19735 'onchange', 19736 'onsubmit', 19737 'onreset', 19738 'onfocus', 19739 'onblur', 19740 'oninput', 19741 // other common events 19742 'oncontextmenu', 19743 'onfocusin', 19744 'onfocusout' 19745 ] 19746 19747 },{}],26:[function(require,module,exports){ 19748 var events = require('./events') 19749 var eventsLength = events.length 19750 19751 var ELEMENT_NODE = 1 19752 var TEXT_NODE = 3 19753 var COMMENT_NODE = 8 19754 19755 module.exports = morph 19756 19757 // diff elements and apply the resulting patch to the old node 19758 // (obj, obj) -> null 19759 function morph (newNode, oldNode) { 19760 var nodeType = newNode.nodeType 19761 var nodeName = newNode.nodeName 19762 19763 if (nodeType === ELEMENT_NODE) { 19764 copyAttrs(newNode, oldNode) 19765 } 19766 19767 if (nodeType === TEXT_NODE || nodeType === COMMENT_NODE) { 19768 if (oldNode.nodeValue !== newNode.nodeValue) { 19769 oldNode.nodeValue = newNode.nodeValue 19770 } 19771 } 19772 19773 // Some DOM nodes are weird 19774 // https://github.com/patrick-steele-idem/morphdom/blob/master/src/specialElHandlers.js 19775 if (nodeName === 'INPUT') updateInput(newNode, oldNode) 19776 else if (nodeName === 'OPTION') updateOption(newNode, oldNode) 19777 else if (nodeName === 'TEXTAREA') updateTextarea(newNode, oldNode) 19778 19779 copyEvents(newNode, oldNode) 19780 } 19781 19782 function copyAttrs (newNode, oldNode) { 19783 var oldAttrs = oldNode.attributes 19784 var newAttrs = newNode.attributes 19785 var attrNamespaceURI = null 19786 var attrValue = null 19787 var fromValue = null 19788 var attrName = null 19789 var attr = null 19790 19791 for (var i = newAttrs.length - 1; i >= 0; --i) { 19792 attr = newAttrs[i] 19793 attrName = attr.name 19794 attrNamespaceURI = attr.namespaceURI 19795 attrValue = attr.value 19796 if (attrNamespaceURI) { 19797 attrName = attr.localName || attrName 19798 fromValue = oldNode.getAttributeNS(attrNamespaceURI, attrName) 19799 if (fromValue !== attrValue) { 19800 oldNode.setAttributeNS(attrNamespaceURI, attrName, attrValue) 19801 } 19802 } else { 19803 if (!oldNode.hasAttribute(attrName)) { 19804 oldNode.setAttribute(attrName, attrValue) 19805 } else { 19806 fromValue = oldNode.getAttribute(attrName) 19807 if (fromValue !== attrValue) { 19808 // apparently values are always cast to strings, ah well 19809 if (attrValue === 'null' || attrValue === 'undefined') { 19810 oldNode.removeAttribute(attrName) 19811 } else { 19812 oldNode.setAttribute(attrName, attrValue) 19813 } 19814 } 19815 } 19816 } 19817 } 19818 19819 // Remove any extra attributes found on the original DOM element that 19820 // weren't found on the target element. 19821 for (var j = oldAttrs.length - 1; j >= 0; --j) { 19822 attr = oldAttrs[j] 19823 if (attr.specified !== false) { 19824 attrName = attr.name 19825 attrNamespaceURI = attr.namespaceURI 19826 19827 if (attrNamespaceURI) { 19828 attrName = attr.localName || attrName 19829 if (!newNode.hasAttributeNS(attrNamespaceURI, attrName)) { 19830 oldNode.removeAttributeNS(attrNamespaceURI, attrName) 19831 } 19832 } else { 19833 if (!newNode.hasAttributeNS(null, attrName)) { 19834 oldNode.removeAttribute(attrName) 19835 } 19836 } 19837 } 19838 } 19839 } 19840 19841 function copyEvents (newNode, oldNode) { 19842 for (var i = 0; i < eventsLength; i++) { 19843 var ev = events[i] 19844 if (newNode[ev]) { // if new element has a whitelisted attribute 19845 oldNode[ev] = newNode[ev] // update existing element 19846 } else if (oldNode[ev]) { // if existing element has it and new one doesnt 19847 oldNode[ev] = undefined // remove it from existing element 19848 } 19849 } 19850 } 19851 19852 function updateOption (newNode, oldNode) { 19853 updateAttribute(newNode, oldNode, 'selected') 19854 } 19855 19856 // The "value" attribute is special for the <input> element since it sets the 19857 // initial value. Changing the "value" attribute without changing the "value" 19858 // property will have no effect since it is only used to the set the initial 19859 // value. Similar for the "checked" attribute, and "disabled". 19860 function updateInput (newNode, oldNode) { 19861 var newValue = newNode.value 19862 var oldValue = oldNode.value 19863 19864 updateAttribute(newNode, oldNode, 'checked') 19865 updateAttribute(newNode, oldNode, 'disabled') 19866 19867 if (newValue !== oldValue) { 19868 oldNode.setAttribute('value', newValue) 19869 oldNode.value = newValue 19870 } 19871 19872 if (newValue === 'null') { 19873 oldNode.value = '' 19874 oldNode.removeAttribute('value') 19875 } 19876 19877 if (!newNode.hasAttributeNS(null, 'value')) { 19878 oldNode.removeAttribute('value') 19879 } else if (oldNode.type === 'range') { 19880 // this is so elements like slider move their UI thingy 19881 oldNode.value = newValue 19882 } 19883 } 19884 19885 function updateTextarea (newNode, oldNode) { 19886 var newValue = newNode.value 19887 if (newValue !== oldNode.value) { 19888 oldNode.value = newValue 19889 } 19890 19891 if (oldNode.firstChild && oldNode.firstChild.nodeValue !== newValue) { 19892 // Needed for IE. Apparently IE sets the placeholder as the 19893 // node value and vise versa. This ignores an empty update. 19894 if (newValue === '' && oldNode.firstChild.nodeValue === oldNode.placeholder) { 19895 return 19896 } 19897 19898 oldNode.firstChild.nodeValue = newValue 19899 } 19900 } 19901 19902 function updateAttribute (newNode, oldNode, name) { 19903 if (newNode[name] !== oldNode[name]) { 19904 oldNode[name] = newNode[name] 19905 if (newNode[name]) { 19906 oldNode.setAttribute(name, '') 19907 } else { 19908 oldNode.removeAttribute(name) 19909 } 19910 } 19911 } 19912 19913 },{"./events":25}],27:[function(require,module,exports){ 19914 var reg = /([^?=&]+)(=([^&]*))?/g 19915 var assert = require('assert') 19916 19917 module.exports = qs 19918 19919 function qs (url) { 19920 assert.equal(typeof url, 'string', 'nanoquery: url should be type string') 19921 19922 var obj = {} 19923 url.replace(/^.*\?/, '').replace(reg, function (a0, a1, a2, a3) { 19924 obj[decodeURIComponent(a1)] = decodeURIComponent(a3) 19925 }) 19926 19927 return obj 19928 } 19929 19930 },{"assert":15}],28:[function(require,module,exports){ 19931 var assert = require('assert') 19932 var wayfarer = require('wayfarer') 19933 19934 // electron support 19935 var isLocalFile = (/file:\/\//.test( 19936 typeof window === 'object' && 19937 window.location && 19938 window.location.origin 19939 )) 19940 19941 /* eslint-disable no-useless-escape */ 19942 var electron = '^(file:\/\/|\/)(.*\.html?\/?)?' 19943 var protocol = '^(http(s)?(:\/\/))?(www\.)?' 19944 var domain = '[a-zA-Z0-9-_\.]+(:[0-9]{1,5})?(\/{1})?' 19945 var qs = '[\?].*$' 19946 /* eslint-enable no-useless-escape */ 19947 19948 var stripElectron = new RegExp(electron) 19949 var prefix = new RegExp(protocol + domain) 19950 var normalize = new RegExp('#') 19951 var suffix = new RegExp(qs) 19952 19953 module.exports = Nanorouter 19954 19955 function Nanorouter (opts) { 19956 if (!(this instanceof Nanorouter)) return new Nanorouter(opts) 19957 opts = opts || {} 19958 this.router = wayfarer(opts.default || '/404') 19959 } 19960 19961 Nanorouter.prototype.on = function (routename, listener) { 19962 assert.equal(typeof routename, 'string') 19963 routename = routename.replace(/^[#/]/, '') 19964 this.router.on(routename, listener) 19965 } 19966 19967 Nanorouter.prototype.emit = function (routename) { 19968 assert.equal(typeof routename, 'string') 19969 routename = pathname(routename, isLocalFile) 19970 return this.router.emit(routename) 19971 } 19972 19973 Nanorouter.prototype.match = function (routename) { 19974 assert.equal(typeof routename, 'string') 19975 routename = pathname(routename, isLocalFile) 19976 return this.router.match(routename) 19977 } 19978 19979 // replace everything in a route but the pathname and hash 19980 function pathname (routename, isElectron) { 19981 if (isElectron) routename = routename.replace(stripElectron, '') 19982 else routename = routename.replace(prefix, '') 19983 return decodeURI(routename.replace(suffix, '').replace(normalize, '/')) 19984 } 19985 19986 },{"assert":15,"wayfarer":42}],29:[function(require,module,exports){ 19987 var assert = require('assert') 19988 19989 var hasWindow = typeof window !== 'undefined' 19990 19991 function createScheduler () { 19992 var scheduler 19993 if (hasWindow) { 19994 if (!window._nanoScheduler) window._nanoScheduler = new NanoScheduler(true) 19995 scheduler = window._nanoScheduler 19996 } else { 19997 scheduler = new NanoScheduler() 19998 } 19999 return scheduler 20000 } 20001 20002 function NanoScheduler (hasWindow) { 20003 this.hasWindow = hasWindow 20004 this.hasIdle = this.hasWindow && window.requestIdleCallback 20005 this.method = this.hasIdle ? window.requestIdleCallback.bind(window) : this.setTimeout 20006 this.scheduled = false 20007 this.queue = [] 20008 } 20009 20010 NanoScheduler.prototype.push = function (cb) { 20011 assert.equal(typeof cb, 'function', 'nanoscheduler.push: cb should be type function') 20012 20013 this.queue.push(cb) 20014 this.schedule() 20015 } 20016 20017 NanoScheduler.prototype.schedule = function () { 20018 if (this.scheduled) return 20019 20020 this.scheduled = true 20021 var self = this 20022 this.method(function (idleDeadline) { 20023 var cb 20024 while (self.queue.length && idleDeadline.timeRemaining() > 0) { 20025 cb = self.queue.shift() 20026 cb(idleDeadline) 20027 } 20028 self.scheduled = false 20029 if (self.queue.length) self.schedule() 20030 }) 20031 } 20032 20033 NanoScheduler.prototype.setTimeout = function (cb) { 20034 setTimeout(cb, 0, { 20035 timeRemaining: function () { 20036 return 1 20037 } 20038 }) 20039 } 20040 20041 module.exports = createScheduler 20042 20043 },{"assert":15}],30:[function(require,module,exports){ 20044 var Nanobus = require('nanobus') 20045 var assert = require('assert') 20046 var Parallelstate = require('./parallel-state') 20047 20048 module.exports = Nanostate 20049 20050 function Nanostate (initialState, transitions) { 20051 if (!(this instanceof Nanostate)) return new Nanostate(initialState, transitions) 20052 assert.equal(typeof initialState, 'string', 'nanostate: initialState should be type string') 20053 assert.equal(typeof transitions, 'object', 'nanostate: transitions should be type object') 20054 20055 this.transitions = transitions 20056 this.state = initialState 20057 this.submachines = {} 20058 this._submachine = null 20059 20060 Nanobus.call(this) 20061 } 20062 20063 Nanostate.prototype = Object.create(Nanobus.prototype) 20064 20065 Nanostate.prototype.constructor = Nanostate 20066 20067 Nanostate.prototype.emit = function (eventName) { 20068 var nextState = this._next(eventName) 20069 assert.ok(nextState, `nanostate.emit: invalid transition ${this.state} -> ${eventName}`) 20070 20071 if (this._submachine && Object.keys(this.transitions).indexOf(nextState) !== -1) { 20072 this._unregister() 20073 } 20074 20075 this.state = nextState 20076 Nanobus.prototype.emit.call(this, nextState) 20077 } 20078 20079 Nanostate.prototype.event = function (eventName, machine) { 20080 this.submachines[eventName] = machine 20081 } 20082 20083 Nanostate.parallel = function (transitions) { 20084 return new Parallelstate(transitions) 20085 } 20086 20087 Nanostate.prototype._unregister = function () { 20088 if (this._submachine) { 20089 this._submachine._unregister() 20090 this._submachine = null 20091 } 20092 } 20093 20094 Nanostate.prototype._next = function (eventName) { 20095 if (this._submachine) { 20096 var nextState = this._submachine._next(eventName) 20097 if (nextState) { 20098 return nextState 20099 } 20100 } 20101 20102 var submachine = this.submachines[eventName] 20103 if (submachine) { 20104 this._submachine = submachine 20105 return submachine.state 20106 } 20107 20108 return this.transitions[this.state][eventName] 20109 } 20110 20111 },{"./parallel-state":31,"assert":15,"nanobus":16}],31:[function(require,module,exports){ 20112 var Nanobus = require('nanobus') 20113 var assert = require('assert') 20114 20115 module.exports = Parallelstate 20116 20117 function Parallelstate (transitions) { 20118 assert.equal(typeof transitions, 'object', 'nanostate: transitions should be type object') 20119 20120 this.scopes = Object.keys(transitions) 20121 this.transitions = transitions 20122 20123 Object.defineProperty(this, 'state', { 20124 get: function () { 20125 return this.scopes.reduce(function (state, scope) { 20126 state[scope] = transitions[scope].state 20127 return state 20128 }, {}) 20129 } 20130 }) 20131 20132 Nanobus.call(this) 20133 } 20134 20135 Parallelstate.prototype = Object.create(Nanobus.prototype) 20136 20137 Parallelstate.prototype.emit = function (eventName) { 20138 var hasColon = eventName.indexOf(':') >= 0 20139 assert.ok(hasColon, `nanostate.emit: invalid transition ${this.state} -> ${eventName}. For parallel nanostate eventName must have a colon ":"`) 20140 20141 var eventNameSplitted = eventName.split(':') 20142 var scope = eventNameSplitted[0] 20143 var event = eventNameSplitted[1] 20144 assert.ok(scope, `nanostate.emit: invalid scope ${scope} for parallel emitting`) 20145 20146 this.transitions[scope].emit(event) 20147 20148 Nanobus.prototype.emit.call(this, eventName) 20149 } 20150 20151 },{"assert":15,"nanobus":16}],32:[function(require,module,exports){ 20152 var scheduler = require('nanoscheduler')() 20153 var assert = require('assert') 20154 20155 var perf 20156 nanotiming.disabled = true 20157 try { 20158 perf = window.performance 20159 nanotiming.disabled = window.localStorage.DISABLE_NANOTIMING === 'true' || !perf.mark 20160 } catch (e) { } 20161 20162 module.exports = nanotiming 20163 20164 function nanotiming (name) { 20165 assert.equal(typeof name, 'string', 'nanotiming: name should be type string') 20166 20167 if (nanotiming.disabled) return noop 20168 20169 var uuid = (perf.now() * 10000).toFixed() % Number.MAX_SAFE_INTEGER 20170 var startName = 'start-' + uuid + '-' + name 20171 perf.mark(startName) 20172 20173 function end (cb) { 20174 var endName = 'end-' + uuid + '-' + name 20175 perf.mark(endName) 20176 20177 scheduler.push(function () { 20178 var err = null 20179 try { 20180 var measureName = name + ' [' + uuid + ']' 20181 perf.measure(measureName, startName, endName) 20182 perf.clearMarks(startName) 20183 perf.clearMarks(endName) 20184 } catch (e) { err = e } 20185 if (cb) cb(err, name) 20186 }) 20187 } 20188 20189 end.uuid = uuid 20190 return end 20191 } 20192 20193 function noop (cb) { 20194 if (cb) { 20195 scheduler.push(function () { 20196 cb(new Error('nanotiming: performance API unavailable')) 20197 }) 20198 } 20199 } 20200 20201 },{"assert":15,"nanoscheduler":29}],33:[function(require,module,exports){ 20202 /* global MutationObserver */ 20203 var document = require('global/document') 20204 var window = require('global/window') 20205 var assert = require('assert') 20206 var watch = Object.create(null) 20207 var KEY_ID = 'onloadid' + (new Date() % 9e6).toString(36) 20208 var KEY_ATTR = 'data-' + KEY_ID 20209 var INDEX = 0 20210 20211 if (window && window.MutationObserver) { 20212 var observer = new MutationObserver(function (mutations) { 20213 if (Object.keys(watch).length < 1) return 20214 for (var i = 0; i < mutations.length; i++) { 20215 if (mutations[i].attributeName === KEY_ATTR) { 20216 eachAttr(mutations[i], turnon, turnoff) 20217 continue 20218 } 20219 eachMutation(mutations[i].removedNodes, turnoff) 20220 eachMutation(mutations[i].addedNodes, turnon) 20221 } 20222 }) 20223 if (document.body) { 20224 beginObserve(observer) 20225 } else { 20226 document.addEventListener('DOMContentLoaded', function (event) { 20227 beginObserve(observer) 20228 }) 20229 } 20230 } 20231 20232 function beginObserve (observer) { 20233 observer.observe(document.documentElement, { 20234 childList: true, 20235 subtree: true, 20236 attributes: true, 20237 attributeOldValue: true, 20238 attributeFilter: [KEY_ATTR] 20239 }) 20240 } 20241 20242 module.exports = function onload (el, on, off, caller) { 20243 assert(document.body, 'on-load: will not work prior to DOMContentLoaded') 20244 on = on || function () {} 20245 off = off || function () {} 20246 el.setAttribute(KEY_ATTR, 'o' + INDEX) 20247 watch['o' + INDEX] = [on, off, 0, caller || onload.caller] 20248 INDEX += 1 20249 return el 20250 } 20251 20252 module.exports.KEY_ATTR = KEY_ATTR 20253 module.exports.KEY_ID = KEY_ID 20254 20255 function turnon (index, el) { 20256 if (watch[index][0] && watch[index][2] === 0) { 20257 watch[index][0](el) 20258 watch[index][2] = 1 20259 } 20260 } 20261 20262 function turnoff (index, el) { 20263 if (watch[index][1] && watch[index][2] === 1) { 20264 watch[index][1](el) 20265 watch[index][2] = 0 20266 } 20267 } 20268 20269 function eachAttr (mutation, on, off) { 20270 var newValue = mutation.target.getAttribute(KEY_ATTR) 20271 if (sameOrigin(mutation.oldValue, newValue)) { 20272 watch[newValue] = watch[mutation.oldValue] 20273 return 20274 } 20275 if (watch[mutation.oldValue]) { 20276 off(mutation.oldValue, mutation.target) 20277 } 20278 if (watch[newValue]) { 20279 on(newValue, mutation.target) 20280 } 20281 } 20282 20283 function sameOrigin (oldValue, newValue) { 20284 if (!oldValue || !newValue) return false 20285 return watch[oldValue][3] === watch[newValue][3] 20286 } 20287 20288 function eachMutation (nodes, fn) { 20289 var keys = Object.keys(watch) 20290 for (var i = 0; i < nodes.length; i++) { 20291 if (nodes[i] && nodes[i].getAttribute && nodes[i].getAttribute(KEY_ATTR)) { 20292 var onloadid = nodes[i].getAttribute(KEY_ATTR) 20293 keys.forEach(function (k) { 20294 if (onloadid === k) { 20295 fn(k, nodes[i]) 20296 } 20297 }) 20298 } 20299 if (nodes[i].childNodes.length > 0) { 20300 eachMutation(nodes[i].childNodes, fn) 20301 } 20302 } 20303 } 20304 20305 },{"assert":15,"global/document":6,"global/window":7}],34:[function(require,module,exports){ 20306 // shim for using process in browser 20307 var process = module.exports = {}; 20308 20309 // cached from whatever global is present so that test runners that stub it 20310 // don't break things. But we need to wrap it in a try catch in case it is 20311 // wrapped in strict mode code which doesn't define any globals. It's inside a 20312 // function because try/catches deoptimize in certain engines. 20313 20314 var cachedSetTimeout; 20315 var cachedClearTimeout; 20316 20317 function defaultSetTimout() { 20318 throw new Error('setTimeout has not been defined'); 20319 } 20320 function defaultClearTimeout () { 20321 throw new Error('clearTimeout has not been defined'); 20322 } 20323 (function () { 20324 try { 20325 if (typeof setTimeout === 'function') { 20326 cachedSetTimeout = setTimeout; 20327 } else { 20328 cachedSetTimeout = defaultSetTimout; 20329 } 20330 } catch (e) { 20331 cachedSetTimeout = defaultSetTimout; 20332 } 20333 try { 20334 if (typeof clearTimeout === 'function') { 20335 cachedClearTimeout = clearTimeout; 20336 } else { 20337 cachedClearTimeout = defaultClearTimeout; 20338 } 20339 } catch (e) { 20340 cachedClearTimeout = defaultClearTimeout; 20341 } 20342 } ()) 20343 function runTimeout(fun) { 20344 if (cachedSetTimeout === setTimeout) { 20345 //normal enviroments in sane situations 20346 return setTimeout(fun, 0); 20347 } 20348 // if setTimeout wasn't available but was latter defined 20349 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { 20350 cachedSetTimeout = setTimeout; 20351 return setTimeout(fun, 0); 20352 } 20353 try { 20354 // when when somebody has screwed with setTimeout but no I.E. maddness 20355 return cachedSetTimeout(fun, 0); 20356 } catch(e){ 20357 try { 20358 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 20359 return cachedSetTimeout.call(null, fun, 0); 20360 } catch(e){ 20361 // 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 20362 return cachedSetTimeout.call(this, fun, 0); 20363 } 20364 } 20365 20366 20367 } 20368 function runClearTimeout(marker) { 20369 if (cachedClearTimeout === clearTimeout) { 20370 //normal enviroments in sane situations 20371 return clearTimeout(marker); 20372 } 20373 // if clearTimeout wasn't available but was latter defined 20374 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { 20375 cachedClearTimeout = clearTimeout; 20376 return clearTimeout(marker); 20377 } 20378 try { 20379 // when when somebody has screwed with setTimeout but no I.E. maddness 20380 return cachedClearTimeout(marker); 20381 } catch (e){ 20382 try { 20383 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally 20384 return cachedClearTimeout.call(null, marker); 20385 } catch (e){ 20386 // 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. 20387 // Some versions of I.E. have different rules for clearTimeout vs setTimeout 20388 return cachedClearTimeout.call(this, marker); 20389 } 20390 } 20391 20392 20393 20394 } 20395 var queue = []; 20396 var draining = false; 20397 var currentQueue; 20398 var queueIndex = -1; 20399 20400 function cleanUpNextTick() { 20401 if (!draining || !currentQueue) { 20402 return; 20403 } 20404 draining = false; 20405 if (currentQueue.length) { 20406 queue = currentQueue.concat(queue); 20407 } else { 20408 queueIndex = -1; 20409 } 20410 if (queue.length) { 20411 drainQueue(); 20412 } 20413 } 20414 20415 function drainQueue() { 20416 if (draining) { 20417 return; 20418 } 20419 var timeout = runTimeout(cleanUpNextTick); 20420 draining = true; 20421 20422 var len = queue.length; 20423 while(len) { 20424 currentQueue = queue; 20425 queue = []; 20426 while (++queueIndex < len) { 20427 if (currentQueue) { 20428 currentQueue[queueIndex].run(); 20429 } 20430 } 20431 queueIndex = -1; 20432 len = queue.length; 20433 } 20434 currentQueue = null; 20435 draining = false; 20436 runClearTimeout(timeout); 20437 } 20438 20439 process.nextTick = function (fun) { 20440 var args = new Array(arguments.length - 1); 20441 if (arguments.length > 1) { 20442 for (var i = 1; i < arguments.length; i++) { 20443 args[i - 1] = arguments[i]; 20444 } 20445 } 20446 queue.push(new Item(fun, args)); 20447 if (queue.length === 1 && !draining) { 20448 runTimeout(drainQueue); 20449 } 20450 }; 20451 20452 // v8 likes predictible objects 20453 function Item(fun, array) { 20454 this.fun = fun; 20455 this.array = array; 20456 } 20457 Item.prototype.run = function () { 20458 this.fun.apply(null, this.array); 20459 }; 20460 process.title = 'browser'; 20461 process.browser = true; 20462 process.env = {}; 20463 process.argv = []; 20464 process.version = ''; // empty string to avoid regexp issues 20465 process.versions = {}; 20466 20467 function noop() {} 20468 20469 process.on = noop; 20470 process.addListener = noop; 20471 process.once = noop; 20472 process.off = noop; 20473 process.removeListener = noop; 20474 process.removeAllListeners = noop; 20475 process.emit = noop; 20476 process.prependListener = noop; 20477 process.prependOnceListener = noop; 20478 20479 process.listeners = function (name) { return [] } 20480 20481 process.binding = function (name) { 20482 throw new Error('process.binding is not supported'); 20483 }; 20484 20485 process.cwd = function () { return '/' }; 20486 process.chdir = function (dir) { 20487 throw new Error('process.chdir is not supported'); 20488 }; 20489 process.umask = function() { return 0; }; 20490 20491 },{}],35:[function(require,module,exports){ 20492 'use strict' 20493 20494 /** 20495 * Remove a range of items from an array 20496 * 20497 * @function removeItems 20498 * @param {Array<*>} arr The target array 20499 * @param {number} startIdx The index to begin removing from (inclusive) 20500 * @param {number} removeCount How many items to remove 20501 */ 20502 module.exports = function removeItems(arr, startIdx, removeCount) 20503 { 20504 var i, length = arr.length 20505 20506 if (startIdx >= length || removeCount === 0) { 20507 return 20508 } 20509 20510 removeCount = (startIdx + removeCount > length ? length - startIdx : removeCount) 20511 20512 var len = length - removeCount 20513 20514 for (i = startIdx; i < len; ++i) { 20515 arr[i] = arr[i + removeCount] 20516 } 20517 20518 arr.length = len 20519 } 20520 20521 },{}],36:[function(require,module,exports){ 20522 (function (global, factory) { 20523 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 20524 typeof define === 'function' && define.amd ? define(factory) : 20525 (global.S = factory()); 20526 }(this, (function () { 'use strict'; 20527 20528 // Public interface 20529 var S = function S(fn, value) { 20530 var node = new ComputationNode(fn, value); 20531 return function computation() { 20532 return node.current(); 20533 }; 20534 }; 20535 // compatibility with commonjs systems that expect default export to be at require('s.js').default rather than just require('s-js') 20536 Object.defineProperty(S, 'default', { value: S }); 20537 S.root = function root(fn) { 20538 var owner = Owner, root = fn.length === 0 ? UNOWNED : new ComputationNode(null, null), result = undefined, disposer = fn.length === 0 ? null : function _dispose() { 20539 if (RunningClock !== null) { 20540 RootClock.disposes.add(root); 20541 } 20542 else { 20543 dispose(root); 20544 } 20545 }; 20546 Owner = root; 20547 if (RunningClock === null) { 20548 result = topLevelRoot(fn, disposer, owner); 20549 } 20550 else { 20551 result = disposer === null ? fn() : fn(disposer); 20552 Owner = owner; 20553 } 20554 return result; 20555 }; 20556 function topLevelRoot(fn, disposer, owner) { 20557 try { 20558 return disposer === null ? fn() : fn(disposer); 20559 } 20560 finally { 20561 Owner = owner; 20562 } 20563 } 20564 S.on = function on(ev, fn, seed, onchanges) { 20565 if (Array.isArray(ev)) 20566 ev = callAll(ev); 20567 onchanges = !!onchanges; 20568 return S(on, seed); 20569 function on(value) { 20570 var running = RunningNode; 20571 ev(); 20572 if (onchanges) 20573 onchanges = false; 20574 else { 20575 RunningNode = null; 20576 value = fn(value); 20577 RunningNode = running; 20578 } 20579 return value; 20580 } 20581 }; 20582 function callAll(ss) { 20583 return function all() { 20584 for (var i = 0; i < ss.length; i++) 20585 ss[i](); 20586 }; 20587 } 20588 S.effect = function effect(fn, value) { 20589 new ComputationNode(fn, value); 20590 }; 20591 S.data = function data(value) { 20592 var node = new DataNode(value); 20593 return function data(value) { 20594 if (arguments.length === 0) { 20595 return node.current(); 20596 } 20597 else { 20598 return node.next(value); 20599 } 20600 }; 20601 }; 20602 S.value = function value(current, eq) { 20603 var data = S.data(current), age = -1; 20604 return function value(update) { 20605 if (arguments.length === 0) { 20606 return data(); 20607 } 20608 else { 20609 var same = eq ? eq(current, update) : current === update; 20610 if (!same) { 20611 var time = RootClock.time; 20612 if (age === time) 20613 throw new Error("conflicting values: " + update + " is not the same as " + current); 20614 age = time; 20615 current = update; 20616 data(update); 20617 } 20618 return update; 20619 } 20620 }; 20621 }; 20622 S.freeze = function freeze(fn) { 20623 var result = undefined; 20624 if (RunningClock !== null) { 20625 result = fn(); 20626 } 20627 else { 20628 RunningClock = RootClock; 20629 RunningClock.changes.reset(); 20630 try { 20631 result = fn(); 20632 event(); 20633 } 20634 finally { 20635 RunningClock = null; 20636 } 20637 } 20638 return result; 20639 }; 20640 S.sample = function sample(fn) { 20641 var result, running = RunningNode; 20642 if (running !== null) { 20643 RunningNode = null; 20644 result = fn(); 20645 RunningNode = running; 20646 } 20647 else { 20648 result = fn(); 20649 } 20650 return result; 20651 }; 20652 S.cleanup = function cleanup(fn) { 20653 if (Owner !== null) { 20654 if (Owner.cleanups === null) 20655 Owner.cleanups = [fn]; 20656 else 20657 Owner.cleanups.push(fn); 20658 } 20659 else { 20660 console.warn("cleanups created without a root or parent will never be run"); 20661 } 20662 }; 20663 // experimental : exposing node constructors and some state 20664 S.makeDataNode = function makeDataNode(value) { 20665 return new DataNode(value); 20666 }; 20667 S.makeComputationNode = function makeComputationNode(fn, seed) { 20668 return new ComputationNode(fn, seed); 20669 }; 20670 S.isFrozen = function isFrozen() { 20671 return RunningClock !== null; 20672 }; 20673 S.isListening = function isListening() { 20674 return RunningNode !== null; 20675 }; 20676 // Internal implementation 20677 /// Graph classes and operations 20678 var Clock = /** @class */ (function () { 20679 function Clock() { 20680 this.time = 0; 20681 this.changes = new Queue(); // batched changes to data nodes 20682 this.updates = new Queue(); // computations to update 20683 this.disposes = new Queue(); // disposals to run after current batch of updates finishes 20684 } 20685 return Clock; 20686 }()); 20687 var RootClockProxy = { 20688 time: function () { return RootClock.time; } 20689 }; 20690 var DataNode = /** @class */ (function () { 20691 function DataNode(value) { 20692 this.value = value; 20693 this.pending = NOTPENDING; 20694 this.log = null; 20695 } 20696 DataNode.prototype.current = function () { 20697 if (RunningNode !== null) { 20698 logDataRead(this, RunningNode); 20699 } 20700 return this.value; 20701 }; 20702 DataNode.prototype.next = function (value) { 20703 if (RunningClock !== null) { 20704 if (this.pending !== NOTPENDING) { // value has already been set once, check for conflicts 20705 if (value !== this.pending) { 20706 throw new Error("conflicting changes: " + value + " !== " + this.pending); 20707 } 20708 } 20709 else { // add to list of changes 20710 this.pending = value; 20711 RootClock.changes.add(this); 20712 } 20713 } 20714 else { // not batching, respond to change now 20715 if (this.log !== null) { 20716 this.pending = value; 20717 RootClock.changes.add(this); 20718 event(); 20719 } 20720 else { 20721 this.value = value; 20722 } 20723 } 20724 return value; 20725 }; 20726 DataNode.prototype.clock = function () { 20727 return RootClockProxy; 20728 }; 20729 return DataNode; 20730 }()); 20731 var ComputationNode = /** @class */ (function () { 20732 function ComputationNode(fn, value) { 20733 this.state = CURRENT; 20734 this.source1 = null; 20735 this.source1slot = 0; 20736 this.sources = null; 20737 this.sourceslots = null; 20738 this.log = null; 20739 this.owned = null; 20740 this.cleanups = null; 20741 this.fn = fn; 20742 this.value = value; 20743 this.age = RootClock.time; 20744 if (fn === null) 20745 return; 20746 var owner = Owner, running = RunningNode; 20747 if (owner === null) 20748 console.warn("computations created without a root or parent will never be disposed"); 20749 Owner = RunningNode = this; 20750 if (RunningClock === null) { 20751 toplevelComputation(this); 20752 } 20753 else { 20754 this.value = this.fn(this.value); 20755 } 20756 if (owner && owner !== UNOWNED) { 20757 if (owner.owned === null) 20758 owner.owned = [this]; 20759 else 20760 owner.owned.push(this); 20761 } 20762 Owner = owner; 20763 RunningNode = running; 20764 } 20765 ComputationNode.prototype.current = function () { 20766 if (RunningNode !== null) { 20767 if (this.age === RootClock.time) { 20768 if (this.state === RUNNING) 20769 throw new Error("circular dependency"); 20770 else 20771 updateNode(this); // checks for state === STALE internally, so don't need to check here 20772 } 20773 logComputationRead(this, RunningNode); 20774 } 20775 return this.value; 20776 }; 20777 ComputationNode.prototype.clock = function () { 20778 return RootClockProxy; 20779 }; 20780 return ComputationNode; 20781 }()); 20782 var Log = /** @class */ (function () { 20783 function Log() { 20784 this.node1 = null; 20785 this.node1slot = 0; 20786 this.nodes = null; 20787 this.nodeslots = null; 20788 } 20789 return Log; 20790 }()); 20791 var Queue = /** @class */ (function () { 20792 function Queue() { 20793 this.items = []; 20794 this.count = 0; 20795 } 20796 Queue.prototype.reset = function () { 20797 this.count = 0; 20798 }; 20799 Queue.prototype.add = function (item) { 20800 this.items[this.count++] = item; 20801 }; 20802 Queue.prototype.run = function (fn) { 20803 var items = this.items; 20804 for (var i = 0; i < this.count; i++) { 20805 fn(items[i]); 20806 items[i] = null; 20807 } 20808 this.count = 0; 20809 }; 20810 return Queue; 20811 }()); 20812 // Constants 20813 var NOTPENDING = {}, CURRENT = 0, STALE = 1, RUNNING = 2; 20814 // "Globals" used to keep track of current system state 20815 var RootClock = new Clock(), RunningClock = null, // currently running clock 20816 RunningNode = null, // currently running computation 20817 Owner = null, // owner for new computations 20818 UNOWNED = new ComputationNode(null, null); 20819 // Functions 20820 function logRead(from, to) { 20821 var fromslot, toslot = to.source1 === null ? -1 : to.sources === null ? 0 : to.sources.length; 20822 if (from.node1 === null) { 20823 from.node1 = to; 20824 from.node1slot = toslot; 20825 fromslot = -1; 20826 } 20827 else if (from.nodes === null) { 20828 from.nodes = [to]; 20829 from.nodeslots = [toslot]; 20830 fromslot = 0; 20831 } 20832 else { 20833 fromslot = from.nodes.length; 20834 from.nodes.push(to); 20835 from.nodeslots.push(toslot); 20836 } 20837 if (to.source1 === null) { 20838 to.source1 = from; 20839 to.source1slot = fromslot; 20840 } 20841 else if (to.sources === null) { 20842 to.sources = [from]; 20843 to.sourceslots = [fromslot]; 20844 } 20845 else { 20846 to.sources.push(from); 20847 to.sourceslots.push(fromslot); 20848 } 20849 } 20850 function logDataRead(data, to) { 20851 if (data.log === null) 20852 data.log = new Log(); 20853 logRead(data.log, to); 20854 } 20855 function logComputationRead(node, to) { 20856 if (node.log === null) 20857 node.log = new Log(); 20858 logRead(node.log, to); 20859 } 20860 function event() { 20861 // b/c we might be under a top level S.root(), have to preserve current root 20862 var owner = Owner; 20863 RootClock.updates.reset(); 20864 RootClock.time++; 20865 try { 20866 run(RootClock); 20867 } 20868 finally { 20869 RunningClock = RunningNode = null; 20870 Owner = owner; 20871 } 20872 } 20873 function toplevelComputation(node) { 20874 RunningClock = RootClock; 20875 RootClock.changes.reset(); 20876 RootClock.updates.reset(); 20877 try { 20878 node.value = node.fn(node.value); 20879 if (RootClock.changes.count > 0 || RootClock.updates.count > 0) { 20880 RootClock.time++; 20881 run(RootClock); 20882 } 20883 } 20884 finally { 20885 RunningClock = Owner = RunningNode = null; 20886 } 20887 } 20888 function run(clock) { 20889 var running = RunningClock, count = 0; 20890 RunningClock = clock; 20891 clock.disposes.reset(); 20892 // for each batch ... 20893 while (clock.changes.count !== 0 || clock.updates.count !== 0 || clock.disposes.count !== 0) { 20894 if (count > 0) // don't tick on first run, or else we expire already scheduled updates 20895 clock.time++; 20896 clock.changes.run(applyDataChange); 20897 clock.updates.run(updateNode); 20898 clock.disposes.run(dispose); 20899 // if there are still changes after excessive batches, assume runaway 20900 if (count++ > 1e5) { 20901 throw new Error("Runaway clock detected"); 20902 } 20903 } 20904 RunningClock = running; 20905 } 20906 function applyDataChange(data) { 20907 data.value = data.pending; 20908 data.pending = NOTPENDING; 20909 if (data.log) 20910 markComputationsStale(data.log); 20911 } 20912 function markComputationsStale(log) { 20913 var node1 = log.node1, nodes = log.nodes; 20914 // mark all downstream nodes stale which haven't been already 20915 if (node1 !== null) 20916 markNodeStale(node1); 20917 if (nodes !== null) { 20918 for (var i = 0, len = nodes.length; i < len; i++) { 20919 markNodeStale(nodes[i]); 20920 } 20921 } 20922 } 20923 function markNodeStale(node) { 20924 var time = RootClock.time; 20925 if (node.age < time) { 20926 node.age = time; 20927 node.state = STALE; 20928 RootClock.updates.add(node); 20929 if (node.owned !== null) 20930 markOwnedNodesForDisposal(node.owned); 20931 if (node.log !== null) 20932 markComputationsStale(node.log); 20933 } 20934 } 20935 function markOwnedNodesForDisposal(owned) { 20936 for (var i = 0; i < owned.length; i++) { 20937 var child = owned[i]; 20938 child.age = RootClock.time; 20939 child.state = CURRENT; 20940 if (child.owned !== null) 20941 markOwnedNodesForDisposal(child.owned); 20942 } 20943 } 20944 function updateNode(node) { 20945 if (node.state === STALE) { 20946 var owner = Owner, running = RunningNode; 20947 Owner = RunningNode = node; 20948 node.state = RUNNING; 20949 cleanup(node, false); 20950 node.value = node.fn(node.value); 20951 node.state = CURRENT; 20952 Owner = owner; 20953 RunningNode = running; 20954 } 20955 } 20956 function cleanup(node, final) { 20957 var source1 = node.source1, sources = node.sources, sourceslots = node.sourceslots, cleanups = node.cleanups, owned = node.owned, i, len; 20958 if (cleanups !== null) { 20959 for (i = 0; i < cleanups.length; i++) { 20960 cleanups[i](final); 20961 } 20962 node.cleanups = null; 20963 } 20964 if (owned !== null) { 20965 for (i = 0; i < owned.length; i++) { 20966 dispose(owned[i]); 20967 } 20968 node.owned = null; 20969 } 20970 if (source1 !== null) { 20971 cleanupSource(source1, node.source1slot); 20972 node.source1 = null; 20973 } 20974 if (sources !== null) { 20975 for (i = 0, len = sources.length; i < len; i++) { 20976 cleanupSource(sources.pop(), sourceslots.pop()); 20977 } 20978 } 20979 } 20980 function cleanupSource(source, slot) { 20981 var nodes = source.nodes, nodeslots = source.nodeslots, last, lastslot; 20982 if (slot === -1) { 20983 source.node1 = null; 20984 } 20985 else { 20986 last = nodes.pop(); 20987 lastslot = nodeslots.pop(); 20988 if (slot !== nodes.length) { 20989 nodes[slot] = last; 20990 nodeslots[slot] = lastslot; 20991 if (lastslot === -1) { 20992 last.source1slot = slot; 20993 } 20994 else { 20995 last.sourceslots[lastslot] = slot; 20996 } 20997 } 20998 } 20999 } 21000 function dispose(node) { 21001 node.fn = null; 21002 node.log = null; 21003 cleanup(node, true); 21004 } 21005 21006 return S; 21007 21008 }))); 21009 21010 },{}],37:[function(require,module,exports){ 21011 // Utilities 21012 const lowerCase = require('./lower-case') 21013 const specials = require('./specials') 21014 21015 const regex = /(?:(?:(\s?(?:^|[.\(\)!?;:"-])\s*)(\w))|(\w))(\w*[’']*\w*)/g 21016 21017 const convertToRegExp = specials => specials.map(s => [new RegExp(`\\b${s}\\b`, 'gi'), s]) 21018 21019 function parseMatch(match) { 21020 const firstCharacter = match[0] 21021 21022 // test first character 21023 if (/\s/.test(firstCharacter)) { 21024 // if whitespace - trim and return 21025 return match.substr(1) 21026 } 21027 if (/[\(\)]/.test(firstCharacter)) { 21028 // if parens - this shouldn't be replaced 21029 return null 21030 } 21031 21032 return match 21033 } 21034 21035 module.exports = (str, options = {}) => { 21036 str = str.toLowerCase().replace(regex, (m, lead = '', forced, lower, rest) => { 21037 const parsedMatch = parseMatch(m) 21038 if (!parsedMatch) { 21039 return m 21040 } 21041 if (!forced) { 21042 const fullLower = lower + rest 21043 21044 if (lowerCase.has(fullLower)) { 21045 return parsedMatch 21046 } 21047 } 21048 21049 return lead + (lower || forced).toUpperCase() + rest 21050 }) 21051 21052 const customSpecials = options.special || [] 21053 const replace = [...specials, ...customSpecials] 21054 const replaceRegExp = convertToRegExp(replace) 21055 21056 replaceRegExp.forEach(([pattern, s]) => { 21057 str = str.replace(pattern, s) 21058 }) 21059 21060 return str 21061 } 21062 21063 },{"./lower-case":38,"./specials":39}],38:[function(require,module,exports){ 21064 const conjunctions = [ 21065 'for', 21066 'and', 21067 'nor', 21068 'but', 21069 'or', 21070 'yet', 21071 'so' 21072 ] 21073 21074 const articles = [ 21075 'a', 21076 'an', 21077 'the' 21078 ] 21079 21080 const prepositions = [ 21081 'aboard', 21082 'about', 21083 'above', 21084 'across', 21085 'after', 21086 'against', 21087 'along', 21088 'amid', 21089 'among', 21090 'anti', 21091 'around', 21092 'as', 21093 'at', 21094 'before', 21095 'behind', 21096 'below', 21097 'beneath', 21098 'beside', 21099 'besides', 21100 'between', 21101 'beyond', 21102 'but', 21103 'by', 21104 'concerning', 21105 'considering', 21106 'despite', 21107 'down', 21108 'during', 21109 'except', 21110 'excepting', 21111 'excluding', 21112 'following', 21113 'for', 21114 'from', 21115 'in', 21116 'inside', 21117 'into', 21118 'like', 21119 'minus', 21120 'near', 21121 'of', 21122 'off', 21123 'on', 21124 'onto', 21125 'opposite', 21126 'over', 21127 'past', 21128 'per', 21129 'plus', 21130 'regarding', 21131 'round', 21132 'save', 21133 'since', 21134 'than', 21135 'through', 21136 'to', 21137 'toward', 21138 'towards', 21139 'under', 21140 'underneath', 21141 'unlike', 21142 'until', 21143 'up', 21144 'upon', 21145 'versus', 21146 'via', 21147 'with', 21148 'within', 21149 'without' 21150 ] 21151 21152 module.exports = new Set([ 21153 ...conjunctions, 21154 ...articles, 21155 ...prepositions 21156 ]) 21157 21158 },{}],39:[function(require,module,exports){ 21159 const intended = [ 21160 'ZEIT', 21161 'ZEIT Inc.', 21162 'CLI', 21163 'API', 21164 'Next.js', 21165 'Node.js', 21166 'HTTP', 21167 'HTTPS', 21168 'JSX', 21169 'DNS', 21170 'URL', 21171 'now.sh', 21172 'now.json', 21173 'CI', 21174 'CDN', 21175 'package.json' 21176 ] 21177 21178 module.exports = intended 21179 21180 },{}],40:[function(require,module,exports){ 21181 module.exports = function isBuffer(arg) { 21182 return arg && typeof arg === 'object' 21183 && typeof arg.copy === 'function' 21184 && typeof arg.fill === 'function' 21185 && typeof arg.readUInt8 === 'function'; 21186 } 21187 },{}],41:[function(require,module,exports){ 21188 (function (process,global){ 21189 // Copyright Joyent, Inc. and other Node contributors. 21190 // 21191 // Permission is hereby granted, free of charge, to any person obtaining a 21192 // copy of this software and associated documentation files (the 21193 // "Software"), to deal in the Software without restriction, including 21194 // without limitation the rights to use, copy, modify, merge, publish, 21195 // distribute, sublicense, and/or sell copies of the Software, and to permit 21196 // persons to whom the Software is furnished to do so, subject to the 21197 // following conditions: 21198 // 21199 // The above copyright notice and this permission notice shall be included 21200 // in all copies or substantial portions of the Software. 21201 // 21202 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21203 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21204 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 21205 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 21206 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 21207 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21208 // USE OR OTHER DEALINGS IN THE SOFTWARE. 21209 21210 var formatRegExp = /%[sdj%]/g; 21211 exports.format = function(f) { 21212 if (!isString(f)) { 21213 var objects = []; 21214 for (var i = 0; i < arguments.length; i++) { 21215 objects.push(inspect(arguments[i])); 21216 } 21217 return objects.join(' '); 21218 } 21219 21220 var i = 1; 21221 var args = arguments; 21222 var len = args.length; 21223 var str = String(f).replace(formatRegExp, function(x) { 21224 if (x === '%%') return '%'; 21225 if (i >= len) return x; 21226 switch (x) { 21227 case '%s': return String(args[i++]); 21228 case '%d': return Number(args[i++]); 21229 case '%j': 21230 try { 21231 return JSON.stringify(args[i++]); 21232 } catch (_) { 21233 return '[Circular]'; 21234 } 21235 default: 21236 return x; 21237 } 21238 }); 21239 for (var x = args[i]; i < len; x = args[++i]) { 21240 if (isNull(x) || !isObject(x)) { 21241 str += ' ' + x; 21242 } else { 21243 str += ' ' + inspect(x); 21244 } 21245 } 21246 return str; 21247 }; 21248 21249 21250 // Mark that a method should not be used. 21251 // Returns a modified function which warns once by default. 21252 // If --no-deprecation is set, then it is a no-op. 21253 exports.deprecate = function(fn, msg) { 21254 // Allow for deprecating things in the process of starting up. 21255 if (isUndefined(global.process)) { 21256 return function() { 21257 return exports.deprecate(fn, msg).apply(this, arguments); 21258 }; 21259 } 21260 21261 if (process.noDeprecation === true) { 21262 return fn; 21263 } 21264 21265 var warned = false; 21266 function deprecated() { 21267 if (!warned) { 21268 if (process.throwDeprecation) { 21269 throw new Error(msg); 21270 } else if (process.traceDeprecation) { 21271 console.trace(msg); 21272 } else { 21273 console.error(msg); 21274 } 21275 warned = true; 21276 } 21277 return fn.apply(this, arguments); 21278 } 21279 21280 return deprecated; 21281 }; 21282 21283 21284 var debugs = {}; 21285 var debugEnviron; 21286 exports.debuglog = function(set) { 21287 if (isUndefined(debugEnviron)) 21288 debugEnviron = process.env.NODE_DEBUG || ''; 21289 set = set.toUpperCase(); 21290 if (!debugs[set]) { 21291 if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) { 21292 var pid = process.pid; 21293 debugs[set] = function() { 21294 var msg = exports.format.apply(exports, arguments); 21295 console.error('%s %d: %s', set, pid, msg); 21296 }; 21297 } else { 21298 debugs[set] = function() {}; 21299 } 21300 } 21301 return debugs[set]; 21302 }; 21303 21304 21305 /** 21306 * Echos the value of a value. Trys to print the value out 21307 * in the best way possible given the different types. 21308 * 21309 * @param {Object} obj The object to print out. 21310 * @param {Object} opts Optional options object that alters the output. 21311 */ 21312 /* legacy: obj, showHidden, depth, colors*/ 21313 function inspect(obj, opts) { 21314 // default options 21315 var ctx = { 21316 seen: [], 21317 stylize: stylizeNoColor 21318 }; 21319 // legacy... 21320 if (arguments.length >= 3) ctx.depth = arguments[2]; 21321 if (arguments.length >= 4) ctx.colors = arguments[3]; 21322 if (isBoolean(opts)) { 21323 // legacy... 21324 ctx.showHidden = opts; 21325 } else if (opts) { 21326 // got an "options" object 21327 exports._extend(ctx, opts); 21328 } 21329 // set default options 21330 if (isUndefined(ctx.showHidden)) ctx.showHidden = false; 21331 if (isUndefined(ctx.depth)) ctx.depth = 2; 21332 if (isUndefined(ctx.colors)) ctx.colors = false; 21333 if (isUndefined(ctx.customInspect)) ctx.customInspect = true; 21334 if (ctx.colors) ctx.stylize = stylizeWithColor; 21335 return formatValue(ctx, obj, ctx.depth); 21336 } 21337 exports.inspect = inspect; 21338 21339 21340 // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics 21341 inspect.colors = { 21342 'bold' : [1, 22], 21343 'italic' : [3, 23], 21344 'underline' : [4, 24], 21345 'inverse' : [7, 27], 21346 'white' : [37, 39], 21347 'grey' : [90, 39], 21348 'black' : [30, 39], 21349 'blue' : [34, 39], 21350 'cyan' : [36, 39], 21351 'green' : [32, 39], 21352 'magenta' : [35, 39], 21353 'red' : [31, 39], 21354 'yellow' : [33, 39] 21355 }; 21356 21357 // Don't use 'blue' not visible on cmd.exe 21358 inspect.styles = { 21359 'special': 'cyan', 21360 'number': 'yellow', 21361 'boolean': 'yellow', 21362 'undefined': 'grey', 21363 'null': 'bold', 21364 'string': 'green', 21365 'date': 'magenta', 21366 // "name": intentionally not styling 21367 'regexp': 'red' 21368 }; 21369 21370 21371 function stylizeWithColor(str, styleType) { 21372 var style = inspect.styles[styleType]; 21373 21374 if (style) { 21375 return '\u001b[' + inspect.colors[style][0] + 'm' + str + 21376 '\u001b[' + inspect.colors[style][1] + 'm'; 21377 } else { 21378 return str; 21379 } 21380 } 21381 21382 21383 function stylizeNoColor(str, styleType) { 21384 return str; 21385 } 21386 21387 21388 function arrayToHash(array) { 21389 var hash = {}; 21390 21391 array.forEach(function(val, idx) { 21392 hash[val] = true; 21393 }); 21394 21395 return hash; 21396 } 21397 21398 21399 function formatValue(ctx, value, recurseTimes) { 21400 // Provide a hook for user-specified inspect functions. 21401 // Check that value is an object with an inspect function on it 21402 if (ctx.customInspect && 21403 value && 21404 isFunction(value.inspect) && 21405 // Filter out the util module, it's inspect function is special 21406 value.inspect !== exports.inspect && 21407 // Also filter out any prototype objects using the circular check. 21408 !(value.constructor && value.constructor.prototype === value)) { 21409 var ret = value.inspect(recurseTimes, ctx); 21410 if (!isString(ret)) { 21411 ret = formatValue(ctx, ret, recurseTimes); 21412 } 21413 return ret; 21414 } 21415 21416 // Primitive types cannot have properties 21417 var primitive = formatPrimitive(ctx, value); 21418 if (primitive) { 21419 return primitive; 21420 } 21421 21422 // Look up the keys of the object. 21423 var keys = Object.keys(value); 21424 var visibleKeys = arrayToHash(keys); 21425 21426 if (ctx.showHidden) { 21427 keys = Object.getOwnPropertyNames(value); 21428 } 21429 21430 // IE doesn't make error fields non-enumerable 21431 // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx 21432 if (isError(value) 21433 && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { 21434 return formatError(value); 21435 } 21436 21437 // Some type of object without properties can be shortcutted. 21438 if (keys.length === 0) { 21439 if (isFunction(value)) { 21440 var name = value.name ? ': ' + value.name : ''; 21441 return ctx.stylize('[Function' + name + ']', 'special'); 21442 } 21443 if (isRegExp(value)) { 21444 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); 21445 } 21446 if (isDate(value)) { 21447 return ctx.stylize(Date.prototype.toString.call(value), 'date'); 21448 } 21449 if (isError(value)) { 21450 return formatError(value); 21451 } 21452 } 21453 21454 var base = '', array = false, braces = ['{', '}']; 21455 21456 // Make Array say that they are Array 21457 if (isArray(value)) { 21458 array = true; 21459 braces = ['[', ']']; 21460 } 21461 21462 // Make functions say that they are functions 21463 if (isFunction(value)) { 21464 var n = value.name ? ': ' + value.name : ''; 21465 base = ' [Function' + n + ']'; 21466 } 21467 21468 // Make RegExps say that they are RegExps 21469 if (isRegExp(value)) { 21470 base = ' ' + RegExp.prototype.toString.call(value); 21471 } 21472 21473 // Make dates with properties first say the date 21474 if (isDate(value)) { 21475 base = ' ' + Date.prototype.toUTCString.call(value); 21476 } 21477 21478 // Make error with message first say the error 21479 if (isError(value)) { 21480 base = ' ' + formatError(value); 21481 } 21482 21483 if (keys.length === 0 && (!array || value.length == 0)) { 21484 return braces[0] + base + braces[1]; 21485 } 21486 21487 if (recurseTimes < 0) { 21488 if (isRegExp(value)) { 21489 return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); 21490 } else { 21491 return ctx.stylize('[Object]', 'special'); 21492 } 21493 } 21494 21495 ctx.seen.push(value); 21496 21497 var output; 21498 if (array) { 21499 output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); 21500 } else { 21501 output = keys.map(function(key) { 21502 return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); 21503 }); 21504 } 21505 21506 ctx.seen.pop(); 21507 21508 return reduceToSingleString(output, base, braces); 21509 } 21510 21511 21512 function formatPrimitive(ctx, value) { 21513 if (isUndefined(value)) 21514 return ctx.stylize('undefined', 'undefined'); 21515 if (isString(value)) { 21516 var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') 21517 .replace(/'/g, "\\'") 21518 .replace(/\\"/g, '"') + '\''; 21519 return ctx.stylize(simple, 'string'); 21520 } 21521 if (isNumber(value)) 21522 return ctx.stylize('' + value, 'number'); 21523 if (isBoolean(value)) 21524 return ctx.stylize('' + value, 'boolean'); 21525 // For some reason typeof null is "object", so special case here. 21526 if (isNull(value)) 21527 return ctx.stylize('null', 'null'); 21528 } 21529 21530 21531 function formatError(value) { 21532 return '[' + Error.prototype.toString.call(value) + ']'; 21533 } 21534 21535 21536 function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { 21537 var output = []; 21538 for (var i = 0, l = value.length; i < l; ++i) { 21539 if (hasOwnProperty(value, String(i))) { 21540 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, 21541 String(i), true)); 21542 } else { 21543 output.push(''); 21544 } 21545 } 21546 keys.forEach(function(key) { 21547 if (!key.match(/^\d+$/)) { 21548 output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, 21549 key, true)); 21550 } 21551 }); 21552 return output; 21553 } 21554 21555 21556 function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { 21557 var name, str, desc; 21558 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; 21559 if (desc.get) { 21560 if (desc.set) { 21561 str = ctx.stylize('[Getter/Setter]', 'special'); 21562 } else { 21563 str = ctx.stylize('[Getter]', 'special'); 21564 } 21565 } else { 21566 if (desc.set) { 21567 str = ctx.stylize('[Setter]', 'special'); 21568 } 21569 } 21570 if (!hasOwnProperty(visibleKeys, key)) { 21571 name = '[' + key + ']'; 21572 } 21573 if (!str) { 21574 if (ctx.seen.indexOf(desc.value) < 0) { 21575 if (isNull(recurseTimes)) { 21576 str = formatValue(ctx, desc.value, null); 21577 } else { 21578 str = formatValue(ctx, desc.value, recurseTimes - 1); 21579 } 21580 if (str.indexOf('\n') > -1) { 21581 if (array) { 21582 str = str.split('\n').map(function(line) { 21583 return ' ' + line; 21584 }).join('\n').substr(2); 21585 } else { 21586 str = '\n' + str.split('\n').map(function(line) { 21587 return ' ' + line; 21588 }).join('\n'); 21589 } 21590 } 21591 } else { 21592 str = ctx.stylize('[Circular]', 'special'); 21593 } 21594 } 21595 if (isUndefined(name)) { 21596 if (array && key.match(/^\d+$/)) { 21597 return str; 21598 } 21599 name = JSON.stringify('' + key); 21600 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { 21601 name = name.substr(1, name.length - 2); 21602 name = ctx.stylize(name, 'name'); 21603 } else { 21604 name = name.replace(/'/g, "\\'") 21605 .replace(/\\"/g, '"') 21606 .replace(/(^"|"$)/g, "'"); 21607 name = ctx.stylize(name, 'string'); 21608 } 21609 } 21610 21611 return name + ': ' + str; 21612 } 21613 21614 21615 function reduceToSingleString(output, base, braces) { 21616 var numLinesEst = 0; 21617 var length = output.reduce(function(prev, cur) { 21618 numLinesEst++; 21619 if (cur.indexOf('\n') >= 0) numLinesEst++; 21620 return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; 21621 }, 0); 21622 21623 if (length > 60) { 21624 return braces[0] + 21625 (base === '' ? '' : base + '\n ') + 21626 ' ' + 21627 output.join(',\n ') + 21628 ' ' + 21629 braces[1]; 21630 } 21631 21632 return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; 21633 } 21634 21635 21636 // NOTE: These type checking functions intentionally don't use `instanceof` 21637 // because it is fragile and can be easily faked with `Object.create()`. 21638 function isArray(ar) { 21639 return Array.isArray(ar); 21640 } 21641 exports.isArray = isArray; 21642 21643 function isBoolean(arg) { 21644 return typeof arg === 'boolean'; 21645 } 21646 exports.isBoolean = isBoolean; 21647 21648 function isNull(arg) { 21649 return arg === null; 21650 } 21651 exports.isNull = isNull; 21652 21653 function isNullOrUndefined(arg) { 21654 return arg == null; 21655 } 21656 exports.isNullOrUndefined = isNullOrUndefined; 21657 21658 function isNumber(arg) { 21659 return typeof arg === 'number'; 21660 } 21661 exports.isNumber = isNumber; 21662 21663 function isString(arg) { 21664 return typeof arg === 'string'; 21665 } 21666 exports.isString = isString; 21667 21668 function isSymbol(arg) { 21669 return typeof arg === 'symbol'; 21670 } 21671 exports.isSymbol = isSymbol; 21672 21673 function isUndefined(arg) { 21674 return arg === void 0; 21675 } 21676 exports.isUndefined = isUndefined; 21677 21678 function isRegExp(re) { 21679 return isObject(re) && objectToString(re) === '[object RegExp]'; 21680 } 21681 exports.isRegExp = isRegExp; 21682 21683 function isObject(arg) { 21684 return typeof arg === 'object' && arg !== null; 21685 } 21686 exports.isObject = isObject; 21687 21688 function isDate(d) { 21689 return isObject(d) && objectToString(d) === '[object Date]'; 21690 } 21691 exports.isDate = isDate; 21692 21693 function isError(e) { 21694 return isObject(e) && 21695 (objectToString(e) === '[object Error]' || e instanceof Error); 21696 } 21697 exports.isError = isError; 21698 21699 function isFunction(arg) { 21700 return typeof arg === 'function'; 21701 } 21702 exports.isFunction = isFunction; 21703 21704 function isPrimitive(arg) { 21705 return arg === null || 21706 typeof arg === 'boolean' || 21707 typeof arg === 'number' || 21708 typeof arg === 'string' || 21709 typeof arg === 'symbol' || // ES6 symbol 21710 typeof arg === 'undefined'; 21711 } 21712 exports.isPrimitive = isPrimitive; 21713 21714 exports.isBuffer = require('./support/isBuffer'); 21715 21716 function objectToString(o) { 21717 return Object.prototype.toString.call(o); 21718 } 21719 21720 21721 function pad(n) { 21722 return n < 10 ? '0' + n.toString(10) : n.toString(10); 21723 } 21724 21725 21726 var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 21727 'Oct', 'Nov', 'Dec']; 21728 21729 // 26 Feb 16:19:34 21730 function timestamp() { 21731 var d = new Date(); 21732 var time = [pad(d.getHours()), 21733 pad(d.getMinutes()), 21734 pad(d.getSeconds())].join(':'); 21735 return [d.getDate(), months[d.getMonth()], time].join(' '); 21736 } 21737 21738 21739 // log is just a thin wrapper to console.log that prepends a timestamp 21740 exports.log = function() { 21741 console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); 21742 }; 21743 21744 21745 /** 21746 * Inherit the prototype methods from one constructor into another. 21747 * 21748 * The Function.prototype.inherits from lang.js rewritten as a standalone 21749 * function (not on Function.prototype). NOTE: If this file is to be loaded 21750 * during bootstrapping this function needs to be rewritten using some native 21751 * functions as prototype setup using normal JavaScript does not work as 21752 * expected during bootstrapping (see mirror.js in r114903). 21753 * 21754 * @param {function} ctor Constructor function which needs to inherit the 21755 * prototype. 21756 * @param {function} superCtor Constructor function to inherit prototype from. 21757 */ 21758 exports.inherits = require('inherits'); 21759 21760 exports._extend = function(origin, add) { 21761 // Don't do anything if add isn't an object 21762 if (!add || !isObject(add)) return origin; 21763 21764 var keys = Object.keys(add); 21765 var i = keys.length; 21766 while (i--) { 21767 origin[keys[i]] = add[keys[i]]; 21768 } 21769 return origin; 21770 }; 21771 21772 function hasOwnProperty(obj, prop) { 21773 return Object.prototype.hasOwnProperty.call(obj, prop); 21774 } 21775 21776 }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 21777 },{"./support/isBuffer":40,"_process":34,"inherits":12}],42:[function(require,module,exports){ 21778 var assert = require('assert') 21779 var trie = require('./trie') 21780 21781 module.exports = Wayfarer 21782 21783 // create a router 21784 // str -> obj 21785 function Wayfarer (dft) { 21786 if (!(this instanceof Wayfarer)) return new Wayfarer(dft) 21787 21788 var _default = (dft || '').replace(/^\//, '') 21789 var _trie = trie() 21790 21791 emit._trie = _trie 21792 emit.on = on 21793 emit.emit = emit 21794 emit.match = match 21795 emit._wayfarer = true 21796 21797 return emit 21798 21799 // define a route 21800 // (str, fn) -> obj 21801 function on (route, fn) { 21802 assert.equal(typeof route, 'string') 21803 assert.equal(typeof fn, 'function') 21804 21805 var cb = fn._wayfarer && fn._trie ? fn : proxy 21806 route = route || '/' 21807 cb.route = route 21808 21809 if (cb._wayfarer && cb._trie) { 21810 _trie.mount(route, cb._trie.trie) 21811 } else { 21812 var node = _trie.create(route) 21813 node.cb = cb 21814 } 21815 21816 return emit 21817 21818 function proxy () { 21819 return fn.apply(this, Array.prototype.slice.call(arguments)) 21820 } 21821 } 21822 21823 // match and call a route 21824 // (str, obj?) -> null 21825 function emit (route) { 21826 var matched = match(route) 21827 21828 var args = new Array(arguments.length) 21829 args[0] = matched.params 21830 for (var i = 1; i < args.length; i++) { 21831 args[i] = arguments[i] 21832 } 21833 21834 return matched.cb.apply(matched.cb, args) 21835 } 21836 21837 function match (route) { 21838 assert.notEqual(route, undefined, "'route' must be defined") 21839 21840 var matched = _trie.match(route) 21841 if (matched && matched.cb) return new Route(matched) 21842 21843 var dft = _trie.match(_default) 21844 if (dft && dft.cb) return new Route(dft) 21845 21846 throw new Error("route '" + route + "' did not match") 21847 } 21848 21849 function Route (matched) { 21850 this.cb = matched.cb 21851 this.route = matched.cb.route 21852 this.params = matched.params 21853 } 21854 } 21855 21856 },{"./trie":43,"assert":2}],43:[function(require,module,exports){ 21857 var mutate = require('xtend/mutable') 21858 var assert = require('assert') 21859 var xtend = require('xtend') 21860 21861 module.exports = Trie 21862 21863 // create a new trie 21864 // null -> obj 21865 function Trie () { 21866 if (!(this instanceof Trie)) return new Trie() 21867 this.trie = { nodes: {} } 21868 } 21869 21870 // create a node on the trie at route 21871 // and return a node 21872 // str -> null 21873 Trie.prototype.create = function (route) { 21874 assert.equal(typeof route, 'string', 'route should be a string') 21875 // strip leading '/' and split routes 21876 var routes = route.replace(/^\//, '').split('/') 21877 21878 function createNode (index, trie) { 21879 var thisRoute = (routes.hasOwnProperty(index) && routes[index]) 21880 if (thisRoute === false) return trie 21881 21882 var node = null 21883 if (/^:|^\*/.test(thisRoute)) { 21884 // if node is a name match, set name and append to ':' node 21885 if (!trie.nodes.hasOwnProperty('$$')) { 21886 node = { nodes: {} } 21887 trie.nodes['$$'] = node 21888 } else { 21889 node = trie.nodes['$$'] 21890 } 21891 21892 if (thisRoute[0] === '*') { 21893 trie.wildcard = true 21894 } 21895 21896 trie.name = thisRoute.replace(/^:|^\*/, '') 21897 } else if (!trie.nodes.hasOwnProperty(thisRoute)) { 21898 node = { nodes: {} } 21899 trie.nodes[thisRoute] = node 21900 } else { 21901 node = trie.nodes[thisRoute] 21902 } 21903 21904 // we must recurse deeper 21905 return createNode(index + 1, node) 21906 } 21907 21908 return createNode(0, this.trie) 21909 } 21910 21911 // match a route on the trie 21912 // and return the node 21913 // str -> obj 21914 Trie.prototype.match = function (route) { 21915 assert.equal(typeof route, 'string', 'route should be a string') 21916 21917 var routes = route.replace(/^\//, '').split('/') 21918 var params = {} 21919 21920 function search (index, trie) { 21921 // either there's no match, or we're done searching 21922 if (trie === undefined) return undefined 21923 var thisRoute = routes[index] 21924 if (thisRoute === undefined) return trie 21925 21926 if (trie.nodes.hasOwnProperty(thisRoute)) { 21927 // match regular routes first 21928 return search(index + 1, trie.nodes[thisRoute]) 21929 } else if (trie.name) { 21930 // match named routes 21931 try { 21932 params[trie.name] = decodeURIComponent(thisRoute) 21933 } catch (e) { 21934 return search(index, undefined) 21935 } 21936 return search(index + 1, trie.nodes['$$']) 21937 } else if (trie.wildcard) { 21938 // match wildcards 21939 try { 21940 params['wildcard'] = decodeURIComponent(routes.slice(index).join('/')) 21941 } catch (e) { 21942 return search(index, undefined) 21943 } 21944 // return early, or else search may keep recursing through the wildcard 21945 return trie.nodes['$$'] 21946 } else { 21947 // no matches found 21948 return search(index + 1) 21949 } 21950 } 21951 21952 var node = search(0, this.trie) 21953 21954 if (!node) return undefined 21955 node = xtend(node) 21956 node.params = params 21957 return node 21958 } 21959 21960 // mount a trie onto a node at route 21961 // (str, obj) -> null 21962 Trie.prototype.mount = function (route, trie) { 21963 assert.equal(typeof route, 'string', 'route should be a string') 21964 assert.equal(typeof trie, 'object', 'trie should be a object') 21965 21966 var split = route.replace(/^\//, '').split('/') 21967 var node = null 21968 var key = null 21969 21970 if (split.length === 1) { 21971 key = split[0] 21972 node = this.create(key) 21973 } else { 21974 var head = split.join('/') 21975 key = split[0] 21976 node = this.create(head) 21977 } 21978 21979 mutate(node.nodes, trie.nodes) 21980 if (trie.name) node.name = trie.name 21981 21982 // delegate properties from '/' to the new node 21983 // '/' cannot be reached once mounted 21984 if (node.nodes['']) { 21985 Object.keys(node.nodes['']).forEach(function (key) { 21986 if (key === 'nodes') return 21987 node[key] = node.nodes[''][key] 21988 }) 21989 mutate(node.nodes, node.nodes[''].nodes) 21990 delete node.nodes[''].nodes 21991 } 21992 } 21993 21994 },{"assert":2,"xtend":45,"xtend/mutable":46}],44:[function(require,module,exports){ 21995 var assert = require('assert') 21996 21997 module.exports = walk 21998 21999 // walk a wayfarer trie 22000 // (obj, fn) -> null 22001 function walk (router, transform) { 22002 assert.equal(typeof router, 'function', 'wayfarer.walk: router should be an function') 22003 assert.equal(typeof transform, 'function', 'wayfarer.walk: transform should be a function') 22004 22005 var trie = router._trie 22006 assert.equal(typeof trie, 'object', 'wayfarer.walk: trie should be an object') 22007 22008 // (str, obj) -> null 22009 ;(function walk (route, trie) { 22010 if (trie.cb) { 22011 trie.cb = transform(route, trie.cb) 22012 } 22013 22014 if (trie.nodes) { 22015 var nodes = trie.nodes 22016 Object.keys(nodes).forEach(function (key) { 22017 var node = nodes[key] 22018 var newRoute = (key === '$$') 22019 ? route + '/:' + trie.name 22020 : route + '/' + key 22021 walk(newRoute, node) 22022 }) 22023 } 22024 })('', trie.trie) 22025 } 22026 22027 },{"assert":2}],45:[function(require,module,exports){ 22028 module.exports = extend 22029 22030 var hasOwnProperty = Object.prototype.hasOwnProperty; 22031 22032 function extend() { 22033 var target = {} 22034 22035 for (var i = 0; i < arguments.length; i++) { 22036 var source = arguments[i] 22037 22038 for (var key in source) { 22039 if (hasOwnProperty.call(source, key)) { 22040 target[key] = source[key] 22041 } 22042 } 22043 } 22044 22045 return target 22046 } 22047 22048 },{}],46:[function(require,module,exports){ 22049 module.exports = extend 22050 22051 var hasOwnProperty = Object.prototype.hasOwnProperty; 22052 22053 function extend(target) { 22054 for (var i = 1; i < arguments.length; i++) { 22055 var source = arguments[i] 22056 22057 for (var key in source) { 22058 if (hasOwnProperty.call(source, key)) { 22059 target[key] = source[key] 22060 } 22061 } 22062 } 22063 22064 return target 22065 } 22066 22067 },{}]},{},[1]);