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){
vendor: 39,721 bytes, lines 2-1710
2(function webpackUniversalModuleDefinition(root, factory) { 3 if(typeof exports === 'object' && typeof module === 'object') 4 module.exports = factory(); 5 else if(typeof define === 'function' && define.amd) 6 define("Barba", [], factory); 7 else if(typeof exports === 'object') 8 exports["Barba"] = factory(); 9 else 10 root["Barba"] = factory(); 11})(this, function() { 12return /******/ (function(modules) { // webpackBootstrap 13/******/ // The module cache 14/******/ var installedModules = {}; 15/******/ 16/******/ // The require function 17/******/ function __webpack_require__(moduleId) { 18/******/ 19/******/ // Check if module is in cache 20/******/ if(installedModules[moduleId]) 21/******/ return installedModules[moduleId].exports; 22/******/ 23/******/ // Create a new module (and put it into the cache) 24/******/ var module = installedModules[moduleId] = { 25/******/ exports: {}, 26/******/ id: moduleId, 27/******/ loaded: false 28/******/ }; 29/******/ 30/******/ // Execute the module function 31/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 32/******/ 33/******/ // Flag the module as loaded 34/******/ module.loaded = true; 35/******/ 36/******/ // Return the exports of the module 37/******/ return module.exports; 38/******/ } 39/******/ 40/******/ 41/******/ // expose the modules object (__webpack_modules__) 42/******/ __webpack_require__.m = modules; 43/******/ 44/******/ // expose the module cache 45/******/ __webpack_require__.c = installedModules; 46/******/ 47/******/ // __webpack_public_path__ 48/******/ __webpack_require__.p = "http://localhost:8080/dist"; 49/******/ 50/******/ // Load entry module and return exports 51/******/ return __webpack_require__(0); 52/******/ }) 53/************************************************************************/ 54/******/ ([ 55/* 0 */ 56/***/ function(module, exports, __webpack_require__) { 57 58 //Promise polyfill https://github.com/taylorhakes/promise-polyfill 59 60 if (typeof Promise !== 'function') { 61 window.Promise = __webpack_require__(1); 62 } 63 64 var Barba = { 65 version: '1.0.0', 66 BaseTransition: __webpack_require__(4), 67 BaseView: __webpack_require__(6), 68 BaseCache: __webpack_require__(8), 69 Dispatcher: __webpack_require__(7), 70 HistoryManager: __webpack_require__(9), 71 Pjax: __webpack_require__(10), 72 Prefetch: __webpack_require__(13), 73 Utils: __webpack_require__(5) 74 }; 75 76 module.exports = Barba; 77 78 79/***/ }, 80/* 1 */ 81/***/ function(module, exports, __webpack_require__) { 82 83 /* WEBPACK VAR INJECTION */(function(setImmediate) {(function (root) { 84 85 // Store setTimeout reference so promise-polyfill will be unaffected by 86 // other code modifying setTimeout (like sinon.useFakeTimers()) 87 var setTimeoutFunc = setTimeout; 88 89 function noop() { 90 } 91 92 // Use polyfill for setImmediate for performance gains 93 var asap = (typeof setImmediate === 'function' && setImmediate) || 94 function (fn) { 95 setTimeoutFunc(fn, 0); 96 }; 97 98 var onUnhandledRejection = function onUnhandledRejection(err) { 99 if (typeof console !== 'undefined' && console) { 100 console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console 101 } 102 }; 103 104 // Polyfill for Function.prototype.bind 105 function bind(fn, thisArg) { 106 return function () { 107 fn.apply(thisArg, arguments); 108 }; 109 } 110 111 function Promise(fn) { 112 if (typeof this !== 'object') throw new TypeError('Promises must be constructed via new'); 113 if (typeof fn !== 'function') throw new TypeError('not a function'); 114 this._state = 0; 115 this._handled = false; 116 this._value = undefined; 117 this._deferreds = []; 118 119 doResolve(fn, this); 120 } 121 122 function handle(self, deferred) { 123 while (self._state === 3) { 124 self = self._value; 125 } 126 if (self._state === 0) { 127 self._deferreds.push(deferred); 128 return; 129 } 130 self._handled = true; 131 asap(function () { 132 var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected; 133 if (cb === null) { 134 (self._state === 1 ? resolve : reject)(deferred.promise, self._value); 135 return; 136 } 137 var ret; 138 try { 139 ret = cb(self._value); 140 } catch (e) { 141 reject(deferred.promise, e); 142 return; 143 } 144 resolve(deferred.promise, ret); 145 }); 146 } 147 148 function resolve(self, newValue) { 149 try { 150 // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure 151 if (newValue === self) throw new TypeError('A promise cannot be resolved with itself.'); 152 if (newValue && (typeof newValue === 'object' || typeof newValue === 'function')) { 153 var then = newValue.then; 154 if (newValue instanceof Promise) { 155 self._state = 3; 156 self._value = newValue; 157 finale(self); 158 return; 159 } else if (typeof then === 'function') { 160 doResolve(bind(then, newValue), self); 161 return; 162 } 163 } 164 self._state = 1; 165 self._value = newValue; 166 finale(self); 167 } catch (e) { 168 reject(self, e); 169 } 170 } 171 172 function reject(self, newValue) { 173 self._state = 2; 174 self._value = newValue; 175 finale(self); 176 } 177 178 function finale(self) { 179 if (self._state === 2 && self._deferreds.length === 0) { 180 asap(function() { 181 if (!self._handled) { 182 onUnhandledRejection(self._value); 183 } 184 }); 185 } 186 187 for (var i = 0, len = self._deferreds.length; i < len; i++) { 188 handle(self, self._deferreds[i]); 189 } 190 self._deferreds = null; 191 } 192 193 function Handler(onFulfilled, onRejected, promise) { 194 this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null; 195 this.onRejected = typeof onRejected === 'function' ? onRejected : null; 196 this.promise = promise; 197 } 198 199 /** 200 * Take a potentially misbehaving resolver function and make sure 201 * onFulfilled and onRejected are only called once. 202 * 203 * Makes no guarantees about asynchrony. 204 */ 205 function doResolve(fn, self) { 206 var done = false; 207 try { 208 fn(function (value) { 209 if (done) return; 210 done = true; 211 resolve(self, value); 212 }, function (reason) { 213 if (done) return; 214 done = true; 215 reject(self, reason); 216 }); 217 } catch (ex) { 218 if (done) return; 219 done = true; 220 reject(self, ex); 221 } 222 } 223 224 Promise.prototype['catch'] = function (onRejected) { 225 return this.then(null, onRejected); 226 }; 227 228 Promise.prototype.then = function (onFulfilled, onRejected) { 229 var prom = new (this.constructor)(noop); 230 231 handle(this, new Handler(onFulfilled, onRejected, prom)); 232 return prom; 233 }; 234 235 Promise.all = function (arr) { 236 var args = Array.prototype.slice.call(arr); 237 238 return new Promise(function (resolve, reject) { 239 if (args.length === 0) return resolve([]); 240 var remaining = args.length; 241 242 function res(i, val) { 243 try { 244 if (val && (typeof val === 'object' || typeof val === 'function')) { 245 var then = val.then; 246 if (typeof then === 'function') { 247 then.call(val, function (val) { 248 res(i, val); 249 }, reject); 250 return; 251 } 252 } 253 args[i] = val; 254 if (--remaining === 0) { 255 resolve(args); 256 } 257 } catch (ex) { 258 reject(ex); 259 } 260 } 261 262 for (var i = 0; i < args.length; i++) { 263 res(i, args[i]); 264 } 265 }); 266 }; 267 268 Promise.resolve = function (value) { 269 if (value && typeof value === 'object' && value.constructor === Promise) { 270 return value; 271 } 272 273 return new Promise(function (resolve) { 274 resolve(value); 275 }); 276 }; 277 278 Promise.reject = function (value) { 279 return new Promise(function (resolve, reject) { 280 reject(value); 281 }); 282 }; 283 284 Promise.race = function (values) { 285 return new Promise(function (resolve, reject) { 286 for (var i = 0, len = values.length; i < len; i++) { 287 values[i].then(resolve, reject); 288 } 289 }); 290 }; 291 292 /** 293 * Set the immediate function to execute callbacks 294 * @param fn {function} Function to execute 295 * @private 296 */ 297 Promise._setImmediateFn = function _setImmediateFn(fn) { 298 asap = fn; 299 }; 300 301 Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) { 302 onUnhandledRejection = fn; 303 }; 304 305 if (typeof module !== 'undefined' && module.exports) { 306 module.exports = Promise; 307 } else if (!root.Promise) { 308 root.Promise = Promise; 309 } 310 311 })(this); 312 313 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2).setImmediate)) 314 315/***/ }, 316/* 2 */ 317/***/ function(module, exports, __webpack_require__) { 318 319 /* WEBPACK VAR INJECTION */(function(setImmediate, clearImmediate) {var nextTick = __webpack_require__(3).nextTick; 320 var apply = Function.prototype.apply; 321 var slice = Array.prototype.slice; 322 var immediateIds = {}; 323 var nextImmediateId = 0; 324 325 // DOM APIs, for completeness 326 327 exports.setTimeout = function() { 328 return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout); 329 }; 330 exports.setInterval = function() { 331 return new Timeout(apply.call(setInterval, window, arguments), clearInterval); 332 }; 333 exports.clearTimeout = 334 exports.clearInterval = function(timeout) { timeout.close(); }; 335 336 function Timeout(id, clearFn) { 337 this._id = id; 338 this._clearFn = clearFn; 339 } 340 Timeout.prototype.unref = Timeout.prototype.ref = function() {}; 341 Timeout.prototype.close = function() { 342 this._clearFn.call(window, this._id); 343 }; 344 345 // Does not start the time, just sets up the members needed. 346 exports.enroll = function(item, msecs) { 347 clearTimeout(item._idleTimeoutId); 348 item._idleTimeout = msecs; 349 }; 350 351 exports.unenroll = function(item) { 352 clearTimeout(item._idleTimeoutId); 353 item._idleTimeout = -1; 354 }; 355 356 exports._unrefActive = exports.active = function(item) { 357 clearTimeout(item._idleTimeoutId); 358 359 var msecs = item._idleTimeout; 360 if (msecs >= 0) { 361 item._idleTimeoutId = setTimeout(function onTimeout() { 362 if (item._onTimeout) 363 item._onTimeout(); 364 }, msecs); 365 } 366 }; 367 368 // That's not how node.js implements it but the exposed api is the same. 369 exports.setImmediate = typeof setImmediate === "function" ? setImmediate : function(fn) { 370 var id = nextImmediateId++; 371 var args = arguments.length < 2 ? false : slice.call(arguments, 1); 372 373 immediateIds[id] = true; 374 375 nextTick(function onNextTick() { 376 if (immediateIds[id]) { 377 // fn.call() is faster so we optimize for the common use-case 378 // @see http://jsperf.com/call-apply-segu 379 if (args) { 380 fn.apply(null, args); 381 } else { 382 fn.call(null); 383 } 384 // Prevent ids from leaking 385 exports.clearImmediate(id); 386 } 387 }); 388 389 return id; 390 }; 391 392 exports.clearImmediate = typeof clearImmediate === "function" ? clearImmediate : function(id) { 393 delete immediateIds[id]; 394 }; 395 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2).setImmediate, __webpack_require__(2).clearImmediate)) 396 397/***/ }, 398/* 3 */ 399/***/ function(module, exports) { 400 401 // shim for using process in browser 402 403 var process = module.exports = {}; 404 405 // cached from whatever global is present so that test runners that stub it 406 // don't break things. But we need to wrap it in a try catch in case it is 407 // wrapped in strict mode code which doesn't define any globals. It's inside a 408 // function because try/catches deoptimize in certain engines. 409 410 var cachedSetTimeout; 411 var cachedClearTimeout; 412 413 (function () { 414 try { 415 cachedSetTimeout = setTimeout; 416 } catch (e) { 417 cachedSetTimeout = function () { 418 throw new Error('setTimeout is not defined'); 419 } 420 } 421 try { 422 cachedClearTimeout = clearTimeout; 423 } catch (e) { 424 cachedClearTimeout = function () { 425 throw new Error('clearTimeout is not defined'); 426 } 427 } 428 } ()) 429 var queue = []; 430 var draining = false; 431 var currentQueue; 432 var queueIndex = -1; 433 434 function cleanUpNextTick() { 435 if (!draining || !currentQueue) { 436 return; 437 } 438 draining = false; 439 if (currentQueue.length) { 440 queue = currentQueue.concat(queue); 441 } else { 442 queueIndex = -1; 443 } 444 if (queue.length) { 445 drainQueue(); 446 } 447 } 448 449 function drainQueue() { 450 if (draining) { 451 return; 452 } 453 var timeout = cachedSetTimeout(cleanUpNextTick); 454 draining = true; 455 456 var len = queue.length; 457 while(len) { 458 currentQueue = queue; 459 queue = []; 460 while (++queueIndex < len) { 461 if (currentQueue) { 462 currentQueue[queueIndex].run(); 463 } 464 } 465 queueIndex = -1; 466 len = queue.length; 467 } 468 currentQueue = null; 469 draining = false; 470 cachedClearTimeout(timeout); 471 } 472 473 process.nextTick = function (fun) { 474 var args = new Array(arguments.length - 1); 475 if (arguments.length > 1) { 476 for (var i = 1; i < arguments.length; i++) { 477 args[i - 1] = arguments[i]; 478 } 479 } 480 queue.push(new Item(fun, args)); 481 if (queue.length === 1 && !draining) { 482 cachedSetTimeout(drainQueue, 0); 483 } 484 }; 485 486 // v8 likes predictible objects 487 function Item(fun, array) { 488 this.fun = fun; 489 this.array = array; 490 } 491 Item.prototype.run = function () { 492 this.fun.apply(null, this.array); 493 }; 494 process.title = 'browser'; 495 process.browser = true; 496 process.env = {}; 497 process.argv = []; 498 process.version = ''; // empty string to avoid regexp issues 499 process.versions = {}; 500 501 function noop() {} 502 503 process.on = noop; 504 process.addListener = noop; 505 process.once = noop; 506 process.off = noop; 507 process.removeListener = noop; 508 process.removeAllListeners = noop; 509 process.emit = noop; 510 511 process.binding = function (name) { 512 throw new Error('process.binding is not supported'); 513 }; 514 515 process.cwd = function () { return '/' }; 516 process.chdir = function (dir) { 517 throw new Error('process.chdir is not supported'); 518 }; 519 process.umask = function() { return 0; }; 520 521 522/***/ }, 523/* 4 */ 524/***/ function(module, exports, __webpack_require__) { 525 526 var Utils = __webpack_require__(5); 527 528 /** 529 * BaseTransition to extend 530 * 531 * @namespace Barba.BaseTransition 532 * @type {Object} 533 */ 534 var BaseTransition = { 535 /** 536 * @memberOf Barba.BaseTransition 537 * @type {HTMLElement} 538 */ 539 oldContainer: undefined, 540 541 /** 542 * @memberOf Barba.BaseTransition 543 * @type {HTMLElement} 544 */ 545 newContainer: undefined, 546 547 /** 548 * @memberOf Barba.BaseTransition 549 * @type {Promise} 550 */ 551 newContainerLoading: undefined, 552 553 /** 554 * Helper to extend the object 555 * 556 * @memberOf Barba.BaseTransition 557 * @param {Object} newObject 558 * @return {Object} newInheritObject 559 */ 560 extend: function(obj){ 561 return Utils.extend(this, obj); 562 }, 563 564 /** 565 * This function is called from Pjax module to initialize 566 * the transition. 567 * 568 * @memberOf Barba.BaseTransition 569 * @private 570 * @param {HTMLElement} oldContainer 571 * @param {Promise} newContainer 572 * @return {Promise} 573 */ 574 init: function(oldContainer, newContainer) { 575 var _this = this; 576 577 this.oldContainer = oldContainer; 578 this._newContainerPromise = newContainer; 579 580 this.deferred = Utils.deferred(); 581 this.newContainerReady = Utils.deferred(); 582 this.newContainerLoading = this.newContainerReady.promise; 583 584 this.start(); 585 586 this._newContainerPromise.then(function(newContainer) { 587 _this.newContainer = newContainer; 588 _this.newContainerReady.resolve(); 589 }); 590 591 return this.deferred.promise; 592 }, 593 594 /** 595 * This function needs to be called as soon the Transition is finished 596 * 597 * @memberOf Barba.BaseTransition 598 */ 599 done: function() { 600 this.oldContainer.parentNode.removeChild(this.oldContainer); 601 this.newContainer.style.visibility = 'visible'; 602 this.deferred.resolve(); 603 }, 604 605 /** 606 * Constructor for your Transition 607 * 608 * @memberOf Barba.BaseTransition 609 * @abstract 610 */ 611 start: function() {}, 612 }; 613 614 module.exports = BaseTransition; 615 616 617/***/ }, 618/* 5 */ 619/***/ function(module, exports) { 620 621 /** 622 * Just an object with some helpful functions 623 * 624 * @type {Object} 625 * @namespace Barba.Utils 626 */ 627 var Utils = { 628 /** 629 * Return the current url 630 * 631 * @memberOf Barba.Utils 632 * @return {String} currentUrl 633 */ 634 getCurrentUrl: function() { 635 return window.location.protocol + '//' + 636 window.location.host + 637 window.location.pathname + 638 window.location.search; 639 }, 640 641 /** 642 * Given an url, return it without the hash 643 * 644 * @memberOf Barba.Utils 645 * @private 646 * @param {String} url 647 * @return {String} newCleanUrl 648 */ 649 cleanLink: function(url) { 650 return url.replace(/#.*/, ''); 651 }, 652 653 /** 654 * Time in millisecond after the xhr request goes in timeout 655 * 656 * @memberOf Barba.Utils 657 * @type {Number} 658 * @default 659 */ 660 xhrTimeout: 5000, 661 662 /** 663 * Start an XMLHttpRequest() and return a Promise 664 * 665 * @memberOf Barba.Utils 666 * @param {String} url 667 * @return {Promise} 668 */ 669 xhr: function(url) { 670 var deferred = this.deferred(); 671 var req = new XMLHttpRequest(); 672 673 req.onreadystatechange = function() { 674 if (req.readyState === 4) { 675 if (req.status === 200) { 676 return deferred.resolve(req.responseText); 677 } else { 678 return deferred.reject(new Error('xhr: HTTP code is not 200')); 679 } 680 } 681 }; 682 683 req.ontimeout = function() { 684 return deferred.reject(new Error('xhr: Timeout exceeded')); 685 }; 686 687 req.open('GET', url); 688 req.timeout = this.xhrTimeout; 689 req.setRequestHeader('x-barba', 'yes'); 690 req.send(); 691 692 return deferred.promise; 693 }, 694 695 /** 696 * Get obj and props and return a new object with the property merged 697 * 698 * @memberOf Barba.Utils 699 * @param {object} obj 700 * @param {object} props 701 * @return {object} 702 */ 703 extend: function(obj, props) { 704 var newObj = Object.create(obj); 705 706 for(var prop in props) { 707 if(props.hasOwnProperty(prop)) { 708 newObj[prop] = props[prop]; 709 } 710 } 711 712 return newObj; 713 }, 714 715 /** 716 * Return a new "Deferred" object 717 * https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred 718 * 719 * @memberOf Barba.Utils 720 * @return {Deferred} 721 */ 722 deferred: function() { 723 return new function() { 724 this.resolve = null; 725 this.reject = null; 726 727 this.promise = new Promise(function(resolve, reject) { 728 this.resolve = resolve; 729 this.reject = reject; 730 }.bind(this)); 731 }; 732 }, 733 734 /** 735 * Return the port number normalized, eventually you can pass a string to be normalized. 736 * 737 * @memberOf Barba.Utils 738 * @private 739 * @param {String} p 740 * @return {Int} port 741 */ 742 getPort: function(p) { 743 var port = typeof p !== 'undefined' ? p : window.location.port; 744 var protocol = window.location.protocol; 745 746 if (port != '') 747 return parseInt(port); 748 749 if (protocol === 'http:') 750 return 80; 751 752 if (protocol === 'https:') 753 return 443; 754 } 755 }; 756 757 module.exports = Utils; 758 759 760/***/ }, 761/* 6 */ 762/***/ function(module, exports, __webpack_require__) { 763 764 var Dispatcher = __webpack_require__(7); 765 var Utils = __webpack_require__(5); 766 767 /** 768 * BaseView to be extended 769 * 770 * @namespace Barba.BaseView 771 * @type {Object} 772 */ 773 var BaseView = { 774 /** 775 * Namespace of the view. 776 * (need to be associated with the data-namespace of the container) 777 * 778 * @memberOf Barba.BaseView 779 * @type {String} 780 */ 781 namespace: null, 782 783 /** 784 * Helper to extend the object 785 * 786 * @memberOf Barba.BaseView 787 * @param {Object} newObject 788 * @return {Object} newInheritObject 789 */ 790 extend: function(obj){ 791 return Utils.extend(this, obj); 792 }, 793 794 /** 795 * Init the view. 796 * P.S. Is suggested to init the view before starting Barba.Pjax.start(), 797 * in this way .onEnter() and .onEnterCompleted() will be fired for the current 798 * container when the page is loaded. 799 * 800 * @memberOf Barba.BaseView 801 */ 802 init: function() { 803 var _this = this; 804 805 Dispatcher.on('initStateChange', 806 function(newStatus, oldStatus) { 807 if (oldStatus && oldStatus.namespace === _this.namespace) 808 _this.onLeave(); 809 } 810 ); 811 812 Dispatcher.on('newPageReady', 813 function(newStatus, oldStatus, container) { 814 _this.container = container; 815 816 if (newStatus.namespace === _this.namespace) 817 _this.onEnter(); 818 } 819 ); 820 821 Dispatcher.on('transitionCompleted', 822 function(newStatus, oldStatus) { 823 if (newStatus.namespace === _this.namespace) 824 _this.onEnterCompleted(); 825 826 if (oldStatus && oldStatus.namespace === _this.namespace) 827 _this.onLeaveCompleted(); 828 } 829 ); 830 }, 831 832 /** 833 * This function will be fired when the container 834 * is ready and attached to the DOM. 835 * 836 * @memberOf Barba.BaseView 837 * @abstract 838 */ 839 onEnter: function() {}, 840 841 /** 842 * This function will be fired when the transition 843 * to this container has just finished. 844 * 845 * @memberOf Barba.BaseView 846 * @abstract 847 */ 848 onEnterCompleted: function() {}, 849 850 /** 851 * This function will be fired when the transition 852 * to a new container has just started. 853 * 854 * @memberOf Barba.BaseView 855 * @abstract 856 */ 857 onLeave: function() {}, 858 859 /** 860 * This function will be fired when the container 861 * has just been removed from the DOM. 862 * 863 * @memberOf Barba.BaseView 864 * @abstract 865 */ 866 onLeaveCompleted: function() {} 867 } 868 869 module.exports = BaseView; 870 871 872/***/ }, 873/* 7 */ 874/***/ function(module, exports) { 875 876 /** 877 * Little Dispatcher inspired by MicroEvent.js 878 * 879 * @namespace Barba.Dispatcher 880 * @type {Object} 881 */ 882 var Dispatcher = { 883 /** 884 * Object that keeps all the events 885 * 886 * @memberOf Barba.Dispatcher 887 * @readOnly 888 * @type {Object} 889 */ 890 events: {}, 891 892 /** 893 * Bind a callback to an event 894 * 895 * @memberOf Barba.Dispatcher 896 * @param {String} eventName 897 * @param {Function} function 898 */ 899 on: function(e, f) { 900 this.events[e] = this.events[e] || []; 901 this.events[e].push(f); 902 }, 903 904 /** 905 * Unbind event 906 * 907 * @memberOf Barba.Dispatcher 908 * @param {String} eventName 909 * @param {Function} function 910 */ 911 off: function(e, f) { 912 if(e in this.events === false) 913 return; 914 915 this.events[e].splice(this.events[e].indexOf(f), 1); 916 }, 917 918 /** 919 * Fire the event running all the event associated to it 920 * 921 * @memberOf Barba.Dispatcher 922 * @param {String} eventName 923 * @param {...*} args 924 */ 925 trigger: function(e) {//e, ...args 926 if (e in this.events === false) 927 return; 928 929 for(var i = 0; i < this.events[e].length; i++){ 930 this.events[e][i].apply(this, Array.prototype.slice.call(arguments, 1)); 931 } 932 } 933 }; 934 935 module.exports = Dispatcher; 936 937 938/***/ }, 939/* 8 */ 940/***/ function(module, exports, __webpack_require__) { 941 942 var Utils = __webpack_require__(5); 943 944 /** 945 * BaseCache it's a simple static cache 946 * 947 * @namespace Barba.BaseCache 948 * @type {Object} 949 */ 950 var BaseCache = { 951 /** 952 * The Object that keeps all the key value information 953 * 954 * @memberOf Barba.BaseCache 955 * @type {Object} 956 */ 957 data: {}, 958 959 /** 960 * Helper to extend this object 961 * 962 * @memberOf Barba.BaseCache 963 * @private 964 * @param {Object} newObject 965 * @return {Object} newInheritObject 966 */ 967 extend: function(obj) { 968 return Utils.extend(this, obj); 969 }, 970 971 /** 972 * Set a key and value data, mainly Barba is going to save promises 973 * 974 * @memberOf Barba.BaseCache 975 * @param {String} key 976 * @param {*} value 977 */ 978 set: function(key, val) { 979 this.data[key] = val; 980 }, 981 982 /** 983 * Retrieve the data using the key 984 * 985 * @memberOf Barba.BaseCache 986 * @param {String} key 987 * @return {*} 988 */ 989 get: function(key) { 990 return this.data[key]; 991 }, 992 993 /** 994 * Flush the cache 995 * 996 * @memberOf Barba.BaseCache 997 */ 998 reset: function() { 999 this.data = {}; 1000 } 1001 }; 1002 1003 module.exports = BaseCache; 1004 1005 1006/***/ }, 1007/* 9 */ 1008/***/ function(module, exports) { 1009 1010 /** 1011 * HistoryManager helps to keep track of the navigation 1012 * 1013 * @namespace Barba.HistoryManager 1014 * @type {Object} 1015 */ 1016 var HistoryManager = { 1017 /** 1018 * Keep track of the status in historic order 1019 * 1020 * @memberOf Barba.HistoryManager 1021 * @readOnly 1022 * @type {Array} 1023 */ 1024 history: [], 1025 1026 /** 1027 * Add a new set of url and namespace 1028 * 1029 * @memberOf Barba.HistoryManager 1030 * @param {String} url 1031 * @param {String} namespace 1032 * @private 1033 */ 1034 add: function(url, namespace) { 1035 if (!namespace) 1036 namespace = undefined; 1037 1038 this.history.push({ 1039 url: url, 1040 namespace: namespace 1041 }); 1042 }, 1043 1044 /** 1045 * Return information about the current status 1046 * 1047 * @memberOf Barba.HistoryManager 1048 * @return {Object} 1049 */ 1050 currentStatus: function() { 1051 return this.history[this.history.length - 1]; 1052 }, 1053 1054 /** 1055 * Return information about the previous status 1056 * 1057 * @memberOf Barba.HistoryManager 1058 * @return {Object} 1059 */ 1060 prevStatus: function() { 1061 var history = this.history; 1062 1063 if (history.length < 2) 1064 return null; 1065 1066 return history[history.length - 2]; 1067 } 1068 }; 1069 1070 module.exports = HistoryManager; 1071 1072 1073/***/ }, 1074/* 10 */ 1075/***/ function(module, exports, __webpack_require__) { 1076 1077 var Utils = __webpack_require__(5); 1078 var Dispatcher = __webpack_require__(7); 1079 var HideShowTransition = __webpack_require__(11); 1080 var BaseCache = __webpack_require__(8); 1081 1082 var HistoryManager = __webpack_require__(9); 1083 var Dom = __webpack_require__(12); 1084 1085 /** 1086 * Pjax is a static object with main function 1087 * 1088 * @namespace Barba.Pjax 1089 * @borrows Dom as Dom 1090 * @type {Object} 1091 */ 1092 var Pjax = { 1093 Dom: Dom, 1094 History: HistoryManager, 1095 Cache: BaseCache, 1096 1097 /** 1098 * Indicate wether or not use the cache 1099 * 1100 * @memberOf Barba.Pjax 1101 * @type {Boolean} 1102 * @default 1103 */ 1104 cacheEnabled: true, 1105 1106 /** 1107 * Indicate if there is an animation in progress 1108 * 1109 * @memberOf Barba.Pjax 1110 * @readOnly 1111 * @type {Boolean} 1112 */ 1113 transitionProgress: false, 1114 1115 /** 1116 * Class name used to ignore links 1117 * 1118 * @memberOf Barba.Pjax 1119 * @type {String} 1120 * @default 1121 */ 1122 ignoreClassLink: 'no-barba', 1123 1124 /** 1125 * Function to be called to start Pjax 1126 * 1127 * @memberOf Barba.Pjax 1128 */ 1129 start: function() { 1130 this.init(); 1131 }, 1132 1133 /** 1134 * Init the events 1135 * 1136 * @memberOf Barba.Pjax 1137 * @private 1138 */ 1139 init: function() { 1140 var container = this.Dom.getContainer(); 1141 var wrapper = this.Dom.getWrapper(); 1142 1143 wrapper.setAttribute('aria-live', 'polite'); 1144 1145 this.History.add( 1146 this.getCurrentUrl(), 1147 this.Dom.getNamespace(container) 1148 ); 1149 1150 //Fire for the current view. 1151 Dispatcher.trigger('initStateChange', this.History.currentStatus()); 1152 Dispatcher.trigger('newPageReady', 1153 this.History.currentStatus(), 1154 {}, 1155 container, 1156 this.Dom.currentHTML 1157 ); 1158 Dispatcher.trigger('transitionCompleted', this.History.currentStatus()); 1159 1160 this.bindEvents(); 1161 }, 1162 1163 /** 1164 * Attach the eventlisteners 1165 * 1166 * @memberOf Barba.Pjax 1167 * @private 1168 */ 1169 bindEvents: function() { 1170 document.addEventListener('click', 1171 this.onLinkClick.bind(this) 1172 ); 1173 1174 window.addEventListener('popstate', 1175 this.onStateChange.bind(this) 1176 ); 1177 }, 1178 1179 /** 1180 * Return the currentURL cleaned 1181 * 1182 * @memberOf Barba.Pjax 1183 * @return {String} currentUrl 1184 */ 1185 getCurrentUrl: function() { 1186 return Utils.cleanLink( 1187 Utils.getCurrentUrl() 1188 ); 1189 }, 1190 1191 /** 1192 * Change the URL with pushstate and trigger the state change 1193 * 1194 * @memberOf Barba.Pjax 1195 * @param {String} newUrl 1196 */ 1197 goTo: function(url) { 1198 window.history.pushState(null, null, url); 1199 this.onStateChange(); 1200 }, 1201 1202 /** 1203 * Force the browser to go to a certain url 1204 * 1205 * @memberOf Barba.Pjax 1206 * @param {String} url 1207 * @private 1208 */ 1209 forceGoTo: function(url) { 1210 window.location = url; 1211 }, 1212 1213 /** 1214 * Load an url, will start an xhr request or load from the cache 1215 * 1216 * @memberOf Barba.Pjax 1217 * @private 1218 * @param {String} url 1219 * @return {Promise} 1220 */ 1221 load: function(url) { 1222 var deferred = Utils.deferred(); 1223 var _this = this; 1224 var xhr; 1225 1226 xhr = this.Cache.get(url); 1227 1228 if (!xhr) { 1229 xhr = Utils.xhr(url); 1230 this.Cache.set(url, xhr); 1231 } 1232 1233 xhr.then( 1234 function(data) { 1235 var container = _this.Dom.parseResponse(data); 1236 1237 _this.Dom.putContainer(container); 1238 1239 if (!_this.cacheEnabled) 1240 _this.Cache.reset(); 1241 1242 deferred.resolve(container); 1243 }, 1244 function() { 1245 //Something went wrong (timeout, 404, 505...) 1246 _this.forceGoTo(url); 1247 1248 deferred.reject(); 1249 } 1250 ); 1251 1252 return deferred.promise; 1253 }, 1254 1255 /** 1256 * Get the .href parameter out of an element 1257 * and handle special cases (like xlink:href) 1258 * 1259 * @private 1260 * @memberOf Barba.Pjax 1261 * @param {HTMLElement} el 1262 * @return {String} href 1263 */ 1264 getHref: function(el) { 1265 if (!el) { 1266 return undefined; 1267 } 1268 1269 if (el.getAttribute && typeof el.getAttribute('xlink:href') === 'string') { 1270 return el.getAttribute('xlink:href'); 1271 } 1272 1273 if (typeof el.href === 'string') { 1274 return el.href; 1275 } 1276 1277 return undefined; 1278 }, 1279 1280 /** 1281 * Callback called from click event 1282 * 1283 * @memberOf Barba.Pjax 1284 * @private 1285 * @param {MouseEvent} evt 1286 */ 1287 onLinkClick: function(evt) { 1288 var el = evt.target; 1289 1290 //Go up in the nodelist until we 1291 //find something with an href 1292 while (el && !this.getHref(el)) { 1293 el = el.parentNode; 1294 } 1295 1296 if (this.preventCheck(evt, el)) { 1297 evt.stopPropagation(); 1298 evt.preventDefault(); 1299 1300 Dispatcher.trigger('linkClicked', el, evt); 1301 1302 var href = this.getHref(el); 1303 this.goTo(href); 1304 } 1305 }, 1306 1307 /** 1308 * Determine if the link should be followed 1309 * 1310 * @memberOf Barba.Pjax 1311 * @param {MouseEvent} evt 1312 * @param {HTMLElement} element 1313 * @return {Boolean} 1314 */ 1315 preventCheck: function(evt, element) { 1316 if (!window.history.pushState) 1317 return false; 1318 1319 var href = this.getHref(element); 1320 1321 //User 1322 if (!element || !href) 1323 return false; 1324 1325 //Middle click, cmd click, and ctrl click 1326 if (evt.which > 1 || evt.metaKey || evt.ctrlKey || evt.shiftKey || evt.altKey) 1327 return false; 1328 1329 //Ignore target with _blank target 1330 if (element.target && element.target === '_blank') 1331 return false; 1332 1333 //Check if it's the same domain 1334 if (window.location.protocol !== element.protocol || window.location.hostname !== element.hostname) 1335 return false; 1336 1337 //Check if the port is the same 1338 if (Utils.getPort() !== Utils.getPort(element.port)) 1339 return false; 1340 1341 //Ignore case when a hash is being tacked on the current URL 1342 if (href.indexOf('#') > -1) 1343 return false; 1344 1345 //Ignore case where there is download attribute 1346 if (element.getAttribute && typeof element.getAttribute('download') === 'string') 1347 return false; 1348 1349 //In case you're trying to load the same page 1350 if (Utils.cleanLink(href) == Utils.cleanLink(location.href)) 1351 return false; 1352 1353 if (element.classList.contains(this.ignoreClassLink)) 1354 return false; 1355 1356 return true; 1357 }, 1358 1359 /** 1360 * Return a transition object 1361 * 1362 * @memberOf Barba.Pjax 1363 * @return {Barba.Transition} Transition object 1364 */ 1365 getTransition: function() { 1366 //User customizable 1367 return HideShowTransition; 1368 }, 1369 1370 /** 1371 * Method called after a 'popstate' or from .goTo() 1372 * 1373 * @memberOf Barba.Pjax 1374 * @private 1375 */ 1376 onStateChange: function() { 1377 var newUrl = this.getCurrentUrl(); 1378 1379 if (this.transitionProgress) 1380 this.forceGoTo(newUrl); 1381 1382 if (this.History.currentStatus().url === newUrl) 1383 return false; 1384 1385 this.History.add(newUrl); 1386 1387 var newContainer = this.load(newUrl); 1388 var transition = Object.create(this.getTransition()); 1389 1390 this.transitionProgress = true; 1391 1392 Dispatcher.trigger('initStateChange', 1393 this.History.currentStatus(), 1394 this.History.prevStatus() 1395 ); 1396 1397 var transitionInstance = transition.init( 1398 this.Dom.getContainer(), 1399 newContainer 1400 ); 1401 1402 newContainer.then( 1403 this.onNewContainerLoaded.bind(this) 1404 ); 1405 1406 transitionInstance.then( 1407 this.onTransitionEnd.bind(this) 1408 ); 1409 }, 1410 1411 /** 1412 * Function called as soon the new container is ready 1413 * 1414 * @memberOf Barba.Pjax 1415 * @private 1416 * @param {HTMLElement} container 1417 */ 1418 onNewContainerLoaded: function(container) { 1419 var currentStatus = this.History.currentStatus(); 1420 currentStatus.namespace = this.Dom.getNamespace(container); 1421 1422 Dispatcher.trigger('newPageReady', 1423 this.History.currentStatus(), 1424 this.History.prevStatus(), 1425 container, 1426 this.Dom.currentHTML 1427 ); 1428 }, 1429 1430 /** 1431 * Function called as soon the transition is finished 1432 * 1433 * @memberOf Barba.Pjax 1434 * @private 1435 */ 1436 onTransitionEnd: function() { 1437 this.transitionProgress = false; 1438 1439 Dispatcher.trigger('transitionCompleted', 1440 this.History.currentStatus(), 1441 this.History.prevStatus() 1442 ); 1443 } 1444 }; 1445 1446 module.exports = Pjax; 1447 1448 1449/***/ }, 1450/* 11 */ 1451/***/ function(module, exports, __webpack_require__) { 1452 1453 var BaseTransition = __webpack_require__(4); 1454 1455 /** 1456 * Basic Transition object, wait for the new Container to be ready, 1457 * scroll top, and finish the transition (removing the old container and displaying the new one) 1458 * 1459 * @private 1460 * @namespace Barba.HideShowTransition 1461 * @augments Barba.BaseTransition 1462 */ 1463 var HideShowTransition = BaseTransition.extend({ 1464 start: function() { 1465 this.newContainerLoading.then(this.finish.bind(this)); 1466 }, 1467 1468 finish: function() { 1469 document.body.scrollTop = 0; 1470 this.done(); 1471 } 1472 }); 1473 1474 module.exports = HideShowTransition; 1475 1476 1477/***/ }, 1478/* 12 */ 1479/***/ function(module, exports) { 1480 1481 /** 1482 * Object that is going to deal with DOM parsing/manipulation 1483 * 1484 * @namespace Barba.Pjax.Dom 1485 * @type {Object} 1486 */ 1487 var Dom = { 1488 /** 1489 * The name of the data attribute on the container 1490 * 1491 * @memberOf Barba.Pjax.Dom 1492 * @type {String} 1493 * @default 1494 */ 1495 dataNamespace: 'namespace', 1496 1497 /** 1498 * Id of the main wrapper 1499 * 1500 * @memberOf Barba.Pjax.Dom 1501 * @type {String} 1502 * @default 1503 */ 1504 wrapperId: 'barba-wrapper', 1505 1506 /** 1507 * Class name used to identify the containers 1508 * 1509 * @memberOf Barba.Pjax.Dom 1510 * @type {String} 1511 * @default 1512 */ 1513 containerClass: 'barba-container', 1514 1515 /** 1516 * Full HTML String of the current page. 1517 * By default is the innerHTML of the initial loaded page. 1518 * 1519 * Each time a new page is loaded, the value is the response of the xhr call. 1520 * 1521 * @memberOf Barba.Pjax.Dom 1522 * @type {String} 1523 */ 1524 currentHTML: document.documentElement.innerHTML, 1525 1526 /** 1527 * Parse the responseText obtained from the xhr call 1528 * 1529 * @memberOf Barba.Pjax.Dom 1530 * @private 1531 * @param {String} responseText 1532 * @return {HTMLElement} 1533 */ 1534 parseResponse: function(responseText) { 1535 this.currentHTML = responseText; 1536 1537 var wrapper = document.createElement('div'); 1538 wrapper.innerHTML = responseText; 1539 1540 var titleEl = wrapper.querySelector('title'); 1541 1542 if (titleEl) 1543 document.title = titleEl.textContent; 1544 1545 return this.getContainer(wrapper); 1546 }, 1547 1548 /** 1549 * Get the main barba wrapper by the ID `wrapperId` 1550 * 1551 * @memberOf Barba.Pjax.Dom 1552 * @return {HTMLElement} element 1553 */ 1554 getWrapper: function() { 1555 var wrapper = document.getElementById(this.wrapperId); 1556 1557 if (!wrapper) 1558 throw new Error('Barba.js: wrapper not found!'); 1559 1560 return wrapper; 1561 }, 1562 1563 /** 1564 * Get the container on the current DOM, 1565 * or from an HTMLElement passed via argument 1566 * 1567 * @memberOf Barba.Pjax.Dom 1568 * @private 1569 * @param {HTMLElement} element 1570 * @return {HTMLElement} 1571 */ 1572 getContainer: function(element) { 1573 if (!element) 1574 element = document.body; 1575 1576 if (!element) 1577 throw new Error('Barba.js: DOM not ready!'); 1578 1579 var container = this.parseContainer(element); 1580 1581 if (container && container.jquery) 1582 container = container[0]; 1583 1584 if (!container) 1585 throw new Error('Barba.js: no container found'); 1586 1587 return container; 1588 }, 1589 1590 /** 1591 * Get the namespace of the container 1592 * 1593 * @memberOf Barba.Pjax.Dom 1594 * @private 1595 * @param {HTMLElement} element 1596 * @return {String} 1597 */ 1598 getNamespace: function(element) { 1599 if (element && element.dataset) { 1600 return element.dataset[this.dataNamespace]; 1601 } else if (element) { 1602 return element.getAttribute('data-' + this.dataNamespace); 1603 } 1604 1605 return null; 1606 }, 1607 1608 /** 1609 * Put the container on the page 1610 * 1611 * @memberOf Barba.Pjax.Dom 1612 * @private 1613 * @param {HTMLElement} element 1614 */ 1615 putContainer: function(element) { 1616 element.style.visibility = 'hidden'; 1617 1618 var wrapper = this.getWrapper(); 1619 wrapper.appendChild(element); 1620 }, 1621 1622 /** 1623 * Get container selector 1624 * 1625 * @memberOf Barba.Pjax.Dom 1626 * @private 1627 * @param {HTMLElement} element 1628 * @return {HTMLElement} element 1629 */ 1630 parseContainer: function(element) { 1631 return element.querySelector('.' + this.containerClass); 1632 } 1633 }; 1634 1635 module.exports = Dom; 1636 1637 1638/***/ }, 1639/* 13 */ 1640/***/ function(module, exports, __webpack_require__) { 1641 1642 var Utils = __webpack_require__(5); 1643 var Pjax = __webpack_require__(10); 1644 1645 /** 1646 * Prefetch 1647 * 1648 * @namespace Barba.Prefetch 1649 * @type {Object} 1650 */ 1651 var Prefetch = { 1652 /** 1653 * Class name used to ignore prefetch on links 1654 * 1655 * @memberOf Barba.Prefetch 1656 * @type {String} 1657 * @default 1658 */ 1659 ignoreClassLink: 'no-barba-prefetch', 1660 1661 /** 1662 * Init the event listener on mouseover and touchstart 1663 * for the prefetch 1664 * 1665 * @memberOf Barba.Prefetch 1666 */ 1667 init: function() { 1668 if (!window.history.pushState) { 1669 return false; 1670 } 1671 1672 document.body.addEventListener('mouseover', this.onLinkEnter.bind(this)); 1673 document.body.addEventListener('touchstart', this.onLinkEnter.bind(this)); 1674 }, 1675 1676 /** 1677 * Callback for the mousehover/touchstart 1678 * 1679 * @memberOf Barba.Prefetch 1680 * @private 1681 * @param {Object} evt 1682 */ 1683 onLinkEnter: function(evt) { 1684 var el = evt.target; 1685 1686 while (el && !Pjax.getHref(el)) { 1687 el = el.parentNode; 1688 } 1689 1690 if (!el || el.classList.contains(this.ignoreClassLink)) { 1691 return; 1692 } 1693 1694 var url = Pjax.getHref(el); 1695 1696 //Check if the link is elegible for Pjax 1697 if (Pjax.preventCheck(evt, el) && !Pjax.Cache.get(url)) { 1698 var xhr = Utils.xhr(url); 1699 Pjax.Cache.set(url, xhr); 1700 } 1701 } 1702 }; 1703 1704 module.exports = Prefetch; 1705 1706 1707/***/ } 1708/******/ ]) 1709}); 1710;
1711 1712},{}],2:[function(require,module,exports){ 1713(function (global){(function (){ 1714/** 1715 * @license 1716 * Lodash <https://lodash.com/> 1717 * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> 1718 * Released under MIT license <https://lodash.com/license> 1719 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> 1720 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors 1721 */ 1722;(function() { 1723 1724 /** Used as a safe reference for `undefined` in pre-ES5 environments. */ 1725 var undefined
vendor: 12,195 bytes, lines 1725-2028
1725; 1726 1727 /** Used as the semantic version number. */ 1728 var VERSION = '4.17.21'; 1729 1730 /** Used as the size to enable large array optimizations. */ 1731 var LARGE_ARRAY_SIZE = 200; 1732 1733 /** Error message constants. */ 1734 var CORE_ERROR_TEXT = 'Unsupported core-js use. Try https://npms.io/search?q=ponyfill.', 1735 FUNC_ERROR_TEXT = 'Expected a function', 1736 INVALID_TEMPL_VAR_ERROR_TEXT = 'Invalid `variable` option passed into `_.template`'; 1737 1738 /** Used to stand-in for `undefined` hash values. */ 1739 var HASH_UNDEFINED = '__lodash_hash_undefined__'; 1740 1741 /** Used as the maximum memoize cache size. */ 1742 var MAX_MEMOIZE_SIZE = 500; 1743 1744 /** Used as the internal argument placeholder. */ 1745 var PLACEHOLDER = '__lodash_placeholder__'; 1746 1747 /** Used to compose bitmasks for cloning. */ 1748 var CLONE_DEEP_FLAG = 1, 1749 CLONE_FLAT_FLAG = 2, 1750 CLONE_SYMBOLS_FLAG = 4; 1751 1752 /** Used to compose bitmasks for value comparisons. */ 1753 var COMPARE_PARTIAL_FLAG = 1, 1754 COMPARE_UNORDERED_FLAG = 2; 1755 1756 /** Used to compose bitmasks for function metadata. */ 1757 var WRAP_BIND_FLAG = 1, 1758 WRAP_BIND_KEY_FLAG = 2, 1759 WRAP_CURRY_BOUND_FLAG = 4, 1760 WRAP_CURRY_FLAG = 8, 1761 WRAP_CURRY_RIGHT_FLAG = 16, 1762 WRAP_PARTIAL_FLAG = 32, 1763 WRAP_PARTIAL_RIGHT_FLAG = 64, 1764 WRAP_ARY_FLAG = 128, 1765 WRAP_REARG_FLAG = 256, 1766 WRAP_FLIP_FLAG = 512; 1767 1768 /** Used as default options for `_.truncate`. */ 1769 var DEFAULT_TRUNC_LENGTH = 30, 1770 DEFAULT_TRUNC_OMISSION = '...'; 1771 1772 /** Used to detect hot functions by number of calls within a span of milliseconds. */ 1773 var HOT_COUNT = 800, 1774 HOT_SPAN = 16; 1775 1776 /** Used to indicate the type of lazy iteratees. */ 1777 var LAZY_FILTER_FLAG = 1, 1778 LAZY_MAP_FLAG = 2, 1779 LAZY_WHILE_FLAG = 3; 1780 1781 /** Used as references for various `Number` constants. */ 1782 var INFINITY = 1 / 0, 1783 MAX_SAFE_INTEGER = 9007199254740991, 1784 MAX_INTEGER = 1.7976931348623157e+308, 1785 NAN = 0 / 0; 1786 1787 /** Used as references for the maximum length and index of an array. */ 1788 var MAX_ARRAY_LENGTH = 4294967295, 1789 MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, 1790 HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; 1791 1792 /** Used to associate wrap methods with their bit flags. */ 1793 var wrapFlags = [ 1794 ['ary', WRAP_ARY_FLAG], 1795 ['bind', WRAP_BIND_FLAG], 1796 ['bindKey', WRAP_BIND_KEY_FLAG], 1797 ['curry', WRAP_CURRY_FLAG], 1798 ['curryRight', WRAP_CURRY_RIGHT_FLAG], 1799 ['flip', WRAP_FLIP_FLAG], 1800 ['partial', WRAP_PARTIAL_FLAG], 1801 ['partialRight', WRAP_PARTIAL_RIGHT_FLAG], 1802 ['rearg', WRAP_REARG_FLAG] 1803 ]; 1804 1805 /** `Object#toString` result references. */ 1806 var argsTag = '[object Arguments]', 1807 arrayTag = '[object Array]', 1808 asyncTag = '[object AsyncFunction]', 1809 boolTag = '[object Boolean]', 1810 dateTag = '[object Date]', 1811 domExcTag = '[object DOMException]', 1812 errorTag = '[object Error]', 1813 funcTag = '[object Function]', 1814 genTag = '[object GeneratorFunction]', 1815 mapTag = '[object Map]', 1816 numberTag = '[object Number]', 1817 nullTag = '[object Null]', 1818 objectTag = '[object Object]', 1819 promiseTag = '[object Promise]', 1820 proxyTag = '[object Proxy]', 1821 regexpTag = '[object RegExp]', 1822 setTag = '[object Set]', 1823 stringTag = '[object String]', 1824 symbolTag = '[object Symbol]', 1825 undefinedTag = '[object Undefined]', 1826 weakMapTag = '[object WeakMap]', 1827 weakSetTag = '[object WeakSet]'; 1828 1829 var arrayBufferTag = '[object ArrayBuffer]', 1830 dataViewTag = '[object DataView]', 1831 float32Tag = '[object Float32Array]', 1832 float64Tag = '[object Float64Array]', 1833 int8Tag = '[object Int8Array]', 1834 int16Tag = '[object Int16Array]', 1835 int32Tag = '[object Int32Array]', 1836 uint8Tag = '[object Uint8Array]', 1837 uint8ClampedTag = '[object Uint8ClampedArray]', 1838 uint16Tag = '[object Uint16Array]', 1839 uint32Tag = '[object Uint32Array]'; 1840 1841 /** Used to match empty string literals in compiled template source. */ 1842 var reEmptyStringLeading = /\b__p \+= '';/g, 1843 reEmptyStringMiddle = /\b(__p \+=) '' \+/g, 1844 reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g; 1845 1846 /** Used to match HTML entities and HTML characters. */ 1847 var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g, 1848 reUnescapedHtml = /[&<>"']/g, 1849 reHasEscapedHtml = RegExp(reEscapedHtml.source), 1850 reHasUnescapedHtml = RegExp(reUnescapedHtml.source); 1851 1852 /** Used to match template delimiters. */ 1853 var reEscape = /<%-([\s\S]+?)%>/g, 1854 reEvaluate = /<%([\s\S]+?)%>/g, 1855 reInterpolate = /<%=([\s\S]+?)%>/g; 1856 1857 /** Used to match property names within property paths. */ 1858 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, 1859 reIsPlainProp = /^\w*$/, 1860 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; 1861 1862 /** 1863 * Used to match `RegExp` 1864 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). 1865 */ 1866 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, 1867 reHasRegExpChar = RegExp(reRegExpChar.source); 1868 1869 /** Used to match leading whitespace. */ 1870 var reTrimStart = /^\s+/; 1871 1872 /** Used to match a single whitespace character. */ 1873 var reWhitespace = /\s/; 1874 1875 /** Used to match wrap detail comments. */ 1876 var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, 1877 reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, 1878 reSplitDetails = /,? & /; 1879 1880 /** Used to match words composed of alphanumeric characters. */ 1881 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; 1882 1883 /** 1884 * Used to validate the `validate` option in `_.template` variable. 1885 * 1886 * Forbids characters which could potentially change the meaning of the function argument definition: 1887 * - "()," (modification of function parameters) 1888 * - "=" (default value) 1889 * - "[]{}" (destructuring of function parameters) 1890 * - "/" (beginning of a comment) 1891 * - whitespace 1892 */ 1893 var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/; 1894 1895 /** Used to match backslashes in property paths. */ 1896 var reEscapeChar = /\\(\\)?/g; 1897 1898 /** 1899 * Used to match 1900 * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). 1901 */ 1902 var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; 1903 1904 /** Used to match `RegExp` flags from their coerced string values. */ 1905 var reFlags = /\w*$/; 1906 1907 /** Used to detect bad signed hexadecimal string values. */ 1908 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 1909 1910 /** Used to detect binary string values. */ 1911 var reIsBinary = /^0b[01]+$/i; 1912 1913 /** Used to detect host constructors (Safari). */ 1914 var reIsHostCtor = /^\[object .+?Constructor\]$/; 1915 1916 /** Used to detect octal string values. */ 1917 var reIsOctal = /^0o[0-7]+$/i; 1918 1919 /** Used to detect unsigned integer values. */ 1920 var reIsUint = /^(?:0|[1-9]\d*)$/; 1921 1922 /** Used to match Latin Unicode letters (excluding mathematical operators). */ 1923 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; 1924 1925 /** Used to ensure capturing order of template delimiters. */ 1926 var reNoMatch = /($^)/; 1927 1928 /** Used to match unescaped characters in compiled string literals. */ 1929 var reUnescapedString = /['\n\r\u2028\u2029\\]/g; 1930 1931 /** Used to compose unicode character classes. */ 1932 var rsAstralRange = '\\ud800-\\udfff', 1933 rsComboMarksRange = '\\u0300-\\u036f', 1934 reComboHalfMarksRange = '\\ufe20-\\ufe2f', 1935 rsComboSymbolsRange = '\\u20d0-\\u20ff', 1936 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, 1937 rsDingbatRange = '\\u2700-\\u27bf', 1938 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', 1939 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', 1940 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', 1941 rsPunctuationRange = '\\u2000-\\u206f', 1942 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', 1943 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', 1944 rsVarRange = '\\ufe0e\\ufe0f', 1945 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; 1946 1947 /** Used to compose unicode capture groups. */ 1948 var rsApos = "['\u2019]", 1949 rsAstral = '[' + rsAstralRange + ']', 1950 rsBreak = '[' + rsBreakRange + ']', 1951 rsCombo = '[' + rsComboRange + ']', 1952 rsDigits = '\\d+', 1953 rsDingbat = '[' + rsDingbatRange + ']', 1954 rsLower = '[' + rsLowerRange + ']', 1955 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', 1956 rsFitz = '\\ud83c[\\udffb-\\udfff]', 1957 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', 1958 rsNonAstral = '[^' + rsAstralRange + ']', 1959 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', 1960 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', 1961 rsUpper = '[' + rsUpperRange + ']', 1962 rsZWJ = '\\u200d'; 1963 1964 /** Used to compose unicode regexes. */ 1965 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', 1966 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', 1967 rsOptContrLower = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?', 1968 rsOptContrUpper = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?', 1969 reOptMod = rsModifier + '?', 1970 rsOptVar = '[' + rsVarRange + ']?', 1971 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', 1972 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', 1973 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', 1974 rsSeq = rsOptVar + reOptMod + rsOptJoin, 1975 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, 1976 rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; 1977 1978 /** Used to match apostrophes. */ 1979 var reApos = RegExp(rsApos, 'g'); 1980 1981 /** 1982 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and 1983 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). 1984 */ 1985 var reComboMark = RegExp(rsCombo, 'g'); 1986 1987 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ 1988 var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); 1989 1990 /** Used to match complex or compound words. */ 1991 var reUnicodeWord = RegExp([ 1992 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', 1993 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', 1994 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, 1995 rsUpper + '+' + rsOptContrUpper, 1996 rsOrdUpper, 1997 rsOrdLower, 1998 rsDigits, 1999 rsEmoji 2000 ].join('|'), 'g'); 2001 2002 /** 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/). */ 2003 var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); 2004 2005 /** Used to detect strings that need a more robust regexp to match words. */ 2006 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 ]/; 2007 2008 /** Used to assign default `context` object properties. */ 2009 var contextProps = [ 2010 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 2011 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', 2012 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', 2013 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', 2014 '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' 2015 ]; 2016 2017 /** Used to make template sourceURLs easier to identify. */ 2018 var templateCounter = -1; 2019 2020 /** Used to identify `toStringTag` values of typed arrays. */ 2021 var typedArrayTags = {}; 2022 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = 2023 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = 2024 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = 2025 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = 2026 typedArrayTags[uint32Tag] = true; 2027 typedArrayTags[argsTag] = typedArrayTags[arrayTag] = 2028 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
vendor: 5,923 bytes, lines 2029-2163
2029 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = 2030 typedArrayTags[errorTag] = typedArrayTags[funcTag] = 2031 typedArrayTags[mapTag] = typedArrayTags[numberTag] = 2032 typedArrayTags[objectTag] = typedArrayTags[regexpTag] = 2033 typedArrayTags[setTag] = typedArrayTags[stringTag] = 2034 typedArrayTags[weakMapTag] = false; 2035 2036 /** Used to identify `toStringTag` values supported by `_.clone`. */ 2037 var cloneableTags = {}; 2038 cloneableTags[argsTag] = cloneableTags[arrayTag] = 2039 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = 2040 cloneableTags[boolTag] = cloneableTags[dateTag] = 2041 cloneableTags[float32Tag] = cloneableTags[float64Tag] = 2042 cloneableTags[int8Tag] = cloneableTags[int16Tag] = 2043 cloneableTags[int32Tag] = cloneableTags[mapTag] = 2044 cloneableTags[numberTag] = cloneableTags[objectTag] = 2045 cloneableTags[regexpTag] = cloneableTags[setTag] = 2046 cloneableTags[stringTag] = cloneableTags[symbolTag] = 2047 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = 2048 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; 2049 cloneableTags[errorTag] = cloneableTags[funcTag] = 2050 cloneableTags[weakMapTag] = false; 2051 2052 /** Used to map Latin Unicode letters to basic Latin letters. */ 2053 var deburredLetters = { 2054 // Latin-1 Supplement block. 2055 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', 2056 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', 2057 '\xc7': 'C', '\xe7': 'c', 2058 '\xd0': 'D', '\xf0': 'd', 2059 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', 2060 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', 2061 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', 2062 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', 2063 '\xd1': 'N', '\xf1': 'n', 2064 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', 2065 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', 2066 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', 2067 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', 2068 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', 2069 '\xc6': 'Ae', '\xe6': 'ae', 2070 '\xde': 'Th', '\xfe': 'th', 2071 '\xdf': 'ss', 2072 // Latin Extended-A block. 2073 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', 2074 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', 2075 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', 2076 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', 2077 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', 2078 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', 2079 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', 2080 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', 2081 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', 2082 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', 2083 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', 2084 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', 2085 '\u0134': 'J', '\u0135': 'j', 2086 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', 2087 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', 2088 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', 2089 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', 2090 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', 2091 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O', 2092 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', 2093 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', 2094 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', 2095 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', 2096 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', 2097 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', 2098 '\u0163': 't', '\u0165': 't', '\u0167': 't', 2099 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', 2100 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', 2101 '\u0174': 'W', '\u0175': 'w', 2102 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', 2103 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', 2104 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', 2105 '\u0132': 'IJ', '\u0133': 'ij', 2106 '\u0152': 'Oe', '\u0153': 'oe', 2107 '\u0149': "'n", '\u017f': 's' 2108 }; 2109 2110 /** Used to map characters to HTML entities. */ 2111 var htmlEscapes = { 2112 '&': '&', 2113 '<': '<', 2114 '>': '>', 2115 '"': '"', 2116 "'": ''' 2117 }; 2118 2119 /** Used to map HTML entities to characters. */ 2120 var htmlUnescapes = { 2121 '&': '&', 2122 '<': '<', 2123 '>': '>', 2124 '"': '"', 2125 ''': "'" 2126 }; 2127 2128 /** Used to escape characters for inclusion in compiled string literals. */ 2129 var stringEscapes = { 2130 '\\': '\\', 2131 "'": "'", 2132 '\n': 'n', 2133 '\r': 'r', 2134 '\u2028': 'u2028', 2135 '\u2029': 'u2029' 2136 }; 2137 2138 /** Built-in method references without a dependency on `root`. */ 2139 var freeParseFloat = parseFloat, 2140 freeParseInt = parseInt; 2141 2142 /** Detect free variable `global` from Node.js. */ 2143 var freeGlobal = typeof global == 'object' && global && global.Object === Object && global; 2144 2145 /** Detect free variable `self`. */ 2146 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 2147 2148 /** Used as a reference to the global object. */ 2149 var root = freeGlobal || freeSelf || Function('return this')(); 2150 2151 /** Detect free variable `exports`. */ 2152 var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports; 2153 2154 /** Detect free variable `module`. */ 2155 var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module; 2156 2157 /** Detect the popular CommonJS extension `module.exports`. */ 2158 var moduleExports = freeModule && freeModule.exports === freeExports; 2159 2160 /** Detect free variable `process` from Node.js. */ 2161 var freeProcess = moduleExports && freeGlobal.process; 2162 2163 /** Used to access faster Node.js helpers. */
vendor: 8,860 bytes, lines 2164-2457
2164 var nodeUtil = (function() { 2165 try { 2166 // Use `util.types` for Node.js 10+. 2167 var types = freeModule && freeModule.require && freeModule.require('util').types; 2168 2169 if (types) { 2170 return types; 2171 } 2172 2173 // Legacy `process.binding('util')` for Node.js < 10. 2174 return freeProcess && freeProcess.binding && freeProcess.binding('util'); 2175 } catch (e) {} 2176 }()); 2177 2178 /* Node.js helper references. */ 2179 var nodeIsArrayBuffer = nodeUtil && nodeUtil.isArrayBuffer, 2180 nodeIsDate = nodeUtil && nodeUtil.isDate, 2181 nodeIsMap = nodeUtil && nodeUtil.isMap, 2182 nodeIsRegExp = nodeUtil && nodeUtil.isRegExp, 2183 nodeIsSet = nodeUtil && nodeUtil.isSet, 2184 nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; 2185 2186 /*--------------------------------------------------------------------------*/ 2187 2188 /** 2189 * A faster alternative to `Function#apply`, this function invokes `func` 2190 * with the `this` binding of `thisArg` and the arguments of `args`. 2191 * 2192 * @private 2193 * @param {Function} func The function to invoke. 2194 * @param {*} thisArg The `this` binding of `func`. 2195 * @param {Array} args The arguments to invoke `func` with. 2196 * @returns {*} Returns the result of `func`. 2197 */ 2198 function apply(func, thisArg, args) { 2199 switch (args.length) { 2200 case 0: return func.call(thisArg); 2201 case 1: return func.call(thisArg, args[0]); 2202 case 2: return func.call(thisArg, args[0], args[1]); 2203 case 3: return func.call(thisArg, args[0], args[1], args[2]); 2204 } 2205 return func.apply(thisArg, args); 2206 } 2207 2208 /** 2209 * A specialized version of `baseAggregator` for arrays. 2210 * 2211 * @private 2212 * @param {Array} [array] The array to iterate over. 2213 * @param {Function} setter The function to set `accumulator` values. 2214 * @param {Function} iteratee The iteratee to transform keys. 2215 * @param {Object} accumulator The initial aggregated object. 2216 * @returns {Function} Returns `accumulator`. 2217 */ 2218 function arrayAggregator(array, setter, iteratee, accumulator) { 2219 var index = -1, 2220 length = array == null ? 0 : array.length; 2221 2222 while (++index < length) { 2223 var value = array[index]; 2224 setter(accumulator, value, iteratee(value), array); 2225 } 2226 return accumulator; 2227 } 2228 2229 /** 2230 * A specialized version of `_.forEach` for arrays without support for 2231 * iteratee shorthands. 2232 * 2233 * @private 2234 * @param {Array} [array] The array to iterate over. 2235 * @param {Function} iteratee The function invoked per iteration. 2236 * @returns {Array} Returns `array`. 2237 */ 2238 function arrayEach(array, iteratee) { 2239 var index = -1, 2240 length = array == null ? 0 : array.length; 2241 2242 while (++index < length) { 2243 if (iteratee(array[index], index, array) === false) { 2244 break; 2245 } 2246 } 2247 return array; 2248 } 2249 2250 /** 2251 * A specialized version of `_.forEachRight` for arrays without support for 2252 * iteratee shorthands. 2253 * 2254 * @private 2255 * @param {Array} [array] The array to iterate over. 2256 * @param {Function} iteratee The function invoked per iteration. 2257 * @returns {Array} Returns `array`. 2258 */ 2259 function arrayEachRight(array, iteratee) { 2260 var length = array == null ? 0 : array.length; 2261 2262 while (length--) { 2263 if (iteratee(array[length], length, array) === false) { 2264 break; 2265 } 2266 } 2267 return array; 2268 } 2269 2270 /** 2271 * A specialized version of `_.every` for arrays without support for 2272 * iteratee shorthands. 2273 * 2274 * @private 2275 * @param {Array} [array] The array to iterate over. 2276 * @param {Function} predicate The function invoked per iteration. 2277 * @returns {boolean} Returns `true` if all elements pass the predicate check, 2278 * else `false`. 2279 */ 2280 function arrayEvery(array, predicate) { 2281 var index = -1, 2282 length = array == null ? 0 : array.length; 2283 2284 while (++index < length) { 2285 if (!predicate(array[index], index, array)) { 2286 return false; 2287 } 2288 } 2289 return true; 2290 } 2291 2292 /** 2293 * A specialized version of `_.filter` for arrays without support for 2294 * iteratee shorthands. 2295 * 2296 * @private 2297 * @param {Array} [array] The array to iterate over. 2298 * @param {Function} predicate The function invoked per iteration. 2299 * @returns {Array} Returns the new filtered array. 2300 */ 2301 function arrayFilter(array, predicate) { 2302 var index = -1, 2303 length = array == null ? 0 : array.length, 2304 resIndex = 0, 2305 result = []; 2306 2307 while (++index < length) { 2308 var value = array[index]; 2309 if (predicate(value, index, array)) { 2310 result[resIndex++] = value; 2311 } 2312 } 2313 return result; 2314 } 2315 2316 /** 2317 * A specialized version of `_.includes` for arrays without support for 2318 * specifying an index to search from. 2319 * 2320 * @private 2321 * @param {Array} [array] The array to inspect. 2322 * @param {*} target The value to search for. 2323 * @returns {boolean} Returns `true` if `target` is found, else `false`. 2324 */ 2325 function arrayIncludes(array, value) { 2326 var length = array == null ? 0 : array.length; 2327 return !!length && baseIndexOf(array, value, 0) > -1; 2328 } 2329 2330 /** 2331 * This function is like `arrayIncludes` except that it accepts a comparator. 2332 * 2333 * @private 2334 * @param {Array} [array] The array to inspect. 2335 * @param {*} target The value to search for. 2336 * @param {Function} comparator The comparator invoked per element. 2337 * @returns {boolean} Returns `true` if `target` is found, else `false`. 2338 */ 2339 function arrayIncludesWith(array, value, comparator) { 2340 var index = -1, 2341 length = array == null ? 0 : array.length; 2342 2343 while (++index < length) { 2344 if (comparator(value, array[index])) { 2345 return true; 2346 } 2347 } 2348 return false; 2349 } 2350 2351 /** 2352 * A specialized version of `_.map` for arrays without support for iteratee 2353 * shorthands. 2354 * 2355 * @private 2356 * @param {Array} [array] The array to iterate over. 2357 * @param {Function} iteratee The function invoked per iteration. 2358 * @returns {Array} Returns the new mapped array. 2359 */ 2360 function arrayMap(array, iteratee) { 2361 var index = -1, 2362 length = array == null ? 0 : array.length, 2363 result = Array(length); 2364 2365 while (++index < length) { 2366 result[index] = iteratee(array[index], index, array); 2367 } 2368 return result; 2369 } 2370 2371 /** 2372 * Appends the elements of `values` to `array`. 2373 * 2374 * @private 2375 * @param {Array} array The array to modify. 2376 * @param {Array} values The values to append. 2377 * @returns {Array} Returns `array`. 2378 */ 2379 function arrayPush(array, values) { 2380 var index = -1, 2381 length = values.length, 2382 offset = array.length; 2383 2384 while (++index < length) { 2385 array[offset + index] = values[index]; 2386 } 2387 return array; 2388 } 2389 2390 /** 2391 * A specialized version of `_.reduce` for arrays without support for 2392 * iteratee shorthands. 2393 * 2394 * @private 2395 * @param {Array} [array] The array to iterate over. 2396 * @param {Function} iteratee The function invoked per iteration. 2397 * @param {*} [accumulator] The initial value. 2398 * @param {boolean} [initAccum] Specify using the first element of `array` as 2399 * the initial value. 2400 * @returns {*} Returns the accumulated value. 2401 */ 2402 function arrayReduce(array, iteratee, accumulator, initAccum) { 2403 var index = -1, 2404 length = array == null ? 0 : array.length; 2405 2406 if (initAccum && length) { 2407 accumulator = array[++index]; 2408 } 2409 while (++index < length) { 2410 accumulator = iteratee(accumulator, array[index], index, array); 2411 } 2412 return accumulator; 2413 } 2414 2415 /** 2416 * A specialized version of `_.reduceRight` for arrays without support for 2417 * iteratee shorthands. 2418 * 2419 * @private 2420 * @param {Array} [array] The array to iterate over. 2421 * @param {Function} iteratee The function invoked per iteration. 2422 * @param {*} [accumulator] The initial value. 2423 * @param {boolean} [initAccum] Specify using the last element of `array` as 2424 * the initial value. 2425 * @returns {*} Returns the accumulated value. 2426 */ 2427 function arrayReduceRight(array, iteratee, accumulator, initAccum) { 2428 var length = array == null ? 0 : array.length; 2429 if (initAccum && length) { 2430 accumulator = array[--length]; 2431 } 2432 while (length--) { 2433 accumulator = iteratee(accumulator, array[length], length, array); 2434 } 2435 return accumulator; 2436 } 2437 2438 /** 2439 * A specialized version of `_.some` for arrays without support for iteratee 2440 * shorthands. 2441 * 2442 * @private 2443 * @param {Array} [array] The array to iterate over. 2444 * @param {Function} predicate The function invoked per iteration. 2445 * @returns {boolean} Returns `true` if any element passes the predicate check, 2446 * else `false`. 2447 */ 2448 function arraySome(array, predicate) { 2449 var index = -1, 2450 length = array == null ? 0 : array.length; 2451 2452 while (++index < length) { 2453 if (predicate(array[index], index, array)) { 2454 return true; 2455 } 2456 } 2457 return false;
vendor: 12,899 bytes, lines 2458-2895
2458 } 2459 2460 /** 2461 * Gets the size of an ASCII `string`. 2462 * 2463 * @private 2464 * @param {string} string The string inspect. 2465 * @returns {number} Returns the string size. 2466 */ 2467 var asciiSize = baseProperty('length'); 2468 2469 /** 2470 * Converts an ASCII `string` to an array. 2471 * 2472 * @private 2473 * @param {string} string The string to convert. 2474 * @returns {Array} Returns the converted array. 2475 */ 2476 function asciiToArray(string) { 2477 return string.split(''); 2478 } 2479 2480 /** 2481 * Splits an ASCII `string` into an array of its words. 2482 * 2483 * @private 2484 * @param {string} The string to inspect. 2485 * @returns {Array} Returns the words of `string`. 2486 */ 2487 function asciiWords(string) { 2488 return string.match(reAsciiWord) || []; 2489 } 2490 2491 /** 2492 * The base implementation of methods like `_.findKey` and `_.findLastKey`, 2493 * without support for iteratee shorthands, which iterates over `collection` 2494 * using `eachFunc`. 2495 * 2496 * @private 2497 * @param {Array|Object} collection The collection to inspect. 2498 * @param {Function} predicate The function invoked per iteration. 2499 * @param {Function} eachFunc The function to iterate over `collection`. 2500 * @returns {*} Returns the found element or its key, else `undefined`. 2501 */ 2502 function baseFindKey(collection, predicate, eachFunc) { 2503 var result; 2504 eachFunc(collection, function(value, key, collection) { 2505 if (predicate(value, key, collection)) { 2506 result = key; 2507 return false; 2508 } 2509 }); 2510 return result; 2511 } 2512 2513 /** 2514 * The base implementation of `_.findIndex` and `_.findLastIndex` without 2515 * support for iteratee shorthands. 2516 * 2517 * @private 2518 * @param {Array} array The array to inspect. 2519 * @param {Function} predicate The function invoked per iteration. 2520 * @param {number} fromIndex The index to search from. 2521 * @param {boolean} [fromRight] Specify iterating from right to left. 2522 * @returns {number} Returns the index of the matched value, else `-1`. 2523 */ 2524 function baseFindIndex(array, predicate, fromIndex, fromRight) { 2525 var length = array.length, 2526 index = fromIndex + (fromRight ? 1 : -1); 2527 2528 while ((fromRight ? index-- : ++index < length)) { 2529 if (predicate(array[index], index, array)) { 2530 return index; 2531 } 2532 } 2533 return -1; 2534 } 2535 2536 /** 2537 * The base implementation of `_.indexOf` without `fromIndex` bounds checks. 2538 * 2539 * @private 2540 * @param {Array} array The array to inspect. 2541 * @param {*} value The value to search for. 2542 * @param {number} fromIndex The index to search from. 2543 * @returns {number} Returns the index of the matched value, else `-1`. 2544 */ 2545 function baseIndexOf(array, value, fromIndex) { 2546 return value === value 2547 ? strictIndexOf(array, value, fromIndex) 2548 : baseFindIndex(array, baseIsNaN, fromIndex); 2549 } 2550 2551 /** 2552 * This function is like `baseIndexOf` except that it accepts a comparator. 2553 * 2554 * @private 2555 * @param {Array} array The array to inspect. 2556 * @param {*} value The value to search for. 2557 * @param {number} fromIndex The index to search from. 2558 * @param {Function} comparator The comparator invoked per element. 2559 * @returns {number} Returns the index of the matched value, else `-1`. 2560 */ 2561 function baseIndexOfWith(array, value, fromIndex, comparator) { 2562 var index = fromIndex - 1, 2563 length = array.length; 2564 2565 while (++index < length) { 2566 if (comparator(array[index], value)) { 2567 return index; 2568 } 2569 } 2570 return -1; 2571 } 2572 2573 /** 2574 * The base implementation of `_.isNaN` without support for number objects. 2575 * 2576 * @private 2577 * @param {*} value The value to check. 2578 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 2579 */ 2580 function baseIsNaN(value) { 2581 return value !== value; 2582 } 2583 2584 /** 2585 * The base implementation of `_.mean` and `_.meanBy` without support for 2586 * iteratee shorthands. 2587 * 2588 * @private 2589 * @param {Array} array The array to iterate over. 2590 * @param {Function} iteratee The function invoked per iteration. 2591 * @returns {number} Returns the mean. 2592 */ 2593 function baseMean(array, iteratee) { 2594 var length = array == null ? 0 : array.length; 2595 return length ? (baseSum(array, iteratee) / length) : NAN; 2596 } 2597 2598 /** 2599 * The base implementation of `_.property` without support for deep paths. 2600 * 2601 * @private 2602 * @param {string} key The key of the property to get. 2603 * @returns {Function} Returns the new accessor function. 2604 */ 2605 function baseProperty(key) { 2606 return function(object) { 2607 return object == null ? undefined : object[key]; 2608 }; 2609 } 2610 2611 /** 2612 * The base implementation of `_.propertyOf` without support for deep paths. 2613 * 2614 * @private 2615 * @param {Object} object The object to query. 2616 * @returns {Function} Returns the new accessor function. 2617 */ 2618 function basePropertyOf(object) { 2619 return function(key) { 2620 return object == null ? undefined : object[key]; 2621 }; 2622 } 2623 2624 /** 2625 * The base implementation of `_.reduce` and `_.reduceRight`, without support 2626 * for iteratee shorthands, which iterates over `collection` using `eachFunc`. 2627 * 2628 * @private 2629 * @param {Array|Object} collection The collection to iterate over. 2630 * @param {Function} iteratee The function invoked per iteration. 2631 * @param {*} accumulator The initial value. 2632 * @param {boolean} initAccum Specify using the first or last element of 2633 * `collection` as the initial value. 2634 * @param {Function} eachFunc The function to iterate over `collection`. 2635 * @returns {*} Returns the accumulated value. 2636 */ 2637 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { 2638 eachFunc(collection, function(value, index, collection) { 2639 accumulator = initAccum 2640 ? (initAccum = false, value) 2641 : iteratee(accumulator, value, index, collection); 2642 }); 2643 return accumulator; 2644 } 2645 2646 /** 2647 * The base implementation of `_.sortBy` which uses `comparer` to define the 2648 * sort order of `array` and replaces criteria objects with their corresponding 2649 * values. 2650 * 2651 * @private 2652 * @param {Array} array The array to sort. 2653 * @param {Function} comparer The function to define sort order. 2654 * @returns {Array} Returns `array`. 2655 */ 2656 function baseSortBy(array, comparer) { 2657 var length = array.length; 2658 2659 array.sort(comparer); 2660 while (length--) { 2661 array[length] = array[length].value; 2662 } 2663 return array; 2664 } 2665 2666 /** 2667 * The base implementation of `_.sum` and `_.sumBy` without support for 2668 * iteratee shorthands. 2669 * 2670 * @private 2671 * @param {Array} array The array to iterate over. 2672 * @param {Function} iteratee The function invoked per iteration. 2673 * @returns {number} Returns the sum. 2674 */ 2675 function baseSum(array, iteratee) { 2676 var result, 2677 index = -1, 2678 length = array.length; 2679 2680 while (++index < length) { 2681 var current = iteratee(array[index]); 2682 if (current !== undefined) { 2683 result = result === undefined ? current : (result + current); 2684 } 2685 } 2686 return result; 2687 } 2688 2689 /** 2690 * The base implementation of `_.times` without support for iteratee shorthands 2691 * or max array length checks. 2692 * 2693 * @private 2694 * @param {number} n The number of times to invoke `iteratee`. 2695 * @param {Function} iteratee The function invoked per iteration. 2696 * @returns {Array} Returns the array of results. 2697 */ 2698 function baseTimes(n, iteratee) { 2699 var index = -1, 2700 result = Array(n); 2701 2702 while (++index < n) { 2703 result[index] = iteratee(index); 2704 } 2705 return result; 2706 } 2707 2708 /** 2709 * The base implementation of `_.toPairs` and `_.toPairsIn` which creates an array 2710 * of key-value pairs for `object` corresponding to the property names of `props`. 2711 * 2712 * @private 2713 * @param {Object} object The object to query. 2714 * @param {Array} props The property names to get values for. 2715 * @returns {Object} Returns the key-value pairs. 2716 */ 2717 function baseToPairs(object, props) { 2718 return arrayMap(props, function(key) { 2719 return [key, object[key]]; 2720 }); 2721 } 2722 2723 /** 2724 * The base implementation of `_.trim`. 2725 * 2726 * @private 2727 * @param {string} string The string to trim. 2728 * @returns {string} Returns the trimmed string. 2729 */ 2730 function baseTrim(string) { 2731 return string 2732 ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') 2733 : string; 2734 } 2735 2736 /** 2737 * The base implementation of `_.unary` without support for storing metadata. 2738 * 2739 * @private 2740 * @param {Function} func The function to cap arguments for. 2741 * @returns {Function} Returns the new capped function. 2742 */ 2743 function baseUnary(func) { 2744 return function(value) { 2745 return func(value); 2746 }; 2747 } 2748 2749 /** 2750 * The base implementation of `_.values` and `_.valuesIn` which creates an 2751 * array of `object` property values corresponding to the property names 2752 * of `props`. 2753 * 2754 * @private 2755 * @param {Object} object The object to query. 2756 * @param {Array} props The property names to get values for. 2757 * @returns {Object} Returns the array of property values. 2758 */ 2759 function baseValues(object, props) { 2760 return arrayMap(props, function(key) { 2761 return object[key]; 2762 }); 2763 } 2764 2765 /** 2766 * Checks if a `cache` value for `key` exists. 2767 * 2768 * @private 2769 * @param {Object} cache The cache to query. 2770 * @param {string} key The key of the entry to check. 2771 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 2772 */ 2773 function cacheHas(cache, key) { 2774 return cache.has(key); 2775 } 2776 2777 /** 2778 * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol 2779 * that is not found in the character symbols. 2780 * 2781 * @private 2782 * @param {Array} strSymbols The string symbols to inspect. 2783 * @param {Array} chrSymbols The character symbols to find. 2784 * @returns {number} Returns the index of the first unmatched string symbol. 2785 */ 2786 function charsStartIndex(strSymbols, chrSymbols) { 2787 var index = -1, 2788 length = strSymbols.length; 2789 2790 while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 2791 return index; 2792 } 2793 2794 /** 2795 * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol 2796 * that is not found in the character symbols. 2797 * 2798 * @private 2799 * @param {Array} strSymbols The string symbols to inspect. 2800 * @param {Array} chrSymbols The character symbols to find. 2801 * @returns {number} Returns the index of the last unmatched string symbol. 2802 */ 2803 function charsEndIndex(strSymbols, chrSymbols) { 2804 var index = strSymbols.length; 2805 2806 while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {} 2807 return index; 2808 } 2809 2810 /** 2811 * Gets the number of `placeholder` occurrences in `array`. 2812 * 2813 * @private 2814 * @param {Array} array The array to inspect. 2815 * @param {*} placeholder The placeholder to search for. 2816 * @returns {number} Returns the placeholder count. 2817 */ 2818 function countHolders(array, placeholder) { 2819 var length = array.length, 2820 result = 0; 2821 2822 while (length--) { 2823 if (array[length] === placeholder) { 2824 ++result; 2825 } 2826 } 2827 return result; 2828 } 2829 2830 /** 2831 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A 2832 * letters to basic Latin letters. 2833 * 2834 * @private 2835 * @param {string} letter The matched letter to deburr. 2836 * @returns {string} Returns the deburred letter. 2837 */ 2838 var deburrLetter = basePropertyOf(deburredLetters); 2839 2840 /** 2841 * Used by `_.escape` to convert characters to HTML entities. 2842 * 2843 * @private 2844 * @param {string} chr The matched character to escape. 2845 * @returns {string} Returns the escaped character. 2846 */ 2847 var escapeHtmlChar = basePropertyOf(htmlEscapes); 2848 2849 /** 2850 * Used by `_.template` to escape characters for inclusion in compiled string literals. 2851 * 2852 * @private 2853 * @param {string} chr The matched character to escape. 2854 * @returns {string} Returns the escaped character. 2855 */ 2856 function escapeStringChar(chr) { 2857 return '\\' + stringEscapes[chr]; 2858 } 2859 2860 /** 2861 * Gets the value at `key` of `object`. 2862 * 2863 * @private 2864 * @param {Object} [object] The object to query. 2865 * @param {string} key The key of the property to get. 2866 * @returns {*} Returns the property value. 2867 */ 2868 function getValue(object, key) { 2869 return object == null ? undefined : object[key]; 2870 } 2871 2872 /** 2873 * Checks if `string` contains Unicode symbols. 2874 * 2875 * @private 2876 * @param {string} string The string to inspect. 2877 * @returns {boolean} Returns `true` if a symbol is found, else `false`. 2878 */ 2879 function hasUnicode(string) { 2880 return reHasUnicode.test(string); 2881 } 2882 2883 /** 2884 * Checks if `string` contains a word composed of Unicode symbols. 2885 * 2886 * @private 2887 * @param {string} string The string to inspect. 2888 * @returns {boolean} Returns `true` if a word is found, else `false`. 2889 */ 2890 function hasUnicodeWord(string) { 2891 return reHasUnicodeWord.test(string); 2892 } 2893 2894 /** 2895 * Converts `iterator` to an array.
vendor: 8,214 bytes, lines 2896-3205
2896 * 2897 * @private 2898 * @param {Object} iterator The iterator to convert. 2899 * @returns {Array} Returns the converted array. 2900 */ 2901 function iteratorToArray(iterator) { 2902 var data, 2903 result = []; 2904 2905 while (!(data = iterator.next()).done) { 2906 result.push(data.value); 2907 } 2908 return result; 2909 } 2910 2911 /** 2912 * Converts `map` to its key-value pairs. 2913 * 2914 * @private 2915 * @param {Object} map The map to convert. 2916 * @returns {Array} Returns the key-value pairs. 2917 */ 2918 function mapToArray(map) { 2919 var index = -1, 2920 result = Array(map.size); 2921 2922 map.forEach(function(value, key) { 2923 result[++index] = [key, value]; 2924 }); 2925 return result; 2926 } 2927 2928 /** 2929 * Creates a unary function that invokes `func` with its argument transformed. 2930 * 2931 * @private 2932 * @param {Function} func The function to wrap. 2933 * @param {Function} transform The argument transform. 2934 * @returns {Function} Returns the new function. 2935 */ 2936 function overArg(func, transform) { 2937 return function(arg) { 2938 return func(transform(arg)); 2939 }; 2940 } 2941 2942 /** 2943 * Replaces all `placeholder` elements in `array` with an internal placeholder 2944 * and returns an array of their indexes. 2945 * 2946 * @private 2947 * @param {Array} array The array to modify. 2948 * @param {*} placeholder The placeholder to replace. 2949 * @returns {Array} Returns the new array of placeholder indexes. 2950 */ 2951 function replaceHolders(array, placeholder) { 2952 var index = -1, 2953 length = array.length, 2954 resIndex = 0, 2955 result = []; 2956 2957 while (++index < length) { 2958 var value = array[index]; 2959 if (value === placeholder || value === PLACEHOLDER) { 2960 array[index] = PLACEHOLDER; 2961 result[resIndex++] = index; 2962 } 2963 } 2964 return result; 2965 } 2966 2967 /** 2968 * Converts `set` to an array of its values. 2969 * 2970 * @private 2971 * @param {Object} set The set to convert. 2972 * @returns {Array} Returns the values. 2973 */ 2974 function setToArray(set) { 2975 var index = -1, 2976 result = Array(set.size); 2977 2978 set.forEach(function(value) { 2979 result[++index] = value; 2980 }); 2981 return result; 2982 } 2983 2984 /** 2985 * Converts `set` to its value-value pairs. 2986 * 2987 * @private 2988 * @param {Object} set The set to convert. 2989 * @returns {Array} Returns the value-value pairs. 2990 */ 2991 function setToPairs(set) { 2992 var index = -1, 2993 result = Array(set.size); 2994 2995 set.forEach(function(value) { 2996 result[++index] = [value, value]; 2997 }); 2998 return result; 2999 } 3000 3001 /** 3002 * A specialized version of `_.indexOf` which performs strict equality 3003 * comparisons of values, i.e. `===`. 3004 * 3005 * @private 3006 * @param {Array} array The array to inspect. 3007 * @param {*} value The value to search for. 3008 * @param {number} fromIndex The index to search from. 3009 * @returns {number} Returns the index of the matched value, else `-1`. 3010 */ 3011 function strictIndexOf(array, value, fromIndex) { 3012 var index = fromIndex - 1, 3013 length = array.length; 3014 3015 while (++index < length) { 3016 if (array[index] === value) { 3017 return index; 3018 } 3019 } 3020 return -1; 3021 } 3022 3023 /** 3024 * A specialized version of `_.lastIndexOf` which performs strict equality 3025 * comparisons of values, i.e. `===`. 3026 * 3027 * @private 3028 * @param {Array} array The array to inspect. 3029 * @param {*} value The value to search for. 3030 * @param {number} fromIndex The index to search from. 3031 * @returns {number} Returns the index of the matched value, else `-1`. 3032 */ 3033 function strictLastIndexOf(array, value, fromIndex) { 3034 var index = fromIndex + 1; 3035 while (index--) { 3036 if (array[index] === value) { 3037 return index; 3038 } 3039 } 3040 return index; 3041 } 3042 3043 /** 3044 * Gets the number of symbols in `string`. 3045 * 3046 * @private 3047 * @param {string} string The string to inspect. 3048 * @returns {number} Returns the string size. 3049 */ 3050 function stringSize(string) { 3051 return hasUnicode(string) 3052 ? unicodeSize(string) 3053 : asciiSize(string); 3054 } 3055 3056 /** 3057 * Converts `string` to an array. 3058 * 3059 * @private 3060 * @param {string} string The string to convert. 3061 * @returns {Array} Returns the converted array. 3062 */ 3063 function stringToArray(string) { 3064 return hasUnicode(string) 3065 ? unicodeToArray(string) 3066 : asciiToArray(string); 3067 } 3068 3069 /** 3070 * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace 3071 * character of `string`. 3072 * 3073 * @private 3074 * @param {string} string The string to inspect. 3075 * @returns {number} Returns the index of the last non-whitespace character. 3076 */ 3077 function trimmedEndIndex(string) { 3078 var index = string.length; 3079 3080 while (index-- && reWhitespace.test(string.charAt(index))) {} 3081 return index; 3082 } 3083 3084 /** 3085 * Used by `_.unescape` to convert HTML entities to characters. 3086 * 3087 * @private 3088 * @param {string} chr The matched character to unescape. 3089 * @returns {string} Returns the unescaped character. 3090 */ 3091 var unescapeHtmlChar = basePropertyOf(htmlUnescapes); 3092 3093 /** 3094 * Gets the size of a Unicode `string`. 3095 * 3096 * @private 3097 * @param {string} string The string inspect. 3098 * @returns {number} Returns the string size. 3099 */ 3100 function unicodeSize(string) { 3101 var result = reUnicode.lastIndex = 0; 3102 while (reUnicode.test(string)) { 3103 ++result; 3104 } 3105 return result; 3106 } 3107 3108 /** 3109 * Converts a Unicode `string` to an array. 3110 * 3111 * @private 3112 * @param {string} string The string to convert. 3113 * @returns {Array} Returns the converted array. 3114 */ 3115 function unicodeToArray(string) { 3116 return string.match(reUnicode) || []; 3117 } 3118 3119 /** 3120 * Splits a Unicode `string` into an array of its words. 3121 * 3122 * @private 3123 * @param {string} The string to inspect. 3124 * @returns {Array} Returns the words of `string`. 3125 */ 3126 function unicodeWords(string) { 3127 return string.match(reUnicodeWord) || []; 3128 } 3129 3130 /*--------------------------------------------------------------------------*/ 3131 3132 /** 3133 * Create a new pristine `lodash` function using the `context` object. 3134 * 3135 * @static 3136 * @memberOf _ 3137 * @since 1.1.0 3138 * @category Util 3139 * @param {Object} [context=root] The context object. 3140 * @returns {Function} Returns a new `lodash` function. 3141 * @example 3142 * 3143 * _.mixin({ 'foo': _.constant('foo') }); 3144 * 3145 * var lodash = _.runInContext(); 3146 * lodash.mixin({ 'bar': lodash.constant('bar') }); 3147 * 3148 * _.isFunction(_.foo); 3149 * // => true 3150 * _.isFunction(_.bar); 3151 * // => false 3152 * 3153 * lodash.isFunction(lodash.foo); 3154 * // => false 3155 * lodash.isFunction(lodash.bar); 3156 * // => true 3157 * 3158 * // Create a suped-up `defer` in Node.js. 3159 * var defer = _.runInContext({ 'setTimeout': setImmediate }).defer; 3160 */ 3161 var runInContext = (function runInContext(context) { 3162 context = context == null ? root : _.defaults(root.Object(), context, _.pick(root, contextProps)); 3163 3164 /** Built-in constructor references. */ 3165 var Array = context.Array, 3166 Date = context.Date, 3167 Error = context.Error, 3168 Function = context.Function, 3169 Math = context.Math, 3170 Object = context.Object, 3171 RegExp = context.RegExp, 3172 String = context.String, 3173 TypeError = context.TypeError; 3174 3175 /** Used for built-in method references. */ 3176 var arrayProto = Array.prototype, 3177 funcProto = Function.prototype, 3178 objectProto = Object.prototype; 3179 3180 /** Used to detect overreaching core-js shims. */ 3181 var coreJsData = context['__core-js_shared__']; 3182 3183 /** Used to resolve the decompiled source of functions. */ 3184 var funcToString = funcProto.toString; 3185 3186 /** Used to check objects for own properties. */ 3187 var hasOwnProperty = objectProto.hasOwnProperty; 3188 3189 /** Used to generate unique IDs. */ 3190 var idCounter = 0; 3191 3192 /** Used to detect methods masquerading as native. */ 3193 var maskSrcKey = (function() { 3194 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || ''); 3195 return uid ? ('Symbol(src)_1.' + uid) : ''; 3196 }()); 3197 3198 /** 3199 * Used to resolve the 3200 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 3201 * of values. 3202 */ 3203 var nativeObjectToString = objectProto.toString; 3204 3205 /** Used to infer the `Object` constructor. */
vendor: 25,659 bytes, lines 3206-4003
3206 var objectCtorString = funcToString.call(Object); 3207 3208 /** Used to restore the original `_` reference in `_.noConflict`. */ 3209 var oldDash = root._; 3210 3211 /** Used to detect if a method is native. */ 3212 var reIsNative = RegExp('^' + 3213 funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&') 3214 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 3215 ); 3216 3217 /** Built-in value references. */ 3218 var Buffer = moduleExports ? context.Buffer : undefined, 3219 Symbol = context.Symbol, 3220 Uint8Array = context.Uint8Array, 3221 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined, 3222 getPrototype = overArg(Object.getPrototypeOf, Object), 3223 objectCreate = Object.create, 3224 propertyIsEnumerable = objectProto.propertyIsEnumerable, 3225 splice = arrayProto.splice, 3226 spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined, 3227 symIterator = Symbol ? Symbol.iterator : undefined, 3228 symToStringTag = Symbol ? Symbol.toStringTag : undefined; 3229 3230 var defineProperty = (function() { 3231 try { 3232 var func = getNative(Object, 'defineProperty'); 3233 func({}, '', {}); 3234 return func; 3235 } catch (e) {} 3236 }()); 3237 3238 /** Mocked built-ins. */ 3239 var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, 3240 ctxNow = Date && Date.now !== root.Date.now && Date.now, 3241 ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; 3242 3243 /* Built-in method references for those with the same name as other `lodash` methods. */ 3244 var nativeCeil = Math.ceil, 3245 nativeFloor = Math.floor, 3246 nativeGetSymbols = Object.getOwnPropertySymbols, 3247 nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, 3248 nativeIsFinite = context.isFinite, 3249 nativeJoin = arrayProto.join, 3250 nativeKeys = overArg(Object.keys, Object), 3251 nativeMax = Math.max, 3252 nativeMin = Math.min, 3253 nativeNow = Date.now, 3254 nativeParseInt = context.parseInt, 3255 nativeRandom = Math.random, 3256 nativeReverse = arrayProto.reverse; 3257 3258 /* Built-in method references that are verified to be native. */ 3259 var DataView = getNative(context, 'DataView'), 3260 Map = getNative(context, 'Map'), 3261 Promise = getNative(context, 'Promise'), 3262 Set = getNative(context, 'Set'), 3263 WeakMap = getNative(context, 'WeakMap'), 3264 nativeCreate = getNative(Object, 'create'); 3265 3266 /** Used to store function metadata. */ 3267 var metaMap = WeakMap && new WeakMap; 3268 3269 /** Used to lookup unminified function names. */ 3270 var realNames = {}; 3271 3272 /** Used to detect maps, sets, and weakmaps. */ 3273 var dataViewCtorString = toSource(DataView), 3274 mapCtorString = toSource(Map), 3275 promiseCtorString = toSource(Promise), 3276 setCtorString = toSource(Set), 3277 weakMapCtorString = toSource(WeakMap); 3278 3279 /** Used to convert symbols to primitives and strings. */ 3280 var symbolProto = Symbol ? Symbol.prototype : undefined, 3281 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined, 3282 symbolToString = symbolProto ? symbolProto.toString : undefined; 3283 3284 /*------------------------------------------------------------------------*/ 3285 3286 /** 3287 * Creates a `lodash` object which wraps `value` to enable implicit method 3288 * chain sequences. Methods that operate on and return arrays, collections, 3289 * and functions can be chained together. Methods that retrieve a single value 3290 * or may return a primitive value will automatically end the chain sequence 3291 * and return the unwrapped value. Otherwise, the value must be unwrapped 3292 * with `_#value`. 3293 * 3294 * Explicit chain sequences, which must be unwrapped with `_#value`, may be 3295 * enabled using `_.chain`. 3296 * 3297 * The execution of chained methods is lazy, that is, it's deferred until 3298 * `_#value` is implicitly or explicitly called. 3299 * 3300 * Lazy evaluation allows several methods to support shortcut fusion. 3301 * Shortcut fusion is an optimization to merge iteratee calls; this avoids 3302 * the creation of intermediate arrays and can greatly reduce the number of 3303 * iteratee executions. Sections of a chain sequence qualify for shortcut 3304 * fusion if the section is applied to an array and iteratees accept only 3305 * one argument. The heuristic for whether a section qualifies for shortcut 3306 * fusion is subject to change. 3307 * 3308 * Chaining is supported in custom builds as long as the `_#value` method is 3309 * directly or indirectly included in the build. 3310 * 3311 * In addition to lodash methods, wrappers have `Array` and `String` methods. 3312 * 3313 * The wrapper `Array` methods are: 3314 * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift` 3315 * 3316 * The wrapper `String` methods are: 3317 * `replace` and `split` 3318 * 3319 * The wrapper methods that support shortcut fusion are: 3320 * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`, 3321 * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`, 3322 * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray` 3323 * 3324 * The chainable wrapper methods are: 3325 * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`, 3326 * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`, 3327 * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, 3328 * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, 3329 * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`, 3330 * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`, 3331 * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`, 3332 * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, 3333 * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`, 3334 * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, 3335 * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, 3336 * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, 3337 * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, 3338 * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`, 3339 * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, 3340 * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`, 3341 * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`, 3342 * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`, 3343 * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, 3344 * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`, 3345 * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, 3346 * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`, 3347 * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, 3348 * `zipObject`, `zipObjectDeep`, and `zipWith` 3349 * 3350 * The wrapper methods that are **not** chainable by default are: 3351 * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, 3352 * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`, 3353 * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`, 3354 * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`, 3355 * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`, 3356 * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, 3357 * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, 3358 * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`, 3359 * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`, 3360 * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, 3361 * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, 3362 * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, 3363 * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`, 3364 * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`, 3365 * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, 3366 * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`, 3367 * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, 3368 * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`, 3369 * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, 3370 * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`, 3371 * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`, 3372 * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`, 3373 * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`, 3374 * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`, 3375 * `upperFirst`, `value`, and `words` 3376 * 3377 * @name _ 3378 * @constructor 3379 * @category Seq 3380 * @param {*} value The value to wrap in a `lodash` instance. 3381 * @returns {Object} Returns the new `lodash` wrapper instance. 3382 * @example 3383 * 3384 * function square(n) { 3385 * return n * n; 3386 * } 3387 * 3388 * var wrapped = _([1, 2, 3]); 3389 * 3390 * // Returns an unwrapped value. 3391 * wrapped.reduce(_.add); 3392 * // => 6 3393 * 3394 * // Returns a wrapped value. 3395 * var squares = wrapped.map(square); 3396 * 3397 * _.isArray(squares); 3398 * // => false 3399 * 3400 * _.isArray(squares.value()); 3401 * // => true 3402 */ 3403 function lodash(value) { 3404 if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) { 3405 if (value instanceof LodashWrapper) { 3406 return value; 3407 } 3408 if (hasOwnProperty.call(value, '__wrapped__')) { 3409 return wrapperClone(value); 3410 } 3411 } 3412 return new LodashWrapper(value); 3413 } 3414 3415 /** 3416 * The base implementation of `_.create` without support for assigning 3417 * properties to the created object. 3418 * 3419 * @private 3420 * @param {Object} proto The object to inherit from. 3421 * @returns {Object} Returns the new object. 3422 */ 3423 var baseCreate = (function() { 3424 function object() {} 3425 return function(proto) { 3426 if (!isObject(proto)) { 3427 return {}; 3428 } 3429 if (objectCreate) { 3430 return objectCreate(proto); 3431 } 3432 object.prototype = proto; 3433 var result = new object; 3434 object.prototype = undefined; 3435 return result; 3436 }; 3437 }()); 3438 3439 /** 3440 * The function whose prototype chain sequence wrappers inherit from. 3441 * 3442 * @private 3443 */ 3444 function baseLodash() { 3445 // No operation performed. 3446 } 3447 3448 /** 3449 * The base constructor for creating `lodash` wrapper objects. 3450 * 3451 * @private 3452 * @param {*} value The value to wrap. 3453 * @param {boolean} [chainAll] Enable explicit method chain sequences. 3454 */ 3455 function LodashWrapper(value, chainAll) { 3456 this.__wrapped__ = value; 3457 this.__actions__ = []; 3458 this.__chain__ = !!chainAll; 3459 this.__index__ = 0; 3460 this.__values__ = undefined; 3461 } 3462 3463 /** 3464 * By default, the template delimiters used by lodash are like those in 3465 * embedded Ruby (ERB) as well as ES2015 template strings. Change the 3466 * following template settings to use alternative delimiters. 3467 * 3468 * @static 3469 * @memberOf _ 3470 * @type {Object} 3471 */ 3472 lodash.templateSettings = { 3473 3474 /** 3475 * Used to detect `data` property values to be HTML-escaped. 3476 * 3477 * @memberOf _.templateSettings 3478 * @type {RegExp} 3479 */ 3480 'escape': reEscape, 3481 3482 /** 3483 * Used to detect code to be evaluated. 3484 * 3485 * @memberOf _.templateSettings 3486 * @type {RegExp} 3487 */ 3488 'evaluate': reEvaluate, 3489 3490 /** 3491 * Used to detect `data` property values to inject. 3492 * 3493 * @memberOf _.templateSettings 3494 * @type {RegExp} 3495 */ 3496 'interpolate': reInterpolate, 3497 3498 /** 3499 * Used to reference the data object in the template text. 3500 * 3501 * @memberOf _.templateSettings 3502 * @type {string} 3503 */ 3504 'variable': '', 3505 3506 /** 3507 * Used to import variables into the compiled template. 3508 * 3509 * @memberOf _.templateSettings 3510 * @type {Object} 3511 */ 3512 'imports': { 3513 3514 /** 3515 * A reference to the `lodash` function. 3516 * 3517 * @memberOf _.templateSettings.imports 3518 * @type {Function} 3519 */ 3520 '_': lodash 3521 } 3522 }; 3523 3524 // Ensure wrappers are instances of `baseLodash`. 3525 lodash.prototype = baseLodash.prototype; 3526 lodash.prototype.constructor = lodash; 3527 3528 LodashWrapper.prototype = baseCreate(baseLodash.prototype); 3529 LodashWrapper.prototype.constructor = LodashWrapper; 3530 3531 /*------------------------------------------------------------------------*/ 3532 3533 /** 3534 * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. 3535 * 3536 * @private 3537 * @constructor 3538 * @param {*} value The value to wrap. 3539 */ 3540 function LazyWrapper(value) { 3541 this.__wrapped__ = value; 3542 this.__actions__ = []; 3543 this.__dir__ = 1; 3544 this.__filtered__ = false; 3545 this.__iteratees__ = []; 3546 this.__takeCount__ = MAX_ARRAY_LENGTH; 3547 this.__views__ = []; 3548 } 3549 3550 /** 3551 * Creates a clone of the lazy wrapper object. 3552 * 3553 * @private 3554 * @name clone 3555 * @memberOf LazyWrapper 3556 * @returns {Object} Returns the cloned `LazyWrapper` object. 3557 */ 3558 function lazyClone() { 3559 var result = new LazyWrapper(this.__wrapped__); 3560 result.__actions__ = copyArray(this.__actions__); 3561 result.__dir__ = this.__dir__; 3562 result.__filtered__ = this.__filtered__; 3563 result.__iteratees__ = copyArray(this.__iteratees__); 3564 result.__takeCount__ = this.__takeCount__; 3565 result.__views__ = copyArray(this.__views__); 3566 return result; 3567 } 3568 3569 /** 3570 * Reverses the direction of lazy iteration. 3571 * 3572 * @private 3573 * @name reverse 3574 * @memberOf LazyWrapper 3575 * @returns {Object} Returns the new reversed `LazyWrapper` object. 3576 */ 3577 function lazyReverse() { 3578 if (this.__filtered__) { 3579 var result = new LazyWrapper(this); 3580 result.__dir__ = -1; 3581 result.__filtered__ = true; 3582 } else { 3583 result = this.clone(); 3584 result.__dir__ *= -1; 3585 } 3586 return result; 3587 } 3588 3589 /** 3590 * Extracts the unwrapped value from its lazy wrapper. 3591 * 3592 * @private 3593 * @name value 3594 * @memberOf LazyWrapper 3595 * @returns {*} Returns the unwrapped value. 3596 */ 3597 function lazyValue() { 3598 var array = this.__wrapped__.value(), 3599 dir = this.__dir__, 3600 isArr = isArray(array), 3601 isRight = dir < 0, 3602 arrLength = isArr ? array.length : 0, 3603 view = getView(0, arrLength, this.__views__), 3604 start = view.start, 3605 end = view.end, 3606 length = end - start, 3607 index = isRight ? end : (start - 1), 3608 iteratees = this.__iteratees__, 3609 iterLength = iteratees.length, 3610 resIndex = 0, 3611 takeCount = nativeMin(length, this.__takeCount__); 3612 3613 if (!isArr || (!isRight && arrLength == length && takeCount == length)) { 3614 return baseWrapperValue(array, this.__actions__); 3615 } 3616 var result = []; 3617 3618 outer: 3619 while (length-- && resIndex < takeCount) { 3620 index += dir; 3621 3622 var iterIndex = -1, 3623 value = array[index]; 3624 3625 while (++iterIndex < iterLength) { 3626 var data = iteratees[iterIndex], 3627 iteratee = data.iteratee, 3628 type = data.type, 3629 computed = iteratee(value); 3630 3631 if (type == LAZY_MAP_FLAG) { 3632 value = computed; 3633 } else if (!computed) { 3634 if (type == LAZY_FILTER_FLAG) { 3635 continue outer; 3636 } else { 3637 break outer; 3638 } 3639 } 3640 } 3641 result[resIndex++] = value; 3642 } 3643 return result; 3644 } 3645 3646 // Ensure `LazyWrapper` is an instance of `baseLodash`. 3647 LazyWrapper.prototype = baseCreate(baseLodash.prototype); 3648 LazyWrapper.prototype.constructor = LazyWrapper; 3649 3650 /*------------------------------------------------------------------------*/ 3651 3652 /** 3653 * Creates a hash object. 3654 * 3655 * @private 3656 * @constructor 3657 * @param {Array} [entries] The key-value pairs to cache. 3658 */ 3659 function Hash(entries) { 3660 var index = -1, 3661 length = entries == null ? 0 : entries.length; 3662 3663 this.clear(); 3664 while (++index < length) { 3665 var entry = entries[index]; 3666 this.set(entry[0], entry[1]); 3667 } 3668 } 3669 3670 /** 3671 * Removes all key-value entries from the hash. 3672 * 3673 * @private 3674 * @name clear 3675 * @memberOf Hash 3676 */ 3677 function hashClear() { 3678 this.__data__ = nativeCreate ? nativeCreate(null) : {}; 3679 this.size = 0; 3680 } 3681 3682 /** 3683 * Removes `key` and its value from the hash. 3684 * 3685 * @private 3686 * @name delete 3687 * @memberOf Hash 3688 * @param {Object} hash The hash to modify. 3689 * @param {string} key The key of the value to remove. 3690 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 3691 */ 3692 function hashDelete(key) { 3693 var result = this.has(key) && delete this.__data__[key]; 3694 this.size -= result ? 1 : 0; 3695 return result; 3696 } 3697 3698 /** 3699 * Gets the hash value for `key`. 3700 * 3701 * @private 3702 * @name get 3703 * @memberOf Hash 3704 * @param {string} key The key of the value to get. 3705 * @returns {*} Returns the entry value. 3706 */ 3707 function hashGet(key) { 3708 var data = this.__data__; 3709 if (nativeCreate) { 3710 var result = data[key]; 3711 return result === HASH_UNDEFINED ? undefined : result; 3712 } 3713 return hasOwnProperty.call(data, key) ? data[key] : undefined; 3714 } 3715 3716 /** 3717 * Checks if a hash value for `key` exists. 3718 * 3719 * @private 3720 * @name has 3721 * @memberOf Hash 3722 * @param {string} key The key of the entry to check. 3723 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 3724 */ 3725 function hashHas(key) { 3726 var data = this.__data__; 3727 return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key); 3728 } 3729 3730 /** 3731 * Sets the hash `key` to `value`. 3732 * 3733 * @private 3734 * @name set 3735 * @memberOf Hash 3736 * @param {string} key The key of the value to set. 3737 * @param {*} value The value to set. 3738 * @returns {Object} Returns the hash instance. 3739 */ 3740 function hashSet(key, value) { 3741 var data = this.__data__; 3742 this.size += this.has(key) ? 0 : 1; 3743 data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; 3744 return this; 3745 } 3746 3747 // Add methods to `Hash`. 3748 Hash.prototype.clear = hashClear; 3749 Hash.prototype['delete'] = hashDelete; 3750 Hash.prototype.get = hashGet; 3751 Hash.prototype.has = hashHas; 3752 Hash.prototype.set = hashSet; 3753 3754 /*------------------------------------------------------------------------*/ 3755 3756 /** 3757 * Creates an list cache object. 3758 * 3759 * @private 3760 * @constructor 3761 * @param {Array} [entries] The key-value pairs to cache. 3762 */ 3763 function ListCache(entries) { 3764 var index = -1, 3765 length = entries == null ? 0 : entries.length; 3766 3767 this.clear(); 3768 while (++index < length) { 3769 var entry = entries[index]; 3770 this.set(entry[0], entry[1]); 3771 } 3772 } 3773 3774 /** 3775 * Removes all key-value entries from the list cache. 3776 * 3777 * @private 3778 * @name clear 3779 * @memberOf ListCache 3780 */ 3781 function listCacheClear() { 3782 this.__data__ = []; 3783 this.size = 0; 3784 } 3785 3786 /** 3787 * Removes `key` and its value from the list cache. 3788 * 3789 * @private 3790 * @name delete 3791 * @memberOf ListCache 3792 * @param {string} key The key of the value to remove. 3793 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 3794 */ 3795 function listCacheDelete(key) { 3796 var data = this.__data__, 3797 index = assocIndexOf(data, key); 3798 3799 if (index < 0) { 3800 return false; 3801 } 3802 var lastIndex = data.length - 1; 3803 if (index == lastIndex) { 3804 data.pop(); 3805 } else { 3806 splice.call(data, index, 1); 3807 } 3808 --this.size; 3809 return true; 3810 } 3811 3812 /** 3813 * Gets the list cache value for `key`. 3814 * 3815 * @private 3816 * @name get 3817 * @memberOf ListCache 3818 * @param {string} key The key of the value to get. 3819 * @returns {*} Returns the entry value. 3820 */ 3821 function listCacheGet(key) { 3822 var data = this.__data__, 3823 index = assocIndexOf(data, key); 3824 3825 return index < 0 ? undefined : data[index][1]; 3826 } 3827 3828 /** 3829 * Checks if a list cache value for `key` exists. 3830 * 3831 * @private 3832 * @name has 3833 * @memberOf ListCache 3834 * @param {string} key The key of the entry to check. 3835 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 3836 */ 3837 function listCacheHas(key) { 3838 return assocIndexOf(this.__data__, key) > -1; 3839 } 3840 3841 /** 3842 * Sets the list cache `key` to `value`. 3843 * 3844 * @private 3845 * @name set 3846 * @memberOf ListCache 3847 * @param {string} key The key of the value to set. 3848 * @param {*} value The value to set. 3849 * @returns {Object} Returns the list cache instance. 3850 */ 3851 function listCacheSet(key, value) { 3852 var data = this.__data__, 3853 index = assocIndexOf(data, key); 3854 3855 if (index < 0) { 3856 ++this.size; 3857 data.push([key, value]); 3858 } else { 3859 data[index][1] = value; 3860 } 3861 return this; 3862 } 3863 3864 // Add methods to `ListCache`. 3865 ListCache.prototype.clear = listCacheClear; 3866 ListCache.prototype['delete'] = listCacheDelete; 3867 ListCache.prototype.get = listCacheGet; 3868 ListCache.prototype.has = listCacheHas; 3869 ListCache.prototype.set = listCacheSet; 3870 3871 /*------------------------------------------------------------------------*/ 3872 3873 /** 3874 * Creates a map cache object to store key-value pairs. 3875 * 3876 * @private 3877 * @constructor 3878 * @param {Array} [entries] The key-value pairs to cache. 3879 */ 3880 function MapCache(entries) { 3881 var index = -1, 3882 length = entries == null ? 0 : entries.length; 3883 3884 this.clear(); 3885 while (++index < length) { 3886 var entry = entries[index]; 3887 this.set(entry[0], entry[1]); 3888 } 3889 } 3890 3891 /** 3892 * Removes all key-value entries from the map. 3893 * 3894 * @private 3895 * @name clear 3896 * @memberOf MapCache 3897 */ 3898 function mapCacheClear() { 3899 this.size = 0; 3900 this.__data__ = { 3901 'hash': new Hash, 3902 'map': new (Map || ListCache), 3903 'string': new Hash 3904 }; 3905 } 3906 3907 /** 3908 * Removes `key` and its value from the map. 3909 * 3910 * @private 3911 * @name delete 3912 * @memberOf MapCache 3913 * @param {string} key The key of the value to remove. 3914 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 3915 */ 3916 function mapCacheDelete(key) { 3917 var result = getMapData(this, key)['delete'](key); 3918 this.size -= result ? 1 : 0; 3919 return result; 3920 } 3921 3922 /** 3923 * Gets the map value for `key`. 3924 * 3925 * @private 3926 * @name get 3927 * @memberOf MapCache 3928 * @param {string} key The key of the value to get. 3929 * @returns {*} Returns the entry value. 3930 */ 3931 function mapCacheGet(key) { 3932 return getMapData(this, key).get(key); 3933 } 3934 3935 /** 3936 * Checks if a map value for `key` exists. 3937 * 3938 * @private 3939 * @name has 3940 * @memberOf MapCache 3941 * @param {string} key The key of the entry to check. 3942 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 3943 */ 3944 function mapCacheHas(key) { 3945 return getMapData(this, key).has(key); 3946 } 3947 3948 /** 3949 * Sets the map `key` to `value`. 3950 * 3951 * @private 3952 * @name set 3953 * @memberOf MapCache 3954 * @param {string} key The key of the value to set. 3955 * @param {*} value The value to set. 3956 * @returns {Object} Returns the map cache instance. 3957 */ 3958 function mapCacheSet(key, value) { 3959 var data = getMapData(this, key), 3960 size = data.size; 3961 3962 data.set(key, value); 3963 this.size += data.size == size ? 0 : 1; 3964 return this; 3965 } 3966 3967 // Add methods to `MapCache`. 3968 MapCache.prototype.clear = mapCacheClear; 3969 MapCache.prototype['delete'] = mapCacheDelete; 3970 MapCache.prototype.get = mapCacheGet; 3971 MapCache.prototype.has = mapCacheHas; 3972 MapCache.prototype.set = mapCacheSet; 3973 3974 /*------------------------------------------------------------------------*/ 3975 3976 /** 3977 * 3978 * Creates an array cache object to store unique values. 3979 * 3980 * @private 3981 * @constructor 3982 * @param {Array} [values] The values to cache. 3983 */ 3984 function SetCache(values) { 3985 var index = -1, 3986 length = values == null ? 0 : values.length; 3987 3988 this.__data__ = new MapCache; 3989 while (++index < length) { 3990 this.add(values[index]); 3991 } 3992 } 3993 3994 /** 3995 * Adds `value` to the array cache. 3996 * 3997 * @private 3998 * @name add 3999 * @memberOf SetCache 4000 * @alias push 4001 * @param {*} value The value to cache. 4002 * @returns {Object} Returns the cache instance. 4003 */
vendor: 3,741 bytes, lines 4004-4140
4004 function setCacheAdd(value) { 4005 this.__data__.set(value, HASH_UNDEFINED); 4006 return this; 4007 } 4008 4009 /** 4010 * Checks if `value` is in the array cache. 4011 * 4012 * @private 4013 * @name has 4014 * @memberOf SetCache 4015 * @param {*} value The value to search for. 4016 * @returns {number} Returns `true` if `value` is found, else `false`. 4017 */ 4018 function setCacheHas(value) { 4019 return this.__data__.has(value); 4020 } 4021 4022 // Add methods to `SetCache`. 4023 SetCache.prototype.add = SetCache.prototype.push = setCacheAdd; 4024 SetCache.prototype.has = setCacheHas; 4025 4026 /*------------------------------------------------------------------------*/ 4027 4028 /** 4029 * Creates a stack cache object to store key-value pairs. 4030 * 4031 * @private 4032 * @constructor 4033 * @param {Array} [entries] The key-value pairs to cache. 4034 */ 4035 function Stack(entries) { 4036 var data = this.__data__ = new ListCache(entries); 4037 this.size = data.size; 4038 } 4039 4040 /** 4041 * Removes all key-value entries from the stack. 4042 * 4043 * @private 4044 * @name clear 4045 * @memberOf Stack 4046 */ 4047 function stackClear() { 4048 this.__data__ = new ListCache; 4049 this.size = 0; 4050 } 4051 4052 /** 4053 * Removes `key` and its value from the stack. 4054 * 4055 * @private 4056 * @name delete 4057 * @memberOf Stack 4058 * @param {string} key The key of the value to remove. 4059 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 4060 */ 4061 function stackDelete(key) { 4062 var data = this.__data__, 4063 result = data['delete'](key); 4064 4065 this.size = data.size; 4066 return result; 4067 } 4068 4069 /** 4070 * Gets the stack value for `key`. 4071 * 4072 * @private 4073 * @name get 4074 * @memberOf Stack 4075 * @param {string} key The key of the value to get. 4076 * @returns {*} Returns the entry value. 4077 */ 4078 function stackGet(key) { 4079 return this.__data__.get(key); 4080 } 4081 4082 /** 4083 * Checks if a stack value for `key` exists. 4084 * 4085 * @private 4086 * @name has 4087 * @memberOf Stack 4088 * @param {string} key The key of the entry to check. 4089 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 4090 */ 4091 function stackHas(key) { 4092 return this.__data__.has(key); 4093 } 4094 4095 /** 4096 * Sets the stack `key` to `value`. 4097 * 4098 * @private 4099 * @name set 4100 * @memberOf Stack 4101 * @param {string} key The key of the value to set. 4102 * @param {*} value The value to set. 4103 * @returns {Object} Returns the stack cache instance. 4104 */ 4105 function stackSet(key, value) { 4106 var data = this.__data__; 4107 if (data instanceof ListCache) { 4108 var pairs = data.__data__; 4109 if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { 4110 pairs.push([key, value]); 4111 this.size = ++data.size; 4112 return this; 4113 } 4114 data = this.__data__ = new MapCache(pairs); 4115 } 4116 data.set(key, value); 4117 this.size = data.size; 4118 return this; 4119 } 4120 4121 // Add methods to `Stack`. 4122 Stack.prototype.clear = stackClear; 4123 Stack.prototype['delete'] = stackDelete; 4124 Stack.prototype.get = stackGet; 4125 Stack.prototype.has = stackHas; 4126 Stack.prototype.set = stackSet; 4127 4128 /*------------------------------------------------------------------------*/ 4129 4130 /** 4131 * Creates an array of the enumerable property names of the array-like `value`. 4132 * 4133 * @private 4134 * @param {*} value The value to query. 4135 * @param {boolean} inherited Specify returning inherited property names. 4136 * @returns {Array} Returns the array of property names. 4137 */ 4138 function arrayLikeKeys(value, inherited) { 4139 var isArr = isArray(value), 4140 isArg = !isArr && isArguments(value),
vendor: 111,524 bytes, lines 4141-7434
4141 isBuff = !isArr && !isArg && isBuffer(value), 4142 isType = !isArr && !isArg && !isBuff && isTypedArray(value), 4143 skipIndexes = isArr || isArg || isBuff || isType, 4144 result = skipIndexes ? baseTimes(value.length, String) : [], 4145 length = result.length; 4146 4147 for (var key in value) { 4148 if ((inherited || hasOwnProperty.call(value, key)) && 4149 !(skipIndexes && ( 4150 // Safari 9 has enumerable `arguments.length` in strict mode. 4151 key == 'length' || 4152 // Node.js 0.10 has enumerable non-index properties on buffers. 4153 (isBuff && (key == 'offset' || key == 'parent')) || 4154 // PhantomJS 2 has enumerable non-index properties on typed arrays. 4155 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || 4156 // Skip index properties. 4157 isIndex(key, length) 4158 ))) { 4159 result.push(key); 4160 } 4161 } 4162 return result; 4163 } 4164 4165 /** 4166 * A specialized version of `_.sample` for arrays. 4167 * 4168 * @private 4169 * @param {Array} array The array to sample. 4170 * @returns {*} Returns the random element. 4171 */ 4172 function arraySample(array) { 4173 var length = array.length; 4174 return length ? array[baseRandom(0, length - 1)] : undefined; 4175 } 4176 4177 /** 4178 * A specialized version of `_.sampleSize` for arrays. 4179 * 4180 * @private 4181 * @param {Array} array The array to sample. 4182 * @param {number} n The number of elements to sample. 4183 * @returns {Array} Returns the random elements. 4184 */ 4185 function arraySampleSize(array, n) { 4186 return shuffleSelf(copyArray(array), baseClamp(n, 0, array.length)); 4187 } 4188 4189 /** 4190 * A specialized version of `_.shuffle` for arrays. 4191 * 4192 * @private 4193 * @param {Array} array The array to shuffle. 4194 * @returns {Array} Returns the new shuffled array. 4195 */ 4196 function arrayShuffle(array) { 4197 return shuffleSelf(copyArray(array)); 4198 } 4199 4200 /** 4201 * This function is like `assignValue` except that it doesn't assign 4202 * `undefined` values. 4203 * 4204 * @private 4205 * @param {Object} object The object to modify. 4206 * @param {string} key The key of the property to assign. 4207 * @param {*} value The value to assign. 4208 */ 4209 function assignMergeValue(object, key, value) { 4210 if ((value !== undefined && !eq(object[key], value)) || 4211 (value === undefined && !(key in object))) { 4212 baseAssignValue(object, key, value); 4213 } 4214 } 4215 4216 /** 4217 * Assigns `value` to `key` of `object` if the existing value is not equivalent 4218 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 4219 * for equality comparisons. 4220 * 4221 * @private 4222 * @param {Object} object The object to modify. 4223 * @param {string} key The key of the property to assign. 4224 * @param {*} value The value to assign. 4225 */ 4226 function assignValue(object, key, value) { 4227 var objValue = object[key]; 4228 if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) || 4229 (value === undefined && !(key in object))) { 4230 baseAssignValue(object, key, value); 4231 } 4232 } 4233 4234 /** 4235 * Gets the index at which the `key` is found in `array` of key-value pairs. 4236 * 4237 * @private 4238 * @param {Array} array The array to inspect. 4239 * @param {*} key The key to search for. 4240 * @returns {number} Returns the index of the matched value, else `-1`. 4241 */ 4242 function assocIndexOf(array, key) { 4243 var length = array.length; 4244 while (length--) { 4245 if (eq(array[length][0], key)) { 4246 return length; 4247 } 4248 } 4249 return -1; 4250 } 4251 4252 /** 4253 * Aggregates elements of `collection` on `accumulator` with keys transformed 4254 * by `iteratee` and values set by `setter`. 4255 * 4256 * @private 4257 * @param {Array|Object} collection The collection to iterate over. 4258 * @param {Function} setter The function to set `accumulator` values. 4259 * @param {Function} iteratee The iteratee to transform keys. 4260 * @param {Object} accumulator The initial aggregated object. 4261 * @returns {Function} Returns `accumulator`. 4262 */ 4263 function baseAggregator(collection, setter, iteratee, accumulator) { 4264 baseEach(collection, function(value, key, collection) { 4265 setter(accumulator, value, iteratee(value), collection); 4266 }); 4267 return accumulator; 4268 } 4269 4270 /** 4271 * The base implementation of `_.assign` without support for multiple sources 4272 * or `customizer` functions. 4273 * 4274 * @private 4275 * @param {Object} object The destination object. 4276 * @param {Object} source The source object. 4277 * @returns {Object} Returns `object`. 4278 */ 4279 function baseAssign(object, source) { 4280 return object && copyObject(source, keys(source), object); 4281 } 4282 4283 /** 4284 * The base implementation of `_.assignIn` without support for multiple sources 4285 * or `customizer` functions. 4286 * 4287 * @private 4288 * @param {Object} object The destination object. 4289 * @param {Object} source The source object. 4290 * @returns {Object} Returns `object`. 4291 */ 4292 function baseAssignIn(object, source) { 4293 return object && copyObject(source, keysIn(source), object); 4294 } 4295 4296 /** 4297 * The base implementation of `assignValue` and `assignMergeValue` without 4298 * value checks. 4299 * 4300 * @private 4301 * @param {Object} object The object to modify. 4302 * @param {string} key The key of the property to assign. 4303 * @param {*} value The value to assign. 4304 */ 4305 function baseAssignValue(object, key, value) { 4306 if (key == '__proto__' && defineProperty) { 4307 defineProperty(object, key, { 4308 'configurable': true, 4309 'enumerable': true, 4310 'value': value, 4311 'writable': true 4312 }); 4313 } else { 4314 object[key] = value; 4315 } 4316 } 4317 4318 /** 4319 * The base implementation of `_.at` without support for individual paths. 4320 * 4321 * @private 4322 * @param {Object} object The object to iterate over. 4323 * @param {string[]} paths The property paths to pick. 4324 * @returns {Array} Returns the picked elements. 4325 */ 4326 function baseAt(object, paths) { 4327 var index = -1, 4328 length = paths.length, 4329 result = Array(length), 4330 skip = object == null; 4331 4332 while (++index < length) { 4333 result[index] = skip ? undefined : get(object, paths[index]); 4334 } 4335 return result; 4336 } 4337 4338 /** 4339 * The base implementation of `_.clamp` which doesn't coerce arguments. 4340 * 4341 * @private 4342 * @param {number} number The number to clamp. 4343 * @param {number} [lower] The lower bound. 4344 * @param {number} upper The upper bound. 4345 * @returns {number} Returns the clamped number. 4346 */ 4347 function baseClamp(number, lower, upper) { 4348 if (number === number) { 4349 if (upper !== undefined) { 4350 number = number <= upper ? number : upper; 4351 } 4352 if (lower !== undefined) { 4353 number = number >= lower ? number : lower; 4354 } 4355 } 4356 return number; 4357 } 4358 4359 /** 4360 * The base implementation of `_.clone` and `_.cloneDeep` which tracks 4361 * traversed objects. 4362 * 4363 * @private 4364 * @param {*} value The value to clone. 4365 * @param {boolean} bitmask The bitmask flags. 4366 * 1 - Deep clone 4367 * 2 - Flatten inherited properties 4368 * 4 - Clone symbols 4369 * @param {Function} [customizer] The function to customize cloning. 4370 * @param {string} [key] The key of `value`. 4371 * @param {Object} [object] The parent object of `value`. 4372 * @param {Object} [stack] Tracks traversed objects and their clone counterparts. 4373 * @returns {*} Returns the cloned value. 4374 */ 4375 function baseClone(value, bitmask, customizer, key, object, stack) { 4376 var result, 4377 isDeep = bitmask & CLONE_DEEP_FLAG, 4378 isFlat = bitmask & CLONE_FLAT_FLAG, 4379 isFull = bitmask & CLONE_SYMBOLS_FLAG; 4380 4381 if (customizer) { 4382 result = object ? customizer(value, key, object, stack) : customizer(value); 4383 } 4384 if (result !== undefined) { 4385 return result; 4386 } 4387 if (!isObject(value)) { 4388 return value; 4389 } 4390 var isArr = isArray(value); 4391 if (isArr) { 4392 result = initCloneArray(value); 4393 if (!isDeep) { 4394 return copyArray(value, result); 4395 } 4396 } else { 4397 var tag = getTag(value), 4398 isFunc = tag == funcTag || tag == genTag; 4399 4400 if (isBuffer(value)) { 4401 return cloneBuffer(value, isDeep); 4402 } 4403 if (tag == objectTag || tag == argsTag || (isFunc && !object)) { 4404 result = (isFlat || isFunc) ? {} : initCloneObject(value); 4405 if (!isDeep) { 4406 return isFlat 4407 ? copySymbolsIn(value, baseAssignIn(result, value)) 4408 : copySymbols(value, baseAssign(result, value)); 4409 } 4410 } else { 4411 if (!cloneableTags[tag]) { 4412 return object ? value : {}; 4413 } 4414 result = initCloneByTag(value, tag, isDeep); 4415 } 4416 } 4417 // Check for circular references and return its corresponding clone. 4418 stack || (stack = new Stack); 4419 var stacked = stack.get(value); 4420 if (stacked) { 4421 return stacked; 4422 } 4423 stack.set(value, result); 4424 4425 if (isSet(value)) { 4426 value.forEach(function(subValue) { 4427 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); 4428 }); 4429 } else if (isMap(value)) { 4430 value.forEach(function(subValue, key) { 4431 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); 4432 }); 4433 } 4434 4435 var keysFunc = isFull 4436 ? (isFlat ? getAllKeysIn : getAllKeys) 4437 : (isFlat ? keysIn : keys); 4438 4439 var props = isArr ? undefined : keysFunc(value); 4440 arrayEach(props || value, function(subValue, key) { 4441 if (props) { 4442 key = subValue; 4443 subValue = value[key]; 4444 } 4445 // Recursively populate clone (susceptible to call stack limits). 4446 assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); 4447 }); 4448 return result; 4449 } 4450 4451 /** 4452 * The base implementation of `_.conforms` which doesn't clone `source`. 4453 * 4454 * @private 4455 * @param {Object} source The object of property predicates to conform to. 4456 * @returns {Function} Returns the new spec function. 4457 */ 4458 function baseConforms(source) { 4459 var props = keys(source); 4460 return function(object) { 4461 return baseConformsTo(object, source, props); 4462 }; 4463 } 4464 4465 /** 4466 * The base implementation of `_.conformsTo` which accepts `props` to check. 4467 * 4468 * @private 4469 * @param {Object} object The object to inspect. 4470 * @param {Object} source The object of property predicates to conform to. 4471 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 4472 */ 4473 function baseConformsTo(object, source, props) { 4474 var length = props.length; 4475 if (object == null) { 4476 return !length; 4477 } 4478 object = Object(object); 4479 while (length--) { 4480 var key = props[length], 4481 predicate = source[key], 4482 value = object[key]; 4483 4484 if ((value === undefined && !(key in object)) || !predicate(value)) { 4485 return false; 4486 } 4487 } 4488 return true; 4489 } 4490 4491 /** 4492 * The base implementation of `_.delay` and `_.defer` which accepts `args` 4493 * to provide to `func`. 4494 * 4495 * @private 4496 * @param {Function} func The function to delay. 4497 * @param {number} wait The number of milliseconds to delay invocation. 4498 * @param {Array} args The arguments to provide to `func`. 4499 * @returns {number|Object} Returns the timer id or timeout object. 4500 */ 4501 function baseDelay(func, wait, args) { 4502 if (typeof func != 'function') { 4503 throw new TypeError(FUNC_ERROR_TEXT); 4504 } 4505 return setTimeout(function() { func.apply(undefined, args); }, wait); 4506 } 4507 4508 /** 4509 * The base implementation of methods like `_.difference` without support 4510 * for excluding multiple arrays or iteratee shorthands. 4511 * 4512 * @private 4513 * @param {Array} array The array to inspect. 4514 * @param {Array} values The values to exclude. 4515 * @param {Function} [iteratee] The iteratee invoked per element. 4516 * @param {Function} [comparator] The comparator invoked per element. 4517 * @returns {Array} Returns the new array of filtered values. 4518 */ 4519 function baseDifference(array, values, iteratee, comparator) { 4520 var index = -1, 4521 includes = arrayIncludes, 4522 isCommon = true, 4523 length = array.length, 4524 result = [], 4525 valuesLength = values.length; 4526 4527 if (!length) { 4528 return result; 4529 } 4530 if (iteratee) { 4531 values = arrayMap(values, baseUnary(iteratee)); 4532 } 4533 if (comparator) { 4534 includes = arrayIncludesWith; 4535 isCommon = false; 4536 } 4537 else if (values.length >= LARGE_ARRAY_SIZE) { 4538 includes = cacheHas; 4539 isCommon = false; 4540 values = new SetCache(values); 4541 } 4542 outer: 4543 while (++index < length) { 4544 var value = array[index], 4545 computed = iteratee == null ? value : iteratee(value); 4546 4547 value = (comparator || value !== 0) ? value : 0; 4548 if (isCommon && computed === computed) { 4549 var valuesIndex = valuesLength; 4550 while (valuesIndex--) { 4551 if (values[valuesIndex] === computed) { 4552 continue outer; 4553 } 4554 } 4555 result.push(value); 4556 } 4557 else if (!includes(values, computed, comparator)) { 4558 result.push(value); 4559 } 4560 } 4561 return result; 4562 } 4563 4564 /** 4565 * The base implementation of `_.forEach` without support for iteratee shorthands. 4566 * 4567 * @private 4568 * @param {Array|Object} collection The collection to iterate over. 4569 * @param {Function} iteratee The function invoked per iteration. 4570 * @returns {Array|Object} Returns `collection`. 4571 */ 4572 var baseEach = createBaseEach(baseForOwn); 4573 4574 /** 4575 * The base implementation of `_.forEachRight` without support for iteratee shorthands. 4576 * 4577 * @private 4578 * @param {Array|Object} collection The collection to iterate over. 4579 * @param {Function} iteratee The function invoked per iteration. 4580 * @returns {Array|Object} Returns `collection`. 4581 */ 4582 var baseEachRight = createBaseEach(baseForOwnRight, true); 4583 4584 /** 4585 * The base implementation of `_.every` without support for iteratee shorthands. 4586 * 4587 * @private 4588 * @param {Array|Object} collection The collection to iterate over. 4589 * @param {Function} predicate The function invoked per iteration. 4590 * @returns {boolean} Returns `true` if all elements pass the predicate check, 4591 * else `false` 4592 */ 4593 function baseEvery(collection, predicate) { 4594 var result = true; 4595 baseEach(collection, function(value, index, collection) { 4596 result = !!predicate(value, index, collection); 4597 return result; 4598 }); 4599 return result; 4600 } 4601 4602 /** 4603 * The base implementation of methods like `_.max` and `_.min` which accepts a 4604 * `comparator` to determine the extremum value. 4605 * 4606 * @private 4607 * @param {Array} array The array to iterate over. 4608 * @param {Function} iteratee The iteratee invoked per iteration. 4609 * @param {Function} comparator The comparator used to compare values. 4610 * @returns {*} Returns the extremum value. 4611 */ 4612 function baseExtremum(array, iteratee, comparator) { 4613 var index = -1, 4614 length = array.length; 4615 4616 while (++index < length) { 4617 var value = array[index], 4618 current = iteratee(value); 4619 4620 if (current != null && (computed === undefined 4621 ? (current === current && !isSymbol(current)) 4622 : comparator(current, computed) 4623 )) { 4624 var computed = current, 4625 result = value; 4626 } 4627 } 4628 return result; 4629 } 4630 4631 /** 4632 * The base implementation of `_.fill` without an iteratee call guard. 4633 * 4634 * @private 4635 * @param {Array} array The array to fill. 4636 * @param {*} value The value to fill `array` with. 4637 * @param {number} [start=0] The start position. 4638 * @param {number} [end=array.length] The end position. 4639 * @returns {Array} Returns `array`. 4640 */ 4641 function baseFill(array, value, start, end) { 4642 var length = array.length; 4643 4644 start = toInteger(start); 4645 if (start < 0) { 4646 start = -start > length ? 0 : (length + start); 4647 } 4648 end = (end === undefined || end > length) ? length : toInteger(end); 4649 if (end < 0) { 4650 end += length; 4651 } 4652 end = start > end ? 0 : toLength(end); 4653 while (start < end) { 4654 array[start++] = value; 4655 } 4656 return array; 4657 } 4658 4659 /** 4660 * The base implementation of `_.filter` without support for iteratee shorthands. 4661 * 4662 * @private 4663 * @param {Array|Object} collection The collection to iterate over. 4664 * @param {Function} predicate The function invoked per iteration. 4665 * @returns {Array} Returns the new filtered array. 4666 */ 4667 function baseFilter(collection, predicate) { 4668 var result = []; 4669 baseEach(collection, function(value, index, collection) { 4670 if (predicate(value, index, collection)) { 4671 result.push(value); 4672 } 4673 }); 4674 return result; 4675 } 4676 4677 /** 4678 * The base implementation of `_.flatten` with support for restricting flattening. 4679 * 4680 * @private 4681 * @param {Array} array The array to flatten. 4682 * @param {number} depth The maximum recursion depth. 4683 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration. 4684 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks. 4685 * @param {Array} [result=[]] The initial result value. 4686 * @returns {Array} Returns the new flattened array. 4687 */ 4688 function baseFlatten(array, depth, predicate, isStrict, result) { 4689 var index = -1, 4690 length = array.length; 4691 4692 predicate || (predicate = isFlattenable); 4693 result || (result = []); 4694 4695 while (++index < length) { 4696 var value = array[index]; 4697 if (depth > 0 && predicate(value)) { 4698 if (depth > 1) { 4699 // Recursively flatten arrays (susceptible to call stack limits). 4700 baseFlatten(value, depth - 1, predicate, isStrict, result); 4701 } else { 4702 arrayPush(result, value); 4703 } 4704 } else if (!isStrict) { 4705 result[result.length] = value; 4706 } 4707 } 4708 return result; 4709 } 4710 4711 /** 4712 * The base implementation of `baseForOwn` which iterates over `object` 4713 * properties returned by `keysFunc` and invokes `iteratee` for each property. 4714 * Iteratee functions may exit iteration early by explicitly returning `false`. 4715 * 4716 * @private 4717 * @param {Object} object The object to iterate over. 4718 * @param {Function} iteratee The function invoked per iteration. 4719 * @param {Function} keysFunc The function to get the keys of `object`. 4720 * @returns {Object} Returns `object`. 4721 */ 4722 var baseFor = createBaseFor(); 4723 4724 /** 4725 * This function is like `baseFor` except that it iterates over properties 4726 * in the opposite order. 4727 * 4728 * @private 4729 * @param {Object} object The object to iterate over. 4730 * @param {Function} iteratee The function invoked per iteration. 4731 * @param {Function} keysFunc The function to get the keys of `object`. 4732 * @returns {Object} Returns `object`. 4733 */ 4734 var baseForRight = createBaseFor(true); 4735 4736 /** 4737 * The base implementation of `_.forOwn` without support for iteratee shorthands. 4738 * 4739 * @private 4740 * @param {Object} object The object to iterate over. 4741 * @param {Function} iteratee The function invoked per iteration. 4742 * @returns {Object} Returns `object`. 4743 */ 4744 function baseForOwn(object, iteratee) { 4745 return object && baseFor(object, iteratee, keys); 4746 } 4747 4748 /** 4749 * The base implementation of `_.forOwnRight` without support for iteratee shorthands. 4750 * 4751 * @private 4752 * @param {Object} object The object to iterate over. 4753 * @param {Function} iteratee The function invoked per iteration. 4754 * @returns {Object} Returns `object`. 4755 */ 4756 function baseForOwnRight(object, iteratee) { 4757 return object && baseForRight(object, iteratee, keys); 4758 } 4759 4760 /** 4761 * The base implementation of `_.functions` which creates an array of 4762 * `object` function property names filtered from `props`. 4763 * 4764 * @private 4765 * @param {Object} object The object to inspect. 4766 * @param {Array} props The property names to filter. 4767 * @returns {Array} Returns the function names. 4768 */ 4769 function baseFunctions(object, props) { 4770 return arrayFilter(props, function(key) { 4771 return isFunction(object[key]); 4772 }); 4773 } 4774 4775 /** 4776 * The base implementation of `_.get` without support for default values. 4777 * 4778 * @private 4779 * @param {Object} object The object to query. 4780 * @param {Array|string} path The path of the property to get. 4781 * @returns {*} Returns the resolved value. 4782 */ 4783 function baseGet(object, path) { 4784 path = castPath(path, object); 4785 4786 var index = 0, 4787 length = path.length; 4788 4789 while (object != null && index < length) { 4790 object = object[toKey(path[index++])]; 4791 } 4792 return (index && index == length) ? object : undefined; 4793 } 4794 4795 /** 4796 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses 4797 * `keysFunc` and `symbolsFunc` to get the enumerable property names and 4798 * symbols of `object`. 4799 * 4800 * @private 4801 * @param {Object} object The object to query. 4802 * @param {Function} keysFunc The function to get the keys of `object`. 4803 * @param {Function} symbolsFunc The function to get the symbols of `object`. 4804 * @returns {Array} Returns the array of property names and symbols. 4805 */ 4806 function baseGetAllKeys(object, keysFunc, symbolsFunc) { 4807 var result = keysFunc(object); 4808 return isArray(object) ? result : arrayPush(result, symbolsFunc(object)); 4809 } 4810 4811 /** 4812 * The base implementation of `getTag` without fallbacks for buggy environments. 4813 * 4814 * @private 4815 * @param {*} value The value to query. 4816 * @returns {string} Returns the `toStringTag`. 4817 */ 4818 function baseGetTag(value) { 4819 if (value == null) { 4820 return value === undefined ? undefinedTag : nullTag; 4821 } 4822 return (symToStringTag && symToStringTag in Object(value)) 4823 ? getRawTag(value) 4824 : objectToString(value); 4825 } 4826 4827 /** 4828 * The base implementation of `_.gt` which doesn't coerce arguments. 4829 * 4830 * @private 4831 * @param {*} value The value to compare. 4832 * @param {*} other The other value to compare. 4833 * @returns {boolean} Returns `true` if `value` is greater than `other`, 4834 * else `false`. 4835 */ 4836 function baseGt(value, other) { 4837 return value > other; 4838 } 4839 4840 /** 4841 * The base implementation of `_.has` without support for deep paths. 4842 * 4843 * @private 4844 * @param {Object} [object] The object to query. 4845 * @param {Array|string} key The key to check. 4846 * @returns {boolean} Returns `true` if `key` exists, else `false`. 4847 */ 4848 function baseHas(object, key) { 4849 return object != null && hasOwnProperty.call(object, key); 4850 } 4851 4852 /** 4853 * The base implementation of `_.hasIn` without support for deep paths. 4854 * 4855 * @private 4856 * @param {Object} [object] The object to query. 4857 * @param {Array|string} key The key to check. 4858 * @returns {boolean} Returns `true` if `key` exists, else `false`. 4859 */ 4860 function baseHasIn(object, key) { 4861 return object != null && key in Object(object); 4862 } 4863 4864 /** 4865 * The base implementation of `_.inRange` which doesn't coerce arguments. 4866 * 4867 * @private 4868 * @param {number} number The number to check. 4869 * @param {number} start The start of the range. 4870 * @param {number} end The end of the range. 4871 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 4872 */ 4873 function baseInRange(number, start, end) { 4874 return number >= nativeMin(start, end) && number < nativeMax(start, end); 4875 } 4876 4877 /** 4878 * The base implementation of methods like `_.intersection`, without support 4879 * for iteratee shorthands, that accepts an array of arrays to inspect. 4880 * 4881 * @private 4882 * @param {Array} arrays The arrays to inspect. 4883 * @param {Function} [iteratee] The iteratee invoked per element. 4884 * @param {Function} [comparator] The comparator invoked per element. 4885 * @returns {Array} Returns the new array of shared values. 4886 */ 4887 function baseIntersection(arrays, iteratee, comparator) { 4888 var includes = comparator ? arrayIncludesWith : arrayIncludes, 4889 length = arrays[0].length, 4890 othLength = arrays.length, 4891 othIndex = othLength, 4892 caches = Array(othLength), 4893 maxLength = Infinity, 4894 result = []; 4895 4896 while (othIndex--) { 4897 var array = arrays[othIndex]; 4898 if (othIndex && iteratee) { 4899 array = arrayMap(array, baseUnary(iteratee)); 4900 } 4901 maxLength = nativeMin(array.length, maxLength); 4902 caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120)) 4903 ? new SetCache(othIndex && array) 4904 : undefined; 4905 } 4906 array = arrays[0]; 4907 4908 var index = -1, 4909 seen = caches[0]; 4910 4911 outer: 4912 while (++index < length && result.length < maxLength) { 4913 var value = array[index], 4914 computed = iteratee ? iteratee(value) : value; 4915 4916 value = (comparator || value !== 0) ? value : 0; 4917 if (!(seen 4918 ? cacheHas(seen, computed) 4919 : includes(result, computed, comparator) 4920 )) { 4921 othIndex = othLength; 4922 while (--othIndex) { 4923 var cache = caches[othIndex]; 4924 if (!(cache 4925 ? cacheHas(cache, computed) 4926 : includes(arrays[othIndex], computed, comparator)) 4927 ) { 4928 continue outer; 4929 } 4930 } 4931 if (seen) { 4932 seen.push(computed); 4933 } 4934 result.push(value); 4935 } 4936 } 4937 return result; 4938 } 4939 4940 /** 4941 * The base implementation of `_.invert` and `_.invertBy` which inverts 4942 * `object` with values transformed by `iteratee` and set by `setter`. 4943 * 4944 * @private 4945 * @param {Object} object The object to iterate over. 4946 * @param {Function} setter The function to set `accumulator` values. 4947 * @param {Function} iteratee The iteratee to transform values. 4948 * @param {Object} accumulator The initial inverted object. 4949 * @returns {Function} Returns `accumulator`. 4950 */ 4951 function baseInverter(object, setter, iteratee, accumulator) { 4952 baseForOwn(object, function(value, key, object) { 4953 setter(accumulator, iteratee(value), key, object); 4954 }); 4955 return accumulator; 4956 } 4957 4958 /** 4959 * The base implementation of `_.invoke` without support for individual 4960 * method arguments. 4961 * 4962 * @private 4963 * @param {Object} object The object to query. 4964 * @param {Array|string} path The path of the method to invoke. 4965 * @param {Array} args The arguments to invoke the method with. 4966 * @returns {*} Returns the result of the invoked method. 4967 */ 4968 function baseInvoke(object, path, args) { 4969 path = castPath(path, object); 4970 object = parent(object, path); 4971 var func = object == null ? object : object[toKey(last(path))]; 4972 return func == null ? undefined : apply(func, object, args); 4973 } 4974 4975 /** 4976 * The base implementation of `_.isArguments`. 4977 * 4978 * @private 4979 * @param {*} value The value to check. 4980 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 4981 */ 4982 function baseIsArguments(value) { 4983 return isObjectLike(value) && baseGetTag(value) == argsTag; 4984 } 4985 4986 /** 4987 * The base implementation of `_.isArrayBuffer` without Node.js optimizations. 4988 * 4989 * @private 4990 * @param {*} value The value to check. 4991 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 4992 */ 4993 function baseIsArrayBuffer(value) { 4994 return isObjectLike(value) && baseGetTag(value) == arrayBufferTag; 4995 } 4996 4997 /** 4998 * The base implementation of `_.isDate` without Node.js optimizations. 4999 * 5000 * @private 5001 * @param {*} value The value to check. 5002 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 5003 */ 5004 function baseIsDate(value) { 5005 return isObjectLike(value) && baseGetTag(value) == dateTag; 5006 } 5007 5008 /** 5009 * The base implementation of `_.isEqual` which supports partial comparisons 5010 * and tracks traversed objects. 5011 * 5012 * @private 5013 * @param {*} value The value to compare. 5014 * @param {*} other The other value to compare. 5015 * @param {boolean} bitmask The bitmask flags. 5016 * 1 - Unordered comparison 5017 * 2 - Partial comparison 5018 * @param {Function} [customizer] The function to customize comparisons. 5019 * @param {Object} [stack] Tracks traversed `value` and `other` objects. 5020 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 5021 */ 5022 function baseIsEqual(value, other, bitmask, customizer, stack) { 5023 if (value === other) { 5024 return true; 5025 } 5026 if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) { 5027 return value !== value && other !== other; 5028 } 5029 return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); 5030 } 5031 5032 /** 5033 * A specialized version of `baseIsEqual` for arrays and objects which performs 5034 * deep comparisons and tracks traversed objects enabling objects with circular 5035 * references to be compared. 5036 * 5037 * @private 5038 * @param {Object} object The object to compare. 5039 * @param {Object} other The other object to compare. 5040 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 5041 * @param {Function} customizer The function to customize comparisons. 5042 * @param {Function} equalFunc The function to determine equivalents of values. 5043 * @param {Object} [stack] Tracks traversed `object` and `other` objects. 5044 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 5045 */ 5046 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { 5047 var objIsArr = isArray(object), 5048 othIsArr = isArray(other), 5049 objTag = objIsArr ? arrayTag : getTag(object), 5050 othTag = othIsArr ? arrayTag : getTag(other); 5051 5052 objTag = objTag == argsTag ? objectTag : objTag; 5053 othTag = othTag == argsTag ? objectTag : othTag; 5054 5055 var objIsObj = objTag == objectTag, 5056 othIsObj = othTag == objectTag, 5057 isSameTag = objTag == othTag; 5058 5059 if (isSameTag && isBuffer(object)) { 5060 if (!isBuffer(other)) { 5061 return false; 5062 } 5063 objIsArr = true; 5064 objIsObj = false; 5065 } 5066 if (isSameTag && !objIsObj) { 5067 stack || (stack = new Stack); 5068 return (objIsArr || isTypedArray(object)) 5069 ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) 5070 : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); 5071 } 5072 if (!(bitmask & COMPARE_PARTIAL_FLAG)) { 5073 var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), 5074 othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); 5075 5076 if (objIsWrapped || othIsWrapped) { 5077 var objUnwrapped = objIsWrapped ? object.value() : object, 5078 othUnwrapped = othIsWrapped ? other.value() : other; 5079 5080 stack || (stack = new Stack); 5081 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); 5082 } 5083 } 5084 if (!isSameTag) { 5085 return false; 5086 } 5087 stack || (stack = new Stack); 5088 return equalObjects(object, other, bitmask, customizer, equalFunc, stack); 5089 } 5090 5091 /** 5092 * The base implementation of `_.isMap` without Node.js optimizations. 5093 * 5094 * @private 5095 * @param {*} value The value to check. 5096 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 5097 */ 5098 function baseIsMap(value) { 5099 return isObjectLike(value) && getTag(value) == mapTag; 5100 } 5101 5102 /** 5103 * The base implementation of `_.isMatch` without support for iteratee shorthands. 5104 * 5105 * @private 5106 * @param {Object} object The object to inspect. 5107 * @param {Object} source The object of property values to match. 5108 * @param {Array} matchData The property names, values, and compare flags to match. 5109 * @param {Function} [customizer] The function to customize comparisons. 5110 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 5111 */ 5112 function baseIsMatch(object, source, matchData, customizer) { 5113 var index = matchData.length, 5114 length = index, 5115 noCustomizer = !customizer; 5116 5117 if (object == null) { 5118 return !length; 5119 } 5120 object = Object(object); 5121 while (index--) { 5122 var data = matchData[index]; 5123 if ((noCustomizer && data[2]) 5124 ? data[1] !== object[data[0]] 5125 : !(data[0] in object) 5126 ) { 5127 return false; 5128 } 5129 } 5130 while (++index < length) { 5131 data = matchData[index]; 5132 var key = data[0], 5133 objValue = object[key], 5134 srcValue = data[1]; 5135 5136 if (noCustomizer && data[2]) { 5137 if (objValue === undefined && !(key in object)) { 5138 return false; 5139 } 5140 } else { 5141 var stack = new Stack; 5142 if (customizer) { 5143 var result = customizer(objValue, srcValue, key, object, source, stack); 5144 } 5145 if (!(result === undefined 5146 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG, customizer, stack) 5147 : result 5148 )) { 5149 return false; 5150 } 5151 } 5152 } 5153 return true; 5154 } 5155 5156 /** 5157 * The base implementation of `_.isNative` without bad shim checks. 5158 * 5159 * @private 5160 * @param {*} value The value to check. 5161 * @returns {boolean} Returns `true` if `value` is a native function, 5162 * else `false`. 5163 */ 5164 function baseIsNative(value) { 5165 if (!isObject(value) || isMasked(value)) { 5166 return false; 5167 } 5168 var pattern = isFunction(value) ? reIsNative : reIsHostCtor; 5169 return pattern.test(toSource(value)); 5170 } 5171 5172 /** 5173 * The base implementation of `_.isRegExp` without Node.js optimizations. 5174 * 5175 * @private 5176 * @param {*} value The value to check. 5177 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 5178 */ 5179 function baseIsRegExp(value) { 5180 return isObjectLike(value) && baseGetTag(value) == regexpTag; 5181 } 5182 5183 /** 5184 * The base implementation of `_.isSet` without Node.js optimizations. 5185 * 5186 * @private 5187 * @param {*} value The value to check. 5188 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 5189 */ 5190 function baseIsSet(value) { 5191 return isObjectLike(value) && getTag(value) == setTag; 5192 } 5193 5194 /** 5195 * The base implementation of `_.isTypedArray` without Node.js optimizations. 5196 * 5197 * @private 5198 * @param {*} value The value to check. 5199 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 5200 */ 5201 function baseIsTypedArray(value) { 5202 return isObjectLike(value) && 5203 isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; 5204 } 5205 5206 /** 5207 * The base implementation of `_.iteratee`. 5208 * 5209 * @private 5210 * @param {*} [value=_.identity] The value to convert to an iteratee. 5211 * @returns {Function} Returns the iteratee. 5212 */ 5213 function baseIteratee(value) { 5214 // Don't store the `typeof` result in a variable to avoid a JIT bug in Safari 9. 5215 // See https://bugs.webkit.org/show_bug.cgi?id=156034 for more details. 5216 if (typeof value == 'function') { 5217 return value; 5218 } 5219 if (value == null) { 5220 return identity; 5221 } 5222 if (typeof value == 'object') { 5223 return isArray(value) 5224 ? baseMatchesProperty(value[0], value[1]) 5225 : baseMatches(value); 5226 } 5227 return property(value); 5228 } 5229 5230 /** 5231 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. 5232 * 5233 * @private 5234 * @param {Object} object The object to query. 5235 * @returns {Array} Returns the array of property names. 5236 */ 5237 function baseKeys(object) { 5238 if (!isPrototype(object)) { 5239 return nativeKeys(object); 5240 } 5241 var result = []; 5242 for (var key in Object(object)) { 5243 if (hasOwnProperty.call(object, key) && key != 'constructor') { 5244 result.push(key); 5245 } 5246 } 5247 return result; 5248 } 5249 5250 /** 5251 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. 5252 * 5253 * @private 5254 * @param {Object} object The object to query. 5255 * @returns {Array} Returns the array of property names. 5256 */ 5257 function baseKeysIn(object) { 5258 if (!isObject(object)) { 5259 return nativeKeysIn(object); 5260 } 5261 var isProto = isPrototype(object), 5262 result = []; 5263 5264 for (var key in object) { 5265 if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { 5266 result.push(key); 5267 } 5268 } 5269 return result; 5270 } 5271 5272 /** 5273 * The base implementation of `_.lt` which doesn't coerce arguments. 5274 * 5275 * @private 5276 * @param {*} value The value to compare. 5277 * @param {*} other The other value to compare. 5278 * @returns {boolean} Returns `true` if `value` is less than `other`, 5279 * else `false`. 5280 */ 5281 function baseLt(value, other) { 5282 return value < other; 5283 } 5284 5285 /** 5286 * The base implementation of `_.map` without support for iteratee shorthands. 5287 * 5288 * @private 5289 * @param {Array|Object} collection The collection to iterate over. 5290 * @param {Function} iteratee The function invoked per iteration. 5291 * @returns {Array} Returns the new mapped array. 5292 */ 5293 function baseMap(collection, iteratee) { 5294 var index = -1, 5295 result = isArrayLike(collection) ? Array(collection.length) : []; 5296 5297 baseEach(collection, function(value, key, collection) { 5298 result[++index] = iteratee(value, key, collection); 5299 }); 5300 return result; 5301 } 5302 5303 /** 5304 * The base implementation of `_.matches` which doesn't clone `source`. 5305 * 5306 * @private 5307 * @param {Object} source The object of property values to match. 5308 * @returns {Function} Returns the new spec function. 5309 */ 5310 function baseMatches(source) { 5311 var matchData = getMatchData(source); 5312 if (matchData.length == 1 && matchData[0][2]) { 5313 return matchesStrictComparable(matchData[0][0], matchData[0][1]); 5314 } 5315 return function(object) { 5316 return object === source || baseIsMatch(object, source, matchData); 5317 }; 5318 } 5319 5320 /** 5321 * The base implementation of `_.matchesProperty` which doesn't clone `srcValue`. 5322 * 5323 * @private 5324 * @param {string} path The path of the property to get. 5325 * @param {*} srcValue The value to match. 5326 * @returns {Function} Returns the new spec function. 5327 */ 5328 function baseMatchesProperty(path, srcValue) { 5329 if (isKey(path) && isStrictComparable(srcValue)) { 5330 return matchesStrictComparable(toKey(path), srcValue); 5331 } 5332 return function(object) { 5333 var objValue = get(object, path); 5334 return (objValue === undefined && objValue === srcValue) 5335 ? hasIn(object, path) 5336 : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG); 5337 }; 5338 } 5339 5340 /** 5341 * The base implementation of `_.merge` without support for multiple sources. 5342 * 5343 * @private 5344 * @param {Object} object The destination object. 5345 * @param {Object} source The source object. 5346 * @param {number} srcIndex The index of `source`. 5347 * @param {Function} [customizer] The function to customize merged values. 5348 * @param {Object} [stack] Tracks traversed source values and their merged 5349 * counterparts. 5350 */ 5351 function baseMerge(object, source, srcIndex, customizer, stack) { 5352 if (object === source) { 5353 return; 5354 } 5355 baseFor(source, function(srcValue, key) { 5356 stack || (stack = new Stack); 5357 if (isObject(srcValue)) { 5358 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); 5359 } 5360 else { 5361 var newValue = customizer 5362 ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack) 5363 : undefined; 5364 5365 if (newValue === undefined) { 5366 newValue = srcValue; 5367 } 5368 assignMergeValue(object, key, newValue); 5369 } 5370 }, keysIn); 5371 } 5372 5373 /** 5374 * A specialized version of `baseMerge` for arrays and objects which performs 5375 * deep merges and tracks traversed objects enabling objects with circular 5376 * references to be merged. 5377 * 5378 * @private 5379 * @param {Object} object The destination object. 5380 * @param {Object} source The source object. 5381 * @param {string} key The key of the value to merge. 5382 * @param {number} srcIndex The index of `source`. 5383 * @param {Function} mergeFunc The function to merge values. 5384 * @param {Function} [customizer] The function to customize assigned values. 5385 * @param {Object} [stack] Tracks traversed source values and their merged 5386 * counterparts. 5387 */ 5388 function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { 5389 var objValue = safeGet(object, key), 5390 srcValue = safeGet(source, key), 5391 stacked = stack.get(srcValue); 5392 5393 if (stacked) { 5394 assignMergeValue(object, key, stacked); 5395 return; 5396 } 5397 var newValue = customizer 5398 ? customizer(objValue, srcValue, (key + ''), object, source, stack) 5399 : undefined; 5400 5401 var isCommon = newValue === undefined; 5402 5403 if (isCommon) { 5404 var isArr = isArray(srcValue), 5405 isBuff = !isArr && isBuffer(srcValue), 5406 isTyped = !isArr && !isBuff && isTypedArray(srcValue); 5407 5408 newValue = srcValue; 5409 if (isArr || isBuff || isTyped) { 5410 if (isArray(objValue)) { 5411 newValue = objValue; 5412 } 5413 else if (isArrayLikeObject(objValue)) { 5414 newValue = copyArray(objValue); 5415 } 5416 else if (isBuff) { 5417 isCommon = false; 5418 newValue = cloneBuffer(srcValue, true); 5419 } 5420 else if (isTyped) { 5421 isCommon = false; 5422 newValue = cloneTypedArray(srcValue, true); 5423 } 5424 else { 5425 newValue = []; 5426 } 5427 } 5428 else if (isPlainObject(srcValue) || isArguments(srcValue)) { 5429 newValue = objValue; 5430 if (isArguments(objValue)) { 5431 newValue = toPlainObject(objValue); 5432 } 5433 else if (!isObject(objValue) || isFunction(objValue)) { 5434 newValue = initCloneObject(srcValue); 5435 } 5436 } 5437 else { 5438 isCommon = false; 5439 } 5440 } 5441 if (isCommon) { 5442 // Recursively merge objects and arrays (susceptible to call stack limits). 5443 stack.set(srcValue, newValue); 5444 mergeFunc(newValue, srcValue, srcIndex, customizer, stack); 5445 stack['delete'](srcValue); 5446 } 5447 assignMergeValue(object, key, newValue); 5448 } 5449 5450 /** 5451 * The base implementation of `_.nth` which doesn't coerce arguments. 5452 * 5453 * @private 5454 * @param {Array} array The array to query. 5455 * @param {number} n The index of the element to return. 5456 * @returns {*} Returns the nth element of `array`. 5457 */ 5458 function baseNth(array, n) { 5459 var length = array.length; 5460 if (!length) { 5461 return; 5462 } 5463 n += n < 0 ? length : 0; 5464 return isIndex(n, length) ? array[n] : undefined; 5465 } 5466 5467 /** 5468 * The base implementation of `_.orderBy` without param guards. 5469 * 5470 * @private 5471 * @param {Array|Object} collection The collection to iterate over. 5472 * @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. 5473 * @param {string[]} orders The sort orders of `iteratees`. 5474 * @returns {Array} Returns the new sorted array. 5475 */ 5476 function baseOrderBy(collection, iteratees, orders) { 5477 if (iteratees.length) { 5478 iteratees = arrayMap(iteratees, function(iteratee) { 5479 if (isArray(iteratee)) { 5480 return function(value) { 5481 return baseGet(value, iteratee.length === 1 ? iteratee[0] : iteratee); 5482 } 5483 } 5484 return iteratee; 5485 }); 5486 } else { 5487 iteratees = [identity]; 5488 } 5489 5490 var index = -1; 5491 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 5492 5493 var result = baseMap(collection, function(value, key, collection) { 5494 var criteria = arrayMap(iteratees, function(iteratee) { 5495 return iteratee(value); 5496 }); 5497 return { 'criteria': criteria, 'index': ++index, 'value': value }; 5498 }); 5499 5500 return baseSortBy(result, function(object, other) { 5501 return compareMultiple(object, other, orders); 5502 }); 5503 } 5504 5505 /** 5506 * The base implementation of `_.pick` without support for individual 5507 * property identifiers. 5508 * 5509 * @private 5510 * @param {Object} object The source object. 5511 * @param {string[]} paths The property paths to pick. 5512 * @returns {Object} Returns the new object. 5513 */ 5514 function basePick(object, paths) { 5515 return basePickBy(object, paths, function(value, path) { 5516 return hasIn(object, path); 5517 }); 5518 } 5519 5520 /** 5521 * The base implementation of `_.pickBy` without support for iteratee shorthands. 5522 * 5523 * @private 5524 * @param {Object} object The source object. 5525 * @param {string[]} paths The property paths to pick. 5526 * @param {Function} predicate The function invoked per property. 5527 * @returns {Object} Returns the new object. 5528 */ 5529 function basePickBy(object, paths, predicate) { 5530 var index = -1, 5531 length = paths.length, 5532 result = {}; 5533 5534 while (++index < length) { 5535 var path = paths[index], 5536 value = baseGet(object, path); 5537 5538 if (predicate(value, path)) { 5539 baseSet(result, castPath(path, object), value); 5540 } 5541 } 5542 return result; 5543 } 5544 5545 /** 5546 * A specialized version of `baseProperty` which supports deep paths. 5547 * 5548 * @private 5549 * @param {Array|string} path The path of the property to get. 5550 * @returns {Function} Returns the new accessor function. 5551 */ 5552 function basePropertyDeep(path) { 5553 return function(object) { 5554 return baseGet(object, path); 5555 }; 5556 } 5557 5558 /** 5559 * The base implementation of `_.pullAllBy` without support for iteratee 5560 * shorthands. 5561 * 5562 * @private 5563 * @param {Array} array The array to modify. 5564 * @param {Array} values The values to remove. 5565 * @param {Function} [iteratee] The iteratee invoked per element. 5566 * @param {Function} [comparator] The comparator invoked per element. 5567 * @returns {Array} Returns `array`. 5568 */ 5569 function basePullAll(array, values, iteratee, comparator) { 5570 var indexOf = comparator ? baseIndexOfWith : baseIndexOf, 5571 index = -1, 5572 length = values.length, 5573 seen = array; 5574 5575 if (array === values) { 5576 values = copyArray(values); 5577 } 5578 if (iteratee) { 5579 seen = arrayMap(array, baseUnary(iteratee)); 5580 } 5581 while (++index < length) { 5582 var fromIndex = 0, 5583 value = values[index], 5584 computed = iteratee ? iteratee(value) : value; 5585 5586 while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) { 5587 if (seen !== array) { 5588 splice.call(seen, fromIndex, 1); 5589 } 5590 splice.call(array, fromIndex, 1); 5591 } 5592 } 5593 return array; 5594 } 5595 5596 /** 5597 * The base implementation of `_.pullAt` without support for individual 5598 * indexes or capturing the removed elements. 5599 * 5600 * @private 5601 * @param {Array} array The array to modify. 5602 * @param {number[]} indexes The indexes of elements to remove. 5603 * @returns {Array} Returns `array`. 5604 */ 5605 function basePullAt(array, indexes) { 5606 var length = array ? indexes.length : 0, 5607 lastIndex = length - 1; 5608 5609 while (length--) { 5610 var index = indexes[length]; 5611 if (length == lastIndex || index !== previous) { 5612 var previous = index; 5613 if (isIndex(index)) { 5614 splice.call(array, index, 1); 5615 } else { 5616 baseUnset(array, index); 5617 } 5618 } 5619 } 5620 return array; 5621 } 5622 5623 /** 5624 * The base implementation of `_.random` without support for returning 5625 * floating-point numbers. 5626 * 5627 * @private 5628 * @param {number} lower The lower bound. 5629 * @param {number} upper The upper bound. 5630 * @returns {number} Returns the random number. 5631 */ 5632 function baseRandom(lower, upper) { 5633 return lower + nativeFloor(nativeRandom() * (upper - lower + 1)); 5634 } 5635 5636 /** 5637 * The base implementation of `_.range` and `_.rangeRight` which doesn't 5638 * coerce arguments. 5639 * 5640 * @private 5641 * @param {number} start The start of the range. 5642 * @param {number} end The end of the range. 5643 * @param {number} step The value to increment or decrement by. 5644 * @param {boolean} [fromRight] Specify iterating from right to left. 5645 * @returns {Array} Returns the range of numbers. 5646 */ 5647 function baseRange(start, end, step, fromRight) { 5648 var index = -1, 5649 length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), 5650 result = Array(length); 5651 5652 while (length--) { 5653 result[fromRight ? length : ++index] = start; 5654 start += step; 5655 } 5656 return result; 5657 } 5658 5659 /** 5660 * The base implementation of `_.repeat` which doesn't coerce arguments. 5661 * 5662 * @private 5663 * @param {string} string The string to repeat. 5664 * @param {number} n The number of times to repeat the string. 5665 * @returns {string} Returns the repeated string. 5666 */ 5667 function baseRepeat(string, n) { 5668 var result = ''; 5669 if (!string || n < 1 || n > MAX_SAFE_INTEGER) { 5670 return result; 5671 } 5672 // Leverage the exponentiation by squaring algorithm for a faster repeat. 5673 // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. 5674 do { 5675 if (n % 2) { 5676 result += string; 5677 } 5678 n = nativeFloor(n / 2); 5679 if (n) { 5680 string += string; 5681 } 5682 } while (n); 5683 5684 return result; 5685 } 5686 5687 /** 5688 * The base implementation of `_.rest` which doesn't validate or coerce arguments. 5689 * 5690 * @private 5691 * @param {Function} func The function to apply a rest parameter to. 5692 * @param {number} [start=func.length-1] The start position of the rest parameter. 5693 * @returns {Function} Returns the new function. 5694 */ 5695 function baseRest(func, start) { 5696 return setToString(overRest(func, start, identity), func + ''); 5697 } 5698 5699 /** 5700 * The base implementation of `_.sample`. 5701 * 5702 * @private 5703 * @param {Array|Object} collection The collection to sample. 5704 * @returns {*} Returns the random element. 5705 */ 5706 function baseSample(collection) { 5707 return arraySample(values(collection)); 5708 } 5709 5710 /** 5711 * The base implementation of `_.sampleSize` without param guards. 5712 * 5713 * @private 5714 * @param {Array|Object} collection The collection to sample. 5715 * @param {number} n The number of elements to sample. 5716 * @returns {Array} Returns the random elements. 5717 */ 5718 function baseSampleSize(collection, n) { 5719 var array = values(collection); 5720 return shuffleSelf(array, baseClamp(n, 0, array.length)); 5721 } 5722 5723 /** 5724 * The base implementation of `_.set`. 5725 * 5726 * @private 5727 * @param {Object} object The object to modify. 5728 * @param {Array|string} path The path of the property to set. 5729 * @param {*} value The value to set. 5730 * @param {Function} [customizer] The function to customize path creation. 5731 * @returns {Object} Returns `object`. 5732 */ 5733 function baseSet(object, path, value, customizer) { 5734 if (!isObject(object)) { 5735 return object; 5736 } 5737 path = castPath(path, object); 5738 5739 var index = -1, 5740 length = path.length, 5741 lastIndex = length - 1, 5742 nested = object; 5743 5744 while (nested != null && ++index < length) { 5745 var key = toKey(path[index]), 5746 newValue = value; 5747 5748 if (key === '__proto__' || key === 'constructor' || key === 'prototype') { 5749 return object; 5750 } 5751 5752 if (index != lastIndex) { 5753 var objValue = nested[key]; 5754 newValue = customizer ? customizer(objValue, key, nested) : undefined; 5755 if (newValue === undefined) { 5756 newValue = isObject(objValue) 5757 ? objValue 5758 : (isIndex(path[index + 1]) ? [] : {}); 5759 } 5760 } 5761 assignValue(nested, key, newValue); 5762 nested = nested[key]; 5763 } 5764 return object; 5765 } 5766 5767 /** 5768 * The base implementation of `setData` without support for hot loop shorting. 5769 * 5770 * @private 5771 * @param {Function} func The function to associate metadata with. 5772 * @param {*} data The metadata. 5773 * @returns {Function} Returns `func`. 5774 */ 5775 var baseSetData = !metaMap ? identity : function(func, data) { 5776 metaMap.set(func, data); 5777 return func; 5778 }; 5779 5780 /** 5781 * The base implementation of `setToString` without support for hot loop shorting. 5782 * 5783 * @private 5784 * @param {Function} func The function to modify. 5785 * @param {Function} string The `toString` result. 5786 * @returns {Function} Returns `func`. 5787 */ 5788 var baseSetToString = !defineProperty ? identity : function(func, string) { 5789 return defineProperty(func, 'toString', { 5790 'configurable': true, 5791 'enumerable': false, 5792 'value': constant(string), 5793 'writable': true 5794 }); 5795 }; 5796 5797 /** 5798 * The base implementation of `_.shuffle`. 5799 * 5800 * @private 5801 * @param {Array|Object} collection The collection to shuffle. 5802 * @returns {Array} Returns the new shuffled array. 5803 */ 5804 function baseShuffle(collection) { 5805 return shuffleSelf(values(collection)); 5806 } 5807 5808 /** 5809 * The base implementation of `_.slice` without an iteratee call guard. 5810 * 5811 * @private 5812 * @param {Array} array The array to slice. 5813 * @param {number} [start=0] The start position. 5814 * @param {number} [end=array.length] The end position. 5815 * @returns {Array} Returns the slice of `array`. 5816 */ 5817 function baseSlice(array, start, end) { 5818 var index = -1, 5819 length = array.length; 5820 5821 if (start < 0) { 5822 start = -start > length ? 0 : (length + start); 5823 } 5824 end = end > length ? length : end; 5825 if (end < 0) { 5826 end += length; 5827 } 5828 length = start > end ? 0 : ((end - start) >>> 0); 5829 start >>>= 0; 5830 5831 var result = Array(length); 5832 while (++index < length) { 5833 result[index] = array[index + start]; 5834 } 5835 return result; 5836 } 5837 5838 /** 5839 * The base implementation of `_.some` without support for iteratee shorthands. 5840 * 5841 * @private 5842 * @param {Array|Object} collection The collection to iterate over. 5843 * @param {Function} predicate The function invoked per iteration. 5844 * @returns {boolean} Returns `true` if any element passes the predicate check, 5845 * else `false`. 5846 */ 5847 function baseSome(collection, predicate) { 5848 var result; 5849 5850 baseEach(collection, function(value, index, collection) { 5851 result = predicate(value, index, collection); 5852 return !result; 5853 }); 5854 return !!result; 5855 } 5856 5857 /** 5858 * The base implementation of `_.sortedIndex` and `_.sortedLastIndex` which 5859 * performs a binary search of `array` to determine the index at which `value` 5860 * should be inserted into `array` in order to maintain its sort order. 5861 * 5862 * @private 5863 * @param {Array} array The sorted array to inspect. 5864 * @param {*} value The value to evaluate. 5865 * @param {boolean} [retHighest] Specify returning the highest qualified index. 5866 * @returns {number} Returns the index at which `value` should be inserted 5867 * into `array`. 5868 */ 5869 function baseSortedIndex(array, value, retHighest) { 5870 var low = 0, 5871 high = array == null ? low : array.length; 5872 5873 if (typeof value == 'number' && value === value && high <= HALF_MAX_ARRAY_LENGTH) { 5874 while (low < high) { 5875 var mid = (low + high) >>> 1, 5876 computed = array[mid]; 5877 5878 if (computed !== null && !isSymbol(computed) && 5879 (retHighest ? (computed <= value) : (computed < value))) { 5880 low = mid + 1; 5881 } else { 5882 high = mid; 5883 } 5884 } 5885 return high; 5886 } 5887 return baseSortedIndexBy(array, value, identity, retHighest); 5888 } 5889 5890 /** 5891 * The base implementation of `_.sortedIndexBy` and `_.sortedLastIndexBy` 5892 * which invokes `iteratee` for `value` and each element of `array` to compute 5893 * their sort ranking. The iteratee is invoked with one argument; (value). 5894 * 5895 * @private 5896 * @param {Array} array The sorted array to inspect. 5897 * @param {*} value The value to evaluate. 5898 * @param {Function} iteratee The iteratee invoked per element. 5899 * @param {boolean} [retHighest] Specify returning the highest qualified index. 5900 * @returns {number} Returns the index at which `value` should be inserted 5901 * into `array`. 5902 */ 5903 function baseSortedIndexBy(array, value, iteratee, retHighest) { 5904 var low = 0, 5905 high = array == null ? 0 : array.length; 5906 if (high === 0) { 5907 return 0; 5908 } 5909 5910 value = iteratee(value); 5911 var valIsNaN = value !== value, 5912 valIsNull = value === null, 5913 valIsSymbol = isSymbol(value), 5914 valIsUndefined = value === undefined; 5915 5916 while (low < high) { 5917 var mid = nativeFloor((low + high) / 2), 5918 computed = iteratee(array[mid]), 5919 othIsDefined = computed !== undefined, 5920 othIsNull = computed === null, 5921 othIsReflexive = computed === computed, 5922 othIsSymbol = isSymbol(computed); 5923 5924 if (valIsNaN) { 5925 var setLow = retHighest || othIsReflexive; 5926 } else if (valIsUndefined) { 5927 setLow = othIsReflexive && (retHighest || othIsDefined); 5928 } else if (valIsNull) { 5929 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull); 5930 } else if (valIsSymbol) { 5931 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol); 5932 } else if (othIsNull || othIsSymbol) { 5933 setLow = false; 5934 } else { 5935 setLow = retHighest ? (computed <= value) : (computed < value); 5936 } 5937 if (setLow) { 5938 low = mid + 1; 5939 } else { 5940 high = mid; 5941 } 5942 } 5943 return nativeMin(high, MAX_ARRAY_INDEX); 5944 } 5945 5946 /** 5947 * The base implementation of `_.sortedUniq` and `_.sortedUniqBy` without 5948 * support for iteratee shorthands. 5949 * 5950 * @private 5951 * @param {Array} array The array to inspect. 5952 * @param {Function} [iteratee] The iteratee invoked per element. 5953 * @returns {Array} Returns the new duplicate free array. 5954 */ 5955 function baseSortedUniq(array, iteratee) { 5956 var index = -1, 5957 length = array.length, 5958 resIndex = 0, 5959 result = []; 5960 5961 while (++index < length) { 5962 var value = array[index], 5963 computed = iteratee ? iteratee(value) : value; 5964 5965 if (!index || !eq(computed, seen)) { 5966 var seen = computed; 5967 result[resIndex++] = value === 0 ? 0 : value; 5968 } 5969 } 5970 return result; 5971 } 5972 5973 /** 5974 * The base implementation of `_.toNumber` which doesn't ensure correct 5975 * conversions of binary, hexadecimal, or octal string values. 5976 * 5977 * @private 5978 * @param {*} value The value to process. 5979 * @returns {number} Returns the number. 5980 */ 5981 function baseToNumber(value) { 5982 if (typeof value == 'number') { 5983 return value; 5984 } 5985 if (isSymbol(value)) { 5986 return NAN; 5987 } 5988 return +value; 5989 } 5990 5991 /** 5992 * The base implementation of `_.toString` which doesn't convert nullish 5993 * values to empty strings. 5994 * 5995 * @private 5996 * @param {*} value The value to process. 5997 * @returns {string} Returns the string. 5998 */ 5999 function baseToString(value) { 6000 // Exit early for strings to avoid a performance hit in some environments. 6001 if (typeof value == 'string') { 6002 return value; 6003 } 6004 if (isArray(value)) { 6005 // Recursively convert values (susceptible to call stack limits). 6006 return arrayMap(value, baseToString) + ''; 6007 } 6008 if (isSymbol(value)) { 6009 return symbolToString ? symbolToString.call(value) : ''; 6010 } 6011 var result = (value + ''); 6012 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 6013 } 6014 6015 /** 6016 * The base implementation of `_.uniqBy` without support for iteratee shorthands. 6017 * 6018 * @private 6019 * @param {Array} array The array to inspect. 6020 * @param {Function} [iteratee] The iteratee invoked per element. 6021 * @param {Function} [comparator] The comparator invoked per element. 6022 * @returns {Array} Returns the new duplicate free array. 6023 */ 6024 function baseUniq(array, iteratee, comparator) { 6025 var index = -1, 6026 includes = arrayIncludes, 6027 length = array.length, 6028 isCommon = true, 6029 result = [], 6030 seen = result; 6031 6032 if (comparator) { 6033 isCommon = false; 6034 includes = arrayIncludesWith; 6035 } 6036 else if (length >= LARGE_ARRAY_SIZE) { 6037 var set = iteratee ? null : createSet(array); 6038 if (set) { 6039 return setToArray(set); 6040 } 6041 isCommon = false; 6042 includes = cacheHas; 6043 seen = new SetCache; 6044 } 6045 else { 6046 seen = iteratee ? [] : result; 6047 } 6048 outer: 6049 while (++index < length) { 6050 var value = array[index], 6051 computed = iteratee ? iteratee(value) : value; 6052 6053 value = (comparator || value !== 0) ? value : 0; 6054 if (isCommon && computed === computed) { 6055 var seenIndex = seen.length; 6056 while (seenIndex--) { 6057 if (seen[seenIndex] === computed) { 6058 continue outer; 6059 } 6060 } 6061 if (iteratee) { 6062 seen.push(computed); 6063 } 6064 result.push(value); 6065 } 6066 else if (!includes(seen, computed, comparator)) { 6067 if (seen !== result) { 6068 seen.push(computed); 6069 } 6070 result.push(value); 6071 } 6072 } 6073 return result; 6074 } 6075 6076 /** 6077 * The base implementation of `_.unset`. 6078 * 6079 * @private 6080 * @param {Object} object The object to modify. 6081 * @param {Array|string} path The property path to unset. 6082 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 6083 */ 6084 function baseUnset(object, path) { 6085 path = castPath(path, object); 6086 object = parent(object, path); 6087 return object == null || delete object[toKey(last(path))]; 6088 } 6089 6090 /** 6091 * The base implementation of `_.update`. 6092 * 6093 * @private 6094 * @param {Object} object The object to modify. 6095 * @param {Array|string} path The path of the property to update. 6096 * @param {Function} updater The function to produce the updated value. 6097 * @param {Function} [customizer] The function to customize path creation. 6098 * @returns {Object} Returns `object`. 6099 */ 6100 function baseUpdate(object, path, updater, customizer) { 6101 return baseSet(object, path, updater(baseGet(object, path)), customizer); 6102 } 6103 6104 /** 6105 * The base implementation of methods like `_.dropWhile` and `_.takeWhile` 6106 * without support for iteratee shorthands. 6107 * 6108 * @private 6109 * @param {Array} array The array to query. 6110 * @param {Function} predicate The function invoked per iteration. 6111 * @param {boolean} [isDrop] Specify dropping elements instead of taking them. 6112 * @param {boolean} [fromRight] Specify iterating from right to left. 6113 * @returns {Array} Returns the slice of `array`. 6114 */ 6115 function baseWhile(array, predicate, isDrop, fromRight) { 6116 var length = array.length, 6117 index = fromRight ? length : -1; 6118 6119 while ((fromRight ? index-- : ++index < length) && 6120 predicate(array[index], index, array)) {} 6121 6122 return isDrop 6123 ? baseSlice(array, (fromRight ? 0 : index), (fromRight ? index + 1 : length)) 6124 : baseSlice(array, (fromRight ? index + 1 : 0), (fromRight ? length : index)); 6125 } 6126 6127 /** 6128 * The base implementation of `wrapperValue` which returns the result of 6129 * performing a sequence of actions on the unwrapped `value`, where each 6130 * successive action is supplied the return value of the previous. 6131 * 6132 * @private 6133 * @param {*} value The unwrapped value. 6134 * @param {Array} actions Actions to perform to resolve the unwrapped value. 6135 * @returns {*} Returns the resolved value. 6136 */ 6137 function baseWrapperValue(value, actions) { 6138 var result = value; 6139 if (result instanceof LazyWrapper) { 6140 result = result.value(); 6141 } 6142 return arrayReduce(actions, function(result, action) { 6143 return action.func.apply(action.thisArg, arrayPush([result], action.args)); 6144 }, result); 6145 } 6146 6147 /** 6148 * The base implementation of methods like `_.xor`, without support for 6149 * iteratee shorthands, that accepts an array of arrays to inspect. 6150 * 6151 * @private 6152 * @param {Array} arrays The arrays to inspect. 6153 * @param {Function} [iteratee] The iteratee invoked per element. 6154 * @param {Function} [comparator] The comparator invoked per element. 6155 * @returns {Array} Returns the new array of values. 6156 */ 6157 function baseXor(arrays, iteratee, comparator) { 6158 var length = arrays.length; 6159 if (length < 2) { 6160 return length ? baseUniq(arrays[0]) : []; 6161 } 6162 var index = -1, 6163 result = Array(length); 6164 6165 while (++index < length) { 6166 var array = arrays[index], 6167 othIndex = -1; 6168 6169 while (++othIndex < length) { 6170 if (othIndex != index) { 6171 result[index] = baseDifference(result[index] || array, arrays[othIndex], iteratee, comparator); 6172 } 6173 } 6174 } 6175 return baseUniq(baseFlatten(result, 1), iteratee, comparator); 6176 } 6177 6178 /** 6179 * This base implementation of `_.zipObject` which assigns values using `assignFunc`. 6180 * 6181 * @private 6182 * @param {Array} props The property identifiers. 6183 * @param {Array} values The property values. 6184 * @param {Function} assignFunc The function to assign values. 6185 * @returns {Object} Returns the new object. 6186 */ 6187 function baseZipObject(props, values, assignFunc) { 6188 var index = -1, 6189 length = props.length, 6190 valsLength = values.length, 6191 result = {}; 6192 6193 while (++index < length) { 6194 var value = index < valsLength ? values[index] : undefined; 6195 assignFunc(result, props[index], value); 6196 } 6197 return result; 6198 } 6199 6200 /** 6201 * Casts `value` to an empty array if it's not an array like object. 6202 * 6203 * @private 6204 * @param {*} value The value to inspect. 6205 * @returns {Array|Object} Returns the cast array-like object. 6206 */ 6207 function castArrayLikeObject(value) { 6208 return isArrayLikeObject(value) ? value : []; 6209 } 6210 6211 /** 6212 * Casts `value` to `identity` if it's not a function. 6213 * 6214 * @private 6215 * @param {*} value The value to inspect. 6216 * @returns {Function} Returns cast function. 6217 */ 6218 function castFunction(value) { 6219 return typeof value == 'function' ? value : identity; 6220 } 6221 6222 /** 6223 * Casts `value` to a path array if it's not one. 6224 * 6225 * @private 6226 * @param {*} value The value to inspect. 6227 * @param {Object} [object] The object to query keys on. 6228 * @returns {Array} Returns the cast property path array. 6229 */ 6230 function castPath(value, object) { 6231 if (isArray(value)) { 6232 return value; 6233 } 6234 return isKey(value, object) ? [value] : stringToPath(toString(value)); 6235 } 6236 6237 /** 6238 * A `baseRest` alias which can be replaced with `identity` by module 6239 * replacement plugins. 6240 * 6241 * @private 6242 * @type {Function} 6243 * @param {Function} func The function to apply a rest parameter to. 6244 * @returns {Function} Returns the new function. 6245 */ 6246 var castRest = baseRest; 6247 6248 /** 6249 * Casts `array` to a slice if it's needed. 6250 * 6251 * @private 6252 * @param {Array} array The array to inspect. 6253 * @param {number} start The start position. 6254 * @param {number} [end=array.length] The end position. 6255 * @returns {Array} Returns the cast slice. 6256 */ 6257 function castSlice(array, start, end) { 6258 var length = array.length; 6259 end = end === undefined ? length : end; 6260 return (!start && end >= length) ? array : baseSlice(array, start, end); 6261 } 6262 6263 /** 6264 * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). 6265 * 6266 * @private 6267 * @param {number|Object} id The timer id or timeout object of the timer to clear. 6268 */ 6269 var clearTimeout = ctxClearTimeout || function(id) { 6270 return root.clearTimeout(id); 6271 }; 6272 6273 /** 6274 * Creates a clone of `buffer`. 6275 * 6276 * @private 6277 * @param {Buffer} buffer The buffer to clone. 6278 * @param {boolean} [isDeep] Specify a deep clone. 6279 * @returns {Buffer} Returns the cloned buffer. 6280 */ 6281 function cloneBuffer(buffer, isDeep) { 6282 if (isDeep) { 6283 return buffer.slice(); 6284 } 6285 var length = buffer.length, 6286 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); 6287 6288 buffer.copy(result); 6289 return result; 6290 } 6291 6292 /** 6293 * Creates a clone of `arrayBuffer`. 6294 * 6295 * @private 6296 * @param {ArrayBuffer} arrayBuffer The array buffer to clone. 6297 * @returns {ArrayBuffer} Returns the cloned array buffer. 6298 */ 6299 function cloneArrayBuffer(arrayBuffer) { 6300 var result = new arrayBuffer.constructor(arrayBuffer.byteLength); 6301 new Uint8Array(result).set(new Uint8Array(arrayBuffer)); 6302 return result; 6303 } 6304 6305 /** 6306 * Creates a clone of `dataView`. 6307 * 6308 * @private 6309 * @param {Object} dataView The data view to clone. 6310 * @param {boolean} [isDeep] Specify a deep clone. 6311 * @returns {Object} Returns the cloned data view. 6312 */ 6313 function cloneDataView(dataView, isDeep) { 6314 var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer; 6315 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); 6316 } 6317 6318 /** 6319 * Creates a clone of `regexp`. 6320 * 6321 * @private 6322 * @param {Object} regexp The regexp to clone. 6323 * @returns {Object} Returns the cloned regexp. 6324 */ 6325 function cloneRegExp(regexp) { 6326 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); 6327 result.lastIndex = regexp.lastIndex; 6328 return result; 6329 } 6330 6331 /** 6332 * Creates a clone of the `symbol` object. 6333 * 6334 * @private 6335 * @param {Object} symbol The symbol object to clone. 6336 * @returns {Object} Returns the cloned symbol object. 6337 */ 6338 function cloneSymbol(symbol) { 6339 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; 6340 } 6341 6342 /** 6343 * Creates a clone of `typedArray`. 6344 * 6345 * @private 6346 * @param {Object} typedArray The typed array to clone. 6347 * @param {boolean} [isDeep] Specify a deep clone. 6348 * @returns {Object} Returns the cloned typed array. 6349 */ 6350 function cloneTypedArray(typedArray, isDeep) { 6351 var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; 6352 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); 6353 } 6354 6355 /** 6356 * Compares values to sort them in ascending order. 6357 * 6358 * @private 6359 * @param {*} value The value to compare. 6360 * @param {*} other The other value to compare. 6361 * @returns {number} Returns the sort order indicator for `value`. 6362 */ 6363 function compareAscending(value, other) { 6364 if (value !== other) { 6365 var valIsDefined = value !== undefined, 6366 valIsNull = value === null, 6367 valIsReflexive = value === value, 6368 valIsSymbol = isSymbol(value); 6369 6370 var othIsDefined = other !== undefined, 6371 othIsNull = other === null, 6372 othIsReflexive = other === other, 6373 othIsSymbol = isSymbol(other); 6374 6375 if ((!othIsNull && !othIsSymbol && !valIsSymbol && value > other) || 6376 (valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol) || 6377 (valIsNull && othIsDefined && othIsReflexive) || 6378 (!valIsDefined && othIsReflexive) || 6379 !valIsReflexive) { 6380 return 1; 6381 } 6382 if ((!valIsNull && !valIsSymbol && !othIsSymbol && value < other) || 6383 (othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol) || 6384 (othIsNull && valIsDefined && valIsReflexive) || 6385 (!othIsDefined && valIsReflexive) || 6386 !othIsReflexive) { 6387 return -1; 6388 } 6389 } 6390 return 0; 6391 } 6392 6393 /** 6394 * Used by `_.orderBy` to compare multiple properties of a value to another 6395 * and stable sort them. 6396 * 6397 * If `orders` is unspecified, all values are sorted in ascending order. Otherwise, 6398 * specify an order of "desc" for descending or "asc" for ascending sort order 6399 * of corresponding values. 6400 * 6401 * @private 6402 * @param {Object} object The object to compare. 6403 * @param {Object} other The other object to compare. 6404 * @param {boolean[]|string[]} orders The order to sort by for each property. 6405 * @returns {number} Returns the sort order indicator for `object`. 6406 */ 6407 function compareMultiple(object, other, orders) { 6408 var index = -1, 6409 objCriteria = object.criteria, 6410 othCriteria = other.criteria, 6411 length = objCriteria.length, 6412 ordersLength = orders.length; 6413 6414 while (++index < length) { 6415 var result = compareAscending(objCriteria[index], othCriteria[index]); 6416 if (result) { 6417 if (index >= ordersLength) { 6418 return result; 6419 } 6420 var order = orders[index]; 6421 return result * (order == 'desc' ? -1 : 1); 6422 } 6423 } 6424 // Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications 6425 // that causes it, under certain circumstances, to provide the same value for 6426 // `object` and `other`. See https://github.com/jashkenas/underscore/pull/1247 6427 // for more details. 6428 // 6429 // This also ensures a stable sort in V8 and other engines. 6430 // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details. 6431 return object.index - other.index; 6432 } 6433 6434 /** 6435 * Creates an array that is the composition of partially applied arguments, 6436 * placeholders, and provided arguments into a single array of arguments. 6437 * 6438 * @private 6439 * @param {Array} args The provided arguments. 6440 * @param {Array} partials The arguments to prepend to those provided. 6441 * @param {Array} holders The `partials` placeholder indexes. 6442 * @params {boolean} [isCurried] Specify composing for a curried function. 6443 * @returns {Array} Returns the new array of composed arguments. 6444 */ 6445 function composeArgs(args, partials, holders, isCurried) { 6446 var argsIndex = -1, 6447 argsLength = args.length, 6448 holdersLength = holders.length, 6449 leftIndex = -1, 6450 leftLength = partials.length, 6451 rangeLength = nativeMax(argsLength - holdersLength, 0), 6452 result = Array(leftLength + rangeLength), 6453 isUncurried = !isCurried; 6454 6455 while (++leftIndex < leftLength) { 6456 result[leftIndex] = partials[leftIndex]; 6457 } 6458 while (++argsIndex < holdersLength) { 6459 if (isUncurried || argsIndex < argsLength) { 6460 result[holders[argsIndex]] = args[argsIndex]; 6461 } 6462 } 6463 while (rangeLength--) { 6464 result[leftIndex++] = args[argsIndex++]; 6465 } 6466 return result; 6467 } 6468 6469 /** 6470 * This function is like `composeArgs` except that the arguments composition 6471 * is tailored for `_.partialRight`. 6472 * 6473 * @private 6474 * @param {Array} args The provided arguments. 6475 * @param {Array} partials The arguments to append to those provided. 6476 * @param {Array} holders The `partials` placeholder indexes. 6477 * @params {boolean} [isCurried] Specify composing for a curried function. 6478 * @returns {Array} Returns the new array of composed arguments. 6479 */ 6480 function composeArgsRight(args, partials, holders, isCurried) { 6481 var argsIndex = -1, 6482 argsLength = args.length, 6483 holdersIndex = -1, 6484 holdersLength = holders.length, 6485 rightIndex = -1, 6486 rightLength = partials.length, 6487 rangeLength = nativeMax(argsLength - holdersLength, 0), 6488 result = Array(rangeLength + rightLength), 6489 isUncurried = !isCurried; 6490 6491 while (++argsIndex < rangeLength) { 6492 result[argsIndex] = args[argsIndex]; 6493 } 6494 var offset = argsIndex; 6495 while (++rightIndex < rightLength) { 6496 result[offset + rightIndex] = partials[rightIndex]; 6497 } 6498 while (++holdersIndex < holdersLength) { 6499 if (isUncurried || argsIndex < argsLength) { 6500 result[offset + holders[holdersIndex]] = args[argsIndex++]; 6501 } 6502 } 6503 return result; 6504 } 6505 6506 /** 6507 * Copies the values of `source` to `array`. 6508 * 6509 * @private 6510 * @param {Array} source The array to copy values from. 6511 * @param {Array} [array=[]] The array to copy values to. 6512 * @returns {Array} Returns `array`. 6513 */ 6514 function copyArray(source, array) { 6515 var index = -1, 6516 length = source.length; 6517 6518 array || (array = Array(length)); 6519 while (++index < length) { 6520 array[index] = source[index]; 6521 } 6522 return array; 6523 } 6524 6525 /** 6526 * Copies properties of `source` to `object`. 6527 * 6528 * @private 6529 * @param {Object} source The object to copy properties from. 6530 * @param {Array} props The property identifiers to copy. 6531 * @param {Object} [object={}] The object to copy properties to. 6532 * @param {Function} [customizer] The function to customize copied values. 6533 * @returns {Object} Returns `object`. 6534 */ 6535 function copyObject(source, props, object, customizer) { 6536 var isNew = !object; 6537 object || (object = {}); 6538 6539 var index = -1, 6540 length = props.length; 6541 6542 while (++index < length) { 6543 var key = props[index]; 6544 6545 var newValue = customizer 6546 ? customizer(object[key], source[key], key, object, source) 6547 : undefined; 6548 6549 if (newValue === undefined) { 6550 newValue = source[key]; 6551 } 6552 if (isNew) { 6553 baseAssignValue(object, key, newValue); 6554 } else { 6555 assignValue(object, key, newValue); 6556 } 6557 } 6558 return object; 6559 } 6560 6561 /** 6562 * Copies own symbols of `source` to `object`. 6563 * 6564 * @private 6565 * @param {Object} source The object to copy symbols from. 6566 * @param {Object} [object={}] The object to copy symbols to. 6567 * @returns {Object} Returns `object`. 6568 */ 6569 function copySymbols(source, object) { 6570 return copyObject(source, getSymbols(source), object); 6571 } 6572 6573 /** 6574 * Copies own and inherited symbols of `source` to `object`. 6575 * 6576 * @private 6577 * @param {Object} source The object to copy symbols from. 6578 * @param {Object} [object={}] The object to copy symbols to. 6579 * @returns {Object} Returns `object`. 6580 */ 6581 function copySymbolsIn(source, object) { 6582 return copyObject(source, getSymbolsIn(source), object); 6583 } 6584 6585 /** 6586 * Creates a function like `_.groupBy`. 6587 * 6588 * @private 6589 * @param {Function} setter The function to set accumulator values. 6590 * @param {Function} [initializer] The accumulator object initializer. 6591 * @returns {Function} Returns the new aggregator function. 6592 */ 6593 function createAggregator(setter, initializer) { 6594 return function(collection, iteratee) { 6595 var func = isArray(collection) ? arrayAggregator : baseAggregator, 6596 accumulator = initializer ? initializer() : {}; 6597 6598 return func(collection, setter, getIteratee(iteratee, 2), accumulator); 6599 }; 6600 } 6601 6602 /** 6603 * Creates a function like `_.assign`. 6604 * 6605 * @private 6606 * @param {Function} assigner The function to assign values. 6607 * @returns {Function} Returns the new assigner function. 6608 */ 6609 function createAssigner(assigner) { 6610 return baseRest(function(object, sources) { 6611 var index = -1, 6612 length = sources.length, 6613 customizer = length > 1 ? sources[length - 1] : undefined, 6614 guard = length > 2 ? sources[2] : undefined; 6615 6616 customizer = (assigner.length > 3 && typeof customizer == 'function') 6617 ? (length--, customizer) 6618 : undefined; 6619 6620 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 6621 customizer = length < 3 ? undefined : customizer; 6622 length = 1; 6623 } 6624 object = Object(object); 6625 while (++index < length) { 6626 var source = sources[index]; 6627 if (source) { 6628 assigner(object, source, index, customizer); 6629 } 6630 } 6631 return object; 6632 }); 6633 } 6634 6635 /** 6636 * Creates a `baseEach` or `baseEachRight` function. 6637 * 6638 * @private 6639 * @param {Function} eachFunc The function to iterate over a collection. 6640 * @param {boolean} [fromRight] Specify iterating from right to left. 6641 * @returns {Function} Returns the new base function. 6642 */ 6643 function createBaseEach(eachFunc, fromRight) { 6644 return function(collection, iteratee) { 6645 if (collection == null) { 6646 return collection; 6647 } 6648 if (!isArrayLike(collection)) { 6649 return eachFunc(collection, iteratee); 6650 } 6651 var length = collection.length, 6652 index = fromRight ? length : -1, 6653 iterable = Object(collection); 6654 6655 while ((fromRight ? index-- : ++index < length)) { 6656 if (iteratee(iterable[index], index, iterable) === false) { 6657 break; 6658 } 6659 } 6660 return collection; 6661 }; 6662 } 6663 6664 /** 6665 * Creates a base function for methods like `_.forIn` and `_.forOwn`. 6666 * 6667 * @private 6668 * @param {boolean} [fromRight] Specify iterating from right to left. 6669 * @returns {Function} Returns the new base function. 6670 */ 6671 function createBaseFor(fromRight) { 6672 return function(object, iteratee, keysFunc) { 6673 var index = -1, 6674 iterable = Object(object), 6675 props = keysFunc(object), 6676 length = props.length; 6677 6678 while (length--) { 6679 var key = props[fromRight ? length : ++index]; 6680 if (iteratee(iterable[key], key, iterable) === false) { 6681 break; 6682 } 6683 } 6684 return object; 6685 }; 6686 } 6687 6688 /** 6689 * Creates a function that wraps `func` to invoke it with the optional `this` 6690 * binding of `thisArg`. 6691 * 6692 * @private 6693 * @param {Function} func The function to wrap. 6694 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 6695 * @param {*} [thisArg] The `this` binding of `func`. 6696 * @returns {Function} Returns the new wrapped function. 6697 */ 6698 function createBind(func, bitmask, thisArg) { 6699 var isBind = bitmask & WRAP_BIND_FLAG, 6700 Ctor = createCtor(func); 6701 6702 function wrapper() { 6703 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 6704 return fn.apply(isBind ? thisArg : this, arguments); 6705 } 6706 return wrapper; 6707 } 6708 6709 /** 6710 * Creates a function like `_.lowerFirst`. 6711 * 6712 * @private 6713 * @param {string} methodName The name of the `String` case method to use. 6714 * @returns {Function} Returns the new case function. 6715 */ 6716 function createCaseFirst(methodName) { 6717 return function(string) { 6718 string = toString(string); 6719 6720 var strSymbols = hasUnicode(string) 6721 ? stringToArray(string) 6722 : undefined; 6723 6724 var chr = strSymbols 6725 ? strSymbols[0] 6726 : string.charAt(0); 6727 6728 var trailing = strSymbols 6729 ? castSlice(strSymbols, 1).join('') 6730 : string.slice(1); 6731 6732 return chr[methodName]() + trailing; 6733 }; 6734 } 6735 6736 /** 6737 * Creates a function like `_.camelCase`. 6738 * 6739 * @private 6740 * @param {Function} callback The function to combine each word. 6741 * @returns {Function} Returns the new compounder function. 6742 */ 6743 function createCompounder(callback) { 6744 return function(string) { 6745 return arrayReduce(words(deburr(string).replace(reApos, '')), callback, ''); 6746 }; 6747 } 6748 6749 /** 6750 * Creates a function that produces an instance of `Ctor` regardless of 6751 * whether it was invoked as part of a `new` expression or by `call` or `apply`. 6752 * 6753 * @private 6754 * @param {Function} Ctor The constructor to wrap. 6755 * @returns {Function} Returns the new wrapped function. 6756 */ 6757 function createCtor(Ctor) { 6758 return function() { 6759 // Use a `switch` statement to work with class constructors. See 6760 // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist 6761 // for more details. 6762 var args = arguments; 6763 switch (args.length) { 6764 case 0: return new Ctor; 6765 case 1: return new Ctor(args[0]); 6766 case 2: return new Ctor(args[0], args[1]); 6767 case 3: return new Ctor(args[0], args[1], args[2]); 6768 case 4: return new Ctor(args[0], args[1], args[2], args[3]); 6769 case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); 6770 case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); 6771 case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); 6772 } 6773 var thisBinding = baseCreate(Ctor.prototype), 6774 result = Ctor.apply(thisBinding, args); 6775 6776 // Mimic the constructor's `return` behavior. 6777 // See https://es5.github.io/#x13.2.2 for more details. 6778 return isObject(result) ? result : thisBinding; 6779 }; 6780 } 6781 6782 /** 6783 * Creates a function that wraps `func` to enable currying. 6784 * 6785 * @private 6786 * @param {Function} func The function to wrap. 6787 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 6788 * @param {number} arity The arity of `func`. 6789 * @returns {Function} Returns the new wrapped function. 6790 */ 6791 function createCurry(func, bitmask, arity) { 6792 var Ctor = createCtor(func); 6793 6794 function wrapper() { 6795 var length = arguments.length, 6796 args = Array(length), 6797 index = length, 6798 placeholder = getHolder(wrapper); 6799 6800 while (index--) { 6801 args[index] = arguments[index]; 6802 } 6803 var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder) 6804 ? [] 6805 : replaceHolders(args, placeholder); 6806 6807 length -= holders.length; 6808 if (length < arity) { 6809 return createRecurry( 6810 func, bitmask, createHybrid, wrapper.placeholder, undefined, 6811 args, holders, undefined, undefined, arity - length); 6812 } 6813 var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 6814 return apply(fn, this, args); 6815 } 6816 return wrapper; 6817 } 6818 6819 /** 6820 * Creates a `_.find` or `_.findLast` function. 6821 * 6822 * @private 6823 * @param {Function} findIndexFunc The function to find the collection index. 6824 * @returns {Function} Returns the new find function. 6825 */ 6826 function createFind(findIndexFunc) { 6827 return function(collection, predicate, fromIndex) { 6828 var iterable = Object(collection); 6829 if (!isArrayLike(collection)) { 6830 var iteratee = getIteratee(predicate, 3); 6831 collection = keys(collection); 6832 predicate = function(key) { return iteratee(iterable[key], key, iterable); }; 6833 } 6834 var index = findIndexFunc(collection, predicate, fromIndex); 6835 return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined; 6836 }; 6837 } 6838 6839 /** 6840 * Creates a `_.flow` or `_.flowRight` function. 6841 * 6842 * @private 6843 * @param {boolean} [fromRight] Specify iterating from right to left. 6844 * @returns {Function} Returns the new flow function. 6845 */ 6846 function createFlow(fromRight) { 6847 return flatRest(function(funcs) { 6848 var length = funcs.length, 6849 index = length, 6850 prereq = LodashWrapper.prototype.thru; 6851 6852 if (fromRight) { 6853 funcs.reverse(); 6854 } 6855 while (index--) { 6856 var func = funcs[index]; 6857 if (typeof func != 'function') { 6858 throw new TypeError(FUNC_ERROR_TEXT); 6859 } 6860 if (prereq && !wrapper && getFuncName(func) == 'wrapper') { 6861 var wrapper = new LodashWrapper([], true); 6862 } 6863 } 6864 index = wrapper ? index : length; 6865 while (++index < length) { 6866 func = funcs[index]; 6867 6868 var funcName = getFuncName(func), 6869 data = funcName == 'wrapper' ? getData(func) : undefined; 6870 6871 if (data && isLaziable(data[0]) && 6872 data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && 6873 !data[4].length && data[9] == 1 6874 ) { 6875 wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]); 6876 } else { 6877 wrapper = (func.length == 1 && isLaziable(func)) 6878 ? wrapper[funcName]() 6879 : wrapper.thru(func); 6880 } 6881 } 6882 return function() { 6883 var args = arguments, 6884 value = args[0]; 6885 6886 if (wrapper && args.length == 1 && isArray(value)) { 6887 return wrapper.plant(value).value(); 6888 } 6889 var index = 0, 6890 result = length ? funcs[index].apply(this, args) : value; 6891 6892 while (++index < length) { 6893 result = funcs[index].call(this, result); 6894 } 6895 return result; 6896 }; 6897 }); 6898 } 6899 6900 /** 6901 * Creates a function that wraps `func` to invoke it with optional `this` 6902 * binding of `thisArg`, partial application, and currying. 6903 * 6904 * @private 6905 * @param {Function|string} func The function or method name to wrap. 6906 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 6907 * @param {*} [thisArg] The `this` binding of `func`. 6908 * @param {Array} [partials] The arguments to prepend to those provided to 6909 * the new function. 6910 * @param {Array} [holders] The `partials` placeholder indexes. 6911 * @param {Array} [partialsRight] The arguments to append to those provided 6912 * to the new function. 6913 * @param {Array} [holdersRight] The `partialsRight` placeholder indexes. 6914 * @param {Array} [argPos] The argument positions of the new function. 6915 * @param {number} [ary] The arity cap of `func`. 6916 * @param {number} [arity] The arity of `func`. 6917 * @returns {Function} Returns the new wrapped function. 6918 */ 6919 function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) { 6920 var isAry = bitmask & WRAP_ARY_FLAG, 6921 isBind = bitmask & WRAP_BIND_FLAG, 6922 isBindKey = bitmask & WRAP_BIND_KEY_FLAG, 6923 isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), 6924 isFlip = bitmask & WRAP_FLIP_FLAG, 6925 Ctor = isBindKey ? undefined : createCtor(func); 6926 6927 function wrapper() { 6928 var length = arguments.length, 6929 args = Array(length), 6930 index = length; 6931 6932 while (index--) { 6933 args[index] = arguments[index]; 6934 } 6935 if (isCurried) { 6936 var placeholder = getHolder(wrapper), 6937 holdersCount = countHolders(args, placeholder); 6938 } 6939 if (partials) { 6940 args = composeArgs(args, partials, holders, isCurried); 6941 } 6942 if (partialsRight) { 6943 args = composeArgsRight(args, partialsRight, holdersRight, isCurried); 6944 } 6945 length -= holdersCount; 6946 if (isCurried && length < arity) { 6947 var newHolders = replaceHolders(args, placeholder); 6948 return createRecurry( 6949 func, bitmask, createHybrid, wrapper.placeholder, thisArg, 6950 args, newHolders, argPos, ary, arity - length 6951 ); 6952 } 6953 var thisBinding = isBind ? thisArg : this, 6954 fn = isBindKey ? thisBinding[func] : func; 6955 6956 length = args.length; 6957 if (argPos) { 6958 args = reorder(args, argPos); 6959 } else if (isFlip && length > 1) { 6960 args.reverse(); 6961 } 6962 if (isAry && ary < length) { 6963 args.length = ary; 6964 } 6965 if (this && this !== root && this instanceof wrapper) { 6966 fn = Ctor || createCtor(fn); 6967 } 6968 return fn.apply(thisBinding, args); 6969 } 6970 return wrapper; 6971 } 6972 6973 /** 6974 * Creates a function like `_.invertBy`. 6975 * 6976 * @private 6977 * @param {Function} setter The function to set accumulator values. 6978 * @param {Function} toIteratee The function to resolve iteratees. 6979 * @returns {Function} Returns the new inverter function. 6980 */ 6981 function createInverter(setter, toIteratee) { 6982 return function(object, iteratee) { 6983 return baseInverter(object, setter, toIteratee(iteratee), {}); 6984 }; 6985 } 6986 6987 /** 6988 * Creates a function that performs a mathematical operation on two values. 6989 * 6990 * @private 6991 * @param {Function} operator The function to perform the operation. 6992 * @param {number} [defaultValue] The value used for `undefined` arguments. 6993 * @returns {Function} Returns the new mathematical operation function. 6994 */ 6995 function createMathOperation(operator, defaultValue) { 6996 return function(value, other) { 6997 var result; 6998 if (value === undefined && other === undefined) { 6999 return defaultValue; 7000 } 7001 if (value !== undefined) { 7002 result = value; 7003 } 7004 if (other !== undefined) { 7005 if (result === undefined) { 7006 return other; 7007 } 7008 if (typeof value == 'string' || typeof other == 'string') { 7009 value = baseToString(value); 7010 other = baseToString(other); 7011 } else { 7012 value = baseToNumber(value); 7013 other = baseToNumber(other); 7014 } 7015 result = operator(value, other); 7016 } 7017 return result; 7018 }; 7019 } 7020 7021 /** 7022 * Creates a function like `_.over`. 7023 * 7024 * @private 7025 * @param {Function} arrayFunc The function to iterate over iteratees. 7026 * @returns {Function} Returns the new over function. 7027 */ 7028 function createOver(arrayFunc) { 7029 return flatRest(function(iteratees) { 7030 iteratees = arrayMap(iteratees, baseUnary(getIteratee())); 7031 return baseRest(function(args) { 7032 var thisArg = this; 7033 return arrayFunc(iteratees, function(iteratee) { 7034 return apply(iteratee, thisArg, args); 7035 }); 7036 }); 7037 }); 7038 } 7039 7040 /** 7041 * Creates the padding for `string` based on `length`. The `chars` string 7042 * is truncated if the number of characters exceeds `length`. 7043 * 7044 * @private 7045 * @param {number} length The padding length. 7046 * @param {string} [chars=' '] The string used as padding. 7047 * @returns {string} Returns the padding for `string`. 7048 */ 7049 function createPadding(length, chars) { 7050 chars = chars === undefined ? ' ' : baseToString(chars); 7051 7052 var charsLength = chars.length; 7053 if (charsLength < 2) { 7054 return charsLength ? baseRepeat(chars, length) : chars; 7055 } 7056 var result = baseRepeat(chars, nativeCeil(length / stringSize(chars))); 7057 return hasUnicode(chars) 7058 ? castSlice(stringToArray(result), 0, length).join('') 7059 : result.slice(0, length); 7060 } 7061 7062 /** 7063 * Creates a function that wraps `func` to invoke it with the `this` binding 7064 * of `thisArg` and `partials` prepended to the arguments it receives. 7065 * 7066 * @private 7067 * @param {Function} func The function to wrap. 7068 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7069 * @param {*} thisArg The `this` binding of `func`. 7070 * @param {Array} partials The arguments to prepend to those provided to 7071 * the new function. 7072 * @returns {Function} Returns the new wrapped function. 7073 */ 7074 function createPartial(func, bitmask, thisArg, partials) { 7075 var isBind = bitmask & WRAP_BIND_FLAG, 7076 Ctor = createCtor(func); 7077 7078 function wrapper() { 7079 var argsIndex = -1, 7080 argsLength = arguments.length, 7081 leftIndex = -1, 7082 leftLength = partials.length, 7083 args = Array(leftLength + argsLength), 7084 fn = (this && this !== root && this instanceof wrapper) ? Ctor : func; 7085 7086 while (++leftIndex < leftLength) { 7087 args[leftIndex] = partials[leftIndex]; 7088 } 7089 while (argsLength--) { 7090 args[leftIndex++] = arguments[++argsIndex]; 7091 } 7092 return apply(fn, isBind ? thisArg : this, args); 7093 } 7094 return wrapper; 7095 } 7096 7097 /** 7098 * Creates a `_.range` or `_.rangeRight` function. 7099 * 7100 * @private 7101 * @param {boolean} [fromRight] Specify iterating from right to left. 7102 * @returns {Function} Returns the new range function. 7103 */ 7104 function createRange(fromRight) { 7105 return function(start, end, step) { 7106 if (step && typeof step != 'number' && isIterateeCall(start, end, step)) { 7107 end = step = undefined; 7108 } 7109 // Ensure the sign of `-0` is preserved. 7110 start = toFinite(start); 7111 if (end === undefined) { 7112 end = start; 7113 start = 0; 7114 } else { 7115 end = toFinite(end); 7116 } 7117 step = step === undefined ? (start < end ? 1 : -1) : toFinite(step); 7118 return baseRange(start, end, step, fromRight); 7119 }; 7120 } 7121 7122 /** 7123 * Creates a function that performs a relational operation on two values. 7124 * 7125 * @private 7126 * @param {Function} operator The function to perform the operation. 7127 * @returns {Function} Returns the new relational operation function. 7128 */ 7129 function createRelationalOperation(operator) { 7130 return function(value, other) { 7131 if (!(typeof value == 'string' && typeof other == 'string')) { 7132 value = toNumber(value); 7133 other = toNumber(other); 7134 } 7135 return operator(value, other); 7136 }; 7137 } 7138 7139 /** 7140 * Creates a function that wraps `func` to continue currying. 7141 * 7142 * @private 7143 * @param {Function} func The function to wrap. 7144 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 7145 * @param {Function} wrapFunc The function to create the `func` wrapper. 7146 * @param {*} placeholder The placeholder value. 7147 * @param {*} [thisArg] The `this` binding of `func`. 7148 * @param {Array} [partials] The arguments to prepend to those provided to 7149 * the new function. 7150 * @param {Array} [holders] The `partials` placeholder indexes. 7151 * @param {Array} [argPos] The argument positions of the new function. 7152 * @param {number} [ary] The arity cap of `func`. 7153 * @param {number} [arity] The arity of `func`. 7154 * @returns {Function} Returns the new wrapped function. 7155 */ 7156 function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { 7157 var isCurry = bitmask & WRAP_CURRY_FLAG, 7158 newHolders = isCurry ? holders : undefined, 7159 newHoldersRight = isCurry ? undefined : holders, 7160 newPartials = isCurry ? partials : undefined, 7161 newPartialsRight = isCurry ? undefined : partials; 7162 7163 bitmask |= (isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG); 7164 bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG); 7165 7166 if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) { 7167 bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG); 7168 } 7169 var newData = [ 7170 func, bitmask, thisArg, newPartials, newHolders, newPartialsRight, 7171 newHoldersRight, argPos, ary, arity 7172 ]; 7173 7174 var result = wrapFunc.apply(undefined, newData); 7175 if (isLaziable(func)) { 7176 setData(result, newData); 7177 } 7178 result.placeholder = placeholder; 7179 return setWrapToString(result, func, bitmask); 7180 } 7181 7182 /** 7183 * Creates a function like `_.round`. 7184 * 7185 * @private 7186 * @param {string} methodName The name of the `Math` method to use when rounding. 7187 * @returns {Function} Returns the new round function. 7188 */ 7189 function createRound(methodName) { 7190 var func = Math[methodName]; 7191 return function(number, precision) { 7192 number = toNumber(number); 7193 precision = precision == null ? 0 : nativeMin(toInteger(precision), 292); 7194 if (precision && nativeIsFinite(number)) { 7195 // Shift with exponential notation to avoid floating-point issues. 7196 // See [MDN](https://mdn.io/round#Examples) for more details. 7197 var pair = (toString(number) + 'e').split('e'), 7198 value = func(pair[0] + 'e' + (+pair[1] + precision)); 7199 7200 pair = (toString(value) + 'e').split('e'); 7201 return +(pair[0] + 'e' + (+pair[1] - precision)); 7202 } 7203 return func(number); 7204 }; 7205 } 7206 7207 /** 7208 * Creates a set object of `values`. 7209 * 7210 * @private 7211 * @param {Array} values The values to add to the set. 7212 * @returns {Object} Returns the new set. 7213 */ 7214 var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) { 7215 return new Set(values); 7216 }; 7217 7218 /** 7219 * Creates a `_.toPairs` or `_.toPairsIn` function. 7220 * 7221 * @private 7222 * @param {Function} keysFunc The function to get the keys of a given object. 7223 * @returns {Function} Returns the new pairs function. 7224 */ 7225 function createToPairs(keysFunc) { 7226 return function(object) { 7227 var tag = getTag(object); 7228 if (tag == mapTag) { 7229 return mapToArray(object); 7230 } 7231 if (tag == setTag) { 7232 return setToPairs(object); 7233 } 7234 return baseToPairs(object, keysFunc(object)); 7235 }; 7236 } 7237 7238 /** 7239 * Creates a function that either curries or invokes `func` with optional 7240 * `this` binding and partially applied arguments. 7241 * 7242 * @private 7243 * @param {Function|string} func The function or method name to wrap. 7244 * @param {number} bitmask The bitmask flags. 7245 * 1 - `_.bind` 7246 * 2 - `_.bindKey` 7247 * 4 - `_.curry` or `_.curryRight` of a bound function 7248 * 8 - `_.curry` 7249 * 16 - `_.curryRight` 7250 * 32 - `_.partial` 7251 * 64 - `_.partialRight` 7252 * 128 - `_.rearg` 7253 * 256 - `_.ary` 7254 * 512 - `_.flip` 7255 * @param {*} [thisArg] The `this` binding of `func`. 7256 * @param {Array} [partials] The arguments to be partially applied. 7257 * @param {Array} [holders] The `partials` placeholder indexes. 7258 * @param {Array} [argPos] The argument positions of the new function. 7259 * @param {number} [ary] The arity cap of `func`. 7260 * @param {number} [arity] The arity of `func`. 7261 * @returns {Function} Returns the new wrapped function. 7262 */ 7263 function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { 7264 var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; 7265 if (!isBindKey && typeof func != 'function') { 7266 throw new TypeError(FUNC_ERROR_TEXT); 7267 } 7268 var length = partials ? partials.length : 0; 7269 if (!length) { 7270 bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); 7271 partials = holders = undefined; 7272 } 7273 ary = ary === undefined ? ary : nativeMax(toInteger(ary), 0); 7274 arity = arity === undefined ? arity : toInteger(arity); 7275 length -= holders ? holders.length : 0; 7276 7277 if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { 7278 var partialsRight = partials, 7279 holdersRight = holders; 7280 7281 partials = holders = undefined; 7282 } 7283 var data = isBindKey ? undefined : getData(func); 7284 7285 var newData = [ 7286 func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, 7287 argPos, ary, arity 7288 ]; 7289 7290 if (data) { 7291 mergeData(newData, data); 7292 } 7293 func = newData[0]; 7294 bitmask = newData[1]; 7295 thisArg = newData[2]; 7296 partials = newData[3]; 7297 holders = newData[4]; 7298 arity = newData[9] = newData[9] === undefined 7299 ? (isBindKey ? 0 : func.length) 7300 : nativeMax(newData[9] - length, 0); 7301 7302 if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { 7303 bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); 7304 } 7305 if (!bitmask || bitmask == WRAP_BIND_FLAG) { 7306 var result = createBind(func, bitmask, thisArg); 7307 } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { 7308 result = createCurry(func, bitmask, arity); 7309 } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { 7310 result = createPartial(func, bitmask, thisArg, partials); 7311 } else { 7312 result = createHybrid.apply(undefined, newData); 7313 } 7314 var setter = data ? baseSetData : setData; 7315 return setWrapToString(setter(result, newData), func, bitmask); 7316 } 7317 7318 /** 7319 * Used by `_.defaults` to customize its `_.assignIn` use to assign properties 7320 * of source objects to the destination object for all destination properties 7321 * that resolve to `undefined`. 7322 * 7323 * @private 7324 * @param {*} objValue The destination value. 7325 * @param {*} srcValue The source value. 7326 * @param {string} key The key of the property to assign. 7327 * @param {Object} object The parent object of `objValue`. 7328 * @returns {*} Returns the value to assign. 7329 */ 7330 function customDefaultsAssignIn(objValue, srcValue, key, object) { 7331 if (objValue === undefined || 7332 (eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) { 7333 return srcValue; 7334 } 7335 return objValue; 7336 } 7337 7338 /** 7339 * Used by `_.defaultsDeep` to customize its `_.merge` use to merge source 7340 * objects into destination objects that are passed thru. 7341 * 7342 * @private 7343 * @param {*} objValue The destination value. 7344 * @param {*} srcValue The source value. 7345 * @param {string} key The key of the property to merge. 7346 * @param {Object} object The parent object of `objValue`. 7347 * @param {Object} source The parent object of `srcValue`. 7348 * @param {Object} [stack] Tracks traversed source values and their merged 7349 * counterparts. 7350 * @returns {*} Returns the value to assign. 7351 */ 7352 function customDefaultsMerge(objValue, srcValue, key, object, source, stack) { 7353 if (isObject(objValue) && isObject(srcValue)) { 7354 // Recursively merge objects and arrays (susceptible to call stack limits). 7355 stack.set(srcValue, objValue); 7356 baseMerge(objValue, srcValue, undefined, customDefaultsMerge, stack); 7357 stack['delete'](srcValue); 7358 } 7359 return objValue; 7360 } 7361 7362 /** 7363 * Used by `_.omit` to customize its `_.cloneDeep` use to only clone plain 7364 * objects. 7365 * 7366 * @private 7367 * @param {*} value The value to inspect. 7368 * @param {string} key The key of the property to inspect. 7369 * @returns {*} Returns the uncloned value or `undefined` to defer cloning to `_.cloneDeep`. 7370 */ 7371 function customOmitClone(value) { 7372 return isPlainObject(value) ? undefined : value; 7373 } 7374 7375 /** 7376 * A specialized version of `baseIsEqualDeep` for arrays with support for 7377 * partial deep comparisons. 7378 * 7379 * @private 7380 * @param {Array} array The array to compare. 7381 * @param {Array} other The other array to compare. 7382 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 7383 * @param {Function} customizer The function to customize comparisons. 7384 * @param {Function} equalFunc The function to determine equivalents of values. 7385 * @param {Object} stack Tracks traversed `array` and `other` objects. 7386 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 7387 */ 7388 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { 7389 var isPartial = bitmask & COMPARE_PARTIAL_FLAG, 7390 arrLength = array.length, 7391 othLength = other.length; 7392 7393 if (arrLength != othLength && !(isPartial && othLength > arrLength)) { 7394 return false; 7395 } 7396 // Check that cyclic values are equal. 7397 var arrStacked = stack.get(array); 7398 var othStacked = stack.get(other); 7399 if (arrStacked && othStacked) { 7400 return arrStacked == other && othStacked == array; 7401 } 7402 var index = -1, 7403 result = true, 7404 seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined; 7405 7406 stack.set(array, other); 7407 stack.set(other, array); 7408 7409 // Ignore non-index properties. 7410 while (++index < arrLength) { 7411 var arrValue = array[index], 7412 othValue = other[index]; 7413 7414 if (customizer) { 7415 var compared = isPartial 7416 ? customizer(othValue, arrValue, index, other, array, stack) 7417 : customizer(arrValue, othValue, index, array, other, stack); 7418 } 7419 if (compared !== undefined) { 7420 if (compared) { 7421 continue; 7422 } 7423 result = false; 7424 break; 7425 } 7426 // Recursively compare arrays (susceptible to call stack limits). 7427 if (seen) { 7428 if (!arraySome(other, function(othValue, othIndex) { 7429 if (!cacheHas(seen, othIndex) && 7430 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { 7431 return seen.push(othIndex); 7432 } 7433 })) { 7434 result = false;
vendor: 4,179 bytes, lines 7435-7546
7435 break; 7436 } 7437 } else if (!( 7438 arrValue === othValue || 7439 equalFunc(arrValue, othValue, bitmask, customizer, stack) 7440 )) { 7441 result = false; 7442 break; 7443 } 7444 } 7445 stack['delete'](array); 7446 stack['delete'](other); 7447 return result; 7448 } 7449 7450 /** 7451 * A specialized version of `baseIsEqualDeep` for comparing objects of 7452 * the same `toStringTag`. 7453 * 7454 * **Note:** This function only supports comparing values with tags of 7455 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 7456 * 7457 * @private 7458 * @param {Object} object The object to compare. 7459 * @param {Object} other The other object to compare. 7460 * @param {string} tag The `toStringTag` of the objects to compare. 7461 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 7462 * @param {Function} customizer The function to customize comparisons. 7463 * @param {Function} equalFunc The function to determine equivalents of values. 7464 * @param {Object} stack Tracks traversed `object` and `other` objects. 7465 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 7466 */ 7467 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { 7468 switch (tag) { 7469 case dataViewTag: 7470 if ((object.byteLength != other.byteLength) || 7471 (object.byteOffset != other.byteOffset)) { 7472 return false; 7473 } 7474 object = object.buffer; 7475 other = other.buffer; 7476 7477 case arrayBufferTag: 7478 if ((object.byteLength != other.byteLength) || 7479 !equalFunc(new Uint8Array(object), new Uint8Array(other))) { 7480 return false; 7481 } 7482 return true; 7483 7484 case boolTag: 7485 case dateTag: 7486 case numberTag: 7487 // Coerce booleans to `1` or `0` and dates to milliseconds. 7488 // Invalid dates are coerced to `NaN`. 7489 return eq(+object, +other); 7490 7491 case errorTag: 7492 return object.name == other.name && object.message == other.message; 7493 7494 case regexpTag: 7495 case stringTag: 7496 // Coerce regexes to strings and treat strings, primitives and objects, 7497 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring 7498 // for more details. 7499 return object == (other + ''); 7500 7501 case mapTag: 7502 var convert = mapToArray; 7503 7504 case setTag: 7505 var isPartial = bitmask & COMPARE_PARTIAL_FLAG; 7506 convert || (convert = setToArray); 7507 7508 if (object.size != other.size && !isPartial) { 7509 return false; 7510 } 7511 // Assume cyclic values are equal. 7512 var stacked = stack.get(object); 7513 if (stacked) { 7514 return stacked == other; 7515 } 7516 bitmask |= COMPARE_UNORDERED_FLAG; 7517 7518 // Recursively compare objects (susceptible to call stack limits). 7519 stack.set(object, other); 7520 var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); 7521 stack['delete'](object); 7522 return result; 7523 7524 case symbolTag: 7525 if (symbolValueOf) { 7526 return symbolValueOf.call(object) == symbolValueOf.call(other); 7527 } 7528 } 7529 return false; 7530 } 7531 7532 /** 7533 * A specialized version of `baseIsEqualDeep` for objects with support for 7534 * partial deep comparisons. 7535 * 7536 * @private 7537 * @param {Object} object The object to compare. 7538 * @param {Object} other The other object to compare. 7539 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 7540 * @param {Function} customizer The function to customize comparisons. 7541 * @param {Function} equalFunc The function to determine equivalents of values. 7542 * @param {Object} stack Tracks traversed `object` and `other` objects. 7543 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 7544 */ 7545 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { 7546 var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
vendor: 9,614 bytes, lines 7547-7854
7547 objProps = getAllKeys(object), 7548 objLength = objProps.length, 7549 othProps = getAllKeys(other), 7550 othLength = othProps.length; 7551 7552 if (objLength != othLength && !isPartial) { 7553 return false; 7554 } 7555 var index = objLength; 7556 while (index--) { 7557 var key = objProps[index]; 7558 if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { 7559 return false; 7560 } 7561 } 7562 // Check that cyclic values are equal. 7563 var objStacked = stack.get(object); 7564 var othStacked = stack.get(other); 7565 if (objStacked && othStacked) { 7566 return objStacked == other && othStacked == object; 7567 } 7568 var result = true; 7569 stack.set(object, other); 7570 stack.set(other, object); 7571 7572 var skipCtor = isPartial; 7573 while (++index < objLength) { 7574 key = objProps[index]; 7575 var objValue = object[key], 7576 othValue = other[key]; 7577 7578 if (customizer) { 7579 var compared = isPartial 7580 ? customizer(othValue, objValue, key, other, object, stack) 7581 : customizer(objValue, othValue, key, object, other, stack); 7582 } 7583 // Recursively compare objects (susceptible to call stack limits). 7584 if (!(compared === undefined 7585 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) 7586 : compared 7587 )) { 7588 result = false; 7589 break; 7590 } 7591 skipCtor || (skipCtor = key == 'constructor'); 7592 } 7593 if (result && !skipCtor) { 7594 var objCtor = object.constructor, 7595 othCtor = other.constructor; 7596 7597 // Non `Object` object instances with different constructors are not equal. 7598 if (objCtor != othCtor && 7599 ('constructor' in object && 'constructor' in other) && 7600 !(typeof objCtor == 'function' && objCtor instanceof objCtor && 7601 typeof othCtor == 'function' && othCtor instanceof othCtor)) { 7602 result = false; 7603 } 7604 } 7605 stack['delete'](object); 7606 stack['delete'](other); 7607 return result; 7608 } 7609 7610 /** 7611 * A specialized version of `baseRest` which flattens the rest array. 7612 * 7613 * @private 7614 * @param {Function} func The function to apply a rest parameter to. 7615 * @returns {Function} Returns the new function. 7616 */ 7617 function flatRest(func) { 7618 return setToString(overRest(func, undefined, flatten), func + ''); 7619 } 7620 7621 /** 7622 * Creates an array of own enumerable property names and symbols of `object`. 7623 * 7624 * @private 7625 * @param {Object} object The object to query. 7626 * @returns {Array} Returns the array of property names and symbols. 7627 */ 7628 function getAllKeys(object) { 7629 return baseGetAllKeys(object, keys, getSymbols); 7630 } 7631 7632 /** 7633 * Creates an array of own and inherited enumerable property names and 7634 * symbols of `object`. 7635 * 7636 * @private 7637 * @param {Object} object The object to query. 7638 * @returns {Array} Returns the array of property names and symbols. 7639 */ 7640 function getAllKeysIn(object) { 7641 return baseGetAllKeys(object, keysIn, getSymbolsIn); 7642 } 7643 7644 /** 7645 * Gets metadata for `func`. 7646 * 7647 * @private 7648 * @param {Function} func The function to query. 7649 * @returns {*} Returns the metadata for `func`. 7650 */ 7651 var getData = !metaMap ? noop : function(func) { 7652 return metaMap.get(func); 7653 }; 7654 7655 /** 7656 * Gets the name of `func`. 7657 * 7658 * @private 7659 * @param {Function} func The function to query. 7660 * @returns {string} Returns the function name. 7661 */ 7662 function getFuncName(func) { 7663 var result = (func.name + ''), 7664 array = realNames[result], 7665 length = hasOwnProperty.call(realNames, result) ? array.length : 0; 7666 7667 while (length--) { 7668 var data = array[length], 7669 otherFunc = data.func; 7670 if (otherFunc == null || otherFunc == func) { 7671 return data.name; 7672 } 7673 } 7674 return result; 7675 } 7676 7677 /** 7678 * Gets the argument placeholder value for `func`. 7679 * 7680 * @private 7681 * @param {Function} func The function to inspect. 7682 * @returns {*} Returns the placeholder value. 7683 */ 7684 function getHolder(func) { 7685 var object = hasOwnProperty.call(lodash, 'placeholder') ? lodash : func; 7686 return object.placeholder; 7687 } 7688 7689 /** 7690 * Gets the appropriate "iteratee" function. If `_.iteratee` is customized, 7691 * this function returns the custom method, otherwise it returns `baseIteratee`. 7692 * If arguments are provided, the chosen function is invoked with them and 7693 * its result is returned. 7694 * 7695 * @private 7696 * @param {*} [value] The value to convert to an iteratee. 7697 * @param {number} [arity] The arity of the created iteratee. 7698 * @returns {Function} Returns the chosen function or its result. 7699 */ 7700 function getIteratee() { 7701 var result = lodash.iteratee || iteratee; 7702 result = result === iteratee ? baseIteratee : result; 7703 return arguments.length ? result(arguments[0], arguments[1]) : result; 7704 } 7705 7706 /** 7707 * Gets the data for `map`. 7708 * 7709 * @private 7710 * @param {Object} map The map to query. 7711 * @param {string} key The reference key. 7712 * @returns {*} Returns the map data. 7713 */ 7714 function getMapData(map, key) { 7715 var data = map.__data__; 7716 return isKeyable(key) 7717 ? data[typeof key == 'string' ? 'string' : 'hash'] 7718 : data.map; 7719 } 7720 7721 /** 7722 * Gets the property names, values, and compare flags of `object`. 7723 * 7724 * @private 7725 * @param {Object} object The object to query. 7726 * @returns {Array} Returns the match data of `object`. 7727 */ 7728 function getMatchData(object) { 7729 var result = keys(object), 7730 length = result.length; 7731 7732 while (length--) { 7733 var key = result[length], 7734 value = object[key]; 7735 7736 result[length] = [key, value, isStrictComparable(value)]; 7737 } 7738 return result; 7739 } 7740 7741 /** 7742 * Gets the native function at `key` of `object`. 7743 * 7744 * @private 7745 * @param {Object} object The object to query. 7746 * @param {string} key The key of the method to get. 7747 * @returns {*} Returns the function if it's native, else `undefined`. 7748 */ 7749 function getNative(object, key) { 7750 var value = getValue(object, key); 7751 return baseIsNative(value) ? value : undefined; 7752 } 7753 7754 /** 7755 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 7756 * 7757 * @private 7758 * @param {*} value The value to query. 7759 * @returns {string} Returns the raw `toStringTag`. 7760 */ 7761 function getRawTag(value) { 7762 var isOwn = hasOwnProperty.call(value, symToStringTag), 7763 tag = value[symToStringTag]; 7764 7765 try { 7766 value[symToStringTag] = undefined; 7767 var unmasked = true; 7768 } catch (e) {} 7769 7770 var result = nativeObjectToString.call(value); 7771 if (unmasked) { 7772 if (isOwn) { 7773 value[symToStringTag] = tag; 7774 } else { 7775 delete value[symToStringTag]; 7776 } 7777 } 7778 return result; 7779 } 7780 7781 /** 7782 * Creates an array of the own enumerable symbols of `object`. 7783 * 7784 * @private 7785 * @param {Object} object The object to query. 7786 * @returns {Array} Returns the array of symbols. 7787 */ 7788 var getSymbols = !nativeGetSymbols ? stubArray : function(object) { 7789 if (object == null) { 7790 return []; 7791 } 7792 object = Object(object); 7793 return arrayFilter(nativeGetSymbols(object), function(symbol) { 7794 return propertyIsEnumerable.call(object, symbol); 7795 }); 7796 }; 7797 7798 /** 7799 * Creates an array of the own and inherited enumerable symbols of `object`. 7800 * 7801 * @private 7802 * @param {Object} object The object to query. 7803 * @returns {Array} Returns the array of symbols. 7804 */ 7805 var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) { 7806 var result = []; 7807 while (object) { 7808 arrayPush(result, getSymbols(object)); 7809 object = getPrototype(object); 7810 } 7811 return result; 7812 }; 7813 7814 /** 7815 * Gets the `toStringTag` of `value`. 7816 * 7817 * @private 7818 * @param {*} value The value to query. 7819 * @returns {string} Returns the `toStringTag`. 7820 */ 7821 var getTag = baseGetTag; 7822 7823 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. 7824 if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) || 7825 (Map && getTag(new Map) != mapTag) || 7826 (Promise && getTag(Promise.resolve()) != promiseTag) || 7827 (Set && getTag(new Set) != setTag) || 7828 (WeakMap && getTag(new WeakMap) != weakMapTag)) { 7829 getTag = function(value) { 7830 var result = baseGetTag(value), 7831 Ctor = result == objectTag ? value.constructor : undefined, 7832 ctorString = Ctor ? toSource(Ctor) : ''; 7833 7834 if (ctorString) { 7835 switch (ctorString) { 7836 case dataViewCtorString: return dataViewTag; 7837 case mapCtorString: return mapTag; 7838 case promiseCtorString: return promiseTag; 7839 case setCtorString: return setTag; 7840 case weakMapCtorString: return weakMapTag; 7841 } 7842 } 7843 return result; 7844 }; 7845 } 7846 7847 /** 7848 * Gets the view, applying any `transforms` to the `start` and `end` positions. 7849 * 7850 * @private 7851 * @param {number} start The start of the view. 7852 * @param {number} end The end of the view. 7853 * @param {Array} transforms The transformations to apply to the view. 7854 * @returns {Object}
vendor: 6,432 bytes, lines 7854-8059
7854 Returns an object containing the `start` and `end` 7855 * positions of the view. 7856 */ 7857 function getView(start, end, transforms) { 7858 var index = -1, 7859 length = transforms.length; 7860 7861 while (++index < length) { 7862 var data = transforms[index], 7863 size = data.size; 7864 7865 switch (data.type) { 7866 case 'drop': start += size; break; 7867 case 'dropRight': end -= size; break; 7868 case 'take': end = nativeMin(end, start + size); break; 7869 case 'takeRight': start = nativeMax(start, end - size); break; 7870 } 7871 } 7872 return { 'start': start, 'end': end }; 7873 } 7874 7875 /** 7876 * Extracts wrapper details from the `source` body comment. 7877 * 7878 * @private 7879 * @param {string} source The source to inspect. 7880 * @returns {Array} Returns the wrapper details. 7881 */ 7882 function getWrapDetails(source) { 7883 var match = source.match(reWrapDetails); 7884 return match ? match[1].split(reSplitDetails) : []; 7885 } 7886 7887 /** 7888 * Checks if `path` exists on `object`. 7889 * 7890 * @private 7891 * @param {Object} object The object to query. 7892 * @param {Array|string} path The path to check. 7893 * @param {Function} hasFunc The function to check properties. 7894 * @returns {boolean} Returns `true` if `path` exists, else `false`. 7895 */ 7896 function hasPath(object, path, hasFunc) { 7897 path = castPath(path, object); 7898 7899 var index = -1, 7900 length = path.length, 7901 result = false; 7902 7903 while (++index < length) { 7904 var key = toKey(path[index]); 7905 if (!(result = object != null && hasFunc(object, key))) { 7906 break; 7907 } 7908 object = object[key]; 7909 } 7910 if (result || ++index != length) { 7911 return result; 7912 } 7913 length = object == null ? 0 : object.length; 7914 return !!length && isLength(length) && isIndex(key, length) && 7915 (isArray(object) || isArguments(object)); 7916 } 7917 7918 /** 7919 * Initializes an array clone. 7920 * 7921 * @private 7922 * @param {Array} array The array to clone. 7923 * @returns {Array} Returns the initialized clone. 7924 */ 7925 function initCloneArray(array) { 7926 var length = array.length, 7927 result = new array.constructor(length); 7928 7929 // Add properties assigned by `RegExp#exec`. 7930 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { 7931 result.index = array.index; 7932 result.input = array.input; 7933 } 7934 return result; 7935 } 7936 7937 /** 7938 * Initializes an object clone. 7939 * 7940 * @private 7941 * @param {Object} object The object to clone. 7942 * @returns {Object} Returns the initialized clone. 7943 */ 7944 function initCloneObject(object) { 7945 return (typeof object.constructor == 'function' && !isPrototype(object)) 7946 ? baseCreate(getPrototype(object)) 7947 : {}; 7948 } 7949 7950 /** 7951 * Initializes an object clone based on its `toStringTag`. 7952 * 7953 * **Note:** This function only supports cloning values with tags of 7954 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. 7955 * 7956 * @private 7957 * @param {Object} object The object to clone. 7958 * @param {string} tag The `toStringTag` of the object to clone. 7959 * @param {boolean} [isDeep] Specify a deep clone. 7960 * @returns {Object} Returns the initialized clone. 7961 */ 7962 function initCloneByTag(object, tag, isDeep) { 7963 var Ctor = object.constructor; 7964 switch (tag) { 7965 case arrayBufferTag: 7966 return cloneArrayBuffer(object); 7967 7968 case boolTag: 7969 case dateTag: 7970 return new Ctor(+object); 7971 7972 case dataViewTag: 7973 return cloneDataView(object, isDeep); 7974 7975 case float32Tag: case float64Tag: 7976 case int8Tag: case int16Tag: case int32Tag: 7977 case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag: 7978 return cloneTypedArray(object, isDeep); 7979 7980 case mapTag: 7981 return new Ctor; 7982 7983 case numberTag: 7984 case stringTag: 7985 return new Ctor(object); 7986 7987 case regexpTag: 7988 return cloneRegExp(object); 7989 7990 case setTag: 7991 return new Ctor; 7992 7993 case symbolTag: 7994 return cloneSymbol(object); 7995 } 7996 } 7997 7998 /** 7999 * Inserts wrapper `details` in a comment at the top of the `source` body. 8000 * 8001 * @private 8002 * @param {string} source The source to modify. 8003 * @returns {Array} details The details to insert. 8004 * @returns {string} Returns the modified source. 8005 */ 8006 function insertWrapDetails(source, details) { 8007 var length = details.length; 8008 if (!length) { 8009 return source; 8010 } 8011 var lastIndex = length - 1; 8012 details[lastIndex] = (length > 1 ? '& ' : '') + details[lastIndex]; 8013 details = details.join(length > 2 ? ', ' : ' '); 8014 return source.replace(reWrapComment, '{\n/* [wrapped with ' + details + '] */\n'); 8015 } 8016 8017 /** 8018 * Checks if `value` is a flattenable `arguments` object or array. 8019 * 8020 * @private 8021 * @param {*} value The value to check. 8022 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`. 8023 */ 8024 function isFlattenable(value) { 8025 return isArray(value) || isArguments(value) || 8026 !!(spreadableSymbol && value && value[spreadableSymbol]); 8027 } 8028 8029 /** 8030 * Checks if `value` is a valid array-like index. 8031 * 8032 * @private 8033 * @param {*} value The value to check. 8034 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 8035 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 8036 */ 8037 function isIndex(value, length) { 8038 var type = typeof value; 8039 length = length == null ? MAX_SAFE_INTEGER : length; 8040 8041 return !!length && 8042 (type == 'number' || 8043 (type != 'symbol' && reIsUint.test(value))) && 8044 (value > -1 && value % 1 == 0 && value < length); 8045 } 8046 8047 /** 8048 * Checks if the given arguments are from an iteratee call. 8049 * 8050 * @private 8051 * @param {*} value The potential iteratee value argument. 8052 * @param {*} index The potential iteratee index or key argument. 8053 * @param {*} object The potential iteratee object argument. 8054 * @returns {boolean} Returns `true` if the arguments are from an iteratee call, 8055 * else `false`. 8056 */ 8057 function isIterateeCall(value, index, object) { 8058 if (!isObject(object)) { 8059 return false;
vendor: 14,387 bytes, lines 8060-8506
8060 } 8061 var type = typeof index; 8062 if (type == 'number' 8063 ? (isArrayLike(object) && isIndex(index, object.length)) 8064 : (type == 'string' && index in object) 8065 ) { 8066 return eq(object[index], value); 8067 } 8068 return false; 8069 } 8070 8071 /** 8072 * Checks if `value` is a property name and not a property path. 8073 * 8074 * @private 8075 * @param {*} value The value to check. 8076 * @param {Object} [object] The object to query keys on. 8077 * @returns {boolean} Returns `true` if `value` is a property name, else `false`. 8078 */ 8079 function isKey(value, object) { 8080 if (isArray(value)) { 8081 return false; 8082 } 8083 var type = typeof value; 8084 if (type == 'number' || type == 'symbol' || type == 'boolean' || 8085 value == null || isSymbol(value)) { 8086 return true; 8087 } 8088 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || 8089 (object != null && value in Object(object)); 8090 } 8091 8092 /** 8093 * Checks if `value` is suitable for use as unique object key. 8094 * 8095 * @private 8096 * @param {*} value The value to check. 8097 * @returns {boolean} Returns `true` if `value` is suitable, else `false`. 8098 */ 8099 function isKeyable(value) { 8100 var type = typeof value; 8101 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 8102 ? (value !== '__proto__') 8103 : (value === null); 8104 } 8105 8106 /** 8107 * Checks if `func` has a lazy counterpart. 8108 * 8109 * @private 8110 * @param {Function} func The function to check. 8111 * @returns {boolean} Returns `true` if `func` has a lazy counterpart, 8112 * else `false`. 8113 */ 8114 function isLaziable(func) { 8115 var funcName = getFuncName(func), 8116 other = lodash[funcName]; 8117 8118 if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { 8119 return false; 8120 } 8121 if (func === other) { 8122 return true; 8123 } 8124 var data = getData(other); 8125 return !!data && func === data[0]; 8126 } 8127 8128 /** 8129 * Checks if `func` has its source masked. 8130 * 8131 * @private 8132 * @param {Function} func The function to check. 8133 * @returns {boolean} Returns `true` if `func` is masked, else `false`. 8134 */ 8135 function isMasked(func) { 8136 return !!maskSrcKey && (maskSrcKey in func); 8137 } 8138 8139 /** 8140 * Checks if `func` is capable of being masked. 8141 * 8142 * @private 8143 * @param {*} value The value to check. 8144 * @returns {boolean} Returns `true` if `func` is maskable, else `false`. 8145 */ 8146 var isMaskable = coreJsData ? isFunction : stubFalse; 8147 8148 /** 8149 * Checks if `value` is likely a prototype object. 8150 * 8151 * @private 8152 * @param {*} value The value to check. 8153 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. 8154 */ 8155 function isPrototype(value) { 8156 var Ctor = value && value.constructor, 8157 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto; 8158 8159 return value === proto; 8160 } 8161 8162 /** 8163 * Checks if `value` is suitable for strict equality comparisons, i.e. `===`. 8164 * 8165 * @private 8166 * @param {*} value The value to check. 8167 * @returns {boolean} Returns `true` if `value` if suitable for strict 8168 * equality comparisons, else `false`. 8169 */ 8170 function isStrictComparable(value) { 8171 return value === value && !isObject(value); 8172 } 8173 8174 /** 8175 * A specialized version of `matchesProperty` for source values suitable 8176 * for strict equality comparisons, i.e. `===`. 8177 * 8178 * @private 8179 * @param {string} key The key of the property to get. 8180 * @param {*} srcValue The value to match. 8181 * @returns {Function} Returns the new spec function. 8182 */ 8183 function matchesStrictComparable(key, srcValue) { 8184 return function(object) { 8185 if (object == null) { 8186 return false; 8187 } 8188 return object[key] === srcValue && 8189 (srcValue !== undefined || (key in Object(object))); 8190 }; 8191 } 8192 8193 /** 8194 * A specialized version of `_.memoize` which clears the memoized function's 8195 * cache when it exceeds `MAX_MEMOIZE_SIZE`. 8196 * 8197 * @private 8198 * @param {Function} func The function to have its output memoized. 8199 * @returns {Function} Returns the new memoized function. 8200 */ 8201 function memoizeCapped(func) { 8202 var result = memoize(func, function(key) { 8203 if (cache.size === MAX_MEMOIZE_SIZE) { 8204 cache.clear(); 8205 } 8206 return key; 8207 }); 8208 8209 var cache = result.cache; 8210 return result; 8211 } 8212 8213 /** 8214 * Merges the function metadata of `source` into `data`. 8215 * 8216 * Merging metadata reduces the number of wrappers used to invoke a function. 8217 * This is possible because methods like `_.bind`, `_.curry`, and `_.partial` 8218 * may be applied regardless of execution order. Methods like `_.ary` and 8219 * `_.rearg` modify function arguments, making the order in which they are 8220 * executed important, preventing the merging of metadata. However, we make 8221 * an exception for a safe combined case where curried functions have `_.ary` 8222 * and or `_.rearg` applied. 8223 * 8224 * @private 8225 * @param {Array} data The destination metadata. 8226 * @param {Array} source The source metadata. 8227 * @returns {Array} Returns `data`. 8228 */ 8229 function mergeData(data, source) { 8230 var bitmask = data[1], 8231 srcBitmask = source[1], 8232 newBitmask = bitmask | srcBitmask, 8233 isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG); 8234 8235 var isCombo = 8236 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_CURRY_FLAG)) || 8237 ((srcBitmask == WRAP_ARY_FLAG) && (bitmask == WRAP_REARG_FLAG) && (data[7].length <= source[8])) || 8238 ((srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == WRAP_CURRY_FLAG)); 8239 8240 // Exit early if metadata can't be merged. 8241 if (!(isCommon || isCombo)) { 8242 return data; 8243 } 8244 // Use source `thisArg` if available. 8245 if (srcBitmask & WRAP_BIND_FLAG) { 8246 data[2] = source[2]; 8247 // Set when currying a bound function. 8248 newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG; 8249 } 8250 // Compose partial arguments. 8251 var value = source[3]; 8252 if (value) { 8253 var partials = data[3]; 8254 data[3] = partials ? composeArgs(partials, value, source[4]) : value; 8255 data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4]; 8256 } 8257 // Compose partial right arguments. 8258 value = source[5]; 8259 if (value) { 8260 partials = data[5]; 8261 data[5] = partials ? composeArgsRight(partials, value, source[6]) : value; 8262 data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6]; 8263 } 8264 // Use source `argPos` if available. 8265 value = source[7]; 8266 if (value) { 8267 data[7] = value; 8268 } 8269 // Use source `ary` if it's smaller. 8270 if (srcBitmask & WRAP_ARY_FLAG) { 8271 data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]); 8272 } 8273 // Use source `arity` if one is not provided. 8274 if (data[9] == null) { 8275 data[9] = source[9]; 8276 } 8277 // Use source `func` and merge bitmasks. 8278 data[0] = source[0]; 8279 data[1] = newBitmask; 8280 8281 return data; 8282 } 8283 8284 /** 8285 * This function is like 8286 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 8287 * except that it includes inherited enumerable properties. 8288 * 8289 * @private 8290 * @param {Object} object The object to query. 8291 * @returns {Array} Returns the array of property names. 8292 */ 8293 function nativeKeysIn(object) { 8294 var result = []; 8295 if (object != null) { 8296 for (var key in Object(object)) { 8297 result.push(key); 8298 } 8299 } 8300 return result; 8301 } 8302 8303 /** 8304 * Converts `value` to a string using `Object.prototype.toString`. 8305 * 8306 * @private 8307 * @param {*} value The value to convert. 8308 * @returns {string} Returns the converted string. 8309 */ 8310 function objectToString(value) { 8311 return nativeObjectToString.call(value); 8312 } 8313 8314 /** 8315 * A specialized version of `baseRest` which transforms the rest array. 8316 * 8317 * @private 8318 * @param {Function} func The function to apply a rest parameter to. 8319 * @param {number} [start=func.length-1] The start position of the rest parameter. 8320 * @param {Function} transform The rest array transform. 8321 * @returns {Function} Returns the new function. 8322 */ 8323 function overRest(func, start, transform) { 8324 start = nativeMax(start === undefined ? (func.length - 1) : start, 0); 8325 return function() { 8326 var args = arguments, 8327 index = -1, 8328 length = nativeMax(args.length - start, 0), 8329 array = Array(length); 8330 8331 while (++index < length) { 8332 array[index] = args[start + index]; 8333 } 8334 index = -1; 8335 var otherArgs = Array(start + 1); 8336 while (++index < start) { 8337 otherArgs[index] = args[index]; 8338 } 8339 otherArgs[start] = transform(array); 8340 return apply(func, this, otherArgs); 8341 }; 8342 } 8343 8344 /** 8345 * Gets the parent value at `path` of `object`. 8346 * 8347 * @private 8348 * @param {Object} object The object to query. 8349 * @param {Array} path The path to get the parent value of. 8350 * @returns {*} Returns the parent value. 8351 */ 8352 function parent(object, path) { 8353 return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1)); 8354 } 8355 8356 /** 8357 * Reorder `array` according to the specified indexes where the element at 8358 * the first index is assigned as the first element, the element at 8359 * the second index is assigned as the second element, and so on. 8360 * 8361 * @private 8362 * @param {Array} array The array to reorder. 8363 * @param {Array} indexes The arranged array indexes. 8364 * @returns {Array} Returns `array`. 8365 */ 8366 function reorder(array, indexes) { 8367 var arrLength = array.length, 8368 length = nativeMin(indexes.length, arrLength), 8369 oldArray = copyArray(array); 8370 8371 while (length--) { 8372 var index = indexes[length]; 8373 array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined; 8374 } 8375 return array; 8376 } 8377 8378 /** 8379 * Gets the value at `key`, unless `key` is "__proto__" or "constructor". 8380 * 8381 * @private 8382 * @param {Object} object The object to query. 8383 * @param {string} key The key of the property to get. 8384 * @returns {*} Returns the property value. 8385 */ 8386 function safeGet(object, key) { 8387 if (key === 'constructor' && typeof object[key] === 'function') { 8388 return; 8389 } 8390 8391 if (key == '__proto__') { 8392 return; 8393 } 8394 8395 return object[key]; 8396 } 8397 8398 /** 8399 * Sets metadata for `func`. 8400 * 8401 * **Note:** If this function becomes hot, i.e. is invoked a lot in a short 8402 * period of time, it will trip its breaker and transition to an identity 8403 * function to avoid garbage collection pauses in V8. See 8404 * [V8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070) 8405 * for more details. 8406 * 8407 * @private 8408 * @param {Function} func The function to associate metadata with. 8409 * @param {*} data The metadata. 8410 * @returns {Function} Returns `func`. 8411 */ 8412 var setData = shortOut(baseSetData); 8413 8414 /** 8415 * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). 8416 * 8417 * @private 8418 * @param {Function} func The function to delay. 8419 * @param {number} wait The number of milliseconds to delay invocation. 8420 * @returns {number|Object} Returns the timer id or timeout object. 8421 */ 8422 var setTimeout = ctxSetTimeout || function(func, wait) { 8423 return root.setTimeout(func, wait); 8424 }; 8425 8426 /** 8427 * Sets the `toString` method of `func` to return `string`. 8428 * 8429 * @private 8430 * @param {Function} func The function to modify. 8431 * @param {Function} string The `toString` result. 8432 * @returns {Function} Returns `func`. 8433 */ 8434 var setToString = shortOut(baseSetToString); 8435 8436 /** 8437 * Sets the `toString` method of `wrapper` to mimic the source of `reference` 8438 * with wrapper details in a comment at the top of the source body. 8439 * 8440 * @private 8441 * @param {Function} wrapper The function to modify. 8442 * @param {Function} reference The reference function. 8443 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 8444 * @returns {Function} Returns `wrapper`. 8445 */ 8446 function setWrapToString(wrapper, reference, bitmask) { 8447 var source = (reference + ''); 8448 return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask))); 8449 } 8450 8451 /** 8452 * Creates a function that'll short out and invoke `identity` instead 8453 * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN` 8454 * milliseconds. 8455 * 8456 * @private 8457 * @param {Function} func The function to restrict. 8458 * @returns {Function} Returns the new shortable function. 8459 */ 8460 function shortOut(func) { 8461 var count = 0, 8462 lastCalled = 0; 8463 8464 return function() { 8465 var stamp = nativeNow(), 8466 remaining = HOT_SPAN - (stamp - lastCalled); 8467 8468 lastCalled = stamp; 8469 if (remaining > 0) { 8470 if (++count >= HOT_COUNT) { 8471 return arguments[0]; 8472 } 8473 } else { 8474 count = 0; 8475 } 8476 return func.apply(undefined, arguments); 8477 }; 8478 } 8479 8480 /** 8481 * A specialized version of `_.shuffle` which mutates and sets the size of `array`. 8482 * 8483 * @private 8484 * @param {Array} array The array to shuffle. 8485 * @param {number} [size=array.length] The size of `array`. 8486 * @returns {Array} Returns `array`. 8487 */ 8488 function shuffleSelf(array, size) { 8489 var index = -1, 8490 length = array.length, 8491 lastIndex = length - 1; 8492 8493 size = size === undefined ? length : size; 8494 while (++index < size) { 8495 var rand = baseRandom(index, lastIndex), 8496 value = array[rand]; 8497 8498 array[rand] = array[index]; 8499 array[index] = value; 8500 } 8501 array.length = size; 8502 return array; 8503 } 8504 8505 /** 8506 * Converts `string` to a property path array.
vendor: 1,775 bytes, lines 8507-8567
8507 * 8508 * @private 8509 * @param {string} string The string to convert. 8510 * @returns {Array} Returns the property path array. 8511 */ 8512 var stringToPath = memoizeCapped(function(string) { 8513 var result = []; 8514 if (string.charCodeAt(0) === 46 /* . */) { 8515 result.push(''); 8516 } 8517 string.replace(rePropName, function(match, number, quote, subString) { 8518 result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match)); 8519 }); 8520 return result; 8521 }); 8522 8523 /** 8524 * Converts `value` to a string key if it's not a string or symbol. 8525 * 8526 * @private 8527 * @param {*} value The value to inspect. 8528 * @returns {string|symbol} Returns the key. 8529 */ 8530 function toKey(value) { 8531 if (typeof value == 'string' || isSymbol(value)) { 8532 return value; 8533 } 8534 var result = (value + ''); 8535 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 8536 } 8537 8538 /** 8539 * Converts `func` to its source code. 8540 * 8541 * @private 8542 * @param {Function} func The function to convert. 8543 * @returns {string} Returns the source code. 8544 */ 8545 function toSource(func) { 8546 if (func != null) { 8547 try { 8548 return funcToString.call(func); 8549 } catch (e) {} 8550 try { 8551 return (func + ''); 8552 } catch (e) {} 8553 } 8554 return ''; 8555 } 8556 8557 /** 8558 * Updates wrapper `details` based on `bitmask` flags. 8559 * 8560 * @private 8561 * @returns {Array} details The details to modify. 8562 * @param {number} bitmask The bitmask flags. See `createWrap` for more details. 8563 * @returns {Array} Returns `details`. 8564 */ 8565 function updateWrapDetails(details, bitmask) { 8566 arrayEach(wrapFlags, function(pair) { 8567 var value = '_.' + pair[0];
vendor: 80,381 bytes, lines 8568-11151
8568 if ((bitmask & pair[1]) && !arrayIncludes(details, value)) { 8569 details.push(value); 8570 } 8571 }); 8572 return details.sort(); 8573 } 8574 8575 /** 8576 * Creates a clone of `wrapper`. 8577 * 8578 * @private 8579 * @param {Object} wrapper The wrapper to clone. 8580 * @returns {Object} Returns the cloned wrapper. 8581 */ 8582 function wrapperClone(wrapper) { 8583 if (wrapper instanceof LazyWrapper) { 8584 return wrapper.clone(); 8585 } 8586 var result = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__); 8587 result.__actions__ = copyArray(wrapper.__actions__); 8588 result.__index__ = wrapper.__index__; 8589 result.__values__ = wrapper.__values__; 8590 return result; 8591 } 8592 8593 /*------------------------------------------------------------------------*/ 8594 8595 /** 8596 * Creates an array of elements split into groups the length of `size`. 8597 * If `array` can't be split evenly, the final chunk will be the remaining 8598 * elements. 8599 * 8600 * @static 8601 * @memberOf _ 8602 * @since 3.0.0 8603 * @category Array 8604 * @param {Array} array The array to process. 8605 * @param {number} [size=1] The length of each chunk 8606 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 8607 * @returns {Array} Returns the new array of chunks. 8608 * @example 8609 * 8610 * _.chunk(['a', 'b', 'c', 'd'], 2); 8611 * // => [['a', 'b'], ['c', 'd']] 8612 * 8613 * _.chunk(['a', 'b', 'c', 'd'], 3); 8614 * // => [['a', 'b', 'c'], ['d']] 8615 */ 8616 function chunk(array, size, guard) { 8617 if ((guard ? isIterateeCall(array, size, guard) : size === undefined)) { 8618 size = 1; 8619 } else { 8620 size = nativeMax(toInteger(size), 0); 8621 } 8622 var length = array == null ? 0 : array.length; 8623 if (!length || size < 1) { 8624 return []; 8625 } 8626 var index = 0, 8627 resIndex = 0, 8628 result = Array(nativeCeil(length / size)); 8629 8630 while (index < length) { 8631 result[resIndex++] = baseSlice(array, index, (index += size)); 8632 } 8633 return result; 8634 } 8635 8636 /** 8637 * Creates an array with all falsey values removed. The values `false`, `null`, 8638 * `0`, `""`, `undefined`, and `NaN` are falsey. 8639 * 8640 * @static 8641 * @memberOf _ 8642 * @since 0.1.0 8643 * @category Array 8644 * @param {Array} array The array to compact. 8645 * @returns {Array} Returns the new array of filtered values. 8646 * @example 8647 * 8648 * _.compact([0, 1, false, 2, '', 3]); 8649 * // => [1, 2, 3] 8650 */ 8651 function compact(array) { 8652 var index = -1, 8653 length = array == null ? 0 : array.length, 8654 resIndex = 0, 8655 result = []; 8656 8657 while (++index < length) { 8658 var value = array[index]; 8659 if (value) { 8660 result[resIndex++] = value; 8661 } 8662 } 8663 return result; 8664 } 8665 8666 /** 8667 * Creates a new array concatenating `array` with any additional arrays 8668 * and/or values. 8669 * 8670 * @static 8671 * @memberOf _ 8672 * @since 4.0.0 8673 * @category Array 8674 * @param {Array} array The array to concatenate. 8675 * @param {...*} [values] The values to concatenate. 8676 * @returns {Array} Returns the new concatenated array. 8677 * @example 8678 * 8679 * var array = [1]; 8680 * var other = _.concat(array, 2, [3], [[4]]); 8681 * 8682 * console.log(other); 8683 * // => [1, 2, 3, [4]] 8684 * 8685 * console.log(array); 8686 * // => [1] 8687 */ 8688 function concat() { 8689 var length = arguments.length; 8690 if (!length) { 8691 return []; 8692 } 8693 var args = Array(length - 1), 8694 array = arguments[0], 8695 index = length; 8696 8697 while (index--) { 8698 args[index - 1] = arguments[index]; 8699 } 8700 return arrayPush(isArray(array) ? copyArray(array) : [array], baseFlatten(args, 1)); 8701 } 8702 8703 /** 8704 * Creates an array of `array` values not included in the other given arrays 8705 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 8706 * for equality comparisons. The order and references of result values are 8707 * determined by the first array. 8708 * 8709 * **Note:** Unlike `_.pullAll`, this method returns a new array. 8710 * 8711 * @static 8712 * @memberOf _ 8713 * @since 0.1.0 8714 * @category Array 8715 * @param {Array} array The array to inspect. 8716 * @param {...Array} [values] The values to exclude. 8717 * @returns {Array} Returns the new array of filtered values. 8718 * @see _.without, _.xor 8719 * @example 8720 * 8721 * _.difference([2, 1], [2, 3]); 8722 * // => [1] 8723 */ 8724 var difference = baseRest(function(array, values) { 8725 return isArrayLikeObject(array) 8726 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) 8727 : []; 8728 }); 8729 8730 /** 8731 * This method is like `_.difference` except that it accepts `iteratee` which 8732 * is invoked for each element of `array` and `values` to generate the criterion 8733 * by which they're compared. The order and references of result values are 8734 * determined by the first array. The iteratee is invoked with one argument: 8735 * (value). 8736 * 8737 * **Note:** Unlike `_.pullAllBy`, this method returns a new array. 8738 * 8739 * @static 8740 * @memberOf _ 8741 * @since 4.0.0 8742 * @category Array 8743 * @param {Array} array The array to inspect. 8744 * @param {...Array} [values] The values to exclude. 8745 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 8746 * @returns {Array} Returns the new array of filtered values. 8747 * @example 8748 * 8749 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); 8750 * // => [1.2] 8751 * 8752 * // The `_.property` iteratee shorthand. 8753 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x'); 8754 * // => [{ 'x': 2 }] 8755 */ 8756 var differenceBy = baseRest(function(array, values) { 8757 var iteratee = last(values); 8758 if (isArrayLikeObject(iteratee)) { 8759 iteratee = undefined; 8760 } 8761 return isArrayLikeObject(array) 8762 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)) 8763 : []; 8764 }); 8765 8766 /** 8767 * This method is like `_.difference` except that it accepts `comparator` 8768 * which is invoked to compare elements of `array` to `values`. The order and 8769 * references of result values are determined by the first array. The comparator 8770 * is invoked with two arguments: (arrVal, othVal). 8771 * 8772 * **Note:** Unlike `_.pullAllWith`, this method returns a new array. 8773 * 8774 * @static 8775 * @memberOf _ 8776 * @since 4.0.0 8777 * @category Array 8778 * @param {Array} array The array to inspect. 8779 * @param {...Array} [values] The values to exclude. 8780 * @param {Function} [comparator] The comparator invoked per element. 8781 * @returns {Array} Returns the new array of filtered values. 8782 * @example 8783 * 8784 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 8785 * 8786 * _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual); 8787 * // => [{ 'x': 2, 'y': 1 }] 8788 */ 8789 var differenceWith = baseRest(function(array, values) { 8790 var comparator = last(values); 8791 if (isArrayLikeObject(comparator)) { 8792 comparator = undefined; 8793 } 8794 return isArrayLikeObject(array) 8795 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), undefined, comparator) 8796 : []; 8797 }); 8798 8799 /** 8800 * Creates a slice of `array` with `n` elements dropped from the beginning. 8801 * 8802 * @static 8803 * @memberOf _ 8804 * @since 0.5.0 8805 * @category Array 8806 * @param {Array} array The array to query. 8807 * @param {number} [n=1] The number of elements to drop. 8808 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 8809 * @returns {Array} Returns the slice of `array`. 8810 * @example 8811 * 8812 * _.drop([1, 2, 3]); 8813 * // => [2, 3] 8814 * 8815 * _.drop([1, 2, 3], 2); 8816 * // => [3] 8817 * 8818 * _.drop([1, 2, 3], 5); 8819 * // => [] 8820 * 8821 * _.drop([1, 2, 3], 0); 8822 * // => [1, 2, 3] 8823 */ 8824 function drop(array, n, guard) { 8825 var length = array == null ? 0 : array.length; 8826 if (!length) { 8827 return []; 8828 } 8829 n = (guard || n === undefined) ? 1 : toInteger(n); 8830 return baseSlice(array, n < 0 ? 0 : n, length); 8831 } 8832 8833 /** 8834 * Creates a slice of `array` with `n` elements dropped from the end. 8835 * 8836 * @static 8837 * @memberOf _ 8838 * @since 3.0.0 8839 * @category Array 8840 * @param {Array} array The array to query. 8841 * @param {number} [n=1] The number of elements to drop. 8842 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 8843 * @returns {Array} Returns the slice of `array`. 8844 * @example 8845 * 8846 * _.dropRight([1, 2, 3]); 8847 * // => [1, 2] 8848 * 8849 * _.dropRight([1, 2, 3], 2); 8850 * // => [1] 8851 * 8852 * _.dropRight([1, 2, 3], 5); 8853 * // => [] 8854 * 8855 * _.dropRight([1, 2, 3], 0); 8856 * // => [1, 2, 3] 8857 */ 8858 function dropRight(array, n, guard) { 8859 var length = array == null ? 0 : array.length; 8860 if (!length) { 8861 return []; 8862 } 8863 n = (guard || n === undefined) ? 1 : toInteger(n); 8864 n = length - n; 8865 return baseSlice(array, 0, n < 0 ? 0 : n); 8866 } 8867 8868 /** 8869 * Creates a slice of `array` excluding elements dropped from the end. 8870 * Elements are dropped until `predicate` returns falsey. The predicate is 8871 * invoked with three arguments: (value, index, array). 8872 * 8873 * @static 8874 * @memberOf _ 8875 * @since 3.0.0 8876 * @category Array 8877 * @param {Array} array The array to query. 8878 * @param {Function} [predicate=_.identity] The function invoked per iteration. 8879 * @returns {Array} Returns the slice of `array`. 8880 * @example 8881 * 8882 * var users = [ 8883 * { 'user': 'barney', 'active': true }, 8884 * { 'user': 'fred', 'active': false }, 8885 * { 'user': 'pebbles', 'active': false } 8886 * ]; 8887 * 8888 * _.dropRightWhile(users, function(o) { return !o.active; }); 8889 * // => objects for ['barney'] 8890 * 8891 * // The `_.matches` iteratee shorthand. 8892 * _.dropRightWhile(users, { 'user': 'pebbles', 'active': false }); 8893 * // => objects for ['barney', 'fred'] 8894 * 8895 * // The `_.matchesProperty` iteratee shorthand. 8896 * _.dropRightWhile(users, ['active', false]); 8897 * // => objects for ['barney'] 8898 * 8899 * // The `_.property` iteratee shorthand. 8900 * _.dropRightWhile(users, 'active'); 8901 * // => objects for ['barney', 'fred', 'pebbles'] 8902 */ 8903 function dropRightWhile(array, predicate) { 8904 return (array && array.length) 8905 ? baseWhile(array, getIteratee(predicate, 3), true, true) 8906 : []; 8907 } 8908 8909 /** 8910 * Creates a slice of `array` excluding elements dropped from the beginning. 8911 * Elements are dropped until `predicate` returns falsey. The predicate is 8912 * invoked with three arguments: (value, index, array). 8913 * 8914 * @static 8915 * @memberOf _ 8916 * @since 3.0.0 8917 * @category Array 8918 * @param {Array} array The array to query. 8919 * @param {Function} [predicate=_.identity] The function invoked per iteration. 8920 * @returns {Array} Returns the slice of `array`. 8921 * @example 8922 * 8923 * var users = [ 8924 * { 'user': 'barney', 'active': false }, 8925 * { 'user': 'fred', 'active': false }, 8926 * { 'user': 'pebbles', 'active': true } 8927 * ]; 8928 * 8929 * _.dropWhile(users, function(o) { return !o.active; }); 8930 * // => objects for ['pebbles'] 8931 * 8932 * // The `_.matches` iteratee shorthand. 8933 * _.dropWhile(users, { 'user': 'barney', 'active': false }); 8934 * // => objects for ['fred', 'pebbles'] 8935 * 8936 * // The `_.matchesProperty` iteratee shorthand. 8937 * _.dropWhile(users, ['active', false]); 8938 * // => objects for ['pebbles'] 8939 * 8940 * // The `_.property` iteratee shorthand. 8941 * _.dropWhile(users, 'active'); 8942 * // => objects for ['barney', 'fred', 'pebbles'] 8943 */ 8944 function dropWhile(array, predicate) { 8945 return (array && array.length) 8946 ? baseWhile(array, getIteratee(predicate, 3), true) 8947 : []; 8948 } 8949 8950 /** 8951 * Fills elements of `array` with `value` from `start` up to, but not 8952 * including, `end`. 8953 * 8954 * **Note:** This method mutates `array`. 8955 * 8956 * @static 8957 * @memberOf _ 8958 * @since 3.2.0 8959 * @category Array 8960 * @param {Array} array The array to fill. 8961 * @param {*} value The value to fill `array` with. 8962 * @param {number} [start=0] The start position. 8963 * @param {number} [end=array.length] The end position. 8964 * @returns {Array} Returns `array`. 8965 * @example 8966 * 8967 * var array = [1, 2, 3]; 8968 * 8969 * _.fill(array, 'a'); 8970 * console.log(array); 8971 * // => ['a', 'a', 'a'] 8972 * 8973 * _.fill(Array(3), 2); 8974 * // => [2, 2, 2] 8975 * 8976 * _.fill([4, 6, 8, 10], '*', 1, 3); 8977 * // => [4, '*', '*', 10] 8978 */ 8979 function fill(array, value, start, end) { 8980 var length = array == null ? 0 : array.length; 8981 if (!length) { 8982 return []; 8983 } 8984 if (start && typeof start != 'number' && isIterateeCall(array, value, start)) { 8985 start = 0; 8986 end = length; 8987 } 8988 return baseFill(array, value, start, end); 8989 } 8990 8991 /** 8992 * This method is like `_.find` except that it returns the index of the first 8993 * element `predicate` returns truthy for instead of the element itself. 8994 * 8995 * @static 8996 * @memberOf _ 8997 * @since 1.1.0 8998 * @category Array 8999 * @param {Array} array The array to inspect. 9000 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9001 * @param {number} [fromIndex=0] The index to search from. 9002 * @returns {number} Returns the index of the found element, else `-1`. 9003 * @example 9004 * 9005 * var users = [ 9006 * { 'user': 'barney', 'active': false }, 9007 * { 'user': 'fred', 'active': false }, 9008 * { 'user': 'pebbles', 'active': true } 9009 * ]; 9010 * 9011 * _.findIndex(users, function(o) { return o.user == 'barney'; }); 9012 * // => 0 9013 * 9014 * // The `_.matches` iteratee shorthand. 9015 * _.findIndex(users, { 'user': 'fred', 'active': false }); 9016 * // => 1 9017 * 9018 * // The `_.matchesProperty` iteratee shorthand. 9019 * _.findIndex(users, ['active', false]); 9020 * // => 0 9021 * 9022 * // The `_.property` iteratee shorthand. 9023 * _.findIndex(users, 'active'); 9024 * // => 2 9025 */ 9026 function findIndex(array, predicate, fromIndex) { 9027 var length = array == null ? 0 : array.length; 9028 if (!length) { 9029 return -1; 9030 } 9031 var index = fromIndex == null ? 0 : toInteger(fromIndex); 9032 if (index < 0) { 9033 index = nativeMax(length + index, 0); 9034 } 9035 return baseFindIndex(array, getIteratee(predicate, 3), index); 9036 } 9037 9038 /** 9039 * This method is like `_.findIndex` except that it iterates over elements 9040 * of `collection` from right to left. 9041 * 9042 * @static 9043 * @memberOf _ 9044 * @since 2.0.0 9045 * @category Array 9046 * @param {Array} array The array to inspect. 9047 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9048 * @param {number} [fromIndex=array.length-1] The index to search from. 9049 * @returns {number} Returns the index of the found element, else `-1`. 9050 * @example 9051 * 9052 * var users = [ 9053 * { 'user': 'barney', 'active': true }, 9054 * { 'user': 'fred', 'active': false }, 9055 * { 'user': 'pebbles', 'active': false } 9056 * ]; 9057 * 9058 * _.findLastIndex(users, function(o) { return o.user == 'pebbles'; }); 9059 * // => 2 9060 * 9061 * // The `_.matches` iteratee shorthand. 9062 * _.findLastIndex(users, { 'user': 'barney', 'active': true }); 9063 * // => 0 9064 * 9065 * // The `_.matchesProperty` iteratee shorthand. 9066 * _.findLastIndex(users, ['active', false]); 9067 * // => 2 9068 * 9069 * // The `_.property` iteratee shorthand. 9070 * _.findLastIndex(users, 'active'); 9071 * // => 0 9072 */ 9073 function findLastIndex(array, predicate, fromIndex) { 9074 var length = array == null ? 0 : array.length; 9075 if (!length) { 9076 return -1; 9077 } 9078 var index = length - 1; 9079 if (fromIndex !== undefined) { 9080 index = toInteger(fromIndex); 9081 index = fromIndex < 0 9082 ? nativeMax(length + index, 0) 9083 : nativeMin(index, length - 1); 9084 } 9085 return baseFindIndex(array, getIteratee(predicate, 3), index, true); 9086 } 9087 9088 /** 9089 * Flattens `array` a single level deep. 9090 * 9091 * @static 9092 * @memberOf _ 9093 * @since 0.1.0 9094 * @category Array 9095 * @param {Array} array The array to flatten. 9096 * @returns {Array} Returns the new flattened array. 9097 * @example 9098 * 9099 * _.flatten([1, [2, [3, [4]], 5]]); 9100 * // => [1, 2, [3, [4]], 5] 9101 */ 9102 function flatten(array) { 9103 var length = array == null ? 0 : array.length; 9104 return length ? baseFlatten(array, 1) : []; 9105 } 9106 9107 /** 9108 * Recursively flattens `array`. 9109 * 9110 * @static 9111 * @memberOf _ 9112 * @since 3.0.0 9113 * @category Array 9114 * @param {Array} array The array to flatten. 9115 * @returns {Array} Returns the new flattened array. 9116 * @example 9117 * 9118 * _.flattenDeep([1, [2, [3, [4]], 5]]); 9119 * // => [1, 2, 3, 4, 5] 9120 */ 9121 function flattenDeep(array) { 9122 var length = array == null ? 0 : array.length; 9123 return length ? baseFlatten(array, INFINITY) : []; 9124 } 9125 9126 /** 9127 * Recursively flatten `array` up to `depth` times. 9128 * 9129 * @static 9130 * @memberOf _ 9131 * @since 4.4.0 9132 * @category Array 9133 * @param {Array} array The array to flatten. 9134 * @param {number} [depth=1] The maximum recursion depth. 9135 * @returns {Array} Returns the new flattened array. 9136 * @example 9137 * 9138 * var array = [1, [2, [3, [4]], 5]]; 9139 * 9140 * _.flattenDepth(array, 1); 9141 * // => [1, 2, [3, [4]], 5] 9142 * 9143 * _.flattenDepth(array, 2); 9144 * // => [1, 2, 3, [4], 5] 9145 */ 9146 function flattenDepth(array, depth) { 9147 var length = array == null ? 0 : array.length; 9148 if (!length) { 9149 return []; 9150 } 9151 depth = depth === undefined ? 1 : toInteger(depth); 9152 return baseFlatten(array, depth); 9153 } 9154 9155 /** 9156 * The inverse of `_.toPairs`; this method returns an object composed 9157 * from key-value `pairs`. 9158 * 9159 * @static 9160 * @memberOf _ 9161 * @since 4.0.0 9162 * @category Array 9163 * @param {Array} pairs The key-value pairs. 9164 * @returns {Object} Returns the new object. 9165 * @example 9166 * 9167 * _.fromPairs([['a', 1], ['b', 2]]); 9168 * // => { 'a': 1, 'b': 2 } 9169 */ 9170 function fromPairs(pairs) { 9171 var index = -1, 9172 length = pairs == null ? 0 : pairs.length, 9173 result = {}; 9174 9175 while (++index < length) { 9176 var pair = pairs[index]; 9177 result[pair[0]] = pair[1]; 9178 } 9179 return result; 9180 } 9181 9182 /** 9183 * Gets the first element of `array`. 9184 * 9185 * @static 9186 * @memberOf _ 9187 * @since 0.1.0 9188 * @alias first 9189 * @category Array 9190 * @param {Array} array The array to query. 9191 * @returns {*} Returns the first element of `array`. 9192 * @example 9193 * 9194 * _.head([1, 2, 3]); 9195 * // => 1 9196 * 9197 * _.head([]); 9198 * // => undefined 9199 */ 9200 function head(array) { 9201 return (array && array.length) ? array[0] : undefined; 9202 } 9203 9204 /** 9205 * Gets the index at which the first occurrence of `value` is found in `array` 9206 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9207 * for equality comparisons. If `fromIndex` is negative, it's used as the 9208 * offset from the end of `array`. 9209 * 9210 * @static 9211 * @memberOf _ 9212 * @since 0.1.0 9213 * @category Array 9214 * @param {Array} array The array to inspect. 9215 * @param {*} value The value to search for. 9216 * @param {number} [fromIndex=0] The index to search from. 9217 * @returns {number} Returns the index of the matched value, else `-1`. 9218 * @example 9219 * 9220 * _.indexOf([1, 2, 1, 2], 2); 9221 * // => 1 9222 * 9223 * // Search from the `fromIndex`. 9224 * _.indexOf([1, 2, 1, 2], 2, 2); 9225 * // => 3 9226 */ 9227 function indexOf(array, value, fromIndex) { 9228 var length = array == null ? 0 : array.length; 9229 if (!length) { 9230 return -1; 9231 } 9232 var index = fromIndex == null ? 0 : toInteger(fromIndex); 9233 if (index < 0) { 9234 index = nativeMax(length + index, 0); 9235 } 9236 return baseIndexOf(array, value, index); 9237 } 9238 9239 /** 9240 * Gets all but the last element of `array`. 9241 * 9242 * @static 9243 * @memberOf _ 9244 * @since 0.1.0 9245 * @category Array 9246 * @param {Array} array The array to query. 9247 * @returns {Array} Returns the slice of `array`. 9248 * @example 9249 * 9250 * _.initial([1, 2, 3]); 9251 * // => [1, 2] 9252 */ 9253 function initial(array) { 9254 var length = array == null ? 0 : array.length; 9255 return length ? baseSlice(array, 0, -1) : []; 9256 } 9257 9258 /** 9259 * Creates an array of unique values that are included in all given arrays 9260 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9261 * for equality comparisons. The order and references of result values are 9262 * determined by the first array. 9263 * 9264 * @static 9265 * @memberOf _ 9266 * @since 0.1.0 9267 * @category Array 9268 * @param {...Array} [arrays] The arrays to inspect. 9269 * @returns {Array} Returns the new array of intersecting values. 9270 * @example 9271 * 9272 * _.intersection([2, 1], [2, 3]); 9273 * // => [2] 9274 */ 9275 var intersection = baseRest(function(arrays) { 9276 var mapped = arrayMap(arrays, castArrayLikeObject); 9277 return (mapped.length && mapped[0] === arrays[0]) 9278 ? baseIntersection(mapped) 9279 : []; 9280 }); 9281 9282 /** 9283 * This method is like `_.intersection` except that it accepts `iteratee` 9284 * which is invoked for each element of each `arrays` to generate the criterion 9285 * by which they're compared. The order and references of result values are 9286 * determined by the first array. The iteratee is invoked with one argument: 9287 * (value). 9288 * 9289 * @static 9290 * @memberOf _ 9291 * @since 4.0.0 9292 * @category Array 9293 * @param {...Array} [arrays] The arrays to inspect. 9294 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 9295 * @returns {Array} Returns the new array of intersecting values. 9296 * @example 9297 * 9298 * _.intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); 9299 * // => [2.1] 9300 * 9301 * // The `_.property` iteratee shorthand. 9302 * _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 9303 * // => [{ 'x': 1 }] 9304 */ 9305 var intersectionBy = baseRest(function(arrays) { 9306 var iteratee = last(arrays), 9307 mapped = arrayMap(arrays, castArrayLikeObject); 9308 9309 if (iteratee === last(mapped)) { 9310 iteratee = undefined; 9311 } else { 9312 mapped.pop(); 9313 } 9314 return (mapped.length && mapped[0] === arrays[0]) 9315 ? baseIntersection(mapped, getIteratee(iteratee, 2)) 9316 : []; 9317 }); 9318 9319 /** 9320 * This method is like `_.intersection` except that it accepts `comparator` 9321 * which is invoked to compare elements of `arrays`. The order and references 9322 * of result values are determined by the first array. The comparator is 9323 * invoked with two arguments: (arrVal, othVal). 9324 * 9325 * @static 9326 * @memberOf _ 9327 * @since 4.0.0 9328 * @category Array 9329 * @param {...Array} [arrays] The arrays to inspect. 9330 * @param {Function} [comparator] The comparator invoked per element. 9331 * @returns {Array} Returns the new array of intersecting values. 9332 * @example 9333 * 9334 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 9335 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 9336 * 9337 * _.intersectionWith(objects, others, _.isEqual); 9338 * // => [{ 'x': 1, 'y': 2 }] 9339 */ 9340 var intersectionWith = baseRest(function(arrays) { 9341 var comparator = last(arrays), 9342 mapped = arrayMap(arrays, castArrayLikeObject); 9343 9344 comparator = typeof comparator == 'function' ? comparator : undefined; 9345 if (comparator) { 9346 mapped.pop(); 9347 } 9348 return (mapped.length && mapped[0] === arrays[0]) 9349 ? baseIntersection(mapped, undefined, comparator) 9350 : []; 9351 }); 9352 9353 /** 9354 * Converts all elements in `array` into a string separated by `separator`. 9355 * 9356 * @static 9357 * @memberOf _ 9358 * @since 4.0.0 9359 * @category Array 9360 * @param {Array} array The array to convert. 9361 * @param {string} [separator=','] The element separator. 9362 * @returns {string} Returns the joined string. 9363 * @example 9364 * 9365 * _.join(['a', 'b', 'c'], '~'); 9366 * // => 'a~b~c' 9367 */ 9368 function join(array, separator) { 9369 return array == null ? '' : nativeJoin.call(array, separator); 9370 } 9371 9372 /** 9373 * Gets the last element of `array`. 9374 * 9375 * @static 9376 * @memberOf _ 9377 * @since 0.1.0 9378 * @category Array 9379 * @param {Array} array The array to query. 9380 * @returns {*} Returns the last element of `array`. 9381 * @example 9382 * 9383 * _.last([1, 2, 3]); 9384 * // => 3 9385 */ 9386 function last(array) { 9387 var length = array == null ? 0 : array.length; 9388 return length ? array[length - 1] : undefined; 9389 } 9390 9391 /** 9392 * This method is like `_.indexOf` except that it iterates over elements of 9393 * `array` from right to left. 9394 * 9395 * @static 9396 * @memberOf _ 9397 * @since 0.1.0 9398 * @category Array 9399 * @param {Array} array The array to inspect. 9400 * @param {*} value The value to search for. 9401 * @param {number} [fromIndex=array.length-1] The index to search from. 9402 * @returns {number} Returns the index of the matched value, else `-1`. 9403 * @example 9404 * 9405 * _.lastIndexOf([1, 2, 1, 2], 2); 9406 * // => 3 9407 * 9408 * // Search from the `fromIndex`. 9409 * _.lastIndexOf([1, 2, 1, 2], 2, 2); 9410 * // => 1 9411 */ 9412 function lastIndexOf(array, value, fromIndex) { 9413 var length = array == null ? 0 : array.length; 9414 if (!length) { 9415 return -1; 9416 } 9417 var index = length; 9418 if (fromIndex !== undefined) { 9419 index = toInteger(fromIndex); 9420 index = index < 0 ? nativeMax(length + index, 0) : nativeMin(index, length - 1); 9421 } 9422 return value === value 9423 ? strictLastIndexOf(array, value, index) 9424 : baseFindIndex(array, baseIsNaN, index, true); 9425 } 9426 9427 /** 9428 * Gets the element at index `n` of `array`. If `n` is negative, the nth 9429 * element from the end is returned. 9430 * 9431 * @static 9432 * @memberOf _ 9433 * @since 4.11.0 9434 * @category Array 9435 * @param {Array} array The array to query. 9436 * @param {number} [n=0] The index of the element to return. 9437 * @returns {*} Returns the nth element of `array`. 9438 * @example 9439 * 9440 * var array = ['a', 'b', 'c', 'd']; 9441 * 9442 * _.nth(array, 1); 9443 * // => 'b' 9444 * 9445 * _.nth(array, -2); 9446 * // => 'c'; 9447 */ 9448 function nth(array, n) { 9449 return (array && array.length) ? baseNth(array, toInteger(n)) : undefined; 9450 } 9451 9452 /** 9453 * Removes all given values from `array` using 9454 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 9455 * for equality comparisons. 9456 * 9457 * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` 9458 * to remove elements from an array by predicate. 9459 * 9460 * @static 9461 * @memberOf _ 9462 * @since 2.0.0 9463 * @category Array 9464 * @param {Array} array The array to modify. 9465 * @param {...*} [values] The values to remove. 9466 * @returns {Array} Returns `array`. 9467 * @example 9468 * 9469 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 9470 * 9471 * _.pull(array, 'a', 'c'); 9472 * console.log(array); 9473 * // => ['b', 'b'] 9474 */ 9475 var pull = baseRest(pullAll); 9476 9477 /** 9478 * This method is like `_.pull` except that it accepts an array of values to remove. 9479 * 9480 * **Note:** Unlike `_.difference`, this method mutates `array`. 9481 * 9482 * @static 9483 * @memberOf _ 9484 * @since 4.0.0 9485 * @category Array 9486 * @param {Array} array The array to modify. 9487 * @param {Array} values The values to remove. 9488 * @returns {Array} Returns `array`. 9489 * @example 9490 * 9491 * var array = ['a', 'b', 'c', 'a', 'b', 'c']; 9492 * 9493 * _.pullAll(array, ['a', 'c']); 9494 * console.log(array); 9495 * // => ['b', 'b'] 9496 */ 9497 function pullAll(array, values) { 9498 return (array && array.length && values && values.length) 9499 ? basePullAll(array, values) 9500 : array; 9501 } 9502 9503 /** 9504 * This method is like `_.pullAll` except that it accepts `iteratee` which is 9505 * invoked for each element of `array` and `values` to generate the criterion 9506 * by which they're compared. The iteratee is invoked with one argument: (value). 9507 * 9508 * **Note:** Unlike `_.differenceBy`, this method mutates `array`. 9509 * 9510 * @static 9511 * @memberOf _ 9512 * @since 4.0.0 9513 * @category Array 9514 * @param {Array} array The array to modify. 9515 * @param {Array} values The values to remove. 9516 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 9517 * @returns {Array} Returns `array`. 9518 * @example 9519 * 9520 * var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }]; 9521 * 9522 * _.pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x'); 9523 * console.log(array); 9524 * // => [{ 'x': 2 }] 9525 */ 9526 function pullAllBy(array, values, iteratee) { 9527 return (array && array.length && values && values.length) 9528 ? basePullAll(array, values, getIteratee(iteratee, 2)) 9529 : array; 9530 } 9531 9532 /** 9533 * This method is like `_.pullAll` except that it accepts `comparator` which 9534 * is invoked to compare elements of `array` to `values`. The comparator is 9535 * invoked with two arguments: (arrVal, othVal). 9536 * 9537 * **Note:** Unlike `_.differenceWith`, this method mutates `array`. 9538 * 9539 * @static 9540 * @memberOf _ 9541 * @since 4.6.0 9542 * @category Array 9543 * @param {Array} array The array to modify. 9544 * @param {Array} values The values to remove. 9545 * @param {Function} [comparator] The comparator invoked per element. 9546 * @returns {Array} Returns `array`. 9547 * @example 9548 * 9549 * var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }]; 9550 * 9551 * _.pullAllWith(array, [{ 'x': 3, 'y': 4 }], _.isEqual); 9552 * console.log(array); 9553 * // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }] 9554 */ 9555 function pullAllWith(array, values, comparator) { 9556 return (array && array.length && values && values.length) 9557 ? basePullAll(array, values, undefined, comparator) 9558 : array; 9559 } 9560 9561 /** 9562 * Removes elements from `array` corresponding to `indexes` and returns an 9563 * array of removed elements. 9564 * 9565 * **Note:** Unlike `_.at`, this method mutates `array`. 9566 * 9567 * @static 9568 * @memberOf _ 9569 * @since 3.0.0 9570 * @category Array 9571 * @param {Array} array The array to modify. 9572 * @param {...(number|number[])} [indexes] The indexes of elements to remove. 9573 * @returns {Array} Returns the new array of removed elements. 9574 * @example 9575 * 9576 * var array = ['a', 'b', 'c', 'd']; 9577 * var pulled = _.pullAt(array, [1, 3]); 9578 * 9579 * console.log(array); 9580 * // => ['a', 'c'] 9581 * 9582 * console.log(pulled); 9583 * // => ['b', 'd'] 9584 */ 9585 var pullAt = flatRest(function(array, indexes) { 9586 var length = array == null ? 0 : array.length, 9587 result = baseAt(array, indexes); 9588 9589 basePullAt(array, arrayMap(indexes, function(index) { 9590 return isIndex(index, length) ? +index : index; 9591 }).sort(compareAscending)); 9592 9593 return result; 9594 }); 9595 9596 /** 9597 * Removes all elements from `array` that `predicate` returns truthy for 9598 * and returns an array of the removed elements. The predicate is invoked 9599 * with three arguments: (value, index, array). 9600 * 9601 * **Note:** Unlike `_.filter`, this method mutates `array`. Use `_.pull` 9602 * to pull elements from an array by value. 9603 * 9604 * @static 9605 * @memberOf _ 9606 * @since 2.0.0 9607 * @category Array 9608 * @param {Array} array The array to modify. 9609 * @param {Function} [predicate=_.identity] The function invoked per iteration. 9610 * @returns {Array} Returns the new array of removed elements. 9611 * @example 9612 * 9613 * var array = [1, 2, 3, 4]; 9614 * var evens = _.remove(array, function(n) { 9615 * return n % 2 == 0; 9616 * }); 9617 * 9618 * console.log(array); 9619 * // => [1, 3] 9620 * 9621 * console.log(evens); 9622 * // => [2, 4] 9623 */ 9624 function remove(array, predicate) { 9625 var result = []; 9626 if (!(array && array.length)) { 9627 return result; 9628 } 9629 var index = -1, 9630 indexes = [], 9631 length = array.length; 9632 9633 predicate = getIteratee(predicate, 3); 9634 while (++index < length) { 9635 var value = array[index]; 9636 if (predicate(value, index, array)) { 9637 result.push(value); 9638 indexes.push(index); 9639 } 9640 } 9641 basePullAt(array, indexes); 9642 return result; 9643 } 9644 9645 /** 9646 * Reverses `array` so that the first element becomes the last, the second 9647 * element becomes the second to last, and so on. 9648 * 9649 * **Note:** This method mutates `array` and is based on 9650 * [`Array#reverse`](https://mdn.io/Array/reverse). 9651 * 9652 * @static 9653 * @memberOf _ 9654 * @since 4.0.0 9655 * @category Array 9656 * @param {Array} array The array to modify. 9657 * @returns {Array} Returns `array`. 9658 * @example 9659 * 9660 * var array = [1, 2, 3]; 9661 * 9662 * _.reverse(array); 9663 * // => [3, 2, 1] 9664 * 9665 * console.log(array); 9666 * // => [3, 2, 1] 9667 */ 9668 function reverse(array) { 9669 return array == null ? array : nativeReverse.call(array); 9670 } 9671 9672 /** 9673 * Creates a slice of `array` from `start` up to, but not including, `end`. 9674 * 9675 * **Note:** This method is used instead of 9676 * [`Array#slice`](https://mdn.io/Array/slice) to ensure dense arrays are 9677 * returned. 9678 * 9679 * @static 9680 * @memberOf _ 9681 * @since 3.0.0 9682 * @category Array 9683 * @param {Array} array The array to slice. 9684 * @param {number} [start=0] The start position. 9685 * @param {number} [end=array.length] The end position. 9686 * @returns {Array} Returns the slice of `array`. 9687 */ 9688 function slice(array, start, end) { 9689 var length = array == null ? 0 : array.length; 9690 if (!length) { 9691 return []; 9692 } 9693 if (end && typeof end != 'number' && isIterateeCall(array, start, end)) { 9694 start = 0; 9695 end = length; 9696 } 9697 else { 9698 start = start == null ? 0 : toInteger(start); 9699 end = end === undefined ? length : toInteger(end); 9700 } 9701 return baseSlice(array, start, end); 9702 } 9703 9704 /** 9705 * Uses a binary search to determine the lowest index at which `value` 9706 * should be inserted into `array` in order to maintain its sort order. 9707 * 9708 * @static 9709 * @memberOf _ 9710 * @since 0.1.0 9711 * @category Array 9712 * @param {Array} array The sorted array to inspect. 9713 * @param {*} value The value to evaluate. 9714 * @returns {number} Returns the index at which `value` should be inserted 9715 * into `array`. 9716 * @example 9717 * 9718 * _.sortedIndex([30, 50], 40); 9719 * // => 1 9720 */ 9721 function sortedIndex(array, value) { 9722 return baseSortedIndex(array, value); 9723 } 9724 9725 /** 9726 * This method is like `_.sortedIndex` except that it accepts `iteratee` 9727 * which is invoked for `value` and each element of `array` to compute their 9728 * sort ranking. The iteratee is invoked with one argument: (value). 9729 * 9730 * @static 9731 * @memberOf _ 9732 * @since 4.0.0 9733 * @category Array 9734 * @param {Array} array The sorted array to inspect. 9735 * @param {*} value The value to evaluate. 9736 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 9737 * @returns {number} Returns the index at which `value` should be inserted 9738 * into `array`. 9739 * @example 9740 * 9741 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 9742 * 9743 * _.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 9744 * // => 0 9745 * 9746 * // The `_.property` iteratee shorthand. 9747 * _.sortedIndexBy(objects, { 'x': 4 }, 'x'); 9748 * // => 0 9749 */ 9750 function sortedIndexBy(array, value, iteratee) { 9751 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2)); 9752 } 9753 9754 /** 9755 * This method is like `_.indexOf` except that it performs a binary 9756 * search on a sorted `array`. 9757 * 9758 * @static 9759 * @memberOf _ 9760 * @since 4.0.0 9761 * @category Array 9762 * @param {Array} array The array to inspect. 9763 * @param {*} value The value to search for. 9764 * @returns {number} Returns the index of the matched value, else `-1`. 9765 * @example 9766 * 9767 * _.sortedIndexOf([4, 5, 5, 5, 6], 5); 9768 * // => 1 9769 */ 9770 function sortedIndexOf(array, value) { 9771 var length = array == null ? 0 : array.length; 9772 if (length) { 9773 var index = baseSortedIndex(array, value); 9774 if (index < length && eq(array[index], value)) { 9775 return index; 9776 } 9777 } 9778 return -1; 9779 } 9780 9781 /** 9782 * This method is like `_.sortedIndex` except that it returns the highest 9783 * index at which `value` should be inserted into `array` in order to 9784 * maintain its sort order. 9785 * 9786 * @static 9787 * @memberOf _ 9788 * @since 3.0.0 9789 * @category Array 9790 * @param {Array} array The sorted array to inspect. 9791 * @param {*} value The value to evaluate. 9792 * @returns {number} Returns the index at which `value` should be inserted 9793 * into `array`. 9794 * @example 9795 * 9796 * _.sortedLastIndex([4, 5, 5, 5, 6], 5); 9797 * // => 4 9798 */ 9799 function sortedLastIndex(array, value) { 9800 return baseSortedIndex(array, value, true); 9801 } 9802 9803 /** 9804 * This method is like `_.sortedLastIndex` except that it accepts `iteratee` 9805 * which is invoked for `value` and each element of `array` to compute their 9806 * sort ranking. The iteratee is invoked with one argument: (value). 9807 * 9808 * @static 9809 * @memberOf _ 9810 * @since 4.0.0 9811 * @category Array 9812 * @param {Array} array The sorted array to inspect. 9813 * @param {*} value The value to evaluate. 9814 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 9815 * @returns {number} Returns the index at which `value` should be inserted 9816 * into `array`. 9817 * @example 9818 * 9819 * var objects = [{ 'x': 4 }, { 'x': 5 }]; 9820 * 9821 * _.sortedLastIndexBy(objects, { 'x': 4 }, function(o) { return o.x; }); 9822 * // => 1 9823 * 9824 * // The `_.property` iteratee shorthand. 9825 * _.sortedLastIndexBy(objects, { 'x': 4 }, 'x'); 9826 * // => 1 9827 */ 9828 function sortedLastIndexBy(array, value, iteratee) { 9829 return baseSortedIndexBy(array, value, getIteratee(iteratee, 2), true); 9830 } 9831 9832 /** 9833 * This method is like `_.lastIndexOf` except that it performs a binary 9834 * search on a sorted `array`. 9835 * 9836 * @static 9837 * @memberOf _ 9838 * @since 4.0.0 9839 * @category Array 9840 * @param {Array} array The array to inspect. 9841 * @param {*} value The value to search for. 9842 * @returns {number} Returns the index of the matched value, else `-1`. 9843 * @example 9844 * 9845 * _.sortedLastIndexOf([4, 5, 5, 5, 6], 5); 9846 * // => 3 9847 */ 9848 function sortedLastIndexOf(array, value) { 9849 var length = array == null ? 0 : array.length; 9850 if (length) { 9851 var index = baseSortedIndex(array, value, true) - 1; 9852 if (eq(array[index], value)) { 9853 return index; 9854 } 9855 } 9856 return -1; 9857 } 9858 9859 /** 9860 * This method is like `_.uniq` except that it's designed and optimized 9861 * for sorted arrays. 9862 * 9863 * @static 9864 * @memberOf _ 9865 * @since 4.0.0 9866 * @category Array 9867 * @param {Array} array The array to inspect. 9868 * @returns {Array} Returns the new duplicate free array. 9869 * @example 9870 * 9871 * _.sortedUniq([1, 1, 2]); 9872 * // => [1, 2] 9873 */ 9874 function sortedUniq(array) { 9875 return (array && array.length) 9876 ? baseSortedUniq(array) 9877 : []; 9878 } 9879 9880 /** 9881 * This method is like `_.uniqBy` except that it's designed and optimized 9882 * for sorted arrays. 9883 * 9884 * @static 9885 * @memberOf _ 9886 * @since 4.0.0 9887 * @category Array 9888 * @param {Array} array The array to inspect. 9889 * @param {Function} [iteratee] The iteratee invoked per element. 9890 * @returns {Array} Returns the new duplicate free array. 9891 * @example 9892 * 9893 * _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor); 9894 * // => [1.1, 2.3] 9895 */ 9896 function sortedUniqBy(array, iteratee) { 9897 return (array && array.length) 9898 ? baseSortedUniq(array, getIteratee(iteratee, 2)) 9899 : []; 9900 } 9901 9902 /** 9903 * Gets all but the first element of `array`. 9904 * 9905 * @static 9906 * @memberOf _ 9907 * @since 4.0.0 9908 * @category Array 9909 * @param {Array} array The array to query. 9910 * @returns {Array} Returns the slice of `array`. 9911 * @example 9912 * 9913 * _.tail([1, 2, 3]); 9914 * // => [2, 3] 9915 */ 9916 function tail(array) { 9917 var length = array == null ? 0 : array.length; 9918 return length ? baseSlice(array, 1, length) : []; 9919 } 9920 9921 /** 9922 * Creates a slice of `array` with `n` elements taken from the beginning. 9923 * 9924 * @static 9925 * @memberOf _ 9926 * @since 0.1.0 9927 * @category Array 9928 * @param {Array} array The array to query. 9929 * @param {number} [n=1] The number of elements to take. 9930 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9931 * @returns {Array} Returns the slice of `array`. 9932 * @example 9933 * 9934 * _.take([1, 2, 3]); 9935 * // => [1] 9936 * 9937 * _.take([1, 2, 3], 2); 9938 * // => [1, 2] 9939 * 9940 * _.take([1, 2, 3], 5); 9941 * // => [1, 2, 3] 9942 * 9943 * _.take([1, 2, 3], 0); 9944 * // => [] 9945 */ 9946 function take(array, n, guard) { 9947 if (!(array && array.length)) { 9948 return []; 9949 } 9950 n = (guard || n === undefined) ? 1 : toInteger(n); 9951 return baseSlice(array, 0, n < 0 ? 0 : n); 9952 } 9953 9954 /** 9955 * Creates a slice of `array` with `n` elements taken from the end. 9956 * 9957 * @static 9958 * @memberOf _ 9959 * @since 3.0.0 9960 * @category Array 9961 * @param {Array} array The array to query. 9962 * @param {number} [n=1] The number of elements to take. 9963 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 9964 * @returns {Array} Returns the slice of `array`. 9965 * @example 9966 * 9967 * _.takeRight([1, 2, 3]); 9968 * // => [3] 9969 * 9970 * _.takeRight([1, 2, 3], 2); 9971 * // => [2, 3] 9972 * 9973 * _.takeRight([1, 2, 3], 5); 9974 * // => [1, 2, 3] 9975 * 9976 * _.takeRight([1, 2, 3], 0); 9977 * // => [] 9978 */ 9979 function takeRight(array, n, guard) { 9980 var length = array == null ? 0 : array.length; 9981 if (!length) { 9982 return []; 9983 } 9984 n = (guard || n === undefined) ? 1 : toInteger(n); 9985 n = length - n; 9986 return baseSlice(array, n < 0 ? 0 : n, length); 9987 } 9988 9989 /** 9990 * Creates a slice of `array` with elements taken from the end. Elements are 9991 * taken until `predicate` returns falsey. The predicate is invoked with 9992 * three arguments: (value, index, array). 9993 * 9994 * @static 9995 * @memberOf _ 9996 * @since 3.0.0 9997 * @category Array 9998 * @param {Array} array The array to query. 9999 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10000 * @returns {Array} Returns the slice of `array`. 10001 * @example 10002 * 10003 * var users = [ 10004 * { 'user': 'barney', 'active': true }, 10005 * { 'user': 'fred', 'active': false }, 10006 * { 'user': 'pebbles', 'active': false } 10007 * ]; 10008 * 10009 * _.takeRightWhile(users, function(o) { return !o.active; }); 10010 * // => objects for ['fred', 'pebbles'] 10011 * 10012 * // The `_.matches` iteratee shorthand. 10013 * _.takeRightWhile(users, { 'user': 'pebbles', 'active': false }); 10014 * // => objects for ['pebbles'] 10015 * 10016 * // The `_.matchesProperty` iteratee shorthand. 10017 * _.takeRightWhile(users, ['active', false]); 10018 * // => objects for ['fred', 'pebbles'] 10019 * 10020 * // The `_.property` iteratee shorthand. 10021 * _.takeRightWhile(users, 'active'); 10022 * // => [] 10023 */ 10024 function takeRightWhile(array, predicate) { 10025 return (array && array.length) 10026 ? baseWhile(array, getIteratee(predicate, 3), false, true) 10027 : []; 10028 } 10029 10030 /** 10031 * Creates a slice of `array` with elements taken from the beginning. Elements 10032 * are taken until `predicate` returns falsey. The predicate is invoked with 10033 * three arguments: (value, index, array). 10034 * 10035 * @static 10036 * @memberOf _ 10037 * @since 3.0.0 10038 * @category Array 10039 * @param {Array} array The array to query. 10040 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10041 * @returns {Array} Returns the slice of `array`. 10042 * @example 10043 * 10044 * var users = [ 10045 * { 'user': 'barney', 'active': false }, 10046 * { 'user': 'fred', 'active': false }, 10047 * { 'user': 'pebbles', 'active': true } 10048 * ]; 10049 * 10050 * _.takeWhile(users, function(o) { return !o.active; }); 10051 * // => objects for ['barney', 'fred'] 10052 * 10053 * // The `_.matches` iteratee shorthand. 10054 * _.takeWhile(users, { 'user': 'barney', 'active': false }); 10055 * // => objects for ['barney'] 10056 * 10057 * // The `_.matchesProperty` iteratee shorthand. 10058 * _.takeWhile(users, ['active', false]); 10059 * // => objects for ['barney', 'fred'] 10060 * 10061 * // The `_.property` iteratee shorthand. 10062 * _.takeWhile(users, 'active'); 10063 * // => [] 10064 */ 10065 function takeWhile(array, predicate) { 10066 return (array && array.length) 10067 ? baseWhile(array, getIteratee(predicate, 3)) 10068 : []; 10069 } 10070 10071 /** 10072 * Creates an array of unique values, in order, from all given arrays using 10073 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 10074 * for equality comparisons. 10075 * 10076 * @static 10077 * @memberOf _ 10078 * @since 0.1.0 10079 * @category Array 10080 * @param {...Array} [arrays] The arrays to inspect. 10081 * @returns {Array} Returns the new array of combined values. 10082 * @example 10083 * 10084 * _.union([2], [1, 2]); 10085 * // => [2, 1] 10086 */ 10087 var union = baseRest(function(arrays) { 10088 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true)); 10089 }); 10090 10091 /** 10092 * This method is like `_.union` except that it accepts `iteratee` which is 10093 * invoked for each element of each `arrays` to generate the criterion by 10094 * which uniqueness is computed. Result values are chosen from the first 10095 * array in which the value occurs. The iteratee is invoked with one argument: 10096 * (value). 10097 * 10098 * @static 10099 * @memberOf _ 10100 * @since 4.0.0 10101 * @category Array 10102 * @param {...Array} [arrays] The arrays to inspect. 10103 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10104 * @returns {Array} Returns the new array of combined values. 10105 * @example 10106 * 10107 * _.unionBy([2.1], [1.2, 2.3], Math.floor); 10108 * // => [2.1, 1.2] 10109 * 10110 * // The `_.property` iteratee shorthand. 10111 * _.unionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 10112 * // => [{ 'x': 1 }, { 'x': 2 }] 10113 */ 10114 var unionBy = baseRest(function(arrays) { 10115 var iteratee = last(arrays); 10116 if (isArrayLikeObject(iteratee)) { 10117 iteratee = undefined; 10118 } 10119 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee, 2)); 10120 }); 10121 10122 /** 10123 * This method is like `_.union` except that it accepts `comparator` which 10124 * is invoked to compare elements of `arrays`. Result values are chosen from 10125 * the first array in which the value occurs. The comparator is invoked 10126 * with two arguments: (arrVal, othVal). 10127 * 10128 * @static 10129 * @memberOf _ 10130 * @since 4.0.0 10131 * @category Array 10132 * @param {...Array} [arrays] The arrays to inspect. 10133 * @param {Function} [comparator] The comparator invoked per element. 10134 * @returns {Array} Returns the new array of combined values. 10135 * @example 10136 * 10137 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 10138 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 10139 * 10140 * _.unionWith(objects, others, _.isEqual); 10141 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 10142 */ 10143 var unionWith = baseRest(function(arrays) { 10144 var comparator = last(arrays); 10145 comparator = typeof comparator == 'function' ? comparator : undefined; 10146 return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined, comparator); 10147 }); 10148 10149 /** 10150 * Creates a duplicate-free version of an array, using 10151 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 10152 * for equality comparisons, in which only the first occurrence of each element 10153 * is kept. The order of result values is determined by the order they occur 10154 * in the array. 10155 * 10156 * @static 10157 * @memberOf _ 10158 * @since 0.1.0 10159 * @category Array 10160 * @param {Array} array The array to inspect. 10161 * @returns {Array} Returns the new duplicate free array. 10162 * @example 10163 * 10164 * _.uniq([2, 1, 2]); 10165 * // => [2, 1] 10166 */ 10167 function uniq(array) { 10168 return (array && array.length) ? baseUniq(array) : []; 10169 } 10170 10171 /** 10172 * This method is like `_.uniq` except that it accepts `iteratee` which is 10173 * invoked for each element in `array` to generate the criterion by which 10174 * uniqueness is computed. The order of result values is determined by the 10175 * order they occur in the array. The iteratee is invoked with one argument: 10176 * (value). 10177 * 10178 * @static 10179 * @memberOf _ 10180 * @since 4.0.0 10181 * @category Array 10182 * @param {Array} array The array to inspect. 10183 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10184 * @returns {Array} Returns the new duplicate free array. 10185 * @example 10186 * 10187 * _.uniqBy([2.1, 1.2, 2.3], Math.floor); 10188 * // => [2.1, 1.2] 10189 * 10190 * // The `_.property` iteratee shorthand. 10191 * _.uniqBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); 10192 * // => [{ 'x': 1 }, { 'x': 2 }] 10193 */ 10194 function uniqBy(array, iteratee) { 10195 return (array && array.length) ? baseUniq(array, getIteratee(iteratee, 2)) : []; 10196 } 10197 10198 /** 10199 * This method is like `_.uniq` except that it accepts `comparator` which 10200 * is invoked to compare elements of `array`. The order of result values is 10201 * determined by the order they occur in the array.The comparator is invoked 10202 * with two arguments: (arrVal, othVal). 10203 * 10204 * @static 10205 * @memberOf _ 10206 * @since 4.0.0 10207 * @category Array 10208 * @param {Array} array The array to inspect. 10209 * @param {Function} [comparator] The comparator invoked per element. 10210 * @returns {Array} Returns the new duplicate free array. 10211 * @example 10212 * 10213 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }]; 10214 * 10215 * _.uniqWith(objects, _.isEqual); 10216 * // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }] 10217 */ 10218 function uniqWith(array, comparator) { 10219 comparator = typeof comparator == 'function' ? comparator : undefined; 10220 return (array && array.length) ? baseUniq(array, undefined, comparator) : []; 10221 } 10222 10223 /** 10224 * This method is like `_.zip` except that it accepts an array of grouped 10225 * elements and creates an array regrouping the elements to their pre-zip 10226 * configuration. 10227 * 10228 * @static 10229 * @memberOf _ 10230 * @since 1.2.0 10231 * @category Array 10232 * @param {Array} array The array of grouped elements to process. 10233 * @returns {Array} Returns the new array of regrouped elements. 10234 * @example 10235 * 10236 * var zipped = _.zip(['a', 'b'], [1, 2], [true, false]); 10237 * // => [['a', 1, true], ['b', 2, false]] 10238 * 10239 * _.unzip(zipped); 10240 * // => [['a', 'b'], [1, 2], [true, false]] 10241 */ 10242 function unzip(array) { 10243 if (!(array && array.length)) { 10244 return []; 10245 } 10246 var length = 0; 10247 array = arrayFilter(array, function(group) { 10248 if (isArrayLikeObject(group)) { 10249 length = nativeMax(group.length, length); 10250 return true; 10251 } 10252 }); 10253 return baseTimes(length, function(index) { 10254 return arrayMap(array, baseProperty(index)); 10255 }); 10256 } 10257 10258 /** 10259 * This method is like `_.unzip` except that it accepts `iteratee` to specify 10260 * how regrouped values should be combined. The iteratee is invoked with the 10261 * elements of each group: (...group). 10262 * 10263 * @static 10264 * @memberOf _ 10265 * @since 3.8.0 10266 * @category Array 10267 * @param {Array} array The array of grouped elements to process. 10268 * @param {Function} [iteratee=_.identity] The function to combine 10269 * regrouped values. 10270 * @returns {Array} Returns the new array of regrouped elements. 10271 * @example 10272 * 10273 * var zipped = _.zip([1, 2], [10, 20], [100, 200]); 10274 * // => [[1, 10, 100], [2, 20, 200]] 10275 * 10276 * _.unzipWith(zipped, _.add); 10277 * // => [3, 30, 300] 10278 */ 10279 function unzipWith(array, iteratee) { 10280 if (!(array && array.length)) { 10281 return []; 10282 } 10283 var result = unzip(array); 10284 if (iteratee == null) { 10285 return result; 10286 } 10287 return arrayMap(result, function(group) { 10288 return apply(iteratee, undefined, group); 10289 }); 10290 } 10291 10292 /** 10293 * Creates an array excluding all given values using 10294 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 10295 * for equality comparisons. 10296 * 10297 * **Note:** Unlike `_.pull`, this method returns a new array. 10298 * 10299 * @static 10300 * @memberOf _ 10301 * @since 0.1.0 10302 * @category Array 10303 * @param {Array} array The array to inspect. 10304 * @param {...*} [values] The values to exclude. 10305 * @returns {Array} Returns the new array of filtered values. 10306 * @see _.difference, _.xor 10307 * @example 10308 * 10309 * _.without([2, 1, 2, 3], 1, 2); 10310 * // => [3] 10311 */ 10312 var without = baseRest(function(array, values) { 10313 return isArrayLikeObject(array) 10314 ? baseDifference(array, values) 10315 : []; 10316 }); 10317 10318 /** 10319 * Creates an array of unique values that is the 10320 * [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) 10321 * of the given arrays. The order of result values is determined by the order 10322 * they occur in the arrays. 10323 * 10324 * @static 10325 * @memberOf _ 10326 * @since 2.4.0 10327 * @category Array 10328 * @param {...Array} [arrays] The arrays to inspect. 10329 * @returns {Array} Returns the new array of filtered values. 10330 * @see _.difference, _.without 10331 * @example 10332 * 10333 * _.xor([2, 1], [2, 3]); 10334 * // => [1, 3] 10335 */ 10336 var xor = baseRest(function(arrays) { 10337 return baseXor(arrayFilter(arrays, isArrayLikeObject)); 10338 }); 10339 10340 /** 10341 * This method is like `_.xor` except that it accepts `iteratee` which is 10342 * invoked for each element of each `arrays` to generate the criterion by 10343 * which by which they're compared. The order of result values is determined 10344 * by the order they occur in the arrays. The iteratee is invoked with one 10345 * argument: (value). 10346 * 10347 * @static 10348 * @memberOf _ 10349 * @since 4.0.0 10350 * @category Array 10351 * @param {...Array} [arrays] The arrays to inspect. 10352 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 10353 * @returns {Array} Returns the new array of filtered values. 10354 * @example 10355 * 10356 * _.xorBy([2.1, 1.2], [2.3, 3.4], Math.floor); 10357 * // => [1.2, 3.4] 10358 * 10359 * // The `_.property` iteratee shorthand. 10360 * _.xorBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x'); 10361 * // => [{ 'x': 2 }] 10362 */ 10363 var xorBy = baseRest(function(arrays) { 10364 var iteratee = last(arrays); 10365 if (isArrayLikeObject(iteratee)) { 10366 iteratee = undefined; 10367 } 10368 return baseXor(arrayFilter(arrays, isArrayLikeObject), getIteratee(iteratee, 2)); 10369 }); 10370 10371 /** 10372 * This method is like `_.xor` except that it accepts `comparator` which is 10373 * invoked to compare elements of `arrays`. The order of result values is 10374 * determined by the order they occur in the arrays. The comparator is invoked 10375 * with two arguments: (arrVal, othVal). 10376 * 10377 * @static 10378 * @memberOf _ 10379 * @since 4.0.0 10380 * @category Array 10381 * @param {...Array} [arrays] The arrays to inspect. 10382 * @param {Function} [comparator] The comparator invoked per element. 10383 * @returns {Array} Returns the new array of filtered values. 10384 * @example 10385 * 10386 * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; 10387 * var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }]; 10388 * 10389 * _.xorWith(objects, others, _.isEqual); 10390 * // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }] 10391 */ 10392 var xorWith = baseRest(function(arrays) { 10393 var comparator = last(arrays); 10394 comparator = typeof comparator == 'function' ? comparator : undefined; 10395 return baseXor(arrayFilter(arrays, isArrayLikeObject), undefined, comparator); 10396 }); 10397 10398 /** 10399 * Creates an array of grouped elements, the first of which contains the 10400 * first elements of the given arrays, the second of which contains the 10401 * second elements of the given arrays, and so on. 10402 * 10403 * @static 10404 * @memberOf _ 10405 * @since 0.1.0 10406 * @category Array 10407 * @param {...Array} [arrays] The arrays to process. 10408 * @returns {Array} Returns the new array of grouped elements. 10409 * @example 10410 * 10411 * _.zip(['a', 'b'], [1, 2], [true, false]); 10412 * // => [['a', 1, true], ['b', 2, false]] 10413 */ 10414 var zip = baseRest(unzip); 10415 10416 /** 10417 * This method is like `_.fromPairs` except that it accepts two arrays, 10418 * one of property identifiers and one of corresponding values. 10419 * 10420 * @static 10421 * @memberOf _ 10422 * @since 0.4.0 10423 * @category Array 10424 * @param {Array} [props=[]] The property identifiers. 10425 * @param {Array} [values=[]] The property values. 10426 * @returns {Object} Returns the new object. 10427 * @example 10428 * 10429 * _.zipObject(['a', 'b'], [1, 2]); 10430 * // => { 'a': 1, 'b': 2 } 10431 */ 10432 function zipObject(props, values) { 10433 return baseZipObject(props || [], values || [], assignValue); 10434 } 10435 10436 /** 10437 * This method is like `_.zipObject` except that it supports property paths. 10438 * 10439 * @static 10440 * @memberOf _ 10441 * @since 4.1.0 10442 * @category Array 10443 * @param {Array} [props=[]] The property identifiers. 10444 * @param {Array} [values=[]] The property values. 10445 * @returns {Object} Returns the new object. 10446 * @example 10447 * 10448 * _.zipObjectDeep(['a.b[0].c', 'a.b[1].d'], [1, 2]); 10449 * // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } } 10450 */ 10451 function zipObjectDeep(props, values) { 10452 return baseZipObject(props || [], values || [], baseSet); 10453 } 10454 10455 /** 10456 * This method is like `_.zip` except that it accepts `iteratee` to specify 10457 * how grouped values should be combined. The iteratee is invoked with the 10458 * elements of each group: (...group). 10459 * 10460 * @static 10461 * @memberOf _ 10462 * @since 3.8.0 10463 * @category Array 10464 * @param {...Array} [arrays] The arrays to process. 10465 * @param {Function} [iteratee=_.identity] The function to combine 10466 * grouped values. 10467 * @returns {Array} Returns the new array of grouped elements. 10468 * @example 10469 * 10470 * _.zipWith([1, 2], [10, 20], [100, 200], function(a, b, c) { 10471 * return a + b + c; 10472 * }); 10473 * // => [111, 222] 10474 */ 10475 var zipWith = baseRest(function(arrays) { 10476 var length = arrays.length, 10477 iteratee = length > 1 ? arrays[length - 1] : undefined; 10478 10479 iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined; 10480 return unzipWith(arrays, iteratee); 10481 }); 10482 10483 /*------------------------------------------------------------------------*/ 10484 10485 /** 10486 * Creates a `lodash` wrapper instance that wraps `value` with explicit method 10487 * chain sequences enabled. The result of such sequences must be unwrapped 10488 * with `_#value`. 10489 * 10490 * @static 10491 * @memberOf _ 10492 * @since 1.3.0 10493 * @category Seq 10494 * @param {*} value The value to wrap. 10495 * @returns {Object} Returns the new `lodash` wrapper instance. 10496 * @example 10497 * 10498 * var users = [ 10499 * { 'user': 'barney', 'age': 36 }, 10500 * { 'user': 'fred', 'age': 40 }, 10501 * { 'user': 'pebbles', 'age': 1 } 10502 * ]; 10503 * 10504 * var youngest = _ 10505 * .chain(users) 10506 * .sortBy('age') 10507 * .map(function(o) { 10508 * return o.user + ' is ' + o.age; 10509 * }) 10510 * .head() 10511 * .value(); 10512 * // => 'pebbles is 1' 10513 */ 10514 function chain(value) { 10515 var result = lodash(value); 10516 result.__chain__ = true; 10517 return result; 10518 } 10519 10520 /** 10521 * This method invokes `interceptor` and returns `value`. The interceptor 10522 * is invoked with one argument; (value). The purpose of this method is to 10523 * "tap into" a method chain sequence in order to modify intermediate results. 10524 * 10525 * @static 10526 * @memberOf _ 10527 * @since 0.1.0 10528 * @category Seq 10529 * @param {*} value The value to provide to `interceptor`. 10530 * @param {Function} interceptor The function to invoke. 10531 * @returns {*} Returns `value`. 10532 * @example 10533 * 10534 * _([1, 2, 3]) 10535 * .tap(function(array) { 10536 * // Mutate input array. 10537 * array.pop(); 10538 * }) 10539 * .reverse() 10540 * .value(); 10541 * // => [2, 1] 10542 */ 10543 function tap(value, interceptor) { 10544 interceptor(value); 10545 return value; 10546 } 10547 10548 /** 10549 * This method is like `_.tap` except that it returns the result of `interceptor`. 10550 * The purpose of this method is to "pass thru" values replacing intermediate 10551 * results in a method chain sequence. 10552 * 10553 * @static 10554 * @memberOf _ 10555 * @since 3.0.0 10556 * @category Seq 10557 * @param {*} value The value to provide to `interceptor`. 10558 * @param {Function} interceptor The function to invoke. 10559 * @returns {*} Returns the result of `interceptor`. 10560 * @example 10561 * 10562 * _(' abc ') 10563 * .chain() 10564 * .trim() 10565 * .thru(function(value) { 10566 * return [value]; 10567 * }) 10568 * .value(); 10569 * // => ['abc'] 10570 */ 10571 function thru(value, interceptor) { 10572 return interceptor(value); 10573 } 10574 10575 /** 10576 * This method is the wrapper version of `_.at`. 10577 * 10578 * @name at 10579 * @memberOf _ 10580 * @since 1.0.0 10581 * @category Seq 10582 * @param {...(string|string[])} [paths] The property paths to pick. 10583 * @returns {Object} Returns the new `lodash` wrapper instance. 10584 * @example 10585 * 10586 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 10587 * 10588 * _(object).at(['a[0].b.c', 'a[1]']).value(); 10589 * // => [3, 4] 10590 */ 10591 var wrapperAt = flatRest(function(paths) { 10592 var length = paths.length, 10593 start = length ? paths[0] : 0, 10594 value = this.__wrapped__, 10595 interceptor = function(object) { return baseAt(object, paths); }; 10596 10597 if (length > 1 || this.__actions__.length || 10598 !(value instanceof LazyWrapper) || !isIndex(start)) { 10599 return this.thru(interceptor); 10600 } 10601 value = value.slice(start, +start + (length ? 1 : 0)); 10602 value.__actions__.push({ 10603 'func': thru, 10604 'args': [interceptor], 10605 'thisArg': undefined 10606 }); 10607 return new LodashWrapper(value, this.__chain__).thru(function(array) { 10608 if (length && !array.length) { 10609 array.push(undefined); 10610 } 10611 return array; 10612 }); 10613 }); 10614 10615 /** 10616 * Creates a `lodash` wrapper instance with explicit method chain sequences enabled. 10617 * 10618 * @name chain 10619 * @memberOf _ 10620 * @since 0.1.0 10621 * @category Seq 10622 * @returns {Object} Returns the new `lodash` wrapper instance. 10623 * @example 10624 * 10625 * var users = [ 10626 * { 'user': 'barney', 'age': 36 }, 10627 * { 'user': 'fred', 'age': 40 } 10628 * ]; 10629 * 10630 * // A sequence without explicit chaining. 10631 * _(users).head(); 10632 * // => { 'user': 'barney', 'age': 36 } 10633 * 10634 * // A sequence with explicit chaining. 10635 * _(users) 10636 * .chain() 10637 * .head() 10638 * .pick('user') 10639 * .value(); 10640 * // => { 'user': 'barney' } 10641 */ 10642 function wrapperChain() { 10643 return chain(this); 10644 } 10645 10646 /** 10647 * Executes the chain sequence and returns the wrapped result. 10648 * 10649 * @name commit 10650 * @memberOf _ 10651 * @since 3.2.0 10652 * @category Seq 10653 * @returns {Object} Returns the new `lodash` wrapper instance. 10654 * @example 10655 * 10656 * var array = [1, 2]; 10657 * var wrapped = _(array).push(3); 10658 * 10659 * console.log(array); 10660 * // => [1, 2] 10661 * 10662 * wrapped = wrapped.commit(); 10663 * console.log(array); 10664 * // => [1, 2, 3] 10665 * 10666 * wrapped.last(); 10667 * // => 3 10668 * 10669 * console.log(array); 10670 * // => [1, 2, 3] 10671 */ 10672 function wrapperCommit() { 10673 return new LodashWrapper(this.value(), this.__chain__); 10674 } 10675 10676 /** 10677 * Gets the next value on a wrapped object following the 10678 * [iterator protocol](https://mdn.io/iteration_protocols#iterator). 10679 * 10680 * @name next 10681 * @memberOf _ 10682 * @since 4.0.0 10683 * @category Seq 10684 * @returns {Object} Returns the next iterator value. 10685 * @example 10686 * 10687 * var wrapped = _([1, 2]); 10688 * 10689 * wrapped.next(); 10690 * // => { 'done': false, 'value': 1 } 10691 * 10692 * wrapped.next(); 10693 * // => { 'done': false, 'value': 2 } 10694 * 10695 * wrapped.next(); 10696 * // => { 'done': true, 'value': undefined } 10697 */ 10698 function wrapperNext() { 10699 if (this.__values__ === undefined) { 10700 this.__values__ = toArray(this.value()); 10701 } 10702 var done = this.__index__ >= this.__values__.length, 10703 value = done ? undefined : this.__values__[this.__index__++]; 10704 10705 return { 'done': done, 'value': value }; 10706 } 10707 10708 /** 10709 * Enables the wrapper to be iterable. 10710 * 10711 * @name Symbol.iterator 10712 * @memberOf _ 10713 * @since 4.0.0 10714 * @category Seq 10715 * @returns {Object} Returns the wrapper object. 10716 * @example 10717 * 10718 * var wrapped = _([1, 2]); 10719 * 10720 * wrapped[Symbol.iterator]() === wrapped; 10721 * // => true 10722 * 10723 * Array.from(wrapped); 10724 * // => [1, 2] 10725 */ 10726 function wrapperToIterator() { 10727 return this; 10728 } 10729 10730 /** 10731 * Creates a clone of the chain sequence planting `value` as the wrapped value. 10732 * 10733 * @name plant 10734 * @memberOf _ 10735 * @since 3.2.0 10736 * @category Seq 10737 * @param {*} value The value to plant. 10738 * @returns {Object} Returns the new `lodash` wrapper instance. 10739 * @example 10740 * 10741 * function square(n) { 10742 * return n * n; 10743 * } 10744 * 10745 * var wrapped = _([1, 2]).map(square); 10746 * var other = wrapped.plant([3, 4]); 10747 * 10748 * other.value(); 10749 * // => [9, 16] 10750 * 10751 * wrapped.value(); 10752 * // => [1, 4] 10753 */ 10754 function wrapperPlant(value) { 10755 var result, 10756 parent = this; 10757 10758 while (parent instanceof baseLodash) { 10759 var clone = wrapperClone(parent); 10760 clone.__index__ = 0; 10761 clone.__values__ = undefined; 10762 if (result) { 10763 previous.__wrapped__ = clone; 10764 } else { 10765 result = clone; 10766 } 10767 var previous = clone; 10768 parent = parent.__wrapped__; 10769 } 10770 previous.__wrapped__ = value; 10771 return result; 10772 } 10773 10774 /** 10775 * This method is the wrapper version of `_.reverse`. 10776 * 10777 * **Note:** This method mutates the wrapped array. 10778 * 10779 * @name reverse 10780 * @memberOf _ 10781 * @since 0.1.0 10782 * @category Seq 10783 * @returns {Object} Returns the new `lodash` wrapper instance. 10784 * @example 10785 * 10786 * var array = [1, 2, 3]; 10787 * 10788 * _(array).reverse().value() 10789 * // => [3, 2, 1] 10790 * 10791 * console.log(array); 10792 * // => [3, 2, 1] 10793 */ 10794 function wrapperReverse() { 10795 var value = this.__wrapped__; 10796 if (value instanceof LazyWrapper) { 10797 var wrapped = value; 10798 if (this.__actions__.length) { 10799 wrapped = new LazyWrapper(this); 10800 } 10801 wrapped = wrapped.reverse(); 10802 wrapped.__actions__.push({ 10803 'func': thru, 10804 'args': [reverse], 10805 'thisArg': undefined 10806 }); 10807 return new LodashWrapper(wrapped, this.__chain__); 10808 } 10809 return this.thru(reverse); 10810 } 10811 10812 /** 10813 * Executes the chain sequence to resolve the unwrapped value. 10814 * 10815 * @name value 10816 * @memberOf _ 10817 * @since 0.1.0 10818 * @alias toJSON, valueOf 10819 * @category Seq 10820 * @returns {*} Returns the resolved unwrapped value. 10821 * @example 10822 * 10823 * _([1, 2, 3]).value(); 10824 * // => [1, 2, 3] 10825 */ 10826 function wrapperValue() { 10827 return baseWrapperValue(this.__wrapped__, this.__actions__); 10828 } 10829 10830 /*------------------------------------------------------------------------*/ 10831 10832 /** 10833 * Creates an object composed of keys generated from the results of running 10834 * each element of `collection` thru `iteratee`. The corresponding value of 10835 * each key is the number of times the key was returned by `iteratee`. The 10836 * iteratee is invoked with one argument: (value). 10837 * 10838 * @static 10839 * @memberOf _ 10840 * @since 0.5.0 10841 * @category Collection 10842 * @param {Array|Object} collection The collection to iterate over. 10843 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 10844 * @returns {Object} Returns the composed aggregate object. 10845 * @example 10846 * 10847 * _.countBy([6.1, 4.2, 6.3], Math.floor); 10848 * // => { '4': 1, '6': 2 } 10849 * 10850 * // The `_.property` iteratee shorthand. 10851 * _.countBy(['one', 'two', 'three'], 'length'); 10852 * // => { '3': 2, '5': 1 } 10853 */ 10854 var countBy = createAggregator(function(result, value, key) { 10855 if (hasOwnProperty.call(result, key)) { 10856 ++result[key]; 10857 } else { 10858 baseAssignValue(result, key, 1); 10859 } 10860 }); 10861 10862 /** 10863 * Checks if `predicate` returns truthy for **all** elements of `collection`. 10864 * Iteration is stopped once `predicate` returns falsey. The predicate is 10865 * invoked with three arguments: (value, index|key, collection). 10866 * 10867 * **Note:** This method returns `true` for 10868 * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because 10869 * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of 10870 * elements of empty collections. 10871 * 10872 * @static 10873 * @memberOf _ 10874 * @since 0.1.0 10875 * @category Collection 10876 * @param {Array|Object} collection The collection to iterate over. 10877 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10878 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 10879 * @returns {boolean} Returns `true` if all elements pass the predicate check, 10880 * else `false`. 10881 * @example 10882 * 10883 * _.every([true, 1, null, 'yes'], Boolean); 10884 * // => false 10885 * 10886 * var users = [ 10887 * { 'user': 'barney', 'age': 36, 'active': false }, 10888 * { 'user': 'fred', 'age': 40, 'active': false } 10889 * ]; 10890 * 10891 * // The `_.matches` iteratee shorthand. 10892 * _.every(users, { 'user': 'barney', 'active': false }); 10893 * // => false 10894 * 10895 * // The `_.matchesProperty` iteratee shorthand. 10896 * _.every(users, ['active', false]); 10897 * // => true 10898 * 10899 * // The `_.property` iteratee shorthand. 10900 * _.every(users, 'active'); 10901 * // => false 10902 */ 10903 function every(collection, predicate, guard) { 10904 var func = isArray(collection) ? arrayEvery : baseEvery; 10905 if (guard && isIterateeCall(collection, predicate, guard)) { 10906 predicate = undefined; 10907 } 10908 return func(collection, getIteratee(predicate, 3)); 10909 } 10910 10911 /** 10912 * Iterates over elements of `collection`, returning an array of all elements 10913 * `predicate` returns truthy for. The predicate is invoked with three 10914 * arguments: (value, index|key, collection). 10915 * 10916 * **Note:** Unlike `_.remove`, this method returns a new array. 10917 * 10918 * @static 10919 * @memberOf _ 10920 * @since 0.1.0 10921 * @category Collection 10922 * @param {Array|Object} collection The collection to iterate over. 10923 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10924 * @returns {Array} Returns the new filtered array. 10925 * @see _.reject 10926 * @example 10927 * 10928 * var users = [ 10929 * { 'user': 'barney', 'age': 36, 'active': true }, 10930 * { 'user': 'fred', 'age': 40, 'active': false } 10931 * ]; 10932 * 10933 * _.filter(users, function(o) { return !o.active; }); 10934 * // => objects for ['fred'] 10935 * 10936 * // The `_.matches` iteratee shorthand. 10937 * _.filter(users, { 'age': 36, 'active': true }); 10938 * // => objects for ['barney'] 10939 * 10940 * // The `_.matchesProperty` iteratee shorthand. 10941 * _.filter(users, ['active', false]); 10942 * // => objects for ['fred'] 10943 * 10944 * // The `_.property` iteratee shorthand. 10945 * _.filter(users, 'active'); 10946 * // => objects for ['barney'] 10947 * 10948 * // Combining several predicates using `_.overEvery` or `_.overSome`. 10949 * _.filter(users, _.overSome([{ 'age': 36 }, ['age', 40]])); 10950 * // => objects for ['fred', 'barney'] 10951 */ 10952 function filter(collection, predicate) { 10953 var func = isArray(collection) ? arrayFilter : baseFilter; 10954 return func(collection, getIteratee(predicate, 3)); 10955 } 10956 10957 /** 10958 * Iterates over elements of `collection`, returning the first element 10959 * `predicate` returns truthy for. The predicate is invoked with three 10960 * arguments: (value, index|key, collection). 10961 * 10962 * @static 10963 * @memberOf _ 10964 * @since 0.1.0 10965 * @category Collection 10966 * @param {Array|Object} collection The collection to inspect. 10967 * @param {Function} [predicate=_.identity] The function invoked per iteration. 10968 * @param {number} [fromIndex=0] The index to search from. 10969 * @returns {*} Returns the matched element, else `undefined`. 10970 * @example 10971 * 10972 * var users = [ 10973 * { 'user': 'barney', 'age': 36, 'active': true }, 10974 * { 'user': 'fred', 'age': 40, 'active': false }, 10975 * { 'user': 'pebbles', 'age': 1, 'active': true } 10976 * ]; 10977 * 10978 * _.find(users, function(o) { return o.age < 40; }); 10979 * // => object for 'barney' 10980 * 10981 * // The `_.matches` iteratee shorthand. 10982 * _.find(users, { 'age': 1, 'active': true }); 10983 * // => object for 'pebbles' 10984 * 10985 * // The `_.matchesProperty` iteratee shorthand. 10986 * _.find(users, ['active', false]); 10987 * // => object for 'fred' 10988 * 10989 * // The `_.property` iteratee shorthand. 10990 * _.find(users, 'active'); 10991 * // => object for 'barney' 10992 */ 10993 var find = createFind(findIndex); 10994 10995 /** 10996 * This method is like `_.find` except that it iterates over elements of 10997 * `collection` from right to left. 10998 * 10999 * @static 11000 * @memberOf _ 11001 * @since 2.0.0 11002 * @category Collection 11003 * @param {Array|Object} collection The collection to inspect. 11004 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11005 * @param {number} [fromIndex=collection.length-1] The index to search from. 11006 * @returns {*} Returns the matched element, else `undefined`. 11007 * @example 11008 * 11009 * _.findLast([1, 2, 3, 4], function(n) { 11010 * return n % 2 == 1; 11011 * }); 11012 * // => 3 11013 */ 11014 var findLast = createFind(findLastIndex); 11015 11016 /** 11017 * Creates a flattened array of values by running each element in `collection` 11018 * thru `iteratee` and flattening the mapped results. The iteratee is invoked 11019 * with three arguments: (value, index|key, collection). 11020 * 11021 * @static 11022 * @memberOf _ 11023 * @since 4.0.0 11024 * @category Collection 11025 * @param {Array|Object} collection The collection to iterate over. 11026 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11027 * @returns {Array} Returns the new flattened array. 11028 * @example 11029 * 11030 * function duplicate(n) { 11031 * return [n, n]; 11032 * } 11033 * 11034 * _.flatMap([1, 2], duplicate); 11035 * // => [1, 1, 2, 2] 11036 */ 11037 function flatMap(collection, iteratee) { 11038 return baseFlatten(map(collection, iteratee), 1); 11039 } 11040 11041 /** 11042 * This method is like `_.flatMap` except that it recursively flattens the 11043 * mapped results. 11044 * 11045 * @static 11046 * @memberOf _ 11047 * @since 4.7.0 11048 * @category Collection 11049 * @param {Array|Object} collection The collection to iterate over. 11050 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11051 * @returns {Array} Returns the new flattened array. 11052 * @example 11053 * 11054 * function duplicate(n) { 11055 * return [[[n, n]]]; 11056 * } 11057 * 11058 * _.flatMapDeep([1, 2], duplicate); 11059 * // => [1, 1, 2, 2] 11060 */ 11061 function flatMapDeep(collection, iteratee) { 11062 return baseFlatten(map(collection, iteratee), INFINITY); 11063 } 11064 11065 /** 11066 * This method is like `_.flatMap` except that it recursively flattens the 11067 * mapped results up to `depth` times. 11068 * 11069 * @static 11070 * @memberOf _ 11071 * @since 4.7.0 11072 * @category Collection 11073 * @param {Array|Object} collection The collection to iterate over. 11074 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11075 * @param {number} [depth=1] The maximum recursion depth. 11076 * @returns {Array} Returns the new flattened array. 11077 * @example 11078 * 11079 * function duplicate(n) { 11080 * return [[[n, n]]]; 11081 * } 11082 * 11083 * _.flatMapDepth([1, 2], duplicate, 2); 11084 * // => [[1, 1], [2, 2]] 11085 */ 11086 function flatMapDepth(collection, iteratee, depth) { 11087 depth = depth === undefined ? 1 : toInteger(depth); 11088 return baseFlatten(map(collection, iteratee), depth); 11089 } 11090 11091 /** 11092 * Iterates over elements of `collection` and invokes `iteratee` for each element. 11093 * The iteratee is invoked with three arguments: (value, index|key, collection). 11094 * Iteratee functions may exit iteration early by explicitly returning `false`. 11095 * 11096 * **Note:** As with other "Collections" methods, objects with a "length" 11097 * property are iterated like arrays. To avoid this behavior use `_.forIn` 11098 * or `_.forOwn` for object iteration. 11099 * 11100 * @static 11101 * @memberOf _ 11102 * @since 0.1.0 11103 * @alias each 11104 * @category Collection 11105 * @param {Array|Object} collection The collection to iterate over. 11106 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11107 * @returns {Array|Object} Returns `collection`. 11108 * @see _.forEachRight 11109 * @example 11110 * 11111 * _.forEach([1, 2], function(value) { 11112 * console.log(value); 11113 * }); 11114 * // => Logs `1` then `2`. 11115 * 11116 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 11117 * console.log(key); 11118 * }); 11119 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 11120 */ 11121 function forEach(collection, iteratee) { 11122 var func = isArray(collection) ? arrayEach : baseEach; 11123 return func(collection, getIteratee(iteratee, 3)); 11124 } 11125 11126 /** 11127 * This method is like `_.forEach` except that it iterates over elements of 11128 * `collection` from right to left. 11129 * 11130 * @static 11131 * @memberOf _ 11132 * @since 2.0.0 11133 * @alias eachRight 11134 * @category Collection 11135 * @param {Array|Object} collection The collection to iterate over. 11136 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11137 * @returns {Array|Object} Returns `collection`. 11138 * @see _.forEach 11139 * @example 11140 * 11141 * _.forEachRight([1, 2], function(value) { 11142 * console.log(value); 11143 * }); 11144 * // => Logs `2` then `1`. 11145 */ 11146 function forEachRight(collection, iteratee) { 11147 var func = isArray(collection) ? arrayEachRight : baseEachRight; 11148 return func(collection, getIteratee(iteratee, 3)); 11149 } 11150 11151 /**
vendor: 4,136 bytes, lines 11152-11259
11152 * Creates an object composed of keys generated from the results of running 11153 * each element of `collection` thru `iteratee`. The order of grouped values 11154 * is determined by the order they occur in `collection`. The corresponding 11155 * value of each key is an array of elements responsible for generating the 11156 * key. The iteratee is invoked with one argument: (value). 11157 * 11158 * @static 11159 * @memberOf _ 11160 * @since 0.1.0 11161 * @category Collection 11162 * @param {Array|Object} collection The collection to iterate over. 11163 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 11164 * @returns {Object} Returns the composed aggregate object. 11165 * @example 11166 * 11167 * _.groupBy([6.1, 4.2, 6.3], Math.floor); 11168 * // => { '4': [4.2], '6': [6.1, 6.3] } 11169 * 11170 * // The `_.property` iteratee shorthand. 11171 * _.groupBy(['one', 'two', 'three'], 'length'); 11172 * // => { '3': ['one', 'two'], '5': ['three'] } 11173 */ 11174 var groupBy = createAggregator(function(result, value, key) { 11175 if (hasOwnProperty.call(result, key)) { 11176 result[key].push(value); 11177 } else { 11178 baseAssignValue(result, key, [value]); 11179 } 11180 }); 11181 11182 /** 11183 * Checks if `value` is in `collection`. If `collection` is a string, it's 11184 * checked for a substring of `value`, otherwise 11185 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 11186 * is used for equality comparisons. If `fromIndex` is negative, it's used as 11187 * the offset from the end of `collection`. 11188 * 11189 * @static 11190 * @memberOf _ 11191 * @since 0.1.0 11192 * @category Collection 11193 * @param {Array|Object|string} collection The collection to inspect. 11194 * @param {*} value The value to search for. 11195 * @param {number} [fromIndex=0] The index to search from. 11196 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 11197 * @returns {boolean} Returns `true` if `value` is found, else `false`. 11198 * @example 11199 * 11200 * _.includes([1, 2, 3], 1); 11201 * // => true 11202 * 11203 * _.includes([1, 2, 3], 1, 2); 11204 * // => false 11205 * 11206 * _.includes({ 'a': 1, 'b': 2 }, 1); 11207 * // => true 11208 * 11209 * _.includes('abcd', 'bc'); 11210 * // => true 11211 */ 11212 function includes(collection, value, fromIndex, guard) { 11213 collection = isArrayLike(collection) ? collection : values(collection); 11214 fromIndex = (fromIndex && !guard) ? toInteger(fromIndex) : 0; 11215 11216 var length = collection.length; 11217 if (fromIndex < 0) { 11218 fromIndex = nativeMax(length + fromIndex, 0); 11219 } 11220 return isString(collection) 11221 ? (fromIndex <= length && collection.indexOf(value, fromIndex) > -1) 11222 : (!!length && baseIndexOf(collection, value, fromIndex) > -1); 11223 } 11224 11225 /** 11226 * Invokes the method at `path` of each element in `collection`, returning 11227 * an array of the results of each invoked method. Any additional arguments 11228 * are provided to each invoked method. If `path` is a function, it's invoked 11229 * for, and `this` bound to, each element in `collection`. 11230 * 11231 * @static 11232 * @memberOf _ 11233 * @since 4.0.0 11234 * @category Collection 11235 * @param {Array|Object} collection The collection to iterate over. 11236 * @param {Array|Function|string} path The path of the method to invoke or 11237 * the function invoked per iteration. 11238 * @param {...*} [args] The arguments to invoke each method with. 11239 * @returns {Array} Returns the array of results. 11240 * @example 11241 * 11242 * _.invokeMap([[5, 1, 7], [3, 2, 1]], 'sort'); 11243 * // => [[1, 5, 7], [1, 2, 3]] 11244 * 11245 * _.invokeMap([123, 456], String.prototype.split, ''); 11246 * // => [['1', '2', '3'], ['4', '5', '6']] 11247 */ 11248 var invokeMap = baseRest(function(collection, path, args) { 11249 var index = -1, 11250 isFunc = typeof path == 'function', 11251 result = isArrayLike(collection) ? Array(collection.length) : []; 11252 11253 baseEach(collection, function(value) { 11254 result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args); 11255 }); 11256 return result; 11257 }); 11258 11259 /**
vendor: 68,500 bytes, lines 11260-13374
11260 * Creates an object composed of keys generated from the results of running 11261 * each element of `collection` thru `iteratee`. The corresponding value of 11262 * each key is the last element responsible for generating the key. The 11263 * iteratee is invoked with one argument: (value). 11264 * 11265 * @static 11266 * @memberOf _ 11267 * @since 4.0.0 11268 * @category Collection 11269 * @param {Array|Object} collection The collection to iterate over. 11270 * @param {Function} [iteratee=_.identity] The iteratee to transform keys. 11271 * @returns {Object} Returns the composed aggregate object. 11272 * @example 11273 * 11274 * var array = [ 11275 * { 'dir': 'left', 'code': 97 }, 11276 * { 'dir': 'right', 'code': 100 } 11277 * ]; 11278 * 11279 * _.keyBy(array, function(o) { 11280 * return String.fromCharCode(o.code); 11281 * }); 11282 * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } 11283 * 11284 * _.keyBy(array, 'dir'); 11285 * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } 11286 */ 11287 var keyBy = createAggregator(function(result, value, key) { 11288 baseAssignValue(result, key, value); 11289 }); 11290 11291 /** 11292 * Creates an array of values by running each element in `collection` thru 11293 * `iteratee`. The iteratee is invoked with three arguments: 11294 * (value, index|key, collection). 11295 * 11296 * Many lodash methods are guarded to work as iteratees for methods like 11297 * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. 11298 * 11299 * The guarded methods are: 11300 * `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`, 11301 * `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`, 11302 * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`, 11303 * `template`, `trim`, `trimEnd`, `trimStart`, and `words` 11304 * 11305 * @static 11306 * @memberOf _ 11307 * @since 0.1.0 11308 * @category Collection 11309 * @param {Array|Object} collection The collection to iterate over. 11310 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11311 * @returns {Array} Returns the new mapped array. 11312 * @example 11313 * 11314 * function square(n) { 11315 * return n * n; 11316 * } 11317 * 11318 * _.map([4, 8], square); 11319 * // => [16, 64] 11320 * 11321 * _.map({ 'a': 4, 'b': 8 }, square); 11322 * // => [16, 64] (iteration order is not guaranteed) 11323 * 11324 * var users = [ 11325 * { 'user': 'barney' }, 11326 * { 'user': 'fred' } 11327 * ]; 11328 * 11329 * // The `_.property` iteratee shorthand. 11330 * _.map(users, 'user'); 11331 * // => ['barney', 'fred'] 11332 */ 11333 function map(collection, iteratee) { 11334 var func = isArray(collection) ? arrayMap : baseMap; 11335 return func(collection, getIteratee(iteratee, 3)); 11336 } 11337 11338 /** 11339 * This method is like `_.sortBy` except that it allows specifying the sort 11340 * orders of the iteratees to sort by. If `orders` is unspecified, all values 11341 * are sorted in ascending order. Otherwise, specify an order of "desc" for 11342 * descending or "asc" for ascending sort order of corresponding values. 11343 * 11344 * @static 11345 * @memberOf _ 11346 * @since 4.0.0 11347 * @category Collection 11348 * @param {Array|Object} collection The collection to iterate over. 11349 * @param {Array[]|Function[]|Object[]|string[]} [iteratees=[_.identity]] 11350 * The iteratees to sort by. 11351 * @param {string[]} [orders] The sort orders of `iteratees`. 11352 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.reduce`. 11353 * @returns {Array} Returns the new sorted array. 11354 * @example 11355 * 11356 * var users = [ 11357 * { 'user': 'fred', 'age': 48 }, 11358 * { 'user': 'barney', 'age': 34 }, 11359 * { 'user': 'fred', 'age': 40 }, 11360 * { 'user': 'barney', 'age': 36 } 11361 * ]; 11362 * 11363 * // Sort by `user` in ascending order and by `age` in descending order. 11364 * _.orderBy(users, ['user', 'age'], ['asc', 'desc']); 11365 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]] 11366 */ 11367 function orderBy(collection, iteratees, orders, guard) { 11368 if (collection == null) { 11369 return []; 11370 } 11371 if (!isArray(iteratees)) { 11372 iteratees = iteratees == null ? [] : [iteratees]; 11373 } 11374 orders = guard ? undefined : orders; 11375 if (!isArray(orders)) { 11376 orders = orders == null ? [] : [orders]; 11377 } 11378 return baseOrderBy(collection, iteratees, orders); 11379 } 11380 11381 /** 11382 * Creates an array of elements split into two groups, the first of which 11383 * contains elements `predicate` returns truthy for, the second of which 11384 * contains elements `predicate` returns falsey for. The predicate is 11385 * invoked with one argument: (value). 11386 * 11387 * @static 11388 * @memberOf _ 11389 * @since 3.0.0 11390 * @category Collection 11391 * @param {Array|Object} collection The collection to iterate over. 11392 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11393 * @returns {Array} Returns the array of grouped elements. 11394 * @example 11395 * 11396 * var users = [ 11397 * { 'user': 'barney', 'age': 36, 'active': false }, 11398 * { 'user': 'fred', 'age': 40, 'active': true }, 11399 * { 'user': 'pebbles', 'age': 1, 'active': false } 11400 * ]; 11401 * 11402 * _.partition(users, function(o) { return o.active; }); 11403 * // => objects for [['fred'], ['barney', 'pebbles']] 11404 * 11405 * // The `_.matches` iteratee shorthand. 11406 * _.partition(users, { 'age': 1, 'active': false }); 11407 * // => objects for [['pebbles'], ['barney', 'fred']] 11408 * 11409 * // The `_.matchesProperty` iteratee shorthand. 11410 * _.partition(users, ['active', false]); 11411 * // => objects for [['barney', 'pebbles'], ['fred']] 11412 * 11413 * // The `_.property` iteratee shorthand. 11414 * _.partition(users, 'active'); 11415 * // => objects for [['fred'], ['barney', 'pebbles']] 11416 */ 11417 var partition = createAggregator(function(result, value, key) { 11418 result[key ? 0 : 1].push(value); 11419 }, function() { return [[], []]; }); 11420 11421 /** 11422 * Reduces `collection` to a value which is the accumulated result of running 11423 * each element in `collection` thru `iteratee`, where each successive 11424 * invocation is supplied the return value of the previous. If `accumulator` 11425 * is not given, the first element of `collection` is used as the initial 11426 * value. The iteratee is invoked with four arguments: 11427 * (accumulator, value, index|key, collection). 11428 * 11429 * Many lodash methods are guarded to work as iteratees for methods like 11430 * `_.reduce`, `_.reduceRight`, and `_.transform`. 11431 * 11432 * The guarded methods are: 11433 * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `orderBy`, 11434 * and `sortBy` 11435 * 11436 * @static 11437 * @memberOf _ 11438 * @since 0.1.0 11439 * @category Collection 11440 * @param {Array|Object} collection The collection to iterate over. 11441 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11442 * @param {*} [accumulator] The initial value. 11443 * @returns {*} Returns the accumulated value. 11444 * @see _.reduceRight 11445 * @example 11446 * 11447 * _.reduce([1, 2], function(sum, n) { 11448 * return sum + n; 11449 * }, 0); 11450 * // => 3 11451 * 11452 * _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 11453 * (result[value] || (result[value] = [])).push(key); 11454 * return result; 11455 * }, {}); 11456 * // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed) 11457 */ 11458 function reduce(collection, iteratee, accumulator) { 11459 var func = isArray(collection) ? arrayReduce : baseReduce, 11460 initAccum = arguments.length < 3; 11461 11462 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); 11463 } 11464 11465 /** 11466 * This method is like `_.reduce` except that it iterates over elements of 11467 * `collection` from right to left. 11468 * 11469 * @static 11470 * @memberOf _ 11471 * @since 0.1.0 11472 * @category Collection 11473 * @param {Array|Object} collection The collection to iterate over. 11474 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 11475 * @param {*} [accumulator] The initial value. 11476 * @returns {*} Returns the accumulated value. 11477 * @see _.reduce 11478 * @example 11479 * 11480 * var array = [[0, 1], [2, 3], [4, 5]]; 11481 * 11482 * _.reduceRight(array, function(flattened, other) { 11483 * return flattened.concat(other); 11484 * }, []); 11485 * // => [4, 5, 2, 3, 0, 1] 11486 */ 11487 function reduceRight(collection, iteratee, accumulator) { 11488 var func = isArray(collection) ? arrayReduceRight : baseReduce, 11489 initAccum = arguments.length < 3; 11490 11491 return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); 11492 } 11493 11494 /** 11495 * The opposite of `_.filter`; this method returns the elements of `collection` 11496 * that `predicate` does **not** return truthy for. 11497 * 11498 * @static 11499 * @memberOf _ 11500 * @since 0.1.0 11501 * @category Collection 11502 * @param {Array|Object} collection The collection to iterate over. 11503 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11504 * @returns {Array} Returns the new filtered array. 11505 * @see _.filter 11506 * @example 11507 * 11508 * var users = [ 11509 * { 'user': 'barney', 'age': 36, 'active': false }, 11510 * { 'user': 'fred', 'age': 40, 'active': true } 11511 * ]; 11512 * 11513 * _.reject(users, function(o) { return !o.active; }); 11514 * // => objects for ['fred'] 11515 * 11516 * // The `_.matches` iteratee shorthand. 11517 * _.reject(users, { 'age': 40, 'active': true }); 11518 * // => objects for ['barney'] 11519 * 11520 * // The `_.matchesProperty` iteratee shorthand. 11521 * _.reject(users, ['active', false]); 11522 * // => objects for ['fred'] 11523 * 11524 * // The `_.property` iteratee shorthand. 11525 * _.reject(users, 'active'); 11526 * // => objects for ['barney'] 11527 */ 11528 function reject(collection, predicate) { 11529 var func = isArray(collection) ? arrayFilter : baseFilter; 11530 return func(collection, negate(getIteratee(predicate, 3))); 11531 } 11532 11533 /** 11534 * Gets a random element from `collection`. 11535 * 11536 * @static 11537 * @memberOf _ 11538 * @since 2.0.0 11539 * @category Collection 11540 * @param {Array|Object} collection The collection to sample. 11541 * @returns {*} Returns the random element. 11542 * @example 11543 * 11544 * _.sample([1, 2, 3, 4]); 11545 * // => 2 11546 */ 11547 function sample(collection) { 11548 var func = isArray(collection) ? arraySample : baseSample; 11549 return func(collection); 11550 } 11551 11552 /** 11553 * Gets `n` random elements at unique keys from `collection` up to the 11554 * size of `collection`. 11555 * 11556 * @static 11557 * @memberOf _ 11558 * @since 4.0.0 11559 * @category Collection 11560 * @param {Array|Object} collection The collection to sample. 11561 * @param {number} [n=1] The number of elements to sample. 11562 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 11563 * @returns {Array} Returns the random elements. 11564 * @example 11565 * 11566 * _.sampleSize([1, 2, 3], 2); 11567 * // => [3, 1] 11568 * 11569 * _.sampleSize([1, 2, 3], 4); 11570 * // => [2, 3, 1] 11571 */ 11572 function sampleSize(collection, n, guard) { 11573 if ((guard ? isIterateeCall(collection, n, guard) : n === undefined)) { 11574 n = 1; 11575 } else { 11576 n = toInteger(n); 11577 } 11578 var func = isArray(collection) ? arraySampleSize : baseSampleSize; 11579 return func(collection, n); 11580 } 11581 11582 /** 11583 * Creates an array of shuffled values, using a version of the 11584 * [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle). 11585 * 11586 * @static 11587 * @memberOf _ 11588 * @since 0.1.0 11589 * @category Collection 11590 * @param {Array|Object} collection The collection to shuffle. 11591 * @returns {Array} Returns the new shuffled array. 11592 * @example 11593 * 11594 * _.shuffle([1, 2, 3, 4]); 11595 * // => [4, 1, 3, 2] 11596 */ 11597 function shuffle(collection) { 11598 var func = isArray(collection) ? arrayShuffle : baseShuffle; 11599 return func(collection); 11600 } 11601 11602 /** 11603 * Gets the size of `collection` by returning its length for array-like 11604 * values or the number of own enumerable string keyed properties for objects. 11605 * 11606 * @static 11607 * @memberOf _ 11608 * @since 0.1.0 11609 * @category Collection 11610 * @param {Array|Object|string} collection The collection to inspect. 11611 * @returns {number} Returns the collection size. 11612 * @example 11613 * 11614 * _.size([1, 2, 3]); 11615 * // => 3 11616 * 11617 * _.size({ 'a': 1, 'b': 2 }); 11618 * // => 2 11619 * 11620 * _.size('pebbles'); 11621 * // => 7 11622 */ 11623 function size(collection) { 11624 if (collection == null) { 11625 return 0; 11626 } 11627 if (isArrayLike(collection)) { 11628 return isString(collection) ? stringSize(collection) : collection.length; 11629 } 11630 var tag = getTag(collection); 11631 if (tag == mapTag || tag == setTag) { 11632 return collection.size; 11633 } 11634 return baseKeys(collection).length; 11635 } 11636 11637 /** 11638 * Checks if `predicate` returns truthy for **any** element of `collection`. 11639 * Iteration is stopped once `predicate` returns truthy. The predicate is 11640 * invoked with three arguments: (value, index|key, collection). 11641 * 11642 * @static 11643 * @memberOf _ 11644 * @since 0.1.0 11645 * @category Collection 11646 * @param {Array|Object} collection The collection to iterate over. 11647 * @param {Function} [predicate=_.identity] The function invoked per iteration. 11648 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 11649 * @returns {boolean} Returns `true` if any element passes the predicate check, 11650 * else `false`. 11651 * @example 11652 * 11653 * _.some([null, 0, 'yes', false], Boolean); 11654 * // => true 11655 * 11656 * var users = [ 11657 * { 'user': 'barney', 'active': true }, 11658 * { 'user': 'fred', 'active': false } 11659 * ]; 11660 * 11661 * // The `_.matches` iteratee shorthand. 11662 * _.some(users, { 'user': 'barney', 'active': false }); 11663 * // => false 11664 * 11665 * // The `_.matchesProperty` iteratee shorthand. 11666 * _.some(users, ['active', false]); 11667 * // => true 11668 * 11669 * // The `_.property` iteratee shorthand. 11670 * _.some(users, 'active'); 11671 * // => true 11672 */ 11673 function some(collection, predicate, guard) { 11674 var func = isArray(collection) ? arraySome : baseSome; 11675 if (guard && isIterateeCall(collection, predicate, guard)) { 11676 predicate = undefined; 11677 } 11678 return func(collection, getIteratee(predicate, 3)); 11679 } 11680 11681 /** 11682 * Creates an array of elements, sorted in ascending order by the results of 11683 * running each element in a collection thru each iteratee. This method 11684 * performs a stable sort, that is, it preserves the original sort order of 11685 * equal elements. The iteratees are invoked with one argument: (value). 11686 * 11687 * @static 11688 * @memberOf _ 11689 * @since 0.1.0 11690 * @category Collection 11691 * @param {Array|Object} collection The collection to iterate over. 11692 * @param {...(Function|Function[])} [iteratees=[_.identity]] 11693 * The iteratees to sort by. 11694 * @returns {Array} Returns the new sorted array. 11695 * @example 11696 * 11697 * var users = [ 11698 * { 'user': 'fred', 'age': 48 }, 11699 * { 'user': 'barney', 'age': 36 }, 11700 * { 'user': 'fred', 'age': 30 }, 11701 * { 'user': 'barney', 'age': 34 } 11702 * ]; 11703 * 11704 * _.sortBy(users, [function(o) { return o.user; }]); 11705 * // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 30]] 11706 * 11707 * _.sortBy(users, ['user', 'age']); 11708 * // => objects for [['barney', 34], ['barney', 36], ['fred', 30], ['fred', 48]] 11709 */ 11710 var sortBy = baseRest(function(collection, iteratees) { 11711 if (collection == null) { 11712 return []; 11713 } 11714 var length = iteratees.length; 11715 if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) { 11716 iteratees = []; 11717 } else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) { 11718 iteratees = [iteratees[0]]; 11719 } 11720 return baseOrderBy(collection, baseFlatten(iteratees, 1), []); 11721 }); 11722 11723 /*------------------------------------------------------------------------*/ 11724 11725 /** 11726 * Gets the timestamp of the number of milliseconds that have elapsed since 11727 * the Unix epoch (1 January 1970 00:00:00 UTC). 11728 * 11729 * @static 11730 * @memberOf _ 11731 * @since 2.4.0 11732 * @category Date 11733 * @returns {number} Returns the timestamp. 11734 * @example 11735 * 11736 * _.defer(function(stamp) { 11737 * console.log(_.now() - stamp); 11738 * }, _.now()); 11739 * // => Logs the number of milliseconds it took for the deferred invocation. 11740 */ 11741 var now = ctxNow || function() { 11742 return root.Date.now(); 11743 }; 11744 11745 /*------------------------------------------------------------------------*/ 11746 11747 /** 11748 * The opposite of `_.before`; this method creates a function that invokes 11749 * `func` once it's called `n` or more times. 11750 * 11751 * @static 11752 * @memberOf _ 11753 * @since 0.1.0 11754 * @category Function 11755 * @param {number} n The number of calls before `func` is invoked. 11756 * @param {Function} func The function to restrict. 11757 * @returns {Function} Returns the new restricted function. 11758 * @example 11759 * 11760 * var saves = ['profile', 'settings']; 11761 * 11762 * var done = _.after(saves.length, function() { 11763 * console.log('done saving!'); 11764 * }); 11765 * 11766 * _.forEach(saves, function(type) { 11767 * asyncSave({ 'type': type, 'complete': done }); 11768 * }); 11769 * // => Logs 'done saving!' after the two async saves have completed. 11770 */ 11771 function after(n, func) { 11772 if (typeof func != 'function') { 11773 throw new TypeError(FUNC_ERROR_TEXT); 11774 } 11775 n = toInteger(n); 11776 return function() { 11777 if (--n < 1) { 11778 return func.apply(this, arguments); 11779 } 11780 }; 11781 } 11782 11783 /** 11784 * Creates a function that invokes `func`, with up to `n` arguments, 11785 * ignoring any additional arguments. 11786 * 11787 * @static 11788 * @memberOf _ 11789 * @since 3.0.0 11790 * @category Function 11791 * @param {Function} func The function to cap arguments for. 11792 * @param {number} [n=func.length] The arity cap. 11793 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 11794 * @returns {Function} Returns the new capped function. 11795 * @example 11796 * 11797 * _.map(['6', '8', '10'], _.ary(parseInt, 1)); 11798 * // => [6, 8, 10] 11799 */ 11800 function ary(func, n, guard) { 11801 n = guard ? undefined : n; 11802 n = (func && n == null) ? func.length : n; 11803 return createWrap(func, WRAP_ARY_FLAG, undefined, undefined, undefined, undefined, n); 11804 } 11805 11806 /** 11807 * Creates a function that invokes `func`, with the `this` binding and arguments 11808 * of the created function, while it's called less than `n` times. Subsequent 11809 * calls to the created function return the result of the last `func` invocation. 11810 * 11811 * @static 11812 * @memberOf _ 11813 * @since 3.0.0 11814 * @category Function 11815 * @param {number} n The number of calls at which `func` is no longer invoked. 11816 * @param {Function} func The function to restrict. 11817 * @returns {Function} Returns the new restricted function. 11818 * @example 11819 * 11820 * jQuery(element).on('click', _.before(5, addContactToList)); 11821 * // => Allows adding up to 4 contacts to the list. 11822 */ 11823 function before(n, func) { 11824 var result; 11825 if (typeof func != 'function') { 11826 throw new TypeError(FUNC_ERROR_TEXT); 11827 } 11828 n = toInteger(n); 11829 return function() { 11830 if (--n > 0) { 11831 result = func.apply(this, arguments); 11832 } 11833 if (n <= 1) { 11834 func = undefined; 11835 } 11836 return result; 11837 }; 11838 } 11839 11840 /** 11841 * Creates a function that invokes `func` with the `this` binding of `thisArg` 11842 * and `partials` prepended to the arguments it receives. 11843 * 11844 * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds, 11845 * may be used as a placeholder for partially applied arguments. 11846 * 11847 * **Note:** Unlike native `Function#bind`, this method doesn't set the "length" 11848 * property of bound functions. 11849 * 11850 * @static 11851 * @memberOf _ 11852 * @since 0.1.0 11853 * @category Function 11854 * @param {Function} func The function to bind. 11855 * @param {*} thisArg The `this` binding of `func`. 11856 * @param {...*} [partials] The arguments to be partially applied. 11857 * @returns {Function} Returns the new bound function. 11858 * @example 11859 * 11860 * function greet(greeting, punctuation) { 11861 * return greeting + ' ' + this.user + punctuation; 11862 * } 11863 * 11864 * var object = { 'user': 'fred' }; 11865 * 11866 * var bound = _.bind(greet, object, 'hi'); 11867 * bound('!'); 11868 * // => 'hi fred!' 11869 * 11870 * // Bound with placeholders. 11871 * var bound = _.bind(greet, object, _, '!'); 11872 * bound('hi'); 11873 * // => 'hi fred!' 11874 */ 11875 var bind = baseRest(function(func, thisArg, partials) { 11876 var bitmask = WRAP_BIND_FLAG; 11877 if (partials.length) { 11878 var holders = replaceHolders(partials, getHolder(bind)); 11879 bitmask |= WRAP_PARTIAL_FLAG; 11880 } 11881 return createWrap(func, bitmask, thisArg, partials, holders); 11882 }); 11883 11884 /** 11885 * Creates a function that invokes the method at `object[key]` with `partials` 11886 * prepended to the arguments it receives. 11887 * 11888 * This method differs from `_.bind` by allowing bound functions to reference 11889 * methods that may be redefined or don't yet exist. See 11890 * [Peter Michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern) 11891 * for more details. 11892 * 11893 * The `_.bindKey.placeholder` value, which defaults to `_` in monolithic 11894 * builds, may be used as a placeholder for partially applied arguments. 11895 * 11896 * @static 11897 * @memberOf _ 11898 * @since 0.10.0 11899 * @category Function 11900 * @param {Object} object The object to invoke the method on. 11901 * @param {string} key The key of the method. 11902 * @param {...*} [partials] The arguments to be partially applied. 11903 * @returns {Function} Returns the new bound function. 11904 * @example 11905 * 11906 * var object = { 11907 * 'user': 'fred', 11908 * 'greet': function(greeting, punctuation) { 11909 * return greeting + ' ' + this.user + punctuation; 11910 * } 11911 * }; 11912 * 11913 * var bound = _.bindKey(object, 'greet', 'hi'); 11914 * bound('!'); 11915 * // => 'hi fred!' 11916 * 11917 * object.greet = function(greeting, punctuation) { 11918 * return greeting + 'ya ' + this.user + punctuation; 11919 * }; 11920 * 11921 * bound('!'); 11922 * // => 'hiya fred!' 11923 * 11924 * // Bound with placeholders. 11925 * var bound = _.bindKey(object, 'greet', _, '!'); 11926 * bound('hi'); 11927 * // => 'hiya fred!' 11928 */ 11929 var bindKey = baseRest(function(object, key, partials) { 11930 var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG; 11931 if (partials.length) { 11932 var holders = replaceHolders(partials, getHolder(bindKey)); 11933 bitmask |= WRAP_PARTIAL_FLAG; 11934 } 11935 return createWrap(key, bitmask, object, partials, holders); 11936 }); 11937 11938 /** 11939 * Creates a function that accepts arguments of `func` and either invokes 11940 * `func` returning its result, if at least `arity` number of arguments have 11941 * been provided, or returns a function that accepts the remaining `func` 11942 * arguments, and so on. The arity of `func` may be specified if `func.length` 11943 * is not sufficient. 11944 * 11945 * The `_.curry.placeholder` value, which defaults to `_` in monolithic builds, 11946 * may be used as a placeholder for provided arguments. 11947 * 11948 * **Note:** This method doesn't set the "length" property of curried functions. 11949 * 11950 * @static 11951 * @memberOf _ 11952 * @since 2.0.0 11953 * @category Function 11954 * @param {Function} func The function to curry. 11955 * @param {number} [arity=func.length] The arity of `func`. 11956 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 11957 * @returns {Function} Returns the new curried function. 11958 * @example 11959 * 11960 * var abc = function(a, b, c) { 11961 * return [a, b, c]; 11962 * }; 11963 * 11964 * var curried = _.curry(abc); 11965 * 11966 * curried(1)(2)(3); 11967 * // => [1, 2, 3] 11968 * 11969 * curried(1, 2)(3); 11970 * // => [1, 2, 3] 11971 * 11972 * curried(1, 2, 3); 11973 * // => [1, 2, 3] 11974 * 11975 * // Curried with placeholders. 11976 * curried(1)(_, 3)(2); 11977 * // => [1, 2, 3] 11978 */ 11979 function curry(func, arity, guard) { 11980 arity = guard ? undefined : arity; 11981 var result = createWrap(func, WRAP_CURRY_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 11982 result.placeholder = curry.placeholder; 11983 return result; 11984 } 11985 11986 /** 11987 * This method is like `_.curry` except that arguments are applied to `func` 11988 * in the manner of `_.partialRight` instead of `_.partial`. 11989 * 11990 * The `_.curryRight.placeholder` value, which defaults to `_` in monolithic 11991 * builds, may be used as a placeholder for provided arguments. 11992 * 11993 * **Note:** This method doesn't set the "length" property of curried functions. 11994 * 11995 * @static 11996 * @memberOf _ 11997 * @since 3.0.0 11998 * @category Function 11999 * @param {Function} func The function to curry. 12000 * @param {number} [arity=func.length] The arity of `func`. 12001 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 12002 * @returns {Function} Returns the new curried function. 12003 * @example 12004 * 12005 * var abc = function(a, b, c) { 12006 * return [a, b, c]; 12007 * }; 12008 * 12009 * var curried = _.curryRight(abc); 12010 * 12011 * curried(3)(2)(1); 12012 * // => [1, 2, 3] 12013 * 12014 * curried(2, 3)(1); 12015 * // => [1, 2, 3] 12016 * 12017 * curried(1, 2, 3); 12018 * // => [1, 2, 3] 12019 * 12020 * // Curried with placeholders. 12021 * curried(3)(1, _)(2); 12022 * // => [1, 2, 3] 12023 */ 12024 function curryRight(func, arity, guard) { 12025 arity = guard ? undefined : arity; 12026 var result = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined, undefined, undefined, undefined, undefined, arity); 12027 result.placeholder = curryRight.placeholder; 12028 return result; 12029 } 12030 12031 /** 12032 * Creates a debounced function that delays invoking `func` until after `wait` 12033 * milliseconds have elapsed since the last time the debounced function was 12034 * invoked. The debounced function comes with a `cancel` method to cancel 12035 * delayed `func` invocations and a `flush` method to immediately invoke them. 12036 * Provide `options` to indicate whether `func` should be invoked on the 12037 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 12038 * with the last arguments provided to the debounced function. Subsequent 12039 * calls to the debounced function return the result of the last `func` 12040 * invocation. 12041 * 12042 * **Note:** If `leading` and `trailing` options are `true`, `func` is 12043 * invoked on the trailing edge of the timeout only if the debounced function 12044 * is invoked more than once during the `wait` timeout. 12045 * 12046 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 12047 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 12048 * 12049 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 12050 * for details over the differences between `_.debounce` and `_.throttle`. 12051 * 12052 * @static 12053 * @memberOf _ 12054 * @since 0.1.0 12055 * @category Function 12056 * @param {Function} func The function to debounce. 12057 * @param {number} [wait=0] The number of milliseconds to delay. 12058 * @param {Object} [options={}] The options object. 12059 * @param {boolean} [options.leading=false] 12060 * Specify invoking on the leading edge of the timeout. 12061 * @param {number} [options.maxWait] 12062 * The maximum time `func` is allowed to be delayed before it's invoked. 12063 * @param {boolean} [options.trailing=true] 12064 * Specify invoking on the trailing edge of the timeout. 12065 * @returns {Function} Returns the new debounced function. 12066 * @example 12067 * 12068 * // Avoid costly calculations while the window size is in flux. 12069 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 12070 * 12071 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 12072 * jQuery(element).on('click', _.debounce(sendMail, 300, { 12073 * 'leading': true, 12074 * 'trailing': false 12075 * })); 12076 * 12077 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 12078 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 12079 * var source = new EventSource('/stream'); 12080 * jQuery(source).on('message', debounced); 12081 * 12082 * // Cancel the trailing debounced invocation. 12083 * jQuery(window).on('popstate', debounced.cancel); 12084 */ 12085 function debounce(func, wait, options) { 12086 var lastArgs, 12087 lastThis, 12088 maxWait, 12089 result, 12090 timerId, 12091 lastCallTime, 12092 lastInvokeTime = 0, 12093 leading = false, 12094 maxing = false, 12095 trailing = true; 12096 12097 if (typeof func != 'function') { 12098 throw new TypeError(FUNC_ERROR_TEXT); 12099 } 12100 wait = toNumber(wait) || 0; 12101 if (isObject(options)) { 12102 leading = !!options.leading; 12103 maxing = 'maxWait' in options; 12104 maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait; 12105 trailing = 'trailing' in options ? !!options.trailing : trailing; 12106 } 12107 12108 function invokeFunc(time) { 12109 var args = lastArgs, 12110 thisArg = lastThis; 12111 12112 lastArgs = lastThis = undefined; 12113 lastInvokeTime = time; 12114 result = func.apply(thisArg, args); 12115 return result; 12116 } 12117 12118 function leadingEdge(time) { 12119 // Reset any `maxWait` timer. 12120 lastInvokeTime = time; 12121 // Start the timer for the trailing edge. 12122 timerId = setTimeout(timerExpired, wait); 12123 // Invoke the leading edge. 12124 return leading ? invokeFunc(time) : result; 12125 } 12126 12127 function remainingWait(time) { 12128 var timeSinceLastCall = time - lastCallTime, 12129 timeSinceLastInvoke = time - lastInvokeTime, 12130 timeWaiting = wait - timeSinceLastCall; 12131 12132 return maxing 12133 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) 12134 : timeWaiting; 12135 } 12136 12137 function shouldInvoke(time) { 12138 var timeSinceLastCall = time - lastCallTime, 12139 timeSinceLastInvoke = time - lastInvokeTime; 12140 12141 // Either this is the first call, activity has stopped and we're at the 12142 // trailing edge, the system time has gone backwards and we're treating 12143 // it as the trailing edge, or we've hit the `maxWait` limit. 12144 return (lastCallTime === undefined || (timeSinceLastCall >= wait) || 12145 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 12146 } 12147 12148 function timerExpired() { 12149 var time = now(); 12150 if (shouldInvoke(time)) { 12151 return trailingEdge(time); 12152 } 12153 // Restart the timer. 12154 timerId = setTimeout(timerExpired, remainingWait(time)); 12155 } 12156 12157 function trailingEdge(time) { 12158 timerId = undefined; 12159 12160 // Only invoke if we have `lastArgs` which means `func` has been 12161 // debounced at least once. 12162 if (trailing && lastArgs) { 12163 return invokeFunc(time); 12164 } 12165 lastArgs = lastThis = undefined; 12166 return result; 12167 } 12168 12169 function cancel() { 12170 if (timerId !== undefined) { 12171 clearTimeout(timerId); 12172 } 12173 lastInvokeTime = 0; 12174 lastArgs = lastCallTime = lastThis = timerId = undefined; 12175 } 12176 12177 function flush() { 12178 return timerId === undefined ? result : trailingEdge(now()); 12179 } 12180 12181 function debounced() { 12182 var time = now(), 12183 isInvoking = shouldInvoke(time); 12184 12185 lastArgs = arguments; 12186 lastThis = this; 12187 lastCallTime = time; 12188 12189 if (isInvoking) { 12190 if (timerId === undefined) { 12191 return leadingEdge(lastCallTime); 12192 } 12193 if (maxing) { 12194 // Handle invocations in a tight loop. 12195 clearTimeout(timerId); 12196 timerId = setTimeout(timerExpired, wait); 12197 return invokeFunc(lastCallTime); 12198 } 12199 } 12200 if (timerId === undefined) { 12201 timerId = setTimeout(timerExpired, wait); 12202 } 12203 return result; 12204 } 12205 debounced.cancel = cancel; 12206 debounced.flush = flush; 12207 return debounced; 12208 } 12209 12210 /** 12211 * Defers invoking the `func` until the current call stack has cleared. Any 12212 * additional arguments are provided to `func` when it's invoked. 12213 * 12214 * @static 12215 * @memberOf _ 12216 * @since 0.1.0 12217 * @category Function 12218 * @param {Function} func The function to defer. 12219 * @param {...*} [args] The arguments to invoke `func` with. 12220 * @returns {number} Returns the timer id. 12221 * @example 12222 * 12223 * _.defer(function(text) { 12224 * console.log(text); 12225 * }, 'deferred'); 12226 * // => Logs 'deferred' after one millisecond. 12227 */ 12228 var defer = baseRest(function(func, args) { 12229 return baseDelay(func, 1, args); 12230 }); 12231 12232 /** 12233 * Invokes `func` after `wait` milliseconds. Any additional arguments are 12234 * provided to `func` when it's invoked. 12235 * 12236 * @static 12237 * @memberOf _ 12238 * @since 0.1.0 12239 * @category Function 12240 * @param {Function} func The function to delay. 12241 * @param {number} wait The number of milliseconds to delay invocation. 12242 * @param {...*} [args] The arguments to invoke `func` with. 12243 * @returns {number} Returns the timer id. 12244 * @example 12245 * 12246 * _.delay(function(text) { 12247 * console.log(text); 12248 * }, 1000, 'later'); 12249 * // => Logs 'later' after one second. 12250 */ 12251 var delay = baseRest(function(func, wait, args) { 12252 return baseDelay(func, toNumber(wait) || 0, args); 12253 }); 12254 12255 /** 12256 * Creates a function that invokes `func` with arguments reversed. 12257 * 12258 * @static 12259 * @memberOf _ 12260 * @since 4.0.0 12261 * @category Function 12262 * @param {Function} func The function to flip arguments for. 12263 * @returns {Function} Returns the new flipped function. 12264 * @example 12265 * 12266 * var flipped = _.flip(function() { 12267 * return _.toArray(arguments); 12268 * }); 12269 * 12270 * flipped('a', 'b', 'c', 'd'); 12271 * // => ['d', 'c', 'b', 'a'] 12272 */ 12273 function flip(func) { 12274 return createWrap(func, WRAP_FLIP_FLAG); 12275 } 12276 12277 /** 12278 * Creates a function that memoizes the result of `func`. If `resolver` is 12279 * provided, it determines the cache key for storing the result based on the 12280 * arguments provided to the memoized function. By default, the first argument 12281 * provided to the memoized function is used as the map cache key. The `func` 12282 * is invoked with the `this` binding of the memoized function. 12283 * 12284 * **Note:** The cache is exposed as the `cache` property on the memoized 12285 * function. Its creation may be customized by replacing the `_.memoize.Cache` 12286 * constructor with one whose instances implement the 12287 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) 12288 * method interface of `clear`, `delete`, `get`, `has`, and `set`. 12289 * 12290 * @static 12291 * @memberOf _ 12292 * @since 0.1.0 12293 * @category Function 12294 * @param {Function} func The function to have its output memoized. 12295 * @param {Function} [resolver] The function to resolve the cache key. 12296 * @returns {Function} Returns the new memoized function. 12297 * @example 12298 * 12299 * var object = { 'a': 1, 'b': 2 }; 12300 * var other = { 'c': 3, 'd': 4 }; 12301 * 12302 * var values = _.memoize(_.values); 12303 * values(object); 12304 * // => [1, 2] 12305 * 12306 * values(other); 12307 * // => [3, 4] 12308 * 12309 * object.a = 2; 12310 * values(object); 12311 * // => [1, 2] 12312 * 12313 * // Modify the result cache. 12314 * values.cache.set(object, ['a', 'b']); 12315 * values(object); 12316 * // => ['a', 'b'] 12317 * 12318 * // Replace `_.memoize.Cache`. 12319 * _.memoize.Cache = WeakMap; 12320 */ 12321 function memoize(func, resolver) { 12322 if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) { 12323 throw new TypeError(FUNC_ERROR_TEXT); 12324 } 12325 var memoized = function() { 12326 var args = arguments, 12327 key = resolver ? resolver.apply(this, args) : args[0], 12328 cache = memoized.cache; 12329 12330 if (cache.has(key)) { 12331 return cache.get(key); 12332 } 12333 var result = func.apply(this, args); 12334 memoized.cache = cache.set(key, result) || cache; 12335 return result; 12336 }; 12337 memoized.cache = new (memoize.Cache || MapCache); 12338 return memoized; 12339 } 12340 12341 // Expose `MapCache`. 12342 memoize.Cache = MapCache; 12343 12344 /** 12345 * Creates a function that negates the result of the predicate `func`. The 12346 * `func` predicate is invoked with the `this` binding and arguments of the 12347 * created function. 12348 * 12349 * @static 12350 * @memberOf _ 12351 * @since 3.0.0 12352 * @category Function 12353 * @param {Function} predicate The predicate to negate. 12354 * @returns {Function} Returns the new negated function. 12355 * @example 12356 * 12357 * function isEven(n) { 12358 * return n % 2 == 0; 12359 * } 12360 * 12361 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); 12362 * // => [1, 3, 5] 12363 */ 12364 function negate(predicate) { 12365 if (typeof predicate != 'function') { 12366 throw new TypeError(FUNC_ERROR_TEXT); 12367 } 12368 return function() { 12369 var args = arguments; 12370 switch (args.length) { 12371 case 0: return !predicate.call(this); 12372 case 1: return !predicate.call(this, args[0]); 12373 case 2: return !predicate.call(this, args[0], args[1]); 12374 case 3: return !predicate.call(this, args[0], args[1], args[2]); 12375 } 12376 return !predicate.apply(this, args); 12377 }; 12378 } 12379 12380 /** 12381 * Creates a function that is restricted to invoking `func` once. Repeat calls 12382 * to the function return the value of the first invocation. The `func` is 12383 * invoked with the `this` binding and arguments of the created function. 12384 * 12385 * @static 12386 * @memberOf _ 12387 * @since 0.1.0 12388 * @category Function 12389 * @param {Function} func The function to restrict. 12390 * @returns {Function} Returns the new restricted function. 12391 * @example 12392 * 12393 * var initialize = _.once(createApplication); 12394 * initialize(); 12395 * initialize(); 12396 * // => `createApplication` is invoked once 12397 */ 12398 function once(func) { 12399 return before(2, func); 12400 } 12401 12402 /** 12403 * Creates a function that invokes `func` with its arguments transformed. 12404 * 12405 * @static 12406 * @since 4.0.0 12407 * @memberOf _ 12408 * @category Function 12409 * @param {Function} func The function to wrap. 12410 * @param {...(Function|Function[])} [transforms=[_.identity]] 12411 * The argument transforms. 12412 * @returns {Function} Returns the new function. 12413 * @example 12414 * 12415 * function doubled(n) { 12416 * return n * 2; 12417 * } 12418 * 12419 * function square(n) { 12420 * return n * n; 12421 * } 12422 * 12423 * var func = _.overArgs(function(x, y) { 12424 * return [x, y]; 12425 * }, [square, doubled]); 12426 * 12427 * func(9, 3); 12428 * // => [81, 6] 12429 * 12430 * func(10, 5); 12431 * // => [100, 10] 12432 */ 12433 var overArgs = castRest(function(func, transforms) { 12434 transforms = (transforms.length == 1 && isArray(transforms[0])) 12435 ? arrayMap(transforms[0], baseUnary(getIteratee())) 12436 : arrayMap(baseFlatten(transforms, 1), baseUnary(getIteratee())); 12437 12438 var funcsLength = transforms.length; 12439 return baseRest(function(args) { 12440 var index = -1, 12441 length = nativeMin(args.length, funcsLength); 12442 12443 while (++index < length) { 12444 args[index] = transforms[index].call(this, args[index]); 12445 } 12446 return apply(func, this, args); 12447 }); 12448 }); 12449 12450 /** 12451 * Creates a function that invokes `func` with `partials` prepended to the 12452 * arguments it receives. This method is like `_.bind` except it does **not** 12453 * alter the `this` binding. 12454 * 12455 * The `_.partial.placeholder` value, which defaults to `_` in monolithic 12456 * builds, may be used as a placeholder for partially applied arguments. 12457 * 12458 * **Note:** This method doesn't set the "length" property of partially 12459 * applied functions. 12460 * 12461 * @static 12462 * @memberOf _ 12463 * @since 0.2.0 12464 * @category Function 12465 * @param {Function} func The function to partially apply arguments to. 12466 * @param {...*} [partials] The arguments to be partially applied. 12467 * @returns {Function} Returns the new partially applied function. 12468 * @example 12469 * 12470 * function greet(greeting, name) { 12471 * return greeting + ' ' + name; 12472 * } 12473 * 12474 * var sayHelloTo = _.partial(greet, 'hello'); 12475 * sayHelloTo('fred'); 12476 * // => 'hello fred' 12477 * 12478 * // Partially applied with placeholders. 12479 * var greetFred = _.partial(greet, _, 'fred'); 12480 * greetFred('hi'); 12481 * // => 'hi fred' 12482 */ 12483 var partial = baseRest(function(func, partials) { 12484 var holders = replaceHolders(partials, getHolder(partial)); 12485 return createWrap(func, WRAP_PARTIAL_FLAG, undefined, partials, holders); 12486 }); 12487 12488 /** 12489 * This method is like `_.partial` except that partially applied arguments 12490 * are appended to the arguments it receives. 12491 * 12492 * The `_.partialRight.placeholder` value, which defaults to `_` in monolithic 12493 * builds, may be used as a placeholder for partially applied arguments. 12494 * 12495 * **Note:** This method doesn't set the "length" property of partially 12496 * applied functions. 12497 * 12498 * @static 12499 * @memberOf _ 12500 * @since 1.0.0 12501 * @category Function 12502 * @param {Function} func The function to partially apply arguments to. 12503 * @param {...*} [partials] The arguments to be partially applied. 12504 * @returns {Function} Returns the new partially applied function. 12505 * @example 12506 * 12507 * function greet(greeting, name) { 12508 * return greeting + ' ' + name; 12509 * } 12510 * 12511 * var greetFred = _.partialRight(greet, 'fred'); 12512 * greetFred('hi'); 12513 * // => 'hi fred' 12514 * 12515 * // Partially applied with placeholders. 12516 * var sayHelloTo = _.partialRight(greet, 'hello', _); 12517 * sayHelloTo('fred'); 12518 * // => 'hello fred' 12519 */ 12520 var partialRight = baseRest(function(func, partials) { 12521 var holders = replaceHolders(partials, getHolder(partialRight)); 12522 return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined, partials, holders); 12523 }); 12524 12525 /** 12526 * Creates a function that invokes `func` with arguments arranged according 12527 * to the specified `indexes` where the argument value at the first index is 12528 * provided as the first argument, the argument value at the second index is 12529 * provided as the second argument, and so on. 12530 * 12531 * @static 12532 * @memberOf _ 12533 * @since 3.0.0 12534 * @category Function 12535 * @param {Function} func The function to rearrange arguments for. 12536 * @param {...(number|number[])} indexes The arranged argument indexes. 12537 * @returns {Function} Returns the new function. 12538 * @example 12539 * 12540 * var rearged = _.rearg(function(a, b, c) { 12541 * return [a, b, c]; 12542 * }, [2, 0, 1]); 12543 * 12544 * rearged('b', 'c', 'a') 12545 * // => ['a', 'b', 'c'] 12546 */ 12547 var rearg = flatRest(function(func, indexes) { 12548 return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes); 12549 }); 12550 12551 /** 12552 * Creates a function that invokes `func` with the `this` binding of the 12553 * created function and arguments from `start` and beyond provided as 12554 * an array. 12555 * 12556 * **Note:** This method is based on the 12557 * [rest parameter](https://mdn.io/rest_parameters). 12558 * 12559 * @static 12560 * @memberOf _ 12561 * @since 4.0.0 12562 * @category Function 12563 * @param {Function} func The function to apply a rest parameter to. 12564 * @param {number} [start=func.length-1] The start position of the rest parameter. 12565 * @returns {Function} Returns the new function. 12566 * @example 12567 * 12568 * var say = _.rest(function(what, names) { 12569 * return what + ' ' + _.initial(names).join(', ') + 12570 * (_.size(names) > 1 ? ', & ' : '') + _.last(names); 12571 * }); 12572 * 12573 * say('hello', 'fred', 'barney', 'pebbles'); 12574 * // => 'hello fred, barney, & pebbles' 12575 */ 12576 function rest(func, start) { 12577 if (typeof func != 'function') { 12578 throw new TypeError(FUNC_ERROR_TEXT); 12579 } 12580 start = start === undefined ? start : toInteger(start); 12581 return baseRest(func, start); 12582 } 12583 12584 /** 12585 * Creates a function that invokes `func` with the `this` binding of the 12586 * create function and an array of arguments much like 12587 * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). 12588 * 12589 * **Note:** This method is based on the 12590 * [spread operator](https://mdn.io/spread_operator). 12591 * 12592 * @static 12593 * @memberOf _ 12594 * @since 3.2.0 12595 * @category Function 12596 * @param {Function} func The function to spread arguments over. 12597 * @param {number} [start=0] The start position of the spread. 12598 * @returns {Function} Returns the new function. 12599 * @example 12600 * 12601 * var say = _.spread(function(who, what) { 12602 * return who + ' says ' + what; 12603 * }); 12604 * 12605 * say(['fred', 'hello']); 12606 * // => 'fred says hello' 12607 * 12608 * var numbers = Promise.all([ 12609 * Promise.resolve(40), 12610 * Promise.resolve(36) 12611 * ]); 12612 * 12613 * numbers.then(_.spread(function(x, y) { 12614 * return x + y; 12615 * })); 12616 * // => a Promise of 76 12617 */ 12618 function spread(func, start) { 12619 if (typeof func != 'function') { 12620 throw new TypeError(FUNC_ERROR_TEXT); 12621 } 12622 start = start == null ? 0 : nativeMax(toInteger(start), 0); 12623 return baseRest(function(args) { 12624 var array = args[start], 12625 otherArgs = castSlice(args, 0, start); 12626 12627 if (array) { 12628 arrayPush(otherArgs, array); 12629 } 12630 return apply(func, this, otherArgs); 12631 }); 12632 } 12633 12634 /** 12635 * Creates a throttled function that only invokes `func` at most once per 12636 * every `wait` milliseconds. The throttled function comes with a `cancel` 12637 * method to cancel delayed `func` invocations and a `flush` method to 12638 * immediately invoke them. Provide `options` to indicate whether `func` 12639 * should be invoked on the leading and/or trailing edge of the `wait` 12640 * timeout. The `func` is invoked with the last arguments provided to the 12641 * throttled function. Subsequent calls to the throttled function return the 12642 * result of the last `func` invocation. 12643 * 12644 * **Note:** If `leading` and `trailing` options are `true`, `func` is 12645 * invoked on the trailing edge of the timeout only if the throttled function 12646 * is invoked more than once during the `wait` timeout. 12647 * 12648 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 12649 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 12650 * 12651 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 12652 * for details over the differences between `_.throttle` and `_.debounce`. 12653 * 12654 * @static 12655 * @memberOf _ 12656 * @since 0.1.0 12657 * @category Function 12658 * @param {Function} func The function to throttle. 12659 * @param {number} [wait=0] The number of milliseconds to throttle invocations to. 12660 * @param {Object} [options={}] The options object. 12661 * @param {boolean} [options.leading=true] 12662 * Specify invoking on the leading edge of the timeout. 12663 * @param {boolean} [options.trailing=true] 12664 * Specify invoking on the trailing edge of the timeout. 12665 * @returns {Function} Returns the new throttled function. 12666 * @example 12667 * 12668 * // Avoid excessively updating the position while scrolling. 12669 * jQuery(window).on('scroll', _.throttle(updatePosition, 100)); 12670 * 12671 * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes. 12672 * var throttled = _.throttle(renewToken, 300000, { 'trailing': false }); 12673 * jQuery(element).on('click', throttled); 12674 * 12675 * // Cancel the trailing throttled invocation. 12676 * jQuery(window).on('popstate', throttled.cancel); 12677 */ 12678 function throttle(func, wait, options) { 12679 var leading = true, 12680 trailing = true; 12681 12682 if (typeof func != 'function') { 12683 throw new TypeError(FUNC_ERROR_TEXT); 12684 } 12685 if (isObject(options)) { 12686 leading = 'leading' in options ? !!options.leading : leading; 12687 trailing = 'trailing' in options ? !!options.trailing : trailing; 12688 } 12689 return debounce(func, wait, { 12690 'leading': leading, 12691 'maxWait': wait, 12692 'trailing': trailing 12693 }); 12694 } 12695 12696 /** 12697 * Creates a function that accepts up to one argument, ignoring any 12698 * additional arguments. 12699 * 12700 * @static 12701 * @memberOf _ 12702 * @since 4.0.0 12703 * @category Function 12704 * @param {Function} func The function to cap arguments for. 12705 * @returns {Function} Returns the new capped function. 12706 * @example 12707 * 12708 * _.map(['6', '8', '10'], _.unary(parseInt)); 12709 * // => [6, 8, 10] 12710 */ 12711 function unary(func) { 12712 return ary(func, 1); 12713 } 12714 12715 /** 12716 * Creates a function that provides `value` to `wrapper` as its first 12717 * argument. Any additional arguments provided to the function are appended 12718 * to those provided to the `wrapper`. The wrapper is invoked with the `this` 12719 * binding of the created function. 12720 * 12721 * @static 12722 * @memberOf _ 12723 * @since 0.1.0 12724 * @category Function 12725 * @param {*} value The value to wrap. 12726 * @param {Function} [wrapper=identity] The wrapper function. 12727 * @returns {Function} Returns the new function. 12728 * @example 12729 * 12730 * var p = _.wrap(_.escape, function(func, text) { 12731 * return '<p>' + func(text) + '</p>'; 12732 * }); 12733 * 12734 * p('fred, barney, & pebbles'); 12735 * // => '<p>fred, barney, & pebbles</p>' 12736 */ 12737 function wrap(value, wrapper) { 12738 return partial(castFunction(wrapper), value); 12739 } 12740 12741 /*------------------------------------------------------------------------*/ 12742 12743 /** 12744 * Casts `value` as an array if it's not one. 12745 * 12746 * @static 12747 * @memberOf _ 12748 * @since 4.4.0 12749 * @category Lang 12750 * @param {*} value The value to inspect. 12751 * @returns {Array} Returns the cast array. 12752 * @example 12753 * 12754 * _.castArray(1); 12755 * // => [1] 12756 * 12757 * _.castArray({ 'a': 1 }); 12758 * // => [{ 'a': 1 }] 12759 * 12760 * _.castArray('abc'); 12761 * // => ['abc'] 12762 * 12763 * _.castArray(null); 12764 * // => [null] 12765 * 12766 * _.castArray(undefined); 12767 * // => [undefined] 12768 * 12769 * _.castArray(); 12770 * // => [] 12771 * 12772 * var array = [1, 2, 3]; 12773 * console.log(_.castArray(array) === array); 12774 * // => true 12775 */ 12776 function castArray() { 12777 if (!arguments.length) { 12778 return []; 12779 } 12780 var value = arguments[0]; 12781 return isArray(value) ? value : [value]; 12782 } 12783 12784 /** 12785 * Creates a shallow clone of `value`. 12786 * 12787 * **Note:** This method is loosely based on the 12788 * [structured clone algorithm](https://mdn.io/Structured_clone_algorithm) 12789 * and supports cloning arrays, array buffers, booleans, date objects, maps, 12790 * numbers, `Object` objects, regexes, sets, strings, symbols, and typed 12791 * arrays. The own enumerable properties of `arguments` objects are cloned 12792 * as plain objects. An empty object is returned for uncloneable values such 12793 * as error objects, functions, DOM nodes, and WeakMaps. 12794 * 12795 * @static 12796 * @memberOf _ 12797 * @since 0.1.0 12798 * @category Lang 12799 * @param {*} value The value to clone. 12800 * @returns {*} Returns the cloned value. 12801 * @see _.cloneDeep 12802 * @example 12803 * 12804 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 12805 * 12806 * var shallow = _.clone(objects); 12807 * console.log(shallow[0] === objects[0]); 12808 * // => true 12809 */ 12810 function clone(value) { 12811 return baseClone(value, CLONE_SYMBOLS_FLAG); 12812 } 12813 12814 /** 12815 * This method is like `_.clone` except that it accepts `customizer` which 12816 * is invoked to produce the cloned value. If `customizer` returns `undefined`, 12817 * cloning is handled by the method instead. The `customizer` is invoked with 12818 * up to four arguments; (value [, index|key, object, stack]). 12819 * 12820 * @static 12821 * @memberOf _ 12822 * @since 4.0.0 12823 * @category Lang 12824 * @param {*} value The value to clone. 12825 * @param {Function} [customizer] The function to customize cloning. 12826 * @returns {*} Returns the cloned value. 12827 * @see _.cloneDeepWith 12828 * @example 12829 * 12830 * function customizer(value) { 12831 * if (_.isElement(value)) { 12832 * return value.cloneNode(false); 12833 * } 12834 * } 12835 * 12836 * var el = _.cloneWith(document.body, customizer); 12837 * 12838 * console.log(el === document.body); 12839 * // => false 12840 * console.log(el.nodeName); 12841 * // => 'BODY' 12842 * console.log(el.childNodes.length); 12843 * // => 0 12844 */ 12845 function cloneWith(value, customizer) { 12846 customizer = typeof customizer == 'function' ? customizer : undefined; 12847 return baseClone(value, CLONE_SYMBOLS_FLAG, customizer); 12848 } 12849 12850 /** 12851 * This method is like `_.clone` except that it recursively clones `value`. 12852 * 12853 * @static 12854 * @memberOf _ 12855 * @since 1.0.0 12856 * @category Lang 12857 * @param {*} value The value to recursively clone. 12858 * @returns {*} Returns the deep cloned value. 12859 * @see _.clone 12860 * @example 12861 * 12862 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 12863 * 12864 * var deep = _.cloneDeep(objects); 12865 * console.log(deep[0] === objects[0]); 12866 * // => false 12867 */ 12868 function cloneDeep(value) { 12869 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); 12870 } 12871 12872 /** 12873 * This method is like `_.cloneWith` except that it recursively clones `value`. 12874 * 12875 * @static 12876 * @memberOf _ 12877 * @since 4.0.0 12878 * @category Lang 12879 * @param {*} value The value to recursively clone. 12880 * @param {Function} [customizer] The function to customize cloning. 12881 * @returns {*} Returns the deep cloned value. 12882 * @see _.cloneWith 12883 * @example 12884 * 12885 * function customizer(value) { 12886 * if (_.isElement(value)) { 12887 * return value.cloneNode(true); 12888 * } 12889 * } 12890 * 12891 * var el = _.cloneDeepWith(document.body, customizer); 12892 * 12893 * console.log(el === document.body); 12894 * // => false 12895 * console.log(el.nodeName); 12896 * // => 'BODY' 12897 * console.log(el.childNodes.length); 12898 * // => 20 12899 */ 12900 function cloneDeepWith(value, customizer) { 12901 customizer = typeof customizer == 'function' ? customizer : undefined; 12902 return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer); 12903 } 12904 12905 /** 12906 * Checks if `object` conforms to `source` by invoking the predicate 12907 * properties of `source` with the corresponding property values of `object`. 12908 * 12909 * **Note:** This method is equivalent to `_.conforms` when `source` is 12910 * partially applied. 12911 * 12912 * @static 12913 * @memberOf _ 12914 * @since 4.14.0 12915 * @category Lang 12916 * @param {Object} object The object to inspect. 12917 * @param {Object} source The object of property predicates to conform to. 12918 * @returns {boolean} Returns `true` if `object` conforms, else `false`. 12919 * @example 12920 * 12921 * var object = { 'a': 1, 'b': 2 }; 12922 * 12923 * _.conformsTo(object, { 'b': function(n) { return n > 1; } }); 12924 * // => true 12925 * 12926 * _.conformsTo(object, { 'b': function(n) { return n > 2; } }); 12927 * // => false 12928 */ 12929 function conformsTo(object, source) { 12930 return source == null || baseConformsTo(object, source, keys(source)); 12931 } 12932 12933 /** 12934 * Performs a 12935 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 12936 * comparison between two values to determine if they are equivalent. 12937 * 12938 * @static 12939 * @memberOf _ 12940 * @since 4.0.0 12941 * @category Lang 12942 * @param {*} value The value to compare. 12943 * @param {*} other The other value to compare. 12944 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 12945 * @example 12946 * 12947 * var object = { 'a': 1 }; 12948 * var other = { 'a': 1 }; 12949 * 12950 * _.eq(object, object); 12951 * // => true 12952 * 12953 * _.eq(object, other); 12954 * // => false 12955 * 12956 * _.eq('a', 'a'); 12957 * // => true 12958 * 12959 * _.eq('a', Object('a')); 12960 * // => false 12961 * 12962 * _.eq(NaN, NaN); 12963 * // => true 12964 */ 12965 function eq(value, other) { 12966 return value === other || (value !== value && other !== other); 12967 } 12968 12969 /** 12970 * Checks if `value` is greater than `other`. 12971 * 12972 * @static 12973 * @memberOf _ 12974 * @since 3.9.0 12975 * @category Lang 12976 * @param {*} value The value to compare. 12977 * @param {*} other The other value to compare. 12978 * @returns {boolean} Returns `true` if `value` is greater than `other`, 12979 * else `false`. 12980 * @see _.lt 12981 * @example 12982 * 12983 * _.gt(3, 1); 12984 * // => true 12985 * 12986 * _.gt(3, 3); 12987 * // => false 12988 * 12989 * _.gt(1, 3); 12990 * // => false 12991 */ 12992 var gt = createRelationalOperation(baseGt); 12993 12994 /** 12995 * Checks if `value` is greater than or equal to `other`. 12996 * 12997 * @static 12998 * @memberOf _ 12999 * @since 3.9.0 13000 * @category Lang 13001 * @param {*} value The value to compare. 13002 * @param {*} other The other value to compare. 13003 * @returns {boolean} Returns `true` if `value` is greater than or equal to 13004 * `other`, else `false`. 13005 * @see _.lte 13006 * @example 13007 * 13008 * _.gte(3, 1); 13009 * // => true 13010 * 13011 * _.gte(3, 3); 13012 * // => true 13013 * 13014 * _.gte(1, 3); 13015 * // => false 13016 */ 13017 var gte = createRelationalOperation(function(value, other) { 13018 return value >= other; 13019 }); 13020 13021 /** 13022 * Checks if `value` is likely an `arguments` object. 13023 * 13024 * @static 13025 * @memberOf _ 13026 * @since 0.1.0 13027 * @category Lang 13028 * @param {*} value The value to check. 13029 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 13030 * else `false`. 13031 * @example 13032 * 13033 * _.isArguments(function() { return arguments; }()); 13034 * // => true 13035 * 13036 * _.isArguments([1, 2, 3]); 13037 * // => false 13038 */ 13039 var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { 13040 return isObjectLike(value) && hasOwnProperty.call(value, 'callee') && 13041 !propertyIsEnumerable.call(value, 'callee'); 13042 }; 13043 13044 /** 13045 * Checks if `value` is classified as an `Array` object. 13046 * 13047 * @static 13048 * @memberOf _ 13049 * @since 0.1.0 13050 * @category Lang 13051 * @param {*} value The value to check. 13052 * @returns {boolean} Returns `true` if `value` is an array, else `false`. 13053 * @example 13054 * 13055 * _.isArray([1, 2, 3]); 13056 * // => true 13057 * 13058 * _.isArray(document.body.children); 13059 * // => false 13060 * 13061 * _.isArray('abc'); 13062 * // => false 13063 * 13064 * _.isArray(_.noop); 13065 * // => false 13066 */ 13067 var isArray = Array.isArray; 13068 13069 /** 13070 * Checks if `value` is classified as an `ArrayBuffer` object. 13071 * 13072 * @static 13073 * @memberOf _ 13074 * @since 4.3.0 13075 * @category Lang 13076 * @param {*} value The value to check. 13077 * @returns {boolean} Returns `true` if `value` is an array buffer, else `false`. 13078 * @example 13079 * 13080 * _.isArrayBuffer(new ArrayBuffer(2)); 13081 * // => true 13082 * 13083 * _.isArrayBuffer(new Array(2)); 13084 * // => false 13085 */ 13086 var isArrayBuffer = nodeIsArrayBuffer ? baseUnary(nodeIsArrayBuffer) : baseIsArrayBuffer; 13087 13088 /** 13089 * Checks if `value` is array-like. A value is considered array-like if it's 13090 * not a function and has a `value.length` that's an integer greater than or 13091 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. 13092 * 13093 * @static 13094 * @memberOf _ 13095 * @since 4.0.0 13096 * @category Lang 13097 * @param {*} value The value to check. 13098 * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 13099 * @example 13100 * 13101 * _.isArrayLike([1, 2, 3]); 13102 * // => true 13103 * 13104 * _.isArrayLike(document.body.children); 13105 * // => true 13106 * 13107 * _.isArrayLike('abc'); 13108 * // => true 13109 * 13110 * _.isArrayLike(_.noop); 13111 * // => false 13112 */ 13113 function isArrayLike(value) { 13114 return value != null && isLength(value.length) && !isFunction(value); 13115 } 13116 13117 /** 13118 * This method is like `_.isArrayLike` except that it also checks if `value` 13119 * is an object. 13120 * 13121 * @static 13122 * @memberOf _ 13123 * @since 4.0.0 13124 * @category Lang 13125 * @param {*} value The value to check. 13126 * @returns {boolean} Returns `true` if `value` is an array-like object, 13127 * else `false`. 13128 * @example 13129 * 13130 * _.isArrayLikeObject([1, 2, 3]); 13131 * // => true 13132 * 13133 * _.isArrayLikeObject(document.body.children); 13134 * // => true 13135 * 13136 * _.isArrayLikeObject('abc'); 13137 * // => false 13138 * 13139 * _.isArrayLikeObject(_.noop); 13140 * // => false 13141 */ 13142 function isArrayLikeObject(value) { 13143 return isObjectLike(value) && isArrayLike(value); 13144 } 13145 13146 /** 13147 * Checks if `value` is classified as a boolean primitive or object. 13148 * 13149 * @static 13150 * @memberOf _ 13151 * @since 0.1.0 13152 * @category Lang 13153 * @param {*} value The value to check. 13154 * @returns {boolean} Returns `true` if `value` is a boolean, else `false`. 13155 * @example 13156 * 13157 * _.isBoolean(false); 13158 * // => true 13159 * 13160 * _.isBoolean(null); 13161 * // => false 13162 */ 13163 function isBoolean(value) { 13164 return value === true || value === false || 13165 (isObjectLike(value) && baseGetTag(value) == boolTag); 13166 } 13167 13168 /** 13169 * Checks if `value` is a buffer. 13170 * 13171 * @static 13172 * @memberOf _ 13173 * @since 4.3.0 13174 * @category Lang 13175 * @param {*} value The value to check. 13176 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. 13177 * @example 13178 * 13179 * _.isBuffer(new Buffer(2)); 13180 * // => true 13181 * 13182 * _.isBuffer(new Uint8Array(2)); 13183 * // => false 13184 */ 13185 var isBuffer = nativeIsBuffer || stubFalse; 13186 13187 /** 13188 * Checks if `value` is classified as a `Date` object. 13189 * 13190 * @static 13191 * @memberOf _ 13192 * @since 0.1.0 13193 * @category Lang 13194 * @param {*} value The value to check. 13195 * @returns {boolean} Returns `true` if `value` is a date object, else `false`. 13196 * @example 13197 * 13198 * _.isDate(new Date); 13199 * // => true 13200 * 13201 * _.isDate('Mon April 23 2012'); 13202 * // => false 13203 */ 13204 var isDate = nodeIsDate ? baseUnary(nodeIsDate) : baseIsDate; 13205 13206 /** 13207 * Checks if `value` is likely a DOM element. 13208 * 13209 * @static 13210 * @memberOf _ 13211 * @since 0.1.0 13212 * @category Lang 13213 * @param {*} value The value to check. 13214 * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. 13215 * @example 13216 * 13217 * _.isElement(document.body); 13218 * // => true 13219 * 13220 * _.isElement('<body>'); 13221 * // => false 13222 */ 13223 function isElement(value) { 13224 return isObjectLike(value) && value.nodeType === 1 && !isPlainObject(value); 13225 } 13226 13227 /** 13228 * Checks if `value` is an empty object, collection, map, or set. 13229 * 13230 * Objects are considered empty if they have no own enumerable string keyed 13231 * properties. 13232 * 13233 * Array-like values such as `arguments` objects, arrays, buffers, strings, or 13234 * jQuery-like collections are considered empty if they have a `length` of `0`. 13235 * Similarly, maps and sets are considered empty if they have a `size` of `0`. 13236 * 13237 * @static 13238 * @memberOf _ 13239 * @since 0.1.0 13240 * @category Lang 13241 * @param {*} value The value to check. 13242 * @returns {boolean} Returns `true` if `value` is empty, else `false`. 13243 * @example 13244 * 13245 * _.isEmpty(null); 13246 * // => true 13247 * 13248 * _.isEmpty(true); 13249 * // => true 13250 * 13251 * _.isEmpty(1); 13252 * // => true 13253 * 13254 * _.isEmpty([1, 2, 3]); 13255 * // => false 13256 * 13257 * _.isEmpty({ 'a': 1 }); 13258 * // => false 13259 */ 13260 function isEmpty(value) { 13261 if (value == null) { 13262 return true; 13263 } 13264 if (isArrayLike(value) && 13265 (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || 13266 isBuffer(value) || isTypedArray(value) || isArguments(value))) { 13267 return !value.length; 13268 } 13269 var tag = getTag(value); 13270 if (tag == mapTag || tag == setTag) { 13271 return !value.size; 13272 } 13273 if (isPrototype(value)) { 13274 return !baseKeys(value).length; 13275 } 13276 for (var key in value) { 13277 if (hasOwnProperty.call(value, key)) { 13278 return false; 13279 } 13280 } 13281 return true; 13282 } 13283 13284 /** 13285 * Performs a deep comparison between two values to determine if they are 13286 * equivalent. 13287 * 13288 * **Note:** This method supports comparing arrays, array buffers, booleans, 13289 * date objects, error objects, maps, numbers, `Object` objects, regexes, 13290 * sets, strings, symbols, and typed arrays. `Object` objects are compared 13291 * by their own, not inherited, enumerable properties. Functions and DOM 13292 * nodes are compared by strict equality, i.e. `===`. 13293 * 13294 * @static 13295 * @memberOf _ 13296 * @since 0.1.0 13297 * @category Lang 13298 * @param {*} value The value to compare. 13299 * @param {*} other The other value to compare. 13300 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 13301 * @example 13302 * 13303 * var object = { 'a': 1 }; 13304 * var other = { 'a': 1 }; 13305 * 13306 * _.isEqual(object, other); 13307 * // => true 13308 * 13309 * object === other; 13310 * // => false 13311 */ 13312 function isEqual(value, other) { 13313 return baseIsEqual(value, other); 13314 } 13315 13316 /** 13317 * This method is like `_.isEqual` except that it accepts `customizer` which 13318 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 13319 * are handled by the method instead. The `customizer` is invoked with up to 13320 * six arguments: (objValue, othValue [, index|key, object, other, stack]). 13321 * 13322 * @static 13323 * @memberOf _ 13324 * @since 4.0.0 13325 * @category Lang 13326 * @param {*} value The value to compare. 13327 * @param {*} other The other value to compare. 13328 * @param {Function} [customizer] The function to customize comparisons. 13329 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 13330 * @example 13331 * 13332 * function isGreeting(value) { 13333 * return /^h(?:i|ello)$/.test(value); 13334 * } 13335 * 13336 * function customizer(objValue, othValue) { 13337 * if (isGreeting(objValue) && isGreeting(othValue)) { 13338 * return true; 13339 * } 13340 * } 13341 * 13342 * var array = ['hello', 'goodbye']; 13343 * var other = ['hi', 'goodbye']; 13344 * 13345 * _.isEqualWith(array, other, customizer); 13346 * // => true 13347 */ 13348 function isEqualWith(value, other, customizer) { 13349 customizer = typeof customizer == 'function' ? customizer : undefined; 13350 var result = customizer ? customizer(value, other) : undefined; 13351 return result === undefined ? baseIsEqual(value, other, undefined, customizer) : !!result; 13352 } 13353 13354 /** 13355 * Checks if `value` is an `Error`, `EvalError`, `RangeError`, `ReferenceError`, 13356 * `SyntaxError`, `TypeError`, or `URIError` object. 13357 * 13358 * @static 13359 * @memberOf _ 13360 * @since 3.0.0 13361 * @category Lang 13362 * @param {*} value The value to check. 13363 * @returns {boolean} Returns `true` if `value` is an error object, else `false`. 13364 * @example 13365 * 13366 * _.isError(new Error); 13367 * // => true 13368 * 13369 * _.isError(Error); 13370 * // => false 13371 */ 13372 function isError(value) { 13373 if (!isObjectLike(value)) { 13374 return false;
vendor: 6,607 bytes, lines 13375-13612
13375 } 13376 var tag = baseGetTag(value); 13377 return tag == errorTag || tag == domExcTag || 13378 (typeof value.message == 'string' && typeof value.name == 'string' && !isPlainObject(value)); 13379 } 13380 13381 /** 13382 * Checks if `value` is a finite primitive number. 13383 * 13384 * **Note:** This method is based on 13385 * [`Number.isFinite`](https://mdn.io/Number/isFinite). 13386 * 13387 * @static 13388 * @memberOf _ 13389 * @since 0.1.0 13390 * @category Lang 13391 * @param {*} value The value to check. 13392 * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. 13393 * @example 13394 * 13395 * _.isFinite(3); 13396 * // => true 13397 * 13398 * _.isFinite(Number.MIN_VALUE); 13399 * // => true 13400 * 13401 * _.isFinite(Infinity); 13402 * // => false 13403 * 13404 * _.isFinite('3'); 13405 * // => false 13406 */ 13407 function isFinite(value) { 13408 return typeof value == 'number' && nativeIsFinite(value); 13409 } 13410 13411 /** 13412 * Checks if `value` is classified as a `Function` object. 13413 * 13414 * @static 13415 * @memberOf _ 13416 * @since 0.1.0 13417 * @category Lang 13418 * @param {*} value The value to check. 13419 * @returns {boolean} Returns `true` if `value` is a function, else `false`. 13420 * @example 13421 * 13422 * _.isFunction(_); 13423 * // => true 13424 * 13425 * _.isFunction(/abc/); 13426 * // => false 13427 */ 13428 function isFunction(value) { 13429 if (!isObject(value)) { 13430 return false; 13431 } 13432 // The use of `Object#toString` avoids issues with the `typeof` operator 13433 // in Safari 9 which returns 'object' for typed arrays and other constructors. 13434 var tag = baseGetTag(value); 13435 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; 13436 } 13437 13438 /** 13439 * Checks if `value` is an integer. 13440 * 13441 * **Note:** This method is based on 13442 * [`Number.isInteger`](https://mdn.io/Number/isInteger). 13443 * 13444 * @static 13445 * @memberOf _ 13446 * @since 4.0.0 13447 * @category Lang 13448 * @param {*} value The value to check. 13449 * @returns {boolean} Returns `true` if `value` is an integer, else `false`. 13450 * @example 13451 * 13452 * _.isInteger(3); 13453 * // => true 13454 * 13455 * _.isInteger(Number.MIN_VALUE); 13456 * // => false 13457 * 13458 * _.isInteger(Infinity); 13459 * // => false 13460 * 13461 * _.isInteger('3'); 13462 * // => false 13463 */ 13464 function isInteger(value) { 13465 return typeof value == 'number' && value == toInteger(value); 13466 } 13467 13468 /** 13469 * Checks if `value` is a valid array-like length. 13470 * 13471 * **Note:** This method is loosely based on 13472 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 13473 * 13474 * @static 13475 * @memberOf _ 13476 * @since 4.0.0 13477 * @category Lang 13478 * @param {*} value The value to check. 13479 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 13480 * @example 13481 * 13482 * _.isLength(3); 13483 * // => true 13484 * 13485 * _.isLength(Number.MIN_VALUE); 13486 * // => false 13487 * 13488 * _.isLength(Infinity); 13489 * // => false 13490 * 13491 * _.isLength('3'); 13492 * // => false 13493 */ 13494 function isLength(value) { 13495 return typeof value == 'number' && 13496 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 13497 } 13498 13499 /** 13500 * Checks if `value` is the 13501 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 13502 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 13503 * 13504 * @static 13505 * @memberOf _ 13506 * @since 0.1.0 13507 * @category Lang 13508 * @param {*} value The value to check. 13509 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 13510 * @example 13511 * 13512 * _.isObject({}); 13513 * // => true 13514 * 13515 * _.isObject([1, 2, 3]); 13516 * // => true 13517 * 13518 * _.isObject(_.noop); 13519 * // => true 13520 * 13521 * _.isObject(null); 13522 * // => false 13523 */ 13524 function isObject(value) { 13525 var type = typeof value; 13526 return value != null && (type == 'object' || type == 'function'); 13527 } 13528 13529 /** 13530 * Checks if `value` is object-like. A value is object-like if it's not `null` 13531 * and has a `typeof` result of "object". 13532 * 13533 * @static 13534 * @memberOf _ 13535 * @since 4.0.0 13536 * @category Lang 13537 * @param {*} value The value to check. 13538 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 13539 * @example 13540 * 13541 * _.isObjectLike({}); 13542 * // => true 13543 * 13544 * _.isObjectLike([1, 2, 3]); 13545 * // => true 13546 * 13547 * _.isObjectLike(_.noop); 13548 * // => false 13549 * 13550 * _.isObjectLike(null); 13551 * // => false 13552 */ 13553 function isObjectLike(value) { 13554 return value != null && typeof value == 'object'; 13555 } 13556 13557 /** 13558 * Checks if `value` is classified as a `Map` object. 13559 * 13560 * @static 13561 * @memberOf _ 13562 * @since 4.3.0 13563 * @category Lang 13564 * @param {*} value The value to check. 13565 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 13566 * @example 13567 * 13568 * _.isMap(new Map); 13569 * // => true 13570 * 13571 * _.isMap(new WeakMap); 13572 * // => false 13573 */ 13574 var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap; 13575 13576 /** 13577 * Performs a partial deep comparison between `object` and `source` to 13578 * determine if `object` contains equivalent property values. 13579 * 13580 * **Note:** This method is equivalent to `_.matches` when `source` is 13581 * partially applied. 13582 * 13583 * Partial comparisons will match empty array and empty object `source` 13584 * values against any array or object value, respectively. See `_.isEqual` 13585 * for a list of supported value comparisons. 13586 * 13587 * @static 13588 * @memberOf _ 13589 * @since 3.0.0 13590 * @category Lang 13591 * @param {Object} object The object to inspect. 13592 * @param {Object} source The object of property values to match. 13593 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 13594 * @example 13595 * 13596 * var object = { 'a': 1, 'b': 2 }; 13597 * 13598 * _.isMatch(object, { 'b': 2 }); 13599 * // => true 13600 * 13601 * _.isMatch(object, { 'b': 1 }); 13602 * // => false 13603 */ 13604 function isMatch(object, source) { 13605 return object === source || baseIsMatch(object, source, getMatchData(source)); 13606 } 13607 13608 /** 13609 * This method is like `_.isMatch` except that it accepts `customizer` which 13610 * is invoked to compare values. If `customizer` returns `undefined`, comparisons 13611 * are handled by the method instead. The `customizer` is invoked with five 13612 * arguments: (objValue, srcValue, index|key, object, source).
vendor: 12,241 bytes, lines 13613-14078
13613 * 13614 * @static 13615 * @memberOf _ 13616 * @since 4.0.0 13617 * @category Lang 13618 * @param {Object} object The object to inspect. 13619 * @param {Object} source The object of property values to match. 13620 * @param {Function} [customizer] The function to customize comparisons. 13621 * @returns {boolean} Returns `true` if `object` is a match, else `false`. 13622 * @example 13623 * 13624 * function isGreeting(value) { 13625 * return /^h(?:i|ello)$/.test(value); 13626 * } 13627 * 13628 * function customizer(objValue, srcValue) { 13629 * if (isGreeting(objValue) && isGreeting(srcValue)) { 13630 * return true; 13631 * } 13632 * } 13633 * 13634 * var object = { 'greeting': 'hello' }; 13635 * var source = { 'greeting': 'hi' }; 13636 * 13637 * _.isMatchWith(object, source, customizer); 13638 * // => true 13639 */ 13640 function isMatchWith(object, source, customizer) { 13641 customizer = typeof customizer == 'function' ? customizer : undefined; 13642 return baseIsMatch(object, source, getMatchData(source), customizer); 13643 } 13644 13645 /** 13646 * Checks if `value` is `NaN`. 13647 * 13648 * **Note:** This method is based on 13649 * [`Number.isNaN`](https://mdn.io/Number/isNaN) and is not the same as 13650 * global [`isNaN`](https://mdn.io/isNaN) which returns `true` for 13651 * `undefined` and other non-number values. 13652 * 13653 * @static 13654 * @memberOf _ 13655 * @since 0.1.0 13656 * @category Lang 13657 * @param {*} value The value to check. 13658 * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`. 13659 * @example 13660 * 13661 * _.isNaN(NaN); 13662 * // => true 13663 * 13664 * _.isNaN(new Number(NaN)); 13665 * // => true 13666 * 13667 * isNaN(undefined); 13668 * // => true 13669 * 13670 * _.isNaN(undefined); 13671 * // => false 13672 */ 13673 function isNaN(value) { 13674 // An `NaN` primitive is the only value that is not equal to itself. 13675 // Perform the `toStringTag` check first to avoid errors with some 13676 // ActiveX objects in IE. 13677 return isNumber(value) && value != +value; 13678 } 13679 13680 /** 13681 * Checks if `value` is a pristine native function. 13682 * 13683 * **Note:** This method can't reliably detect native functions in the presence 13684 * of the core-js package because core-js circumvents this kind of detection. 13685 * Despite multiple requests, the core-js maintainer has made it clear: any 13686 * attempt to fix the detection will be obstructed. As a result, we're left 13687 * with little choice but to throw an error. Unfortunately, this also affects 13688 * packages, like [babel-polyfill](https://www.npmjs.com/package/babel-polyfill), 13689 * which rely on core-js. 13690 * 13691 * @static 13692 * @memberOf _ 13693 * @since 3.0.0 13694 * @category Lang 13695 * @param {*} value The value to check. 13696 * @returns {boolean} Returns `true` if `value` is a native function, 13697 * else `false`. 13698 * @example 13699 * 13700 * _.isNative(Array.prototype.push); 13701 * // => true 13702 * 13703 * _.isNative(_); 13704 * // => false 13705 */ 13706 function isNative(value) { 13707 if (isMaskable(value)) { 13708 throw new Error(CORE_ERROR_TEXT); 13709 } 13710 return baseIsNative(value); 13711 } 13712 13713 /** 13714 * Checks if `value` is `null`. 13715 * 13716 * @static 13717 * @memberOf _ 13718 * @since 0.1.0 13719 * @category Lang 13720 * @param {*} value The value to check. 13721 * @returns {boolean} Returns `true` if `value` is `null`, else `false`. 13722 * @example 13723 * 13724 * _.isNull(null); 13725 * // => true 13726 * 13727 * _.isNull(void 0); 13728 * // => false 13729 */ 13730 function isNull(value) { 13731 return value === null; 13732 } 13733 13734 /** 13735 * Checks if `value` is `null` or `undefined`. 13736 * 13737 * @static 13738 * @memberOf _ 13739 * @since 4.0.0 13740 * @category Lang 13741 * @param {*} value The value to check. 13742 * @returns {boolean} Returns `true` if `value` is nullish, else `false`. 13743 * @example 13744 * 13745 * _.isNil(null); 13746 * // => true 13747 * 13748 * _.isNil(void 0); 13749 * // => true 13750 * 13751 * _.isNil(NaN); 13752 * // => false 13753 */ 13754 function isNil(value) { 13755 return value == null; 13756 } 13757 13758 /** 13759 * Checks if `value` is classified as a `Number` primitive or object. 13760 * 13761 * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are 13762 * classified as numbers, use the `_.isFinite` method. 13763 * 13764 * @static 13765 * @memberOf _ 13766 * @since 0.1.0 13767 * @category Lang 13768 * @param {*} value The value to check. 13769 * @returns {boolean} Returns `true` if `value` is a number, else `false`. 13770 * @example 13771 * 13772 * _.isNumber(3); 13773 * // => true 13774 * 13775 * _.isNumber(Number.MIN_VALUE); 13776 * // => true 13777 * 13778 * _.isNumber(Infinity); 13779 * // => true 13780 * 13781 * _.isNumber('3'); 13782 * // => false 13783 */ 13784 function isNumber(value) { 13785 return typeof value == 'number' || 13786 (isObjectLike(value) && baseGetTag(value) == numberTag); 13787 } 13788 13789 /** 13790 * Checks if `value` is a plain object, that is, an object created by the 13791 * `Object` constructor or one with a `[[Prototype]]` of `null`. 13792 * 13793 * @static 13794 * @memberOf _ 13795 * @since 0.8.0 13796 * @category Lang 13797 * @param {*} value The value to check. 13798 * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. 13799 * @example 13800 * 13801 * function Foo() { 13802 * this.a = 1; 13803 * } 13804 * 13805 * _.isPlainObject(new Foo); 13806 * // => false 13807 * 13808 * _.isPlainObject([1, 2, 3]); 13809 * // => false 13810 * 13811 * _.isPlainObject({ 'x': 0, 'y': 0 }); 13812 * // => true 13813 * 13814 * _.isPlainObject(Object.create(null)); 13815 * // => true 13816 */ 13817 function isPlainObject(value) { 13818 if (!isObjectLike(value) || baseGetTag(value) != objectTag) { 13819 return false; 13820 } 13821 var proto = getPrototype(value); 13822 if (proto === null) { 13823 return true; 13824 } 13825 var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; 13826 return typeof Ctor == 'function' && Ctor instanceof Ctor && 13827 funcToString.call(Ctor) == objectCtorString; 13828 } 13829 13830 /** 13831 * Checks if `value` is classified as a `RegExp` object. 13832 * 13833 * @static 13834 * @memberOf _ 13835 * @since 0.1.0 13836 * @category Lang 13837 * @param {*} value The value to check. 13838 * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. 13839 * @example 13840 * 13841 * _.isRegExp(/abc/); 13842 * // => true 13843 * 13844 * _.isRegExp('/abc/'); 13845 * // => false 13846 */ 13847 var isRegExp = nodeIsRegExp ? baseUnary(nodeIsRegExp) : baseIsRegExp; 13848 13849 /** 13850 * Checks if `value` is a safe integer. An integer is safe if it's an IEEE-754 13851 * double precision number which isn't the result of a rounded unsafe integer. 13852 * 13853 * **Note:** This method is based on 13854 * [`Number.isSafeInteger`](https://mdn.io/Number/isSafeInteger). 13855 * 13856 * @static 13857 * @memberOf _ 13858 * @since 4.0.0 13859 * @category Lang 13860 * @param {*} value The value to check. 13861 * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. 13862 * @example 13863 * 13864 * _.isSafeInteger(3); 13865 * // => true 13866 * 13867 * _.isSafeInteger(Number.MIN_VALUE); 13868 * // => false 13869 * 13870 * _.isSafeInteger(Infinity); 13871 * // => false 13872 * 13873 * _.isSafeInteger('3'); 13874 * // => false 13875 */ 13876 function isSafeInteger(value) { 13877 return isInteger(value) && value >= -MAX_SAFE_INTEGER && value <= MAX_SAFE_INTEGER; 13878 } 13879 13880 /** 13881 * Checks if `value` is classified as a `Set` object. 13882 * 13883 * @static 13884 * @memberOf _ 13885 * @since 4.3.0 13886 * @category Lang 13887 * @param {*} value The value to check. 13888 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 13889 * @example 13890 * 13891 * _.isSet(new Set); 13892 * // => true 13893 * 13894 * _.isSet(new WeakSet); 13895 * // => false 13896 */ 13897 var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet; 13898 13899 /** 13900 * Checks if `value` is classified as a `String` primitive or object. 13901 * 13902 * @static 13903 * @since 0.1.0 13904 * @memberOf _ 13905 * @category Lang 13906 * @param {*} value The value to check. 13907 * @returns {boolean} Returns `true` if `value` is a string, else `false`. 13908 * @example 13909 * 13910 * _.isString('abc'); 13911 * // => true 13912 * 13913 * _.isString(1); 13914 * // => false 13915 */ 13916 function isString(value) { 13917 return typeof value == 'string' || 13918 (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); 13919 } 13920 13921 /** 13922 * Checks if `value` is classified as a `Symbol` primitive or object. 13923 * 13924 * @static 13925 * @memberOf _ 13926 * @since 4.0.0 13927 * @category Lang 13928 * @param {*} value The value to check. 13929 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 13930 * @example 13931 * 13932 * _.isSymbol(Symbol.iterator); 13933 * // => true 13934 * 13935 * _.isSymbol('abc'); 13936 * // => false 13937 */ 13938 function isSymbol(value) { 13939 return typeof value == 'symbol' || 13940 (isObjectLike(value) && baseGetTag(value) == symbolTag); 13941 } 13942 13943 /** 13944 * Checks if `value` is classified as a typed array. 13945 * 13946 * @static 13947 * @memberOf _ 13948 * @since 3.0.0 13949 * @category Lang 13950 * @param {*} value The value to check. 13951 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 13952 * @example 13953 * 13954 * _.isTypedArray(new Uint8Array); 13955 * // => true 13956 * 13957 * _.isTypedArray([]); 13958 * // => false 13959 */ 13960 var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; 13961 13962 /** 13963 * Checks if `value` is `undefined`. 13964 * 13965 * @static 13966 * @since 0.1.0 13967 * @memberOf _ 13968 * @category Lang 13969 * @param {*} value The value to check. 13970 * @returns {boolean} Returns `true` if `value` is `undefined`, else `false`. 13971 * @example 13972 * 13973 * _.isUndefined(void 0); 13974 * // => true 13975 * 13976 * _.isUndefined(null); 13977 * // => false 13978 */ 13979 function isUndefined(value) { 13980 return value === undefined; 13981 } 13982 13983 /** 13984 * Checks if `value` is classified as a `WeakMap` object. 13985 * 13986 * @static 13987 * @memberOf _ 13988 * @since 4.3.0 13989 * @category Lang 13990 * @param {*} value The value to check. 13991 * @returns {boolean} Returns `true` if `value` is a weak map, else `false`. 13992 * @example 13993 * 13994 * _.isWeakMap(new WeakMap); 13995 * // => true 13996 * 13997 * _.isWeakMap(new Map); 13998 * // => false 13999 */ 14000 function isWeakMap(value) { 14001 return isObjectLike(value) && getTag(value) == weakMapTag; 14002 } 14003 14004 /** 14005 * Checks if `value` is classified as a `WeakSet` object. 14006 * 14007 * @static 14008 * @memberOf _ 14009 * @since 4.3.0 14010 * @category Lang 14011 * @param {*} value The value to check. 14012 * @returns {boolean} Returns `true` if `value` is a weak set, else `false`. 14013 * @example 14014 * 14015 * _.isWeakSet(new WeakSet); 14016 * // => true 14017 * 14018 * _.isWeakSet(new Set); 14019 * // => false 14020 */ 14021 function isWeakSet(value) { 14022 return isObjectLike(value) && baseGetTag(value) == weakSetTag; 14023 } 14024 14025 /** 14026 * Checks if `value` is less than `other`. 14027 * 14028 * @static 14029 * @memberOf _ 14030 * @since 3.9.0 14031 * @category Lang 14032 * @param {*} value The value to compare. 14033 * @param {*} other The other value to compare. 14034 * @returns {boolean} Returns `true` if `value` is less than `other`, 14035 * else `false`. 14036 * @see _.gt 14037 * @example 14038 * 14039 * _.lt(1, 3); 14040 * // => true 14041 * 14042 * _.lt(3, 3); 14043 * // => false 14044 * 14045 * _.lt(3, 1); 14046 * // => false 14047 */ 14048 var lt = createRelationalOperation(baseLt); 14049 14050 /** 14051 * Checks if `value` is less than or equal to `other`. 14052 * 14053 * @static 14054 * @memberOf _ 14055 * @since 3.9.0 14056 * @category Lang 14057 * @param {*} value The value to compare. 14058 * @param {*} other The other value to compare. 14059 * @returns {boolean} Returns `true` if `value` is less than or equal to 14060 * `other`, else `false`. 14061 * @see _.gte 14062 * @example 14063 * 14064 * _.lte(1, 3); 14065 * // => true 14066 * 14067 * _.lte(3, 3); 14068 * // => true 14069 * 14070 * _.lte(3, 1); 14071 * // => false 14072 */ 14073 var lte = createRelationalOperation(function(value, other) { 14074 return value <= other; 14075 }); 14076 14077 /** 14078 * Converts `value` to an array.
vendor: 11,756 bytes, lines 14079-14508
14079 * 14080 * @static 14081 * @since 0.1.0 14082 * @memberOf _ 14083 * @category Lang 14084 * @param {*} value The value to convert. 14085 * @returns {Array} Returns the converted array. 14086 * @example 14087 * 14088 * _.toArray({ 'a': 1, 'b': 2 }); 14089 * // => [1, 2] 14090 * 14091 * _.toArray('abc'); 14092 * // => ['a', 'b', 'c'] 14093 * 14094 * _.toArray(1); 14095 * // => [] 14096 * 14097 * _.toArray(null); 14098 * // => [] 14099 */ 14100 function toArray(value) { 14101 if (!value) { 14102 return []; 14103 } 14104 if (isArrayLike(value)) { 14105 return isString(value) ? stringToArray(value) : copyArray(value); 14106 } 14107 if (symIterator && value[symIterator]) { 14108 return iteratorToArray(value[symIterator]()); 14109 } 14110 var tag = getTag(value), 14111 func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); 14112 14113 return func(value); 14114 } 14115 14116 /** 14117 * Converts `value` to a finite number. 14118 * 14119 * @static 14120 * @memberOf _ 14121 * @since 4.12.0 14122 * @category Lang 14123 * @param {*} value The value to convert. 14124 * @returns {number} Returns the converted number. 14125 * @example 14126 * 14127 * _.toFinite(3.2); 14128 * // => 3.2 14129 * 14130 * _.toFinite(Number.MIN_VALUE); 14131 * // => 5e-324 14132 * 14133 * _.toFinite(Infinity); 14134 * // => 1.7976931348623157e+308 14135 * 14136 * _.toFinite('3.2'); 14137 * // => 3.2 14138 */ 14139 function toFinite(value) { 14140 if (!value) { 14141 return value === 0 ? value : 0; 14142 } 14143 value = toNumber(value); 14144 if (value === INFINITY || value === -INFINITY) { 14145 var sign = (value < 0 ? -1 : 1); 14146 return sign * MAX_INTEGER; 14147 } 14148 return value === value ? value : 0; 14149 } 14150 14151 /** 14152 * Converts `value` to an integer. 14153 * 14154 * **Note:** This method is loosely based on 14155 * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). 14156 * 14157 * @static 14158 * @memberOf _ 14159 * @since 4.0.0 14160 * @category Lang 14161 * @param {*} value The value to convert. 14162 * @returns {number} Returns the converted integer. 14163 * @example 14164 * 14165 * _.toInteger(3.2); 14166 * // => 3 14167 * 14168 * _.toInteger(Number.MIN_VALUE); 14169 * // => 0 14170 * 14171 * _.toInteger(Infinity); 14172 * // => 1.7976931348623157e+308 14173 * 14174 * _.toInteger('3.2'); 14175 * // => 3 14176 */ 14177 function toInteger(value) { 14178 var result = toFinite(value), 14179 remainder = result % 1; 14180 14181 return result === result ? (remainder ? result - remainder : result) : 0; 14182 } 14183 14184 /** 14185 * Converts `value` to an integer suitable for use as the length of an 14186 * array-like object. 14187 * 14188 * **Note:** This method is based on 14189 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 14190 * 14191 * @static 14192 * @memberOf _ 14193 * @since 4.0.0 14194 * @category Lang 14195 * @param {*} value The value to convert. 14196 * @returns {number} Returns the converted integer. 14197 * @example 14198 * 14199 * _.toLength(3.2); 14200 * // => 3 14201 * 14202 * _.toLength(Number.MIN_VALUE); 14203 * // => 0 14204 * 14205 * _.toLength(Infinity); 14206 * // => 4294967295 14207 * 14208 * _.toLength('3.2'); 14209 * // => 3 14210 */ 14211 function toLength(value) { 14212 return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0; 14213 } 14214 14215 /** 14216 * Converts `value` to a number. 14217 * 14218 * @static 14219 * @memberOf _ 14220 * @since 4.0.0 14221 * @category Lang 14222 * @param {*} value The value to process. 14223 * @returns {number} Returns the number. 14224 * @example 14225 * 14226 * _.toNumber(3.2); 14227 * // => 3.2 14228 * 14229 * _.toNumber(Number.MIN_VALUE); 14230 * // => 5e-324 14231 * 14232 * _.toNumber(Infinity); 14233 * // => Infinity 14234 * 14235 * _.toNumber('3.2'); 14236 * // => 3.2 14237 */ 14238 function toNumber(value) { 14239 if (typeof value == 'number') { 14240 return value; 14241 } 14242 if (isSymbol(value)) { 14243 return NAN; 14244 } 14245 if (isObject(value)) { 14246 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 14247 value = isObject(other) ? (other + '') : other; 14248 } 14249 if (typeof value != 'string') { 14250 return value === 0 ? value : +value; 14251 } 14252 value = baseTrim(value); 14253 var isBinary = reIsBinary.test(value); 14254 return (isBinary || reIsOctal.test(value)) 14255 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 14256 : (reIsBadHex.test(value) ? NAN : +value); 14257 } 14258 14259 /** 14260 * Converts `value` to a plain object flattening inherited enumerable string 14261 * keyed properties of `value` to own properties of the plain object. 14262 * 14263 * @static 14264 * @memberOf _ 14265 * @since 3.0.0 14266 * @category Lang 14267 * @param {*} value The value to convert. 14268 * @returns {Object} Returns the converted plain object. 14269 * @example 14270 * 14271 * function Foo() { 14272 * this.b = 2; 14273 * } 14274 * 14275 * Foo.prototype.c = 3; 14276 * 14277 * _.assign({ 'a': 1 }, new Foo); 14278 * // => { 'a': 1, 'b': 2 } 14279 * 14280 * _.assign({ 'a': 1 }, _.toPlainObject(new Foo)); 14281 * // => { 'a': 1, 'b': 2, 'c': 3 } 14282 */ 14283 function toPlainObject(value) { 14284 return copyObject(value, keysIn(value)); 14285 } 14286 14287 /** 14288 * Converts `value` to a safe integer. A safe integer can be compared and 14289 * represented correctly. 14290 * 14291 * @static 14292 * @memberOf _ 14293 * @since 4.0.0 14294 * @category Lang 14295 * @param {*} value The value to convert. 14296 * @returns {number} Returns the converted integer. 14297 * @example 14298 * 14299 * _.toSafeInteger(3.2); 14300 * // => 3 14301 * 14302 * _.toSafeInteger(Number.MIN_VALUE); 14303 * // => 0 14304 * 14305 * _.toSafeInteger(Infinity); 14306 * // => 9007199254740991 14307 * 14308 * _.toSafeInteger('3.2'); 14309 * // => 3 14310 */ 14311 function toSafeInteger(value) { 14312 return value 14313 ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER) 14314 : (value === 0 ? value : 0); 14315 } 14316 14317 /** 14318 * Converts `value` to a string. An empty string is returned for `null` 14319 * and `undefined` values. The sign of `-0` is preserved. 14320 * 14321 * @static 14322 * @memberOf _ 14323 * @since 4.0.0 14324 * @category Lang 14325 * @param {*} value The value to convert. 14326 * @returns {string} Returns the converted string. 14327 * @example 14328 * 14329 * _.toString(null); 14330 * // => '' 14331 * 14332 * _.toString(-0); 14333 * // => '-0' 14334 * 14335 * _.toString([1, 2, 3]); 14336 * // => '1,2,3' 14337 */ 14338 function toString(value) { 14339 return value == null ? '' : baseToString(value); 14340 } 14341 14342 /*------------------------------------------------------------------------*/ 14343 14344 /** 14345 * Assigns own enumerable string keyed properties of source objects to the 14346 * destination object. Source objects are applied from left to right. 14347 * Subsequent sources overwrite property assignments of previous sources. 14348 * 14349 * **Note:** This method mutates `object` and is loosely based on 14350 * [`Object.assign`](https://mdn.io/Object/assign). 14351 * 14352 * @static 14353 * @memberOf _ 14354 * @since 0.10.0 14355 * @category Object 14356 * @param {Object} object The destination object. 14357 * @param {...Object} [sources] The source objects. 14358 * @returns {Object} Returns `object`. 14359 * @see _.assignIn 14360 * @example 14361 * 14362 * function Foo() { 14363 * this.a = 1; 14364 * } 14365 * 14366 * function Bar() { 14367 * this.c = 3; 14368 * } 14369 * 14370 * Foo.prototype.b = 2; 14371 * Bar.prototype.d = 4; 14372 * 14373 * _.assign({ 'a': 0 }, new Foo, new Bar); 14374 * // => { 'a': 1, 'c': 3 } 14375 */ 14376 var assign = createAssigner(function(object, source) { 14377 if (isPrototype(source) || isArrayLike(source)) { 14378 copyObject(source, keys(source), object); 14379 return; 14380 } 14381 for (var key in source) { 14382 if (hasOwnProperty.call(source, key)) { 14383 assignValue(object, key, source[key]); 14384 } 14385 } 14386 }); 14387 14388 /** 14389 * This method is like `_.assign` except that it iterates over own and 14390 * inherited source properties. 14391 * 14392 * **Note:** This method mutates `object`. 14393 * 14394 * @static 14395 * @memberOf _ 14396 * @since 4.0.0 14397 * @alias extend 14398 * @category Object 14399 * @param {Object} object The destination object. 14400 * @param {...Object} [sources] The source objects. 14401 * @returns {Object} Returns `object`. 14402 * @see _.assign 14403 * @example 14404 * 14405 * function Foo() { 14406 * this.a = 1; 14407 * } 14408 * 14409 * function Bar() { 14410 * this.c = 3; 14411 * } 14412 * 14413 * Foo.prototype.b = 2; 14414 * Bar.prototype.d = 4; 14415 * 14416 * _.assignIn({ 'a': 0 }, new Foo, new Bar); 14417 * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } 14418 */ 14419 var assignIn = createAssigner(function(object, source) { 14420 copyObject(source, keysIn(source), object); 14421 }); 14422 14423 /** 14424 * This method is like `_.assignIn` except that it accepts `customizer` 14425 * which is invoked to produce the assigned values. If `customizer` returns 14426 * `undefined`, assignment is handled by the method instead. The `customizer` 14427 * is invoked with five arguments: (objValue, srcValue, key, object, source). 14428 * 14429 * **Note:** This method mutates `object`. 14430 * 14431 * @static 14432 * @memberOf _ 14433 * @since 4.0.0 14434 * @alias extendWith 14435 * @category Object 14436 * @param {Object} object The destination object. 14437 * @param {...Object} sources The source objects. 14438 * @param {Function} [customizer] The function to customize assigned values. 14439 * @returns {Object} Returns `object`. 14440 * @see _.assignWith 14441 * @example 14442 * 14443 * function customizer(objValue, srcValue) { 14444 * return _.isUndefined(objValue) ? srcValue : objValue; 14445 * } 14446 * 14447 * var defaults = _.partialRight(_.assignInWith, customizer); 14448 * 14449 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 14450 * // => { 'a': 1, 'b': 2 } 14451 */ 14452 var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { 14453 copyObject(source, keysIn(source), object, customizer); 14454 }); 14455 14456 /** 14457 * This method is like `_.assign` except that it accepts `customizer` 14458 * which is invoked to produce the assigned values. If `customizer` returns 14459 * `undefined`, assignment is handled by the method instead. The `customizer` 14460 * is invoked with five arguments: (objValue, srcValue, key, object, source). 14461 * 14462 * **Note:** This method mutates `object`. 14463 * 14464 * @static 14465 * @memberOf _ 14466 * @since 4.0.0 14467 * @category Object 14468 * @param {Object} object The destination object. 14469 * @param {...Object} sources The source objects. 14470 * @param {Function} [customizer] The function to customize assigned values. 14471 * @returns {Object} Returns `object`. 14472 * @see _.assignInWith 14473 * @example 14474 * 14475 * function customizer(objValue, srcValue) { 14476 * return _.isUndefined(objValue) ? srcValue : objValue; 14477 * } 14478 * 14479 * var defaults = _.partialRight(_.assignWith, customizer); 14480 * 14481 * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 14482 * // => { 'a': 1, 'b': 2 } 14483 */ 14484 var assignWith = createAssigner(function(object, source, srcIndex, customizer) { 14485 copyObject(source, keys(source), object, customizer); 14486 }); 14487 14488 /** 14489 * Creates an array of values corresponding to `paths` of `object`. 14490 * 14491 * @static 14492 * @memberOf _ 14493 * @since 1.0.0 14494 * @category Object 14495 * @param {Object} object The object to iterate over. 14496 * @param {...(string|string[])} [paths] The property paths to pick. 14497 * @returns {Array} Returns the picked values. 14498 * @example 14499 * 14500 * var object = { 'a': [{ 'b': { 'c': 3 } }, 4] }; 14501 * 14502 * _.at(object, ['a[0].b.c', 'a[1]']); 14503 * // => [3, 4] 14504 */ 14505 var at = flatRest(baseAt); 14506 14507 /** 14508 * Creates an object that inherits from the `prototype` object. If a
vendor: 13,619 bytes, lines 14509-14973
14509 * `properties` object is given, its own enumerable string keyed properties 14510 * are assigned to the created object. 14511 * 14512 * @static 14513 * @memberOf _ 14514 * @since 2.3.0 14515 * @category Object 14516 * @param {Object} prototype The object to inherit from. 14517 * @param {Object} [properties] The properties to assign to the object. 14518 * @returns {Object} Returns the new object. 14519 * @example 14520 * 14521 * function Shape() { 14522 * this.x = 0; 14523 * this.y = 0; 14524 * } 14525 * 14526 * function Circle() { 14527 * Shape.call(this); 14528 * } 14529 * 14530 * Circle.prototype = _.create(Shape.prototype, { 14531 * 'constructor': Circle 14532 * }); 14533 * 14534 * var circle = new Circle; 14535 * circle instanceof Circle; 14536 * // => true 14537 * 14538 * circle instanceof Shape; 14539 * // => true 14540 */ 14541 function create(prototype, properties) { 14542 var result = baseCreate(prototype); 14543 return properties == null ? result : baseAssign(result, properties); 14544 } 14545 14546 /** 14547 * Assigns own and inherited enumerable string keyed properties of source 14548 * objects to the destination object for all destination properties that 14549 * resolve to `undefined`. Source objects are applied from left to right. 14550 * Once a property is set, additional values of the same property are ignored. 14551 * 14552 * **Note:** This method mutates `object`. 14553 * 14554 * @static 14555 * @since 0.1.0 14556 * @memberOf _ 14557 * @category Object 14558 * @param {Object} object The destination object. 14559 * @param {...Object} [sources] The source objects. 14560 * @returns {Object} Returns `object`. 14561 * @see _.defaultsDeep 14562 * @example 14563 * 14564 * _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); 14565 * // => { 'a': 1, 'b': 2 } 14566 */ 14567 var defaults = baseRest(function(object, sources) { 14568 object = Object(object); 14569 14570 var index = -1; 14571 var length = sources.length; 14572 var guard = length > 2 ? sources[2] : undefined; 14573 14574 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 14575 length = 1; 14576 } 14577 14578 while (++index < length) { 14579 var source = sources[index]; 14580 var props = keysIn(source); 14581 var propsIndex = -1; 14582 var propsLength = props.length; 14583 14584 while (++propsIndex < propsLength) { 14585 var key = props[propsIndex]; 14586 var value = object[key]; 14587 14588 if (value === undefined || 14589 (eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))) { 14590 object[key] = source[key]; 14591 } 14592 } 14593 } 14594 14595 return object; 14596 }); 14597 14598 /** 14599 * This method is like `_.defaults` except that it recursively assigns 14600 * default properties. 14601 * 14602 * **Note:** This method mutates `object`. 14603 * 14604 * @static 14605 * @memberOf _ 14606 * @since 3.10.0 14607 * @category Object 14608 * @param {Object} object The destination object. 14609 * @param {...Object} [sources] The source objects. 14610 * @returns {Object} Returns `object`. 14611 * @see _.defaults 14612 * @example 14613 * 14614 * _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }); 14615 * // => { 'a': { 'b': 2, 'c': 3 } } 14616 */ 14617 var defaultsDeep = baseRest(function(args) { 14618 args.push(undefined, customDefaultsMerge); 14619 return apply(mergeWith, undefined, args); 14620 }); 14621 14622 /** 14623 * This method is like `_.find` except that it returns the key of the first 14624 * element `predicate` returns truthy for instead of the element itself. 14625 * 14626 * @static 14627 * @memberOf _ 14628 * @since 1.1.0 14629 * @category Object 14630 * @param {Object} object The object to inspect. 14631 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14632 * @returns {string|undefined} Returns the key of the matched element, 14633 * else `undefined`. 14634 * @example 14635 * 14636 * var users = { 14637 * 'barney': { 'age': 36, 'active': true }, 14638 * 'fred': { 'age': 40, 'active': false }, 14639 * 'pebbles': { 'age': 1, 'active': true } 14640 * }; 14641 * 14642 * _.findKey(users, function(o) { return o.age < 40; }); 14643 * // => 'barney' (iteration order is not guaranteed) 14644 * 14645 * // The `_.matches` iteratee shorthand. 14646 * _.findKey(users, { 'age': 1, 'active': true }); 14647 * // => 'pebbles' 14648 * 14649 * // The `_.matchesProperty` iteratee shorthand. 14650 * _.findKey(users, ['active', false]); 14651 * // => 'fred' 14652 * 14653 * // The `_.property` iteratee shorthand. 14654 * _.findKey(users, 'active'); 14655 * // => 'barney' 14656 */ 14657 function findKey(object, predicate) { 14658 return baseFindKey(object, getIteratee(predicate, 3), baseForOwn); 14659 } 14660 14661 /** 14662 * This method is like `_.findKey` except that it iterates over elements of 14663 * a collection in the opposite order. 14664 * 14665 * @static 14666 * @memberOf _ 14667 * @since 2.0.0 14668 * @category Object 14669 * @param {Object} object The object to inspect. 14670 * @param {Function} [predicate=_.identity] The function invoked per iteration. 14671 * @returns {string|undefined} Returns the key of the matched element, 14672 * else `undefined`. 14673 * @example 14674 * 14675 * var users = { 14676 * 'barney': { 'age': 36, 'active': true }, 14677 * 'fred': { 'age': 40, 'active': false }, 14678 * 'pebbles': { 'age': 1, 'active': true } 14679 * }; 14680 * 14681 * _.findLastKey(users, function(o) { return o.age < 40; }); 14682 * // => returns 'pebbles' assuming `_.findKey` returns 'barney' 14683 * 14684 * // The `_.matches` iteratee shorthand. 14685 * _.findLastKey(users, { 'age': 36, 'active': true }); 14686 * // => 'barney' 14687 * 14688 * // The `_.matchesProperty` iteratee shorthand. 14689 * _.findLastKey(users, ['active', false]); 14690 * // => 'fred' 14691 * 14692 * // The `_.property` iteratee shorthand. 14693 * _.findLastKey(users, 'active'); 14694 * // => 'pebbles' 14695 */ 14696 function findLastKey(object, predicate) { 14697 return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight); 14698 } 14699 14700 /** 14701 * Iterates over own and inherited enumerable string keyed properties of an 14702 * object and invokes `iteratee` for each property. The iteratee is invoked 14703 * with three arguments: (value, key, object). Iteratee functions may exit 14704 * iteration early by explicitly returning `false`. 14705 * 14706 * @static 14707 * @memberOf _ 14708 * @since 0.3.0 14709 * @category Object 14710 * @param {Object} object The object to iterate over. 14711 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14712 * @returns {Object} Returns `object`. 14713 * @see _.forInRight 14714 * @example 14715 * 14716 * function Foo() { 14717 * this.a = 1; 14718 * this.b = 2; 14719 * } 14720 * 14721 * Foo.prototype.c = 3; 14722 * 14723 * _.forIn(new Foo, function(value, key) { 14724 * console.log(key); 14725 * }); 14726 * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed). 14727 */ 14728 function forIn(object, iteratee) { 14729 return object == null 14730 ? object 14731 : baseFor(object, getIteratee(iteratee, 3), keysIn); 14732 } 14733 14734 /** 14735 * This method is like `_.forIn` except that it iterates over properties of 14736 * `object` in the opposite order. 14737 * 14738 * @static 14739 * @memberOf _ 14740 * @since 2.0.0 14741 * @category Object 14742 * @param {Object} object The object to iterate over. 14743 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14744 * @returns {Object} Returns `object`. 14745 * @see _.forIn 14746 * @example 14747 * 14748 * function Foo() { 14749 * this.a = 1; 14750 * this.b = 2; 14751 * } 14752 * 14753 * Foo.prototype.c = 3; 14754 * 14755 * _.forInRight(new Foo, function(value, key) { 14756 * console.log(key); 14757 * }); 14758 * // => Logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'. 14759 */ 14760 function forInRight(object, iteratee) { 14761 return object == null 14762 ? object 14763 : baseForRight(object, getIteratee(iteratee, 3), keysIn); 14764 } 14765 14766 /** 14767 * Iterates over own enumerable string keyed properties of an object and 14768 * invokes `iteratee` for each property. The iteratee is invoked with three 14769 * arguments: (value, key, object). Iteratee functions may exit iteration 14770 * early by explicitly returning `false`. 14771 * 14772 * @static 14773 * @memberOf _ 14774 * @since 0.3.0 14775 * @category Object 14776 * @param {Object} object The object to iterate over. 14777 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14778 * @returns {Object} Returns `object`. 14779 * @see _.forOwnRight 14780 * @example 14781 * 14782 * function Foo() { 14783 * this.a = 1; 14784 * this.b = 2; 14785 * } 14786 * 14787 * Foo.prototype.c = 3; 14788 * 14789 * _.forOwn(new Foo, function(value, key) { 14790 * console.log(key); 14791 * }); 14792 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 14793 */ 14794 function forOwn(object, iteratee) { 14795 return object && baseForOwn(object, getIteratee(iteratee, 3)); 14796 } 14797 14798 /** 14799 * This method is like `_.forOwn` except that it iterates over properties of 14800 * `object` in the opposite order. 14801 * 14802 * @static 14803 * @memberOf _ 14804 * @since 2.0.0 14805 * @category Object 14806 * @param {Object} object The object to iterate over. 14807 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 14808 * @returns {Object} Returns `object`. 14809 * @see _.forOwn 14810 * @example 14811 * 14812 * function Foo() { 14813 * this.a = 1; 14814 * this.b = 2; 14815 * } 14816 * 14817 * Foo.prototype.c = 3; 14818 * 14819 * _.forOwnRight(new Foo, function(value, key) { 14820 * console.log(key); 14821 * }); 14822 * // => Logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'. 14823 */ 14824 function forOwnRight(object, iteratee) { 14825 return object && baseForOwnRight(object, getIteratee(iteratee, 3)); 14826 } 14827 14828 /** 14829 * Creates an array of function property names from own enumerable properties 14830 * of `object`. 14831 * 14832 * @static 14833 * @since 0.1.0 14834 * @memberOf _ 14835 * @category Object 14836 * @param {Object} object The object to inspect. 14837 * @returns {Array} Returns the function names. 14838 * @see _.functionsIn 14839 * @example 14840 * 14841 * function Foo() { 14842 * this.a = _.constant('a'); 14843 * this.b = _.constant('b'); 14844 * } 14845 * 14846 * Foo.prototype.c = _.constant('c'); 14847 * 14848 * _.functions(new Foo); 14849 * // => ['a', 'b'] 14850 */ 14851 function functions(object) { 14852 return object == null ? [] : baseFunctions(object, keys(object)); 14853 } 14854 14855 /** 14856 * Creates an array of function property names from own and inherited 14857 * enumerable properties of `object`. 14858 * 14859 * @static 14860 * @memberOf _ 14861 * @since 4.0.0 14862 * @category Object 14863 * @param {Object} object The object to inspect. 14864 * @returns {Array} Returns the function names. 14865 * @see _.functions 14866 * @example 14867 * 14868 * function Foo() { 14869 * this.a = _.constant('a'); 14870 * this.b = _.constant('b'); 14871 * } 14872 * 14873 * Foo.prototype.c = _.constant('c'); 14874 * 14875 * _.functionsIn(new Foo); 14876 * // => ['a', 'b', 'c'] 14877 */ 14878 function functionsIn(object) { 14879 return object == null ? [] : baseFunctions(object, keysIn(object)); 14880 } 14881 14882 /** 14883 * Gets the value at `path` of `object`. If the resolved value is 14884 * `undefined`, the `defaultValue` is returned in its place. 14885 * 14886 * @static 14887 * @memberOf _ 14888 * @since 3.7.0 14889 * @category Object 14890 * @param {Object} object The object to query. 14891 * @param {Array|string} path The path of the property to get. 14892 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 14893 * @returns {*} Returns the resolved value. 14894 * @example 14895 * 14896 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 14897 * 14898 * _.get(object, 'a[0].b.c'); 14899 * // => 3 14900 * 14901 * _.get(object, ['a', '0', 'b', 'c']); 14902 * // => 3 14903 * 14904 * _.get(object, 'a.b.c', 'default'); 14905 * // => 'default' 14906 */ 14907 function get(object, path, defaultValue) { 14908 var result = object == null ? undefined : baseGet(object, path); 14909 return result === undefined ? defaultValue : result; 14910 } 14911 14912 /** 14913 * Checks if `path` is a direct property of `object`. 14914 * 14915 * @static 14916 * @since 0.1.0 14917 * @memberOf _ 14918 * @category Object 14919 * @param {Object} object The object to query. 14920 * @param {Array|string} path The path to check. 14921 * @returns {boolean} Returns `true` if `path` exists, else `false`. 14922 * @example 14923 * 14924 * var object = { 'a': { 'b': 2 } }; 14925 * var other = _.create({ 'a': _.create({ 'b': 2 }) }); 14926 * 14927 * _.has(object, 'a'); 14928 * // => true 14929 * 14930 * _.has(object, 'a.b'); 14931 * // => true 14932 * 14933 * _.has(object, ['a', 'b']); 14934 * // => true 14935 * 14936 * _.has(other, 'a'); 14937 * // => false 14938 */ 14939 function has(object, path) { 14940 return object != null && hasPath(object, path, baseHas); 14941 } 14942 14943 /** 14944 * Checks if `path` is a direct or inherited property of `object`. 14945 * 14946 * @static 14947 * @memberOf _ 14948 * @since 4.0.0 14949 * @category Object 14950 * @param {Object} object The object to query. 14951 * @param {Array|string} path The path to check. 14952 * @returns {boolean} Returns `true` if `path` exists, else `false`. 14953 * @example 14954 * 14955 * var object = _.create({ 'a': _.create({ 'b': 2 }) }); 14956 * 14957 * _.hasIn(object, 'a'); 14958 * // => true 14959 * 14960 * _.hasIn(object, 'a.b'); 14961 * // => true 14962 * 14963 * _.hasIn(object, ['a', 'b']); 14964 * // => true 14965 * 14966 * _.hasIn(object, 'b'); 14967 * // => false 14968 */ 14969 function hasIn(object, path) { 14970 return object != null && hasPath(object, path, baseHasIn); 14971 } 14972 14973 /**
vendor: 11,848 bytes, lines 14974-15344
14974 * Creates an object composed of the inverted keys and values of `object`. 14975 * If `object` contains duplicate values, subsequent values overwrite 14976 * property assignments of previous values. 14977 * 14978 * @static 14979 * @memberOf _ 14980 * @since 0.7.0 14981 * @category Object 14982 * @param {Object} object The object to invert. 14983 * @returns {Object} Returns the new inverted object. 14984 * @example 14985 * 14986 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 14987 * 14988 * _.invert(object); 14989 * // => { '1': 'c', '2': 'b' } 14990 */ 14991 var invert = createInverter(function(result, value, key) { 14992 if (value != null && 14993 typeof value.toString != 'function') { 14994 value = nativeObjectToString.call(value); 14995 } 14996 14997 result[value] = key; 14998 }, constant(identity)); 14999 15000 /** 15001 * This method is like `_.invert` except that the inverted object is generated 15002 * from the results of running each element of `object` thru `iteratee`. The 15003 * corresponding inverted value of each inverted key is an array of keys 15004 * responsible for generating the inverted value. The iteratee is invoked 15005 * with one argument: (value). 15006 * 15007 * @static 15008 * @memberOf _ 15009 * @since 4.1.0 15010 * @category Object 15011 * @param {Object} object The object to invert. 15012 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 15013 * @returns {Object} Returns the new inverted object. 15014 * @example 15015 * 15016 * var object = { 'a': 1, 'b': 2, 'c': 1 }; 15017 * 15018 * _.invertBy(object); 15019 * // => { '1': ['a', 'c'], '2': ['b'] } 15020 * 15021 * _.invertBy(object, function(value) { 15022 * return 'group' + value; 15023 * }); 15024 * // => { 'group1': ['a', 'c'], 'group2': ['b'] } 15025 */ 15026 var invertBy = createInverter(function(result, value, key) { 15027 if (value != null && 15028 typeof value.toString != 'function') { 15029 value = nativeObjectToString.call(value); 15030 } 15031 15032 if (hasOwnProperty.call(result, value)) { 15033 result[value].push(key); 15034 } else { 15035 result[value] = [key]; 15036 } 15037 }, getIteratee); 15038 15039 /** 15040 * Invokes the method at `path` of `object`. 15041 * 15042 * @static 15043 * @memberOf _ 15044 * @since 4.0.0 15045 * @category Object 15046 * @param {Object} object The object to query. 15047 * @param {Array|string} path The path of the method to invoke. 15048 * @param {...*} [args] The arguments to invoke the method with. 15049 * @returns {*} Returns the result of the invoked method. 15050 * @example 15051 * 15052 * var object = { 'a': [{ 'b': { 'c': [1, 2, 3, 4] } }] }; 15053 * 15054 * _.invoke(object, 'a[0].b.c.slice', 1, 3); 15055 * // => [2, 3] 15056 */ 15057 var invoke = baseRest(baseInvoke); 15058 15059 /** 15060 * Creates an array of the own enumerable property names of `object`. 15061 * 15062 * **Note:** Non-object values are coerced to objects. See the 15063 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 15064 * for more details. 15065 * 15066 * @static 15067 * @since 0.1.0 15068 * @memberOf _ 15069 * @category Object 15070 * @param {Object} object The object to query. 15071 * @returns {Array} Returns the array of property names. 15072 * @example 15073 * 15074 * function Foo() { 15075 * this.a = 1; 15076 * this.b = 2; 15077 * } 15078 * 15079 * Foo.prototype.c = 3; 15080 * 15081 * _.keys(new Foo); 15082 * // => ['a', 'b'] (iteration order is not guaranteed) 15083 * 15084 * _.keys('hi'); 15085 * // => ['0', '1'] 15086 */ 15087 function keys(object) { 15088 return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); 15089 } 15090 15091 /** 15092 * Creates an array of the own and inherited enumerable property names of `object`. 15093 * 15094 * **Note:** Non-object values are coerced to objects. 15095 * 15096 * @static 15097 * @memberOf _ 15098 * @since 3.0.0 15099 * @category Object 15100 * @param {Object} object The object to query. 15101 * @returns {Array} Returns the array of property names. 15102 * @example 15103 * 15104 * function Foo() { 15105 * this.a = 1; 15106 * this.b = 2; 15107 * } 15108 * 15109 * Foo.prototype.c = 3; 15110 * 15111 * _.keysIn(new Foo); 15112 * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 15113 */ 15114 function keysIn(object) { 15115 return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); 15116 } 15117 15118 /** 15119 * The opposite of `_.mapValues`; this method creates an object with the 15120 * same values as `object` and keys generated by running each own enumerable 15121 * string keyed property of `object` thru `iteratee`. The iteratee is invoked 15122 * with three arguments: (value, key, object). 15123 * 15124 * @static 15125 * @memberOf _ 15126 * @since 3.8.0 15127 * @category Object 15128 * @param {Object} object The object to iterate over. 15129 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15130 * @returns {Object} Returns the new mapped object. 15131 * @see _.mapValues 15132 * @example 15133 * 15134 * _.mapKeys({ 'a': 1, 'b': 2 }, function(value, key) { 15135 * return key + value; 15136 * }); 15137 * // => { 'a1': 1, 'b2': 2 } 15138 */ 15139 function mapKeys(object, iteratee) { 15140 var result = {}; 15141 iteratee = getIteratee(iteratee, 3); 15142 15143 baseForOwn(object, function(value, key, object) { 15144 baseAssignValue(result, iteratee(value, key, object), value); 15145 }); 15146 return result; 15147 } 15148 15149 /** 15150 * Creates an object with the same keys as `object` and values generated 15151 * by running each own enumerable string keyed property of `object` thru 15152 * `iteratee`. The iteratee is invoked with three arguments: 15153 * (value, key, object). 15154 * 15155 * @static 15156 * @memberOf _ 15157 * @since 2.4.0 15158 * @category Object 15159 * @param {Object} object The object to iterate over. 15160 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15161 * @returns {Object} Returns the new mapped object. 15162 * @see _.mapKeys 15163 * @example 15164 * 15165 * var users = { 15166 * 'fred': { 'user': 'fred', 'age': 40 }, 15167 * 'pebbles': { 'user': 'pebbles', 'age': 1 } 15168 * }; 15169 * 15170 * _.mapValues(users, function(o) { return o.age; }); 15171 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 15172 * 15173 * // The `_.property` iteratee shorthand. 15174 * _.mapValues(users, 'age'); 15175 * // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed) 15176 */ 15177 function mapValues(object, iteratee) { 15178 var result = {}; 15179 iteratee = getIteratee(iteratee, 3); 15180 15181 baseForOwn(object, function(value, key, object) { 15182 baseAssignValue(result, key, iteratee(value, key, object)); 15183 }); 15184 return result; 15185 } 15186 15187 /** 15188 * This method is like `_.assign` except that it recursively merges own and 15189 * inherited enumerable string keyed properties of source objects into the 15190 * destination object. Source properties that resolve to `undefined` are 15191 * skipped if a destination value exists. Array and plain object properties 15192 * are merged recursively. Other objects and value types are overridden by 15193 * assignment. Source objects are applied from left to right. Subsequent 15194 * sources overwrite property assignments of previous sources. 15195 * 15196 * **Note:** This method mutates `object`. 15197 * 15198 * @static 15199 * @memberOf _ 15200 * @since 0.5.0 15201 * @category Object 15202 * @param {Object} object The destination object. 15203 * @param {...Object} [sources] The source objects. 15204 * @returns {Object} Returns `object`. 15205 * @example 15206 * 15207 * var object = { 15208 * 'a': [{ 'b': 2 }, { 'd': 4 }] 15209 * }; 15210 * 15211 * var other = { 15212 * 'a': [{ 'c': 3 }, { 'e': 5 }] 15213 * }; 15214 * 15215 * _.merge(object, other); 15216 * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] } 15217 */ 15218 var merge = createAssigner(function(object, source, srcIndex) { 15219 baseMerge(object, source, srcIndex); 15220 }); 15221 15222 /** 15223 * This method is like `_.merge` except that it accepts `customizer` which 15224 * is invoked to produce the merged values of the destination and source 15225 * properties. If `customizer` returns `undefined`, merging is handled by the 15226 * method instead. The `customizer` is invoked with six arguments: 15227 * (objValue, srcValue, key, object, source, stack). 15228 * 15229 * **Note:** This method mutates `object`. 15230 * 15231 * @static 15232 * @memberOf _ 15233 * @since 4.0.0 15234 * @category Object 15235 * @param {Object} object The destination object. 15236 * @param {...Object} sources The source objects. 15237 * @param {Function} customizer The function to customize assigned values. 15238 * @returns {Object} Returns `object`. 15239 * @example 15240 * 15241 * function customizer(objValue, srcValue) { 15242 * if (_.isArray(objValue)) { 15243 * return objValue.concat(srcValue); 15244 * } 15245 * } 15246 * 15247 * var object = { 'a': [1], 'b': [2] }; 15248 * var other = { 'a': [3], 'b': [4] }; 15249 * 15250 * _.mergeWith(object, other, customizer); 15251 * // => { 'a': [1, 3], 'b': [2, 4] } 15252 */ 15253 var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { 15254 baseMerge(object, source, srcIndex, customizer); 15255 }); 15256 15257 /** 15258 * The opposite of `_.pick`; this method creates an object composed of the 15259 * own and inherited enumerable property paths of `object` that are not omitted. 15260 * 15261 * **Note:** This method is considerably slower than `_.pick`. 15262 * 15263 * @static 15264 * @since 0.1.0 15265 * @memberOf _ 15266 * @category Object 15267 * @param {Object} object The source object. 15268 * @param {...(string|string[])} [paths] The property paths to omit. 15269 * @returns {Object} Returns the new object. 15270 * @example 15271 * 15272 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15273 * 15274 * _.omit(object, ['a', 'c']); 15275 * // => { 'b': '2' } 15276 */ 15277 var omit = flatRest(function(object, paths) { 15278 var result = {}; 15279 if (object == null) { 15280 return result; 15281 } 15282 var isDeep = false; 15283 paths = arrayMap(paths, function(path) { 15284 path = castPath(path, object); 15285 isDeep || (isDeep = path.length > 1); 15286 return path; 15287 }); 15288 copyObject(object, getAllKeysIn(object), result); 15289 if (isDeep) { 15290 result = baseClone(result, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone); 15291 } 15292 var length = paths.length; 15293 while (length--) { 15294 baseUnset(result, paths[length]); 15295 } 15296 return result; 15297 }); 15298 15299 /** 15300 * The opposite of `_.pickBy`; this method creates an object composed of 15301 * the own and inherited enumerable string keyed properties of `object` that 15302 * `predicate` doesn't return truthy for. The predicate is invoked with two 15303 * arguments: (value, key). 15304 * 15305 * @static 15306 * @memberOf _ 15307 * @since 4.0.0 15308 * @category Object 15309 * @param {Object} object The source object. 15310 * @param {Function} [predicate=_.identity] The function invoked per property. 15311 * @returns {Object} Returns the new object. 15312 * @example 15313 * 15314 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15315 * 15316 * _.omitBy(object, _.isNumber); 15317 * // => { 'b': '2' } 15318 */ 15319 function omitBy(object, predicate) { 15320 return pickBy(object, negate(getIteratee(predicate))); 15321 } 15322 15323 /** 15324 * Creates an object composed of the picked `object` properties. 15325 * 15326 * @static 15327 * @since 0.1.0 15328 * @memberOf _ 15329 * @category Object 15330 * @param {Object} object The source object. 15331 * @param {...(string|string[])} [paths] The property paths to pick. 15332 * @returns {Object} Returns the new object. 15333 * @example 15334 * 15335 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15336 * 15337 * _.pick(object, ['a', 'c']); 15338 * // => { 'a': 1, 'c': 3 } 15339 */ 15340 var pick = flatRest(function(object, paths) { 15341 return object == null ? {} : basePick(object, paths); 15342 }); 15343 15344 /**
vendor: 11,160 bytes, lines 15345-15683
15345 * Creates an object composed of the `object` properties `predicate` returns 15346 * truthy for. The predicate is invoked with two arguments: (value, key). 15347 * 15348 * @static 15349 * @memberOf _ 15350 * @since 4.0.0 15351 * @category Object 15352 * @param {Object} object The source object. 15353 * @param {Function} [predicate=_.identity] The function invoked per property. 15354 * @returns {Object} Returns the new object. 15355 * @example 15356 * 15357 * var object = { 'a': 1, 'b': '2', 'c': 3 }; 15358 * 15359 * _.pickBy(object, _.isNumber); 15360 * // => { 'a': 1, 'c': 3 } 15361 */ 15362 function pickBy(object, predicate) { 15363 if (object == null) { 15364 return {}; 15365 } 15366 var props = arrayMap(getAllKeysIn(object), function(prop) { 15367 return [prop]; 15368 }); 15369 predicate = getIteratee(predicate); 15370 return basePickBy(object, props, function(value, path) { 15371 return predicate(value, path[0]); 15372 }); 15373 } 15374 15375 /** 15376 * This method is like `_.get` except that if the resolved value is a 15377 * function it's invoked with the `this` binding of its parent object and 15378 * its result is returned. 15379 * 15380 * @static 15381 * @since 0.1.0 15382 * @memberOf _ 15383 * @category Object 15384 * @param {Object} object The object to query. 15385 * @param {Array|string} path The path of the property to resolve. 15386 * @param {*} [defaultValue] The value returned for `undefined` resolved values. 15387 * @returns {*} Returns the resolved value. 15388 * @example 15389 * 15390 * var object = { 'a': [{ 'b': { 'c1': 3, 'c2': _.constant(4) } }] }; 15391 * 15392 * _.result(object, 'a[0].b.c1'); 15393 * // => 3 15394 * 15395 * _.result(object, 'a[0].b.c2'); 15396 * // => 4 15397 * 15398 * _.result(object, 'a[0].b.c3', 'default'); 15399 * // => 'default' 15400 * 15401 * _.result(object, 'a[0].b.c3', _.constant('default')); 15402 * // => 'default' 15403 */ 15404 function result(object, path, defaultValue) { 15405 path = castPath(path, object); 15406 15407 var index = -1, 15408 length = path.length; 15409 15410 // Ensure the loop is entered when path is empty. 15411 if (!length) { 15412 length = 1; 15413 object = undefined; 15414 } 15415 while (++index < length) { 15416 var value = object == null ? undefined : object[toKey(path[index])]; 15417 if (value === undefined) { 15418 index = length; 15419 value = defaultValue; 15420 } 15421 object = isFunction(value) ? value.call(object) : value; 15422 } 15423 return object; 15424 } 15425 15426 /** 15427 * Sets the value at `path` of `object`. If a portion of `path` doesn't exist, 15428 * it's created. Arrays are created for missing index properties while objects 15429 * are created for all other missing properties. Use `_.setWith` to customize 15430 * `path` creation. 15431 * 15432 * **Note:** This method mutates `object`. 15433 * 15434 * @static 15435 * @memberOf _ 15436 * @since 3.7.0 15437 * @category Object 15438 * @param {Object} object The object to modify. 15439 * @param {Array|string} path The path of the property to set. 15440 * @param {*} value The value to set. 15441 * @returns {Object} Returns `object`. 15442 * @example 15443 * 15444 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 15445 * 15446 * _.set(object, 'a[0].b.c', 4); 15447 * console.log(object.a[0].b.c); 15448 * // => 4 15449 * 15450 * _.set(object, ['x', '0', 'y', 'z'], 5); 15451 * console.log(object.x[0].y.z); 15452 * // => 5 15453 */ 15454 function set(object, path, value) { 15455 return object == null ? object : baseSet(object, path, value); 15456 } 15457 15458 /** 15459 * This method is like `_.set` except that it accepts `customizer` which is 15460 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 15461 * path creation is handled by the method instead. The `customizer` is invoked 15462 * with three arguments: (nsValue, key, nsObject). 15463 * 15464 * **Note:** This method mutates `object`. 15465 * 15466 * @static 15467 * @memberOf _ 15468 * @since 4.0.0 15469 * @category Object 15470 * @param {Object} object The object to modify. 15471 * @param {Array|string} path The path of the property to set. 15472 * @param {*} value The value to set. 15473 * @param {Function} [customizer] The function to customize assigned values. 15474 * @returns {Object} Returns `object`. 15475 * @example 15476 * 15477 * var object = {}; 15478 * 15479 * _.setWith(object, '[0][1]', 'a', Object); 15480 * // => { '0': { '1': 'a' } } 15481 */ 15482 function setWith(object, path, value, customizer) { 15483 customizer = typeof customizer == 'function' ? customizer : undefined; 15484 return object == null ? object : baseSet(object, path, value, customizer); 15485 } 15486 15487 /** 15488 * Creates an array of own enumerable string keyed-value pairs for `object` 15489 * which can be consumed by `_.fromPairs`. If `object` is a map or set, its 15490 * entries are returned. 15491 * 15492 * @static 15493 * @memberOf _ 15494 * @since 4.0.0 15495 * @alias entries 15496 * @category Object 15497 * @param {Object} object The object to query. 15498 * @returns {Array} Returns the key-value pairs. 15499 * @example 15500 * 15501 * function Foo() { 15502 * this.a = 1; 15503 * this.b = 2; 15504 * } 15505 * 15506 * Foo.prototype.c = 3; 15507 * 15508 * _.toPairs(new Foo); 15509 * // => [['a', 1], ['b', 2]] (iteration order is not guaranteed) 15510 */ 15511 var toPairs = createToPairs(keys); 15512 15513 /** 15514 * Creates an array of own and inherited enumerable string keyed-value pairs 15515 * for `object` which can be consumed by `_.fromPairs`. If `object` is a map 15516 * or set, its entries are returned. 15517 * 15518 * @static 15519 * @memberOf _ 15520 * @since 4.0.0 15521 * @alias entriesIn 15522 * @category Object 15523 * @param {Object} object The object to query. 15524 * @returns {Array} Returns the key-value pairs. 15525 * @example 15526 * 15527 * function Foo() { 15528 * this.a = 1; 15529 * this.b = 2; 15530 * } 15531 * 15532 * Foo.prototype.c = 3; 15533 * 15534 * _.toPairsIn(new Foo); 15535 * // => [['a', 1], ['b', 2], ['c', 3]] (iteration order is not guaranteed) 15536 */ 15537 var toPairsIn = createToPairs(keysIn); 15538 15539 /** 15540 * An alternative to `_.reduce`; this method transforms `object` to a new 15541 * `accumulator` object which is the result of running each of its own 15542 * enumerable string keyed properties thru `iteratee`, with each invocation 15543 * potentially mutating the `accumulator` object. If `accumulator` is not 15544 * provided, a new object with the same `[[Prototype]]` will be used. The 15545 * iteratee is invoked with four arguments: (accumulator, value, key, object). 15546 * Iteratee functions may exit iteration early by explicitly returning `false`. 15547 * 15548 * @static 15549 * @memberOf _ 15550 * @since 1.3.0 15551 * @category Object 15552 * @param {Object} object The object to iterate over. 15553 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 15554 * @param {*} [accumulator] The custom accumulator value. 15555 * @returns {*} Returns the accumulated value. 15556 * @example 15557 * 15558 * _.transform([2, 3, 4], function(result, n) { 15559 * result.push(n *= n); 15560 * return n % 2 == 0; 15561 * }, []); 15562 * // => [4, 9] 15563 * 15564 * _.transform({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) { 15565 * (result[value] || (result[value] = [])).push(key); 15566 * }, {}); 15567 * // => { '1': ['a', 'c'], '2': ['b'] } 15568 */ 15569 function transform(object, iteratee, accumulator) { 15570 var isArr = isArray(object), 15571 isArrLike = isArr || isBuffer(object) || isTypedArray(object); 15572 15573 iteratee = getIteratee(iteratee, 4); 15574 if (accumulator == null) { 15575 var Ctor = object && object.constructor; 15576 if (isArrLike) { 15577 accumulator = isArr ? new Ctor : []; 15578 } 15579 else if (isObject(object)) { 15580 accumulator = isFunction(Ctor) ? baseCreate(getPrototype(object)) : {}; 15581 } 15582 else { 15583 accumulator = {}; 15584 } 15585 } 15586 (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object) { 15587 return iteratee(accumulator, value, index, object); 15588 }); 15589 return accumulator; 15590 } 15591 15592 /** 15593 * Removes the property at `path` of `object`. 15594 * 15595 * **Note:** This method mutates `object`. 15596 * 15597 * @static 15598 * @memberOf _ 15599 * @since 4.0.0 15600 * @category Object 15601 * @param {Object} object The object to modify. 15602 * @param {Array|string} path The path of the property to unset. 15603 * @returns {boolean} Returns `true` if the property is deleted, else `false`. 15604 * @example 15605 * 15606 * var object = { 'a': [{ 'b': { 'c': 7 } }] }; 15607 * _.unset(object, 'a[0].b.c'); 15608 * // => true 15609 * 15610 * console.log(object); 15611 * // => { 'a': [{ 'b': {} }] }; 15612 * 15613 * _.unset(object, ['a', '0', 'b', 'c']); 15614 * // => true 15615 * 15616 * console.log(object); 15617 * // => { 'a': [{ 'b': {} }] }; 15618 */ 15619 function unset(object, path) { 15620 return object == null ? true : baseUnset(object, path); 15621 } 15622 15623 /** 15624 * This method is like `_.set` except that accepts `updater` to produce the 15625 * value to set. Use `_.updateWith` to customize `path` creation. The `updater` 15626 * is invoked with one argument: (value). 15627 * 15628 * **Note:** This method mutates `object`. 15629 * 15630 * @static 15631 * @memberOf _ 15632 * @since 4.6.0 15633 * @category Object 15634 * @param {Object} object The object to modify. 15635 * @param {Array|string} path The path of the property to set. 15636 * @param {Function} updater The function to produce the updated value. 15637 * @returns {Object} Returns `object`. 15638 * @example 15639 * 15640 * var object = { 'a': [{ 'b': { 'c': 3 } }] }; 15641 * 15642 * _.update(object, 'a[0].b.c', function(n) { return n * n; }); 15643 * console.log(object.a[0].b.c); 15644 * // => 9 15645 * 15646 * _.update(object, 'x[0].y.z', function(n) { return n ? n + 1 : 0; }); 15647 * console.log(object.x[0].y.z); 15648 * // => 0 15649 */ 15650 function update(object, path, updater) { 15651 return object == null ? object : baseUpdate(object, path, castFunction(updater)); 15652 } 15653 15654 /** 15655 * This method is like `_.update` except that it accepts `customizer` which is 15656 * invoked to produce the objects of `path`. If `customizer` returns `undefined` 15657 * path creation is handled by the method instead. The `customizer` is invoked 15658 * with three arguments: (nsValue, key, nsObject). 15659 * 15660 * **Note:** This method mutates `object`. 15661 * 15662 * @static 15663 * @memberOf _ 15664 * @since 4.6.0 15665 * @category Object 15666 * @param {Object} object The object to modify. 15667 * @param {Array|string} path The path of the property to set. 15668 * @param {Function} updater The function to produce the updated value. 15669 * @param {Function} [customizer] The function to customize assigned values. 15670 * @returns {Object} Returns `object`. 15671 * @example 15672 * 15673 * var object = {}; 15674 * 15675 * _.updateWith(object, '[0][1]', _.constant('a'), Object); 15676 * // => { '0': { '1': 'a' } } 15677 */ 15678 function updateWith(object, path, updater, customizer) { 15679 customizer = typeof customizer == 'function' ? customizer : undefined; 15680 return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer); 15681 } 15682 15683 /**
vendor: 1,263 bytes, lines 15684-15733
15684 * Creates an array of the own enumerable string keyed property values of `object`. 15685 * 15686 * **Note:** Non-object values are coerced to objects. 15687 * 15688 * @static 15689 * @since 0.1.0 15690 * @memberOf _ 15691 * @category Object 15692 * @param {Object} object The object to query. 15693 * @returns {Array} Returns the array of property values. 15694 * @example 15695 * 15696 * function Foo() { 15697 * this.a = 1; 15698 * this.b = 2; 15699 * } 15700 * 15701 * Foo.prototype.c = 3; 15702 * 15703 * _.values(new Foo); 15704 * // => [1, 2] (iteration order is not guaranteed) 15705 * 15706 * _.values('hi'); 15707 * // => ['h', 'i'] 15708 */ 15709 function values(object) { 15710 return object == null ? [] : baseValues(object, keys(object)); 15711 } 15712 15713 /** 15714 * Creates an array of the own and inherited enumerable string keyed property 15715 * values of `object`. 15716 * 15717 * **Note:** Non-object values are coerced to objects. 15718 * 15719 * @static 15720 * @memberOf _ 15721 * @since 3.0.0 15722 * @category Object 15723 * @param {Object} object The object to query. 15724 * @returns {Array} Returns the array of property values. 15725 * @example 15726 * 15727 * function Foo() { 15728 * this.a = 1; 15729 * this.b = 2; 15730 * } 15731 * 15732 * Foo.prototype.c = 3; 15733 *
vendor: 9,679 bytes, lines 15734-16054
15734 * _.valuesIn(new Foo); 15735 * // => [1, 2, 3] (iteration order is not guaranteed) 15736 */ 15737 function valuesIn(object) { 15738 return object == null ? [] : baseValues(object, keysIn(object)); 15739 } 15740 15741 /*------------------------------------------------------------------------*/ 15742 15743 /** 15744 * Clamps `number` within the inclusive `lower` and `upper` bounds. 15745 * 15746 * @static 15747 * @memberOf _ 15748 * @since 4.0.0 15749 * @category Number 15750 * @param {number} number The number to clamp. 15751 * @param {number} [lower] The lower bound. 15752 * @param {number} upper The upper bound. 15753 * @returns {number} Returns the clamped number. 15754 * @example 15755 * 15756 * _.clamp(-10, -5, 5); 15757 * // => -5 15758 * 15759 * _.clamp(10, -5, 5); 15760 * // => 5 15761 */ 15762 function clamp(number, lower, upper) { 15763 if (upper === undefined) { 15764 upper = lower; 15765 lower = undefined; 15766 } 15767 if (upper !== undefined) { 15768 upper = toNumber(upper); 15769 upper = upper === upper ? upper : 0; 15770 } 15771 if (lower !== undefined) { 15772 lower = toNumber(lower); 15773 lower = lower === lower ? lower : 0; 15774 } 15775 return baseClamp(toNumber(number), lower, upper); 15776 } 15777 15778 /** 15779 * Checks if `n` is between `start` and up to, but not including, `end`. If 15780 * `end` is not specified, it's set to `start` with `start` then set to `0`. 15781 * If `start` is greater than `end` the params are swapped to support 15782 * negative ranges. 15783 * 15784 * @static 15785 * @memberOf _ 15786 * @since 3.3.0 15787 * @category Number 15788 * @param {number} number The number to check. 15789 * @param {number} [start=0] The start of the range. 15790 * @param {number} end The end of the range. 15791 * @returns {boolean} Returns `true` if `number` is in the range, else `false`. 15792 * @see _.range, _.rangeRight 15793 * @example 15794 * 15795 * _.inRange(3, 2, 4); 15796 * // => true 15797 * 15798 * _.inRange(4, 8); 15799 * // => true 15800 * 15801 * _.inRange(4, 2); 15802 * // => false 15803 * 15804 * _.inRange(2, 2); 15805 * // => false 15806 * 15807 * _.inRange(1.2, 2); 15808 * // => true 15809 * 15810 * _.inRange(5.2, 4); 15811 * // => false 15812 * 15813 * _.inRange(-3, -2, -6); 15814 * // => true 15815 */ 15816 function inRange(number, start, end) { 15817 start = toFinite(start); 15818 if (end === undefined) { 15819 end = start; 15820 start = 0; 15821 } else { 15822 end = toFinite(end); 15823 } 15824 number = toNumber(number); 15825 return baseInRange(number, start, end); 15826 } 15827 15828 /** 15829 * Produces a random number between the inclusive `lower` and `upper` bounds. 15830 * If only one argument is provided a number between `0` and the given number 15831 * is returned. If `floating` is `true`, or either `lower` or `upper` are 15832 * floats, a floating-point number is returned instead of an integer. 15833 * 15834 * **Note:** JavaScript follows the IEEE-754 standard for resolving 15835 * floating-point values which can produce unexpected results. 15836 * 15837 * @static 15838 * @memberOf _ 15839 * @since 0.7.0 15840 * @category Number 15841 * @param {number} [lower=0] The lower bound. 15842 * @param {number} [upper=1] The upper bound. 15843 * @param {boolean} [floating] Specify returning a floating-point number. 15844 * @returns {number} Returns the random number. 15845 * @example 15846 * 15847 * _.random(0, 5); 15848 * // => an integer between 0 and 5 15849 * 15850 * _.random(5); 15851 * // => also an integer between 0 and 5 15852 * 15853 * _.random(5, true); 15854 * // => a floating-point number between 0 and 5 15855 * 15856 * _.random(1.2, 5.2); 15857 * // => a floating-point number between 1.2 and 5.2 15858 */ 15859 function random(lower, upper, floating) { 15860 if (floating && typeof floating != 'boolean' && isIterateeCall(lower, upper, floating)) { 15861 upper = floating = undefined; 15862 } 15863 if (floating === undefined) { 15864 if (typeof upper == 'boolean') { 15865 floating = upper; 15866 upper = undefined; 15867 } 15868 else if (typeof lower == 'boolean') { 15869 floating = lower; 15870 lower = undefined; 15871 } 15872 } 15873 if (lower === undefined && upper === undefined) { 15874 lower = 0; 15875 upper = 1; 15876 } 15877 else { 15878 lower = toFinite(lower); 15879 if (upper === undefined) { 15880 upper = lower; 15881 lower = 0; 15882 } else { 15883 upper = toFinite(upper); 15884 } 15885 } 15886 if (lower > upper) { 15887 var temp = lower; 15888 lower = upper; 15889 upper = temp; 15890 } 15891 if (floating || lower % 1 || upper % 1) { 15892 var rand = nativeRandom(); 15893 return nativeMin(lower + (rand * (upper - lower + freeParseFloat('1e-' + ((rand + '').length - 1)))), upper); 15894 } 15895 return baseRandom(lower, upper); 15896 } 15897 15898 /*------------------------------------------------------------------------*/ 15899 15900 /** 15901 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). 15902 * 15903 * @static 15904 * @memberOf _ 15905 * @since 3.0.0 15906 * @category String 15907 * @param {string} [string=''] The string to convert. 15908 * @returns {string} Returns the camel cased string. 15909 * @example 15910 * 15911 * _.camelCase('Foo Bar'); 15912 * // => 'fooBar' 15913 * 15914 * _.camelCase('--foo-bar--'); 15915 * // => 'fooBar' 15916 * 15917 * _.camelCase('__FOO_BAR__'); 15918 * // => 'fooBar' 15919 */ 15920 var camelCase = createCompounder(function(result, word, index) { 15921 word = word.toLowerCase(); 15922 return result + (index ? capitalize(word) : word); 15923 }); 15924 15925 /** 15926 * Converts the first character of `string` to upper case and the remaining 15927 * to lower case. 15928 * 15929 * @static 15930 * @memberOf _ 15931 * @since 3.0.0 15932 * @category String 15933 * @param {string} [string=''] The string to capitalize. 15934 * @returns {string} Returns the capitalized string. 15935 * @example 15936 * 15937 * _.capitalize('FRED'); 15938 * // => 'Fred' 15939 */ 15940 function capitalize(string) { 15941 return upperFirst(toString(string).toLowerCase()); 15942 } 15943 15944 /** 15945 * Deburrs `string` by converting 15946 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) 15947 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) 15948 * letters to basic Latin letters and removing 15949 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). 15950 * 15951 * @static 15952 * @memberOf _ 15953 * @since 3.0.0 15954 * @category String 15955 * @param {string} [string=''] The string to deburr. 15956 * @returns {string} Returns the deburred string. 15957 * @example 15958 * 15959 * _.deburr('déjàvu'); 15960 * // => 'deja vu' 15961 */ 15962 function deburr(string) { 15963 string = toString(string); 15964 return string && string.replace(reLatin, deburrLetter).replace(reComboMark, ''); 15965 } 15966 15967 /** 15968 * Checks if `string` ends with the given target string. 15969 * 15970 * @static 15971 * @memberOf _ 15972 * @since 3.0.0 15973 * @category String 15974 * @param {string} [string=''] The string to inspect. 15975 * @param {string} [target] The string to search for. 15976 * @param {number} [position=string.length] The position to search up to. 15977 * @returns {boolean} Returns `true` if `string` ends with `target`, 15978 * else `false`. 15979 * @example 15980 * 15981 * _.endsWith('abc', 'c'); 15982 * // => true 15983 * 15984 * _.endsWith('abc', 'b'); 15985 * // => false 15986 * 15987 * _.endsWith('abc', 'b', 2); 15988 * // => true 15989 */ 15990 function endsWith(string, target, position) { 15991 string = toString(string); 15992 target = baseToString(target); 15993 15994 var length = string.length; 15995 position = position === undefined 15996 ? length 15997 : baseClamp(toInteger(position), 0, length); 15998 15999 var end = position; 16000 position -= target.length; 16001 return position >= 0 && string.slice(position, end) == target; 16002 } 16003 16004 /** 16005 * Converts the characters "&", "<", ">", '"', and "'" in `string` to their 16006 * corresponding HTML entities. 16007 * 16008 * **Note:** No other characters are escaped. To escape additional 16009 * characters use a third-party library like [_he_](https://mths.be/he). 16010 * 16011 * Though the ">" character is escaped for symmetry, characters like 16012 * ">" and "/" don't need escaping in HTML and have no special meaning 16013 * unless they're part of a tag or unquoted attribute value. See 16014 * [Mathias Bynens's article](https://mathiasbynens.be/notes/ambiguous-ampersands) 16015 * (under "semi-related fun fact") for more details. 16016 * 16017 * When working with HTML you should always 16018 * [quote attribute values](http://wonko.com/post/html-escaping) to reduce 16019 * XSS vectors. 16020 * 16021 * @static 16022 * @since 0.1.0 16023 * @memberOf _ 16024 * @category String 16025 * @param {string} [string=''] The string to escape. 16026 * @returns {string} Returns the escaped string. 16027 * @example 16028 * 16029 * _.escape('fred, barney, & pebbles'); 16030 * // => 'fred, barney, & pebbles' 16031 */ 16032 function escape(string) { 16033 string = toString(string); 16034 return (string && reHasUnescapedHtml.test(string)) 16035 ? string.replace(reUnescapedHtml, escapeHtmlChar) 16036 : string; 16037 } 16038 16039 /** 16040 * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", 16041 * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. 16042 * 16043 * @static 16044 * @memberOf _ 16045 * @since 3.0.0 16046 * @category String 16047 * @param {string} [string=''] The string to escape. 16048 * @returns {string} Returns the escaped string. 16049 * @example 16050 * 16051 * _.escapeRegExp('[lodash](https://lodash.com/)'); 16052 * // => '\[lodash\]\(https://lodash\.com/\)' 16053 */ 16054 function escapeRegExp(string) {
vendor: 4,658 bytes, lines 16055-16224
16055 string = toString(string); 16056 return (string && reHasRegExpChar.test(string)) 16057 ? string.replace(reRegExpChar, '\\$&') 16058 : string; 16059 } 16060 16061 /** 16062 * Converts `string` to 16063 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 16064 * 16065 * @static 16066 * @memberOf _ 16067 * @since 3.0.0 16068 * @category String 16069 * @param {string} [string=''] The string to convert. 16070 * @returns {string} Returns the kebab cased string. 16071 * @example 16072 * 16073 * _.kebabCase('Foo Bar'); 16074 * // => 'foo-bar' 16075 * 16076 * _.kebabCase('fooBar'); 16077 * // => 'foo-bar' 16078 * 16079 * _.kebabCase('__FOO_BAR__'); 16080 * // => 'foo-bar' 16081 */ 16082 var kebabCase = createCompounder(function(result, word, index) { 16083 return result + (index ? '-' : '') + word.toLowerCase(); 16084 }); 16085 16086 /** 16087 * Converts `string`, as space separated words, to lower case. 16088 * 16089 * @static 16090 * @memberOf _ 16091 * @since 4.0.0 16092 * @category String 16093 * @param {string} [string=''] The string to convert. 16094 * @returns {string} Returns the lower cased string. 16095 * @example 16096 * 16097 * _.lowerCase('--Foo-Bar--'); 16098 * // => 'foo bar' 16099 * 16100 * _.lowerCase('fooBar'); 16101 * // => 'foo bar' 16102 * 16103 * _.lowerCase('__FOO_BAR__'); 16104 * // => 'foo bar' 16105 */ 16106 var lowerCase = createCompounder(function(result, word, index) { 16107 return result + (index ? ' ' : '') + word.toLowerCase(); 16108 }); 16109 16110 /** 16111 * Converts the first character of `string` to lower case. 16112 * 16113 * @static 16114 * @memberOf _ 16115 * @since 4.0.0 16116 * @category String 16117 * @param {string} [string=''] The string to convert. 16118 * @returns {string} Returns the converted string. 16119 * @example 16120 * 16121 * _.lowerFirst('Fred'); 16122 * // => 'fred' 16123 * 16124 * _.lowerFirst('FRED'); 16125 * // => 'fRED' 16126 */ 16127 var lowerFirst = createCaseFirst('toLowerCase'); 16128 16129 /** 16130 * Pads `string` on the left and right sides if it's shorter than `length`. 16131 * Padding characters are truncated if they can't be evenly divided by `length`. 16132 * 16133 * @static 16134 * @memberOf _ 16135 * @since 3.0.0 16136 * @category String 16137 * @param {string} [string=''] The string to pad. 16138 * @param {number} [length=0] The padding length. 16139 * @param {string} [chars=' '] The string used as padding. 16140 * @returns {string} Returns the padded string. 16141 * @example 16142 * 16143 * _.pad('abc', 8); 16144 * // => ' abc ' 16145 * 16146 * _.pad('abc', 8, '_-'); 16147 * // => '_-abc_-_' 16148 * 16149 * _.pad('abc', 3); 16150 * // => 'abc' 16151 */ 16152 function pad(string, length, chars) { 16153 string = toString(string); 16154 length = toInteger(length); 16155 16156 var strLength = length ? stringSize(string) : 0; 16157 if (!length || strLength >= length) { 16158 return string; 16159 } 16160 var mid = (length - strLength) / 2; 16161 return ( 16162 createPadding(nativeFloor(mid), chars) + 16163 string + 16164 createPadding(nativeCeil(mid), chars) 16165 ); 16166 } 16167 16168 /** 16169 * Pads `string` on the right side if it's shorter than `length`. Padding 16170 * characters are truncated if they exceed `length`. 16171 * 16172 * @static 16173 * @memberOf _ 16174 * @since 4.0.0 16175 * @category String 16176 * @param {string} [string=''] The string to pad. 16177 * @param {number} [length=0] The padding length. 16178 * @param {string} [chars=' '] The string used as padding. 16179 * @returns {string} Returns the padded string. 16180 * @example 16181 * 16182 * _.padEnd('abc', 6); 16183 * // => 'abc ' 16184 * 16185 * _.padEnd('abc', 6, '_-'); 16186 * // => 'abc_-_' 16187 * 16188 * _.padEnd('abc', 3); 16189 * // => 'abc' 16190 */ 16191 function padEnd(string, length, chars) { 16192 string = toString(string); 16193 length = toInteger(length); 16194 16195 var strLength = length ? stringSize(string) : 0; 16196 return (length && strLength < length) 16197 ? (string + createPadding(length - strLength, chars)) 16198 : string; 16199 } 16200 16201 /** 16202 * Pads `string` on the left side if it's shorter than `length`. Padding 16203 * characters are truncated if they exceed `length`. 16204 * 16205 * @static 16206 * @memberOf _ 16207 * @since 4.0.0 16208 * @category String 16209 * @param {string} [string=''] The string to pad. 16210 * @param {number} [length=0] The padding length. 16211 * @param {string} [chars=' '] The string used as padding. 16212 * @returns {string} Returns the padded string. 16213 * @example 16214 * 16215 * _.padStart('abc', 6); 16216 * // => ' abc' 16217 * 16218 * _.padStart('abc', 6, '_-'); 16219 * // => '_-_abc' 16220 * 16221 * _.padStart('abc', 3); 16222 * // => 'abc' 16223 */ 16224 function padStart(string, length, chars) {
vendor: 29,827 bytes, lines 16225-17122
16225 string = toString(string); 16226 length = toInteger(length); 16227 16228 var strLength = length ? stringSize(string) : 0; 16229 return (length && strLength < length) 16230 ? (createPadding(length - strLength, chars) + string) 16231 : string; 16232 } 16233 16234 /** 16235 * Converts `string` to an integer of the specified radix. If `radix` is 16236 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a 16237 * hexadecimal, in which case a `radix` of `16` is used. 16238 * 16239 * **Note:** This method aligns with the 16240 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`. 16241 * 16242 * @static 16243 * @memberOf _ 16244 * @since 1.1.0 16245 * @category String 16246 * @param {string} string The string to convert. 16247 * @param {number} [radix=10] The radix to interpret `value` by. 16248 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16249 * @returns {number} Returns the converted integer. 16250 * @example 16251 * 16252 * _.parseInt('08'); 16253 * // => 8 16254 * 16255 * _.map(['6', '08', '10'], _.parseInt); 16256 * // => [6, 8, 10] 16257 */ 16258 function parseInt(string, radix, guard) { 16259 if (guard || radix == null) { 16260 radix = 0; 16261 } else if (radix) { 16262 radix = +radix; 16263 } 16264 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0); 16265 } 16266 16267 /** 16268 * Repeats the given string `n` times. 16269 * 16270 * @static 16271 * @memberOf _ 16272 * @since 3.0.0 16273 * @category String 16274 * @param {string} [string=''] The string to repeat. 16275 * @param {number} [n=1] The number of times to repeat the string. 16276 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16277 * @returns {string} Returns the repeated string. 16278 * @example 16279 * 16280 * _.repeat('*', 3); 16281 * // => '***' 16282 * 16283 * _.repeat('abc', 2); 16284 * // => 'abcabc' 16285 * 16286 * _.repeat('abc', 0); 16287 * // => '' 16288 */ 16289 function repeat(string, n, guard) { 16290 if ((guard ? isIterateeCall(string, n, guard) : n === undefined)) { 16291 n = 1; 16292 } else { 16293 n = toInteger(n); 16294 } 16295 return baseRepeat(toString(string), n); 16296 } 16297 16298 /** 16299 * Replaces matches for `pattern` in `string` with `replacement`. 16300 * 16301 * **Note:** This method is based on 16302 * [`String#replace`](https://mdn.io/String/replace). 16303 * 16304 * @static 16305 * @memberOf _ 16306 * @since 4.0.0 16307 * @category String 16308 * @param {string} [string=''] The string to modify. 16309 * @param {RegExp|string} pattern The pattern to replace. 16310 * @param {Function|string} replacement The match replacement. 16311 * @returns {string} Returns the modified string. 16312 * @example 16313 * 16314 * _.replace('Hi Fred', 'Fred', 'Barney'); 16315 * // => 'Hi Barney' 16316 */ 16317 function replace() { 16318 var args = arguments, 16319 string = toString(args[0]); 16320 16321 return args.length < 3 ? string : string.replace(args[1], args[2]); 16322 } 16323 16324 /** 16325 * Converts `string` to 16326 * [snake case](https://en.wikipedia.org/wiki/Snake_case). 16327 * 16328 * @static 16329 * @memberOf _ 16330 * @since 3.0.0 16331 * @category String 16332 * @param {string} [string=''] The string to convert. 16333 * @returns {string} Returns the snake cased string. 16334 * @example 16335 * 16336 * _.snakeCase('Foo Bar'); 16337 * // => 'foo_bar' 16338 * 16339 * _.snakeCase('fooBar'); 16340 * // => 'foo_bar' 16341 * 16342 * _.snakeCase('--FOO-BAR--'); 16343 * // => 'foo_bar' 16344 */ 16345 var snakeCase = createCompounder(function(result, word, index) { 16346 return result + (index ? '_' : '') + word.toLowerCase(); 16347 }); 16348 16349 /** 16350 * Splits `string` by `separator`. 16351 * 16352 * **Note:** This method is based on 16353 * [`String#split`](https://mdn.io/String/split). 16354 * 16355 * @static 16356 * @memberOf _ 16357 * @since 4.0.0 16358 * @category String 16359 * @param {string} [string=''] The string to split. 16360 * @param {RegExp|string} separator The separator pattern to split by. 16361 * @param {number} [limit] The length to truncate results to. 16362 * @returns {Array} Returns the string segments. 16363 * @example 16364 * 16365 * _.split('a-b-c', '-', 2); 16366 * // => ['a', 'b'] 16367 */ 16368 function split(string, separator, limit) { 16369 if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) { 16370 separator = limit = undefined; 16371 } 16372 limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0; 16373 if (!limit) { 16374 return []; 16375 } 16376 string = toString(string); 16377 if (string && ( 16378 typeof separator == 'string' || 16379 (separator != null && !isRegExp(separator)) 16380 )) { 16381 separator = baseToString(separator); 16382 if (!separator && hasUnicode(string)) { 16383 return castSlice(stringToArray(string), 0, limit); 16384 } 16385 } 16386 return string.split(separator, limit); 16387 } 16388 16389 /** 16390 * Converts `string` to 16391 * [start case](https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage). 16392 * 16393 * @static 16394 * @memberOf _ 16395 * @since 3.1.0 16396 * @category String 16397 * @param {string} [string=''] The string to convert. 16398 * @returns {string} Returns the start cased string. 16399 * @example 16400 * 16401 * _.startCase('--foo-bar--'); 16402 * // => 'Foo Bar' 16403 * 16404 * _.startCase('fooBar'); 16405 * // => 'Foo Bar' 16406 * 16407 * _.startCase('__FOO_BAR__'); 16408 * // => 'FOO BAR' 16409 */ 16410 var startCase = createCompounder(function(result, word, index) { 16411 return result + (index ? ' ' : '') + upperFirst(word); 16412 }); 16413 16414 /** 16415 * Checks if `string` starts with the given target string. 16416 * 16417 * @static 16418 * @memberOf _ 16419 * @since 3.0.0 16420 * @category String 16421 * @param {string} [string=''] The string to inspect. 16422 * @param {string} [target] The string to search for. 16423 * @param {number} [position=0] The position to search from. 16424 * @returns {boolean} Returns `true` if `string` starts with `target`, 16425 * else `false`. 16426 * @example 16427 * 16428 * _.startsWith('abc', 'a'); 16429 * // => true 16430 * 16431 * _.startsWith('abc', 'b'); 16432 * // => false 16433 * 16434 * _.startsWith('abc', 'b', 1); 16435 * // => true 16436 */ 16437 function startsWith(string, target, position) { 16438 string = toString(string); 16439 position = position == null 16440 ? 0 16441 : baseClamp(toInteger(position), 0, string.length); 16442 16443 target = baseToString(target); 16444 return string.slice(position, position + target.length) == target; 16445 } 16446 16447 /** 16448 * Creates a compiled template function that can interpolate data properties 16449 * in "interpolate" delimiters, HTML-escape interpolated data properties in 16450 * "escape" delimiters, and execute JavaScript in "evaluate" delimiters. Data 16451 * properties may be accessed as free variables in the template. If a setting 16452 * object is given, it takes precedence over `_.templateSettings` values. 16453 * 16454 * **Note:** In the development build `_.template` utilizes 16455 * [sourceURLs](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl) 16456 * for easier debugging. 16457 * 16458 * For more information on precompiling templates see 16459 * [lodash's custom builds documentation](https://lodash.com/custom-builds). 16460 * 16461 * For more information on Chrome extension sandboxes see 16462 * [Chrome's extensions documentation](https://developer.chrome.com/extensions/sandboxingEval). 16463 * 16464 * @static 16465 * @since 0.1.0 16466 * @memberOf _ 16467 * @category String 16468 * @param {string} [string=''] The template string. 16469 * @param {Object} [options={}] The options object. 16470 * @param {RegExp} [options.escape=_.templateSettings.escape] 16471 * The HTML "escape" delimiter. 16472 * @param {RegExp} [options.evaluate=_.templateSettings.evaluate] 16473 * The "evaluate" delimiter. 16474 * @param {Object} [options.imports=_.templateSettings.imports] 16475 * An object to import into the template as free variables. 16476 * @param {RegExp} [options.interpolate=_.templateSettings.interpolate] 16477 * The "interpolate" delimiter. 16478 * @param {string} [options.sourceURL='lodash.templateSources[n]'] 16479 * The sourceURL of the compiled template. 16480 * @param {string} [options.variable='obj'] 16481 * The data object variable name. 16482 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16483 * @returns {Function} Returns the compiled template function. 16484 * @example 16485 * 16486 * // Use the "interpolate" delimiter to create a compiled template. 16487 * var compiled = _.template('hello <%= user %>!'); 16488 * compiled({ 'user': 'fred' }); 16489 * // => 'hello fred!' 16490 * 16491 * // Use the HTML "escape" delimiter to escape data property values. 16492 * var compiled = _.template('<b><%- value %></b>'); 16493 * compiled({ 'value': '<script>' }); 16494 * // => '<b><script></b>' 16495 * 16496 * // Use the "evaluate" delimiter to execute JavaScript and generate HTML. 16497 * var compiled = _.template('<% _.forEach(users, function(user) { %><li><%- user %></li><% }); %>'); 16498 * compiled({ 'users': ['fred', 'barney'] }); 16499 * // => '<li>fred</li><li>barney</li>' 16500 * 16501 * // Use the internal `print` function in "evaluate" delimiters. 16502 * var compiled = _.template('<% print("hello " + user); %>!'); 16503 * compiled({ 'user': 'barney' }); 16504 * // => 'hello barney!' 16505 * 16506 * // Use the ES template literal delimiter as an "interpolate" delimiter. 16507 * // Disable support by replacing the "interpolate" delimiter. 16508 * var compiled = _.template('hello ${ user }!'); 16509 * compiled({ 'user': 'pebbles' }); 16510 * // => 'hello pebbles!' 16511 * 16512 * // Use backslashes to treat delimiters as plain text. 16513 * var compiled = _.template('<%= "\\<%- value %\\>" %>'); 16514 * compiled({ 'value': 'ignored' }); 16515 * // => '<%- value %>' 16516 * 16517 * // Use the `imports` option to import `jQuery` as `jq`. 16518 * var text = '<% jq.each(users, function(user) { %><li><%- user %></li><% }); %>'; 16519 * var compiled = _.template(text, { 'imports': { 'jq': jQuery } }); 16520 * compiled({ 'users': ['fred', 'barney'] }); 16521 * // => '<li>fred</li><li>barney</li>' 16522 * 16523 * // Use the `sourceURL` option to specify a custom sourceURL for the template. 16524 * var compiled = _.template('hello <%= user %>!', { 'sourceURL': '/basic/greeting.jst' }); 16525 * compiled(data); 16526 * // => Find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector. 16527 * 16528 * // Use the `variable` option to ensure a with-statement isn't used in the compiled template. 16529 * var compiled = _.template('hi <%= data.user %>!', { 'variable': 'data' }); 16530 * compiled.source; 16531 * // => function(data) { 16532 * // var __t, __p = ''; 16533 * // __p += 'hi ' + ((__t = ( data.user )) == null ? '' : __t) + '!'; 16534 * // return __p; 16535 * // } 16536 * 16537 * // Use custom template delimiters. 16538 * _.templateSettings.interpolate = /{{([\s\S]+?)}}/g; 16539 * var compiled = _.template('hello {{ user }}!'); 16540 * compiled({ 'user': 'mustache' }); 16541 * // => 'hello mustache!' 16542 * 16543 * // Use the `source` property to inline compiled templates for meaningful 16544 * // line numbers in error messages and stack traces. 16545 * fs.writeFileSync(path.join(process.cwd(), 'jst.js'), '\ 16546 * var JST = {\ 16547 * "main": ' + _.template(mainText).source + '\ 16548 * };\ 16549 * '); 16550 */ 16551 function template(string, options, guard) { 16552 // Based on John Resig's `tmpl` implementation 16553 // (http://ejohn.org/blog/javascript-micro-templating/) 16554 // and Laura Doktorova's doT.js (https://github.com/olado/doT). 16555 var settings = lodash.templateSettings; 16556 16557 if (guard && isIterateeCall(string, options, guard)) { 16558 options = undefined; 16559 } 16560 string = toString(string); 16561 options = assignInWith({}, options, settings, customDefaultsAssignIn); 16562 16563 var imports = assignInWith({}, options.imports, settings.imports, customDefaultsAssignIn), 16564 importsKeys = keys(imports), 16565 importsValues = baseValues(imports, importsKeys); 16566 16567 var isEscaping, 16568 isEvaluating, 16569 index = 0, 16570 interpolate = options.interpolate || reNoMatch, 16571 source = "__p += '"; 16572 16573 // Compile the regexp to match each delimiter. 16574 var reDelimiters = RegExp( 16575 (options.escape || reNoMatch).source + '|' + 16576 interpolate.source + '|' + 16577 (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' + 16578 (options.evaluate || reNoMatch).source + '|$' 16579 , 'g'); 16580 16581 // Use a sourceURL for easier debugging. 16582 // The sourceURL gets injected into the source that's eval-ed, so be careful 16583 // to normalize all kinds of whitespace, so e.g. newlines (and unicode versions of it) can't sneak in 16584 // and escape the comment, thus injecting code that gets evaled. 16585 var sourceURL = '//# sourceURL=' + 16586 (hasOwnProperty.call(options, 'sourceURL') 16587 ? (options.sourceURL + '').replace(/\s/g, ' ') 16588 : ('lodash.templateSources[' + (++templateCounter) + ']') 16589 ) + '\n'; 16590 16591 string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) { 16592 interpolateValue || (interpolateValue = esTemplateValue); 16593 16594 // Escape characters that can't be included in string literals. 16595 source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar); 16596 16597 // Replace delimiters with snippets. 16598 if (escapeValue) { 16599 isEscaping = true; 16600 source += "' +\n__e(" + escapeValue + ") +\n'"; 16601 } 16602 if (evaluateValue) { 16603 isEvaluating = true; 16604 source += "';\n" + evaluateValue + ";\n__p += '"; 16605 } 16606 if (interpolateValue) { 16607 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'"; 16608 } 16609 index = offset + match.length; 16610 16611 // The JS engine embedded in Adobe products needs `match` returned in 16612 // order to produce the correct `offset` value. 16613 return match; 16614 }); 16615 16616 source += "';\n"; 16617 16618 // If `variable` is not specified wrap a with-statement around the generated 16619 // code to add the data object to the top of the scope chain. 16620 var variable = hasOwnProperty.call(options, 'variable') && options.variable; 16621 if (!variable) { 16622 source = 'with (obj) {\n' + source + '\n}\n'; 16623 } 16624 // Throw an error if a forbidden character was found in `variable`, to prevent 16625 // potential command injection attacks. 16626 else if (reForbiddenIdentifierChars.test(variable)) { 16627 throw new Error(INVALID_TEMPL_VAR_ERROR_TEXT); 16628 } 16629 16630 // Cleanup code by stripping empty strings. 16631 source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source) 16632 .replace(reEmptyStringMiddle, '$1') 16633 .replace(reEmptyStringTrailing, '$1;'); 16634 16635 // Frame code as the function body. 16636 source = 'function(' + (variable || 'obj') + ') {\n' + 16637 (variable 16638 ? '' 16639 : 'obj || (obj = {});\n' 16640 ) + 16641 "var __t, __p = ''" + 16642 (isEscaping 16643 ? ', __e = _.escape' 16644 : '' 16645 ) + 16646 (isEvaluating 16647 ? ', __j = Array.prototype.join;\n' + 16648 "function print() { __p += __j.call(arguments, '') }\n" 16649 : ';\n' 16650 ) + 16651 source + 16652 'return __p\n}'; 16653 16654 var result = attempt(function() { 16655 return Function(importsKeys, sourceURL + 'return ' + source) 16656 .apply(undefined, importsValues); 16657 }); 16658 16659 // Provide the compiled function's source by its `toString` method or 16660 // the `source` property as a convenience for inlining compiled templates. 16661 result.source = source; 16662 if (isError(result)) { 16663 throw result; 16664 } 16665 return result; 16666 } 16667 16668 /** 16669 * Converts `string`, as a whole, to lower case just like 16670 * [String#toLowerCase](https://mdn.io/toLowerCase). 16671 * 16672 * @static 16673 * @memberOf _ 16674 * @since 4.0.0 16675 * @category String 16676 * @param {string} [string=''] The string to convert. 16677 * @returns {string} Returns the lower cased string. 16678 * @example 16679 * 16680 * _.toLower('--Foo-Bar--'); 16681 * // => '--foo-bar--' 16682 * 16683 * _.toLower('fooBar'); 16684 * // => 'foobar' 16685 * 16686 * _.toLower('__FOO_BAR__'); 16687 * // => '__foo_bar__' 16688 */ 16689 function toLower(value) { 16690 return toString(value).toLowerCase(); 16691 } 16692 16693 /** 16694 * Converts `string`, as a whole, to upper case just like 16695 * [String#toUpperCase](https://mdn.io/toUpperCase). 16696 * 16697 * @static 16698 * @memberOf _ 16699 * @since 4.0.0 16700 * @category String 16701 * @param {string} [string=''] The string to convert. 16702 * @returns {string} Returns the upper cased string. 16703 * @example 16704 * 16705 * _.toUpper('--foo-bar--'); 16706 * // => '--FOO-BAR--' 16707 * 16708 * _.toUpper('fooBar'); 16709 * // => 'FOOBAR' 16710 * 16711 * _.toUpper('__foo_bar__'); 16712 * // => '__FOO_BAR__' 16713 */ 16714 function toUpper(value) { 16715 return toString(value).toUpperCase(); 16716 } 16717 16718 /** 16719 * Removes leading and trailing whitespace or specified characters from `string`. 16720 * 16721 * @static 16722 * @memberOf _ 16723 * @since 3.0.0 16724 * @category String 16725 * @param {string} [string=''] The string to trim. 16726 * @param {string} [chars=whitespace] The characters to trim. 16727 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16728 * @returns {string} Returns the trimmed string. 16729 * @example 16730 * 16731 * _.trim(' abc '); 16732 * // => 'abc' 16733 * 16734 * _.trim('-_-abc-_-', '_-'); 16735 * // => 'abc' 16736 * 16737 * _.map([' foo ', ' bar '], _.trim); 16738 * // => ['foo', 'bar'] 16739 */ 16740 function trim(string, chars, guard) { 16741 string = toString(string); 16742 if (string && (guard || chars === undefined)) { 16743 return baseTrim(string); 16744 } 16745 if (!string || !(chars = baseToString(chars))) { 16746 return string; 16747 } 16748 var strSymbols = stringToArray(string), 16749 chrSymbols = stringToArray(chars), 16750 start = charsStartIndex(strSymbols, chrSymbols), 16751 end = charsEndIndex(strSymbols, chrSymbols) + 1; 16752 16753 return castSlice(strSymbols, start, end).join(''); 16754 } 16755 16756 /** 16757 * Removes trailing whitespace or specified characters from `string`. 16758 * 16759 * @static 16760 * @memberOf _ 16761 * @since 4.0.0 16762 * @category String 16763 * @param {string} [string=''] The string to trim. 16764 * @param {string} [chars=whitespace] The characters to trim. 16765 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16766 * @returns {string} Returns the trimmed string. 16767 * @example 16768 * 16769 * _.trimEnd(' abc '); 16770 * // => ' abc' 16771 * 16772 * _.trimEnd('-_-abc-_-', '_-'); 16773 * // => '-_-abc' 16774 */ 16775 function trimEnd(string, chars, guard) { 16776 string = toString(string); 16777 if (string && (guard || chars === undefined)) { 16778 return string.slice(0, trimmedEndIndex(string) + 1); 16779 } 16780 if (!string || !(chars = baseToString(chars))) { 16781 return string; 16782 } 16783 var strSymbols = stringToArray(string), 16784 end = charsEndIndex(strSymbols, stringToArray(chars)) + 1; 16785 16786 return castSlice(strSymbols, 0, end).join(''); 16787 } 16788 16789 /** 16790 * Removes leading whitespace or specified characters from `string`. 16791 * 16792 * @static 16793 * @memberOf _ 16794 * @since 4.0.0 16795 * @category String 16796 * @param {string} [string=''] The string to trim. 16797 * @param {string} [chars=whitespace] The characters to trim. 16798 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16799 * @returns {string} Returns the trimmed string. 16800 * @example 16801 * 16802 * _.trimStart(' abc '); 16803 * // => 'abc ' 16804 * 16805 * _.trimStart('-_-abc-_-', '_-'); 16806 * // => 'abc-_-' 16807 */ 16808 function trimStart(string, chars, guard) { 16809 string = toString(string); 16810 if (string && (guard || chars === undefined)) { 16811 return string.replace(reTrimStart, ''); 16812 } 16813 if (!string || !(chars = baseToString(chars))) { 16814 return string; 16815 } 16816 var strSymbols = stringToArray(string), 16817 start = charsStartIndex(strSymbols, stringToArray(chars)); 16818 16819 return castSlice(strSymbols, start).join(''); 16820 } 16821 16822 /** 16823 * Truncates `string` if it's longer than the given maximum string length. 16824 * The last characters of the truncated string are replaced with the omission 16825 * string which defaults to "...". 16826 * 16827 * @static 16828 * @memberOf _ 16829 * @since 4.0.0 16830 * @category String 16831 * @param {string} [string=''] The string to truncate. 16832 * @param {Object} [options={}] The options object. 16833 * @param {number} [options.length=30] The maximum string length. 16834 * @param {string} [options.omission='...'] The string to indicate text is omitted. 16835 * @param {RegExp|string} [options.separator] The separator pattern to truncate to. 16836 * @returns {string} Returns the truncated string. 16837 * @example 16838 * 16839 * _.truncate('hi-diddly-ho there, neighborino'); 16840 * // => 'hi-diddly-ho there, neighbo...' 16841 * 16842 * _.truncate('hi-diddly-ho there, neighborino', { 16843 * 'length': 24, 16844 * 'separator': ' ' 16845 * }); 16846 * // => 'hi-diddly-ho there,...' 16847 * 16848 * _.truncate('hi-diddly-ho there, neighborino', { 16849 * 'length': 24, 16850 * 'separator': /,? +/ 16851 * }); 16852 * // => 'hi-diddly-ho there...' 16853 * 16854 * _.truncate('hi-diddly-ho there, neighborino', { 16855 * 'omission': ' [...]' 16856 * }); 16857 * // => 'hi-diddly-ho there, neig [...]' 16858 */ 16859 function truncate(string, options) { 16860 var length = DEFAULT_TRUNC_LENGTH, 16861 omission = DEFAULT_TRUNC_OMISSION; 16862 16863 if (isObject(options)) { 16864 var separator = 'separator' in options ? options.separator : separator; 16865 length = 'length' in options ? toInteger(options.length) : length; 16866 omission = 'omission' in options ? baseToString(options.omission) : omission; 16867 } 16868 string = toString(string); 16869 16870 var strLength = string.length; 16871 if (hasUnicode(string)) { 16872 var strSymbols = stringToArray(string); 16873 strLength = strSymbols.length; 16874 } 16875 if (length >= strLength) { 16876 return string; 16877 } 16878 var end = length - stringSize(omission); 16879 if (end < 1) { 16880 return omission; 16881 } 16882 var result = strSymbols 16883 ? castSlice(strSymbols, 0, end).join('') 16884 : string.slice(0, end); 16885 16886 if (separator === undefined) { 16887 return result + omission; 16888 } 16889 if (strSymbols) { 16890 end += (result.length - end); 16891 } 16892 if (isRegExp(separator)) { 16893 if (string.slice(end).search(separator)) { 16894 var match, 16895 substring = result; 16896 16897 if (!separator.global) { 16898 separator = RegExp(separator.source, toString(reFlags.exec(separator)) + 'g'); 16899 } 16900 separator.lastIndex = 0; 16901 while ((match = separator.exec(substring))) { 16902 var newEnd = match.index; 16903 } 16904 result = result.slice(0, newEnd === undefined ? end : newEnd); 16905 } 16906 } else if (string.indexOf(baseToString(separator), end) != end) { 16907 var index = result.lastIndexOf(separator); 16908 if (index > -1) { 16909 result = result.slice(0, index); 16910 } 16911 } 16912 return result + omission; 16913 } 16914 16915 /** 16916 * The inverse of `_.escape`; this method converts the HTML entities 16917 * `&`, `<`, `>`, `"`, and `'` in `string` to 16918 * their corresponding characters. 16919 * 16920 * **Note:** No other HTML entities are unescaped. To unescape additional 16921 * HTML entities use a third-party library like [_he_](https://mths.be/he). 16922 * 16923 * @static 16924 * @memberOf _ 16925 * @since 0.6.0 16926 * @category String 16927 * @param {string} [string=''] The string to unescape. 16928 * @returns {string} Returns the unescaped string. 16929 * @example 16930 * 16931 * _.unescape('fred, barney, & pebbles'); 16932 * // => 'fred, barney, & pebbles' 16933 */ 16934 function unescape(string) { 16935 string = toString(string); 16936 return (string && reHasEscapedHtml.test(string)) 16937 ? string.replace(reEscapedHtml, unescapeHtmlChar) 16938 : string; 16939 } 16940 16941 /** 16942 * Converts `string`, as space separated words, to upper case. 16943 * 16944 * @static 16945 * @memberOf _ 16946 * @since 4.0.0 16947 * @category String 16948 * @param {string} [string=''] The string to convert. 16949 * @returns {string} Returns the upper cased string. 16950 * @example 16951 * 16952 * _.upperCase('--foo-bar'); 16953 * // => 'FOO BAR' 16954 * 16955 * _.upperCase('fooBar'); 16956 * // => 'FOO BAR' 16957 * 16958 * _.upperCase('__foo_bar__'); 16959 * // => 'FOO BAR' 16960 */ 16961 var upperCase = createCompounder(function(result, word, index) { 16962 return result + (index ? ' ' : '') + word.toUpperCase(); 16963 }); 16964 16965 /** 16966 * Converts the first character of `string` to upper case. 16967 * 16968 * @static 16969 * @memberOf _ 16970 * @since 4.0.0 16971 * @category String 16972 * @param {string} [string=''] The string to convert. 16973 * @returns {string} Returns the converted string. 16974 * @example 16975 * 16976 * _.upperFirst('fred'); 16977 * // => 'Fred' 16978 * 16979 * _.upperFirst('FRED'); 16980 * // => 'FRED' 16981 */ 16982 var upperFirst = createCaseFirst('toUpperCase'); 16983 16984 /** 16985 * Splits `string` into an array of its words. 16986 * 16987 * @static 16988 * @memberOf _ 16989 * @since 3.0.0 16990 * @category String 16991 * @param {string} [string=''] The string to inspect. 16992 * @param {RegExp|string} [pattern] The pattern to match words. 16993 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 16994 * @returns {Array} Returns the words of `string`. 16995 * @example 16996 * 16997 * _.words('fred, barney, & pebbles'); 16998 * // => ['fred', 'barney', 'pebbles'] 16999 * 17000 * _.words('fred, barney, & pebbles', /[^, ]+/g); 17001 * // => ['fred', 'barney', '&', 'pebbles'] 17002 */ 17003 function words(string, pattern, guard) { 17004 string = toString(string); 17005 pattern = guard ? undefined : pattern; 17006 17007 if (pattern === undefined) { 17008 return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string); 17009 } 17010 return string.match(pattern) || []; 17011 } 17012 17013 /*------------------------------------------------------------------------*/ 17014 17015 /** 17016 * Attempts to invoke `func`, returning either the result or the caught error 17017 * object. Any additional arguments are provided to `func` when it's invoked. 17018 * 17019 * @static 17020 * @memberOf _ 17021 * @since 3.0.0 17022 * @category Util 17023 * @param {Function} func The function to attempt. 17024 * @param {...*} [args] The arguments to invoke `func` with. 17025 * @returns {*} Returns the `func` result or error object. 17026 * @example 17027 * 17028 * // Avoid throwing errors for invalid selectors. 17029 * var elements = _.attempt(function(selector) { 17030 * return document.querySelectorAll(selector); 17031 * }, '>_>'); 17032 * 17033 * if (_.isError(elements)) { 17034 * elements = []; 17035 * } 17036 */ 17037 var attempt = baseRest(function(func, args) { 17038 try { 17039 return apply(func, undefined, args); 17040 } catch (e) { 17041 return isError(e) ? e : new Error(e); 17042 } 17043 }); 17044 17045 /** 17046 * Binds methods of an object to the object itself, overwriting the existing 17047 * method. 17048 * 17049 * **Note:** This method doesn't set the "length" property of bound functions. 17050 * 17051 * @static 17052 * @since 0.1.0 17053 * @memberOf _ 17054 * @category Util 17055 * @param {Object} object The object to bind and assign the bound methods to. 17056 * @param {...(string|string[])} methodNames The object method names to bind. 17057 * @returns {Object} Returns `object`. 17058 * @example 17059 * 17060 * var view = { 17061 * 'label': 'docs', 17062 * 'click': function() { 17063 * console.log('clicked ' + this.label); 17064 * } 17065 * }; 17066 * 17067 * _.bindAll(view, ['click']); 17068 * jQuery(element).on('click', view.click); 17069 * // => Logs 'clicked docs' when clicked. 17070 */ 17071 var bindAll = flatRest(function(object, methodNames) { 17072 arrayEach(methodNames, function(key) { 17073 key = toKey(key); 17074 baseAssignValue(object, key, bind(object[key], object)); 17075 }); 17076 return object; 17077 }); 17078 17079 /** 17080 * Creates a function that iterates over `pairs` and invokes the corresponding 17081 * function of the first predicate to return truthy. The predicate-function 17082 * pairs are invoked with the `this` binding and arguments of the created 17083 * function. 17084 * 17085 * @static 17086 * @memberOf _ 17087 * @since 4.0.0 17088 * @category Util 17089 * @param {Array} pairs The predicate-function pairs. 17090 * @returns {Function} Returns the new composite function. 17091 * @example 17092 * 17093 * var func = _.cond([ 17094 * [_.matches({ 'a': 1 }), _.constant('matches A')], 17095 * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], 17096 * [_.stubTrue, _.constant('no match')] 17097 * ]); 17098 * 17099 * func({ 'a': 1, 'b': 2 }); 17100 * // => 'matches A' 17101 * 17102 * func({ 'a': 0, 'b': 1 }); 17103 * // => 'matches B' 17104 * 17105 * func({ 'a': '1', 'b': '2' }); 17106 * // => 'no match' 17107 */ 17108 function cond(pairs) { 17109 var length = pairs == null ? 0 : pairs.length, 17110 toIteratee = getIteratee(); 17111 17112 pairs = !length ? [] : arrayMap(pairs, function(pair) { 17113 if (typeof pair[1] != 'function') { 17114 throw new TypeError(FUNC_ERROR_TEXT); 17115 } 17116 return [toIteratee(pair[0]), pair[1]]; 17117 }); 17118 17119 return baseRest(function(args) { 17120 var index = -1; 17121 while (++index < length) { 17122 var pair = pairs[index];
vendor: 10,296 bytes, lines 17123-17455
17123 if (apply(pair[0], this, args)) { 17124 return apply(pair[1], this, args); 17125 } 17126 } 17127 }); 17128 } 17129 17130 /** 17131 * Creates a function that invokes the predicate properties of `source` with 17132 * the corresponding property values of a given object, returning `true` if 17133 * all predicates return truthy, else `false`. 17134 * 17135 * **Note:** The created function is equivalent to `_.conformsTo` with 17136 * `source` partially applied. 17137 * 17138 * @static 17139 * @memberOf _ 17140 * @since 4.0.0 17141 * @category Util 17142 * @param {Object} source The object of property predicates to conform to. 17143 * @returns {Function} Returns the new spec function. 17144 * @example 17145 * 17146 * var objects = [ 17147 * { 'a': 2, 'b': 1 }, 17148 * { 'a': 1, 'b': 2 } 17149 * ]; 17150 * 17151 * _.filter(objects, _.conforms({ 'b': function(n) { return n > 1; } })); 17152 * // => [{ 'a': 1, 'b': 2 }] 17153 */ 17154 function conforms(source) { 17155 return baseConforms(baseClone(source, CLONE_DEEP_FLAG)); 17156 } 17157 17158 /** 17159 * Creates a function that returns `value`. 17160 * 17161 * @static 17162 * @memberOf _ 17163 * @since 2.4.0 17164 * @category Util 17165 * @param {*} value The value to return from the new function. 17166 * @returns {Function} Returns the new constant function. 17167 * @example 17168 * 17169 * var objects = _.times(2, _.constant({ 'a': 1 })); 17170 * 17171 * console.log(objects); 17172 * // => [{ 'a': 1 }, { 'a': 1 }] 17173 * 17174 * console.log(objects[0] === objects[1]); 17175 * // => true 17176 */ 17177 function constant(value) { 17178 return function() { 17179 return value; 17180 }; 17181 } 17182 17183 /** 17184 * Checks `value` to determine whether a default value should be returned in 17185 * its place. The `defaultValue` is returned if `value` is `NaN`, `null`, 17186 * or `undefined`. 17187 * 17188 * @static 17189 * @memberOf _ 17190 * @since 4.14.0 17191 * @category Util 17192 * @param {*} value The value to check. 17193 * @param {*} defaultValue The default value. 17194 * @returns {*} Returns the resolved value. 17195 * @example 17196 * 17197 * _.defaultTo(1, 10); 17198 * // => 1 17199 * 17200 * _.defaultTo(undefined, 10); 17201 * // => 10 17202 */ 17203 function defaultTo(value, defaultValue) { 17204 return (value == null || value !== value) ? defaultValue : value; 17205 } 17206 17207 /** 17208 * Creates a function that returns the result of invoking the given functions 17209 * with the `this` binding of the created function, where each successive 17210 * invocation is supplied the return value of the previous. 17211 * 17212 * @static 17213 * @memberOf _ 17214 * @since 3.0.0 17215 * @category Util 17216 * @param {...(Function|Function[])} [funcs] The functions to invoke. 17217 * @returns {Function} Returns the new composite function. 17218 * @see _.flowRight 17219 * @example 17220 * 17221 * function square(n) { 17222 * return n * n; 17223 * } 17224 * 17225 * var addSquare = _.flow([_.add, square]); 17226 * addSquare(1, 2); 17227 * // => 9 17228 */ 17229 var flow = createFlow(); 17230 17231 /** 17232 * This method is like `_.flow` except that it creates a function that 17233 * invokes the given functions from right to left. 17234 * 17235 * @static 17236 * @since 3.0.0 17237 * @memberOf _ 17238 * @category Util 17239 * @param {...(Function|Function[])} [funcs] The functions to invoke. 17240 * @returns {Function} Returns the new composite function. 17241 * @see _.flow 17242 * @example 17243 * 17244 * function square(n) { 17245 * return n * n; 17246 * } 17247 * 17248 * var addSquare = _.flowRight([square, _.add]); 17249 * addSquare(1, 2); 17250 * // => 9 17251 */ 17252 var flowRight = createFlow(true); 17253 17254 /** 17255 * This method returns the first argument it receives. 17256 * 17257 * @static 17258 * @since 0.1.0 17259 * @memberOf _ 17260 * @category Util 17261 * @param {*} value Any value. 17262 * @returns {*} Returns `value`. 17263 * @example 17264 * 17265 * var object = { 'a': 1 }; 17266 * 17267 * console.log(_.identity(object) === object); 17268 * // => true 17269 */ 17270 function identity(value) { 17271 return value; 17272 } 17273 17274 /** 17275 * Creates a function that invokes `func` with the arguments of the created 17276 * function. If `func` is a property name, the created function returns the 17277 * property value for a given element. If `func` is an array or object, the 17278 * created function returns `true` for elements that contain the equivalent 17279 * source properties, otherwise it returns `false`. 17280 * 17281 * @static 17282 * @since 4.0.0 17283 * @memberOf _ 17284 * @category Util 17285 * @param {*} [func=_.identity] The value to convert to a callback. 17286 * @returns {Function} Returns the callback. 17287 * @example 17288 * 17289 * var users = [ 17290 * { 'user': 'barney', 'age': 36, 'active': true }, 17291 * { 'user': 'fred', 'age': 40, 'active': false } 17292 * ]; 17293 * 17294 * // The `_.matches` iteratee shorthand. 17295 * _.filter(users, _.iteratee({ 'user': 'barney', 'active': true })); 17296 * // => [{ 'user': 'barney', 'age': 36, 'active': true }] 17297 * 17298 * // The `_.matchesProperty` iteratee shorthand. 17299 * _.filter(users, _.iteratee(['user', 'fred'])); 17300 * // => [{ 'user': 'fred', 'age': 40 }] 17301 * 17302 * // The `_.property` iteratee shorthand. 17303 * _.map(users, _.iteratee('user')); 17304 * // => ['barney', 'fred'] 17305 * 17306 * // Create custom iteratee shorthands. 17307 * _.iteratee = _.wrap(_.iteratee, function(iteratee, func) { 17308 * return !_.isRegExp(func) ? iteratee(func) : function(string) { 17309 * return func.test(string); 17310 * }; 17311 * }); 17312 * 17313 * _.filter(['abc', 'def'], /ef/); 17314 * // => ['def'] 17315 */ 17316 function iteratee(func) { 17317 return baseIteratee(typeof func == 'function' ? func : baseClone(func, CLONE_DEEP_FLAG)); 17318 } 17319 17320 /** 17321 * Creates a function that performs a partial deep comparison between a given 17322 * object and `source`, returning `true` if the given object has equivalent 17323 * property values, else `false`. 17324 * 17325 * **Note:** The created function is equivalent to `_.isMatch` with `source` 17326 * partially applied. 17327 * 17328 * Partial comparisons will match empty array and empty object `source` 17329 * values against any array or object value, respectively. See `_.isEqual` 17330 * for a list of supported value comparisons. 17331 * 17332 * **Note:** Multiple values can be checked by combining several matchers 17333 * using `_.overSome` 17334 * 17335 * @static 17336 * @memberOf _ 17337 * @since 3.0.0 17338 * @category Util 17339 * @param {Object} source The object of property values to match. 17340 * @returns {Function} Returns the new spec function. 17341 * @example 17342 * 17343 * var objects = [ 17344 * { 'a': 1, 'b': 2, 'c': 3 }, 17345 * { 'a': 4, 'b': 5, 'c': 6 } 17346 * ]; 17347 * 17348 * _.filter(objects, _.matches({ 'a': 4, 'c': 6 })); 17349 * // => [{ 'a': 4, 'b': 5, 'c': 6 }] 17350 * 17351 * // Checking for several possible values 17352 * _.filter(objects, _.overSome([_.matches({ 'a': 1 }), _.matches({ 'a': 4 })])); 17353 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 17354 */ 17355 function matches(source) { 17356 return baseMatches(baseClone(source, CLONE_DEEP_FLAG)); 17357 } 17358 17359 /** 17360 * Creates a function that performs a partial deep comparison between the 17361 * value at `path` of a given object to `srcValue`, returning `true` if the 17362 * object value is equivalent, else `false`. 17363 * 17364 * **Note:** Partial comparisons will match empty array and empty object 17365 * `srcValue` values against any array or object value, respectively. See 17366 * `_.isEqual` for a list of supported value comparisons. 17367 * 17368 * **Note:** Multiple values can be checked by combining several matchers 17369 * using `_.overSome` 17370 * 17371 * @static 17372 * @memberOf _ 17373 * @since 3.2.0 17374 * @category Util 17375 * @param {Array|string} path The path of the property to get. 17376 * @param {*} srcValue The value to match. 17377 * @returns {Function} Returns the new spec function. 17378 * @example 17379 * 17380 * var objects = [ 17381 * { 'a': 1, 'b': 2, 'c': 3 }, 17382 * { 'a': 4, 'b': 5, 'c': 6 } 17383 * ]; 17384 * 17385 * _.find(objects, _.matchesProperty('a', 4)); 17386 * // => { 'a': 4, 'b': 5, 'c': 6 } 17387 * 17388 * // Checking for several possible values 17389 * _.filter(objects, _.overSome([_.matchesProperty('a', 1), _.matchesProperty('a', 4)])); 17390 * // => [{ 'a': 1, 'b': 2, 'c': 3 }, { 'a': 4, 'b': 5, 'c': 6 }] 17391 */ 17392 function matchesProperty(path, srcValue) { 17393 return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG)); 17394 } 17395 17396 /** 17397 * Creates a function that invokes the method at `path` of a given object. 17398 * Any additional arguments are provided to the invoked method. 17399 * 17400 * @static 17401 * @memberOf _ 17402 * @since 3.7.0 17403 * @category Util 17404 * @param {Array|string} path The path of the method to invoke. 17405 * @param {...*} [args] The arguments to invoke the method with. 17406 * @returns {Function} Returns the new invoker function. 17407 * @example 17408 * 17409 * var objects = [ 17410 * { 'a': { 'b': _.constant(2) } }, 17411 * { 'a': { 'b': _.constant(1) } } 17412 * ]; 17413 * 17414 * _.map(objects, _.method('a.b')); 17415 * // => [2, 1] 17416 * 17417 * _.map(objects, _.method(['a', 'b'])); 17418 * // => [2, 1] 17419 */ 17420 var method = baseRest(function(path, args) { 17421 return function(object) { 17422 return baseInvoke(object, path, args); 17423 }; 17424 }); 17425 17426 /** 17427 * The opposite of `_.method`; this method creates a function that invokes 17428 * the method at a given path of `object`. Any additional arguments are 17429 * provided to the invoked method. 17430 * 17431 * @static 17432 * @memberOf _ 17433 * @since 3.7.0 17434 * @category Util 17435 * @param {Object} object The object to query. 17436 * @param {...*} [args] The arguments to invoke the method with. 17437 * @returns {Function} Returns the new invoker function. 17438 * @example 17439 * 17440 * var array = _.times(3, _.constant), 17441 * object = { 'a': array, 'b': array, 'c': array }; 17442 * 17443 * _.map(['a[2]', 'c[0]'], _.methodOf(object)); 17444 * // => [2, 0] 17445 * 17446 * _.map([['a', '2'], ['c', '0']], _.methodOf(object)); 17447 * // => [2, 0] 17448 */ 17449 var methodOf = baseRest(function(object, args) { 17450 return function(path) { 17451 return baseInvoke(object, path, args); 17452 }; 17453 }); 17454 17455 /**
vendor: 10,734 bytes, lines 17456-17843
17456 * Adds all own enumerable string keyed function properties of a source 17457 * object to the destination object. If `object` is a function, then methods 17458 * are added to its prototype as well. 17459 * 17460 * **Note:** Use `_.runInContext` to create a pristine `lodash` function to 17461 * avoid conflicts caused by modifying the original. 17462 * 17463 * @static 17464 * @since 0.1.0 17465 * @memberOf _ 17466 * @category Util 17467 * @param {Function|Object} [object=lodash] The destination object. 17468 * @param {Object} source The object of functions to add. 17469 * @param {Object} [options={}] The options object. 17470 * @param {boolean} [options.chain=true] Specify whether mixins are chainable. 17471 * @returns {Function|Object} Returns `object`. 17472 * @example 17473 * 17474 * function vowels(string) { 17475 * return _.filter(string, function(v) { 17476 * return /[aeiou]/i.test(v); 17477 * }); 17478 * } 17479 * 17480 * _.mixin({ 'vowels': vowels }); 17481 * _.vowels('fred'); 17482 * // => ['e'] 17483 * 17484 * _('fred').vowels().value(); 17485 * // => ['e'] 17486 * 17487 * _.mixin({ 'vowels': vowels }, { 'chain': false }); 17488 * _('fred').vowels(); 17489 * // => ['e'] 17490 */ 17491 function mixin(object, source, options) { 17492 var props = keys(source), 17493 methodNames = baseFunctions(source, props); 17494 17495 if (options == null && 17496 !(isObject(source) && (methodNames.length || !props.length))) { 17497 options = source; 17498 source = object; 17499 object = this; 17500 methodNames = baseFunctions(source, keys(source)); 17501 } 17502 var chain = !(isObject(options) && 'chain' in options) || !!options.chain, 17503 isFunc = isFunction(object); 17504 17505 arrayEach(methodNames, function(methodName) { 17506 var func = source[methodName]; 17507 object[methodName] = func; 17508 if (isFunc) { 17509 object.prototype[methodName] = function() { 17510 var chainAll = this.__chain__; 17511 if (chain || chainAll) { 17512 var result = object(this.__wrapped__), 17513 actions = result.__actions__ = copyArray(this.__actions__); 17514 17515 actions.push({ 'func': func, 'args': arguments, 'thisArg': object }); 17516 result.__chain__ = chainAll; 17517 return result; 17518 } 17519 return func.apply(object, arrayPush([this.value()], arguments)); 17520 }; 17521 } 17522 }); 17523 17524 return object; 17525 } 17526 17527 /** 17528 * Reverts the `_` variable to its previous value and returns a reference to 17529 * the `lodash` function. 17530 * 17531 * @static 17532 * @since 0.1.0 17533 * @memberOf _ 17534 * @category Util 17535 * @returns {Function} Returns the `lodash` function. 17536 * @example 17537 * 17538 * var lodash = _.noConflict(); 17539 */ 17540 function noConflict() { 17541 if (root._ === this) { 17542 root._ = oldDash; 17543 } 17544 return this; 17545 } 17546 17547 /** 17548 * This method returns `undefined`. 17549 * 17550 * @static 17551 * @memberOf _ 17552 * @since 2.3.0 17553 * @category Util 17554 * @example 17555 * 17556 * _.times(2, _.noop); 17557 * // => [undefined, undefined] 17558 */ 17559 function noop() { 17560 // No operation performed. 17561 } 17562 17563 /** 17564 * Creates a function that gets the argument at index `n`. If `n` is negative, 17565 * the nth argument from the end is returned. 17566 * 17567 * @static 17568 * @memberOf _ 17569 * @since 4.0.0 17570 * @category Util 17571 * @param {number} [n=0] The index of the argument to return. 17572 * @returns {Function} Returns the new pass-thru function. 17573 * @example 17574 * 17575 * var func = _.nthArg(1); 17576 * func('a', 'b', 'c', 'd'); 17577 * // => 'b' 17578 * 17579 * var func = _.nthArg(-2); 17580 * func('a', 'b', 'c', 'd'); 17581 * // => 'c' 17582 */ 17583 function nthArg(n) { 17584 n = toInteger(n); 17585 return baseRest(function(args) { 17586 return baseNth(args, n); 17587 }); 17588 } 17589 17590 /** 17591 * Creates a function that invokes `iteratees` with the arguments it receives 17592 * and returns their results. 17593 * 17594 * @static 17595 * @memberOf _ 17596 * @since 4.0.0 17597 * @category Util 17598 * @param {...(Function|Function[])} [iteratees=[_.identity]] 17599 * The iteratees to invoke. 17600 * @returns {Function} Returns the new function. 17601 * @example 17602 * 17603 * var func = _.over([Math.max, Math.min]); 17604 * 17605 * func(1, 2, 3, 4); 17606 * // => [4, 1] 17607 */ 17608 var over = createOver(arrayMap); 17609 17610 /** 17611 * Creates a function that checks if **all** of the `predicates` return 17612 * truthy when invoked with the arguments it receives. 17613 * 17614 * Following shorthands are possible for providing predicates. 17615 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 17616 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 17617 * 17618 * @static 17619 * @memberOf _ 17620 * @since 4.0.0 17621 * @category Util 17622 * @param {...(Function|Function[])} [predicates=[_.identity]] 17623 * The predicates to check. 17624 * @returns {Function} Returns the new function. 17625 * @example 17626 * 17627 * var func = _.overEvery([Boolean, isFinite]); 17628 * 17629 * func('1'); 17630 * // => true 17631 * 17632 * func(null); 17633 * // => false 17634 * 17635 * func(NaN); 17636 * // => false 17637 */ 17638 var overEvery = createOver(arrayEvery); 17639 17640 /** 17641 * Creates a function that checks if **any** of the `predicates` return 17642 * truthy when invoked with the arguments it receives. 17643 * 17644 * Following shorthands are possible for providing predicates. 17645 * Pass an `Object` and it will be used as an parameter for `_.matches` to create the predicate. 17646 * Pass an `Array` of parameters for `_.matchesProperty` and the predicate will be created using them. 17647 * 17648 * @static 17649 * @memberOf _ 17650 * @since 4.0.0 17651 * @category Util 17652 * @param {...(Function|Function[])} [predicates=[_.identity]] 17653 * The predicates to check. 17654 * @returns {Function} Returns the new function. 17655 * @example 17656 * 17657 * var func = _.overSome([Boolean, isFinite]); 17658 * 17659 * func('1'); 17660 * // => true 17661 * 17662 * func(null); 17663 * // => true 17664 * 17665 * func(NaN); 17666 * // => false 17667 * 17668 * var matchesFunc = _.overSome([{ 'a': 1 }, { 'a': 2 }]) 17669 * var matchesPropertyFunc = _.overSome([['a', 1], ['a', 2]]) 17670 */ 17671 var overSome = createOver(arraySome); 17672 17673 /** 17674 * Creates a function that returns the value at `path` of a given object. 17675 * 17676 * @static 17677 * @memberOf _ 17678 * @since 2.4.0 17679 * @category Util 17680 * @param {Array|string} path The path of the property to get. 17681 * @returns {Function} Returns the new accessor function. 17682 * @example 17683 * 17684 * var objects = [ 17685 * { 'a': { 'b': 2 } }, 17686 * { 'a': { 'b': 1 } } 17687 * ]; 17688 * 17689 * _.map(objects, _.property('a.b')); 17690 * // => [2, 1] 17691 * 17692 * _.map(_.sortBy(objects, _.property(['a', 'b'])), 'a.b'); 17693 * // => [1, 2] 17694 */ 17695 function property(path) { 17696 return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path); 17697 } 17698 17699 /** 17700 * The opposite of `_.property`; this method creates a function that returns 17701 * the value at a given path of `object`. 17702 * 17703 * @static 17704 * @memberOf _ 17705 * @since 3.0.0 17706 * @category Util 17707 * @param {Object} object The object to query. 17708 * @returns {Function} Returns the new accessor function. 17709 * @example 17710 * 17711 * var array = [0, 1, 2], 17712 * object = { 'a': array, 'b': array, 'c': array }; 17713 * 17714 * _.map(['a[2]', 'c[0]'], _.propertyOf(object)); 17715 * // => [2, 0] 17716 * 17717 * _.map([['a', '2'], ['c', '0']], _.propertyOf(object)); 17718 * // => [2, 0] 17719 */ 17720 function propertyOf(object) { 17721 return function(path) { 17722 return object == null ? undefined : baseGet(object, path); 17723 }; 17724 } 17725 17726 /** 17727 * Creates an array of numbers (positive and/or negative) progressing from 17728 * `start` up to, but not including, `end`. A step of `-1` is used if a negative 17729 * `start` is specified without an `end` or `step`. If `end` is not specified, 17730 * it's set to `start` with `start` then set to `0`. 17731 * 17732 * **Note:** JavaScript follows the IEEE-754 standard for resolving 17733 * floating-point values which can produce unexpected results. 17734 * 17735 * @static 17736 * @since 0.1.0 17737 * @memberOf _ 17738 * @category Util 17739 * @param {number} [start=0] The start of the range. 17740 * @param {number} end The end of the range. 17741 * @param {number} [step=1] The value to increment or decrement by. 17742 * @returns {Array} Returns the range of numbers. 17743 * @see _.inRange, _.rangeRight 17744 * @example 17745 * 17746 * _.range(4); 17747 * // => [0, 1, 2, 3] 17748 * 17749 * _.range(-4); 17750 * // => [0, -1, -2, -3] 17751 * 17752 * _.range(1, 5); 17753 * // => [1, 2, 3, 4] 17754 * 17755 * _.range(0, 20, 5); 17756 * // => [0, 5, 10, 15] 17757 * 17758 * _.range(0, -4, -1); 17759 * // => [0, -1, -2, -3] 17760 * 17761 * _.range(1, 4, 0); 17762 * // => [1, 1, 1] 17763 * 17764 * _.range(0); 17765 * // => [] 17766 */ 17767 var range = createRange(); 17768 17769 /** 17770 * This method is like `_.range` except that it populates values in 17771 * descending order. 17772 * 17773 * @static 17774 * @memberOf _ 17775 * @since 4.0.0 17776 * @category Util 17777 * @param {number} [start=0] The start of the range. 17778 * @param {number} end The end of the range. 17779 * @param {number} [step=1] The value to increment or decrement by. 17780 * @returns {Array} Returns the range of numbers. 17781 * @see _.inRange, _.range 17782 * @example 17783 * 17784 * _.rangeRight(4); 17785 * // => [3, 2, 1, 0] 17786 * 17787 * _.rangeRight(-4); 17788 * // => [-3, -2, -1, 0] 17789 * 17790 * _.rangeRight(1, 5); 17791 * // => [4, 3, 2, 1] 17792 * 17793 * _.rangeRight(0, 20, 5); 17794 * // => [15, 10, 5, 0] 17795 * 17796 * _.rangeRight(0, -4, -1); 17797 * // => [-3, -2, -1, 0] 17798 * 17799 * _.rangeRight(1, 4, 0); 17800 * // => [1, 1, 1] 17801 * 17802 * _.rangeRight(0); 17803 * // => [] 17804 */ 17805 var rangeRight = createRange(true); 17806 17807 /** 17808 * This method returns a new empty array. 17809 * 17810 * @static 17811 * @memberOf _ 17812 * @since 4.13.0 17813 * @category Util 17814 * @returns {Array} Returns the new empty array. 17815 * @example 17816 * 17817 * var arrays = _.times(2, _.stubArray); 17818 * 17819 * console.log(arrays); 17820 * // => [[], []] 17821 * 17822 * console.log(arrays[0] === arrays[1]); 17823 * // => false 17824 */ 17825 function stubArray() { 17826 return []; 17827 } 17828 17829 /** 17830 * This method returns `false`. 17831 * 17832 * @static 17833 * @memberOf _ 17834 * @since 4.13.0 17835 * @category Util 17836 * @returns {boolean} Returns `false`. 17837 * @example 17838 * 17839 * _.times(2, _.stubFalse); 17840 * // => [false, false] 17841 */ 17842 function stubFalse() { 17843 return false;
vendor: 1,044 bytes, lines 17844-17897
17844 } 17845 17846 /** 17847 * This method returns a new empty object. 17848 * 17849 * @static 17850 * @memberOf _ 17851 * @since 4.13.0 17852 * @category Util 17853 * @returns {Object} Returns the new empty object. 17854 * @example 17855 * 17856 * var objects = _.times(2, _.stubObject); 17857 * 17858 * console.log(objects); 17859 * // => [{}, {}] 17860 * 17861 * console.log(objects[0] === objects[1]); 17862 * // => false 17863 */ 17864 function stubObject() { 17865 return {}; 17866 } 17867 17868 /** 17869 * This method returns an empty string. 17870 * 17871 * @static 17872 * @memberOf _ 17873 * @since 4.13.0 17874 * @category Util 17875 * @returns {string} Returns the empty string. 17876 * @example 17877 * 17878 * _.times(2, _.stubString); 17879 * // => ['', ''] 17880 */ 17881 function stubString() { 17882 return ''; 17883 } 17884 17885 /** 17886 * This method returns `true`. 17887 * 17888 * @static 17889 * @memberOf _ 17890 * @since 4.13.0 17891 * @category Util 17892 * @returns {boolean} Returns `true`. 17893 * @example 17894 * 17895 * _.times(2, _.stubTrue); 17896 * // => [true, true] 17897 */
vendor: 9,081 bytes, lines 17898-18241
17898 function stubTrue() { 17899 return true; 17900 } 17901 17902 /** 17903 * Invokes the iteratee `n` times, returning an array of the results of 17904 * each invocation. The iteratee is invoked with one argument; (index). 17905 * 17906 * @static 17907 * @since 0.1.0 17908 * @memberOf _ 17909 * @category Util 17910 * @param {number} n The number of times to invoke `iteratee`. 17911 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 17912 * @returns {Array} Returns the array of results. 17913 * @example 17914 * 17915 * _.times(3, String); 17916 * // => ['0', '1', '2'] 17917 * 17918 * _.times(4, _.constant(0)); 17919 * // => [0, 0, 0, 0] 17920 */ 17921 function times(n, iteratee) { 17922 n = toInteger(n); 17923 if (n < 1 || n > MAX_SAFE_INTEGER) { 17924 return []; 17925 } 17926 var index = MAX_ARRAY_LENGTH, 17927 length = nativeMin(n, MAX_ARRAY_LENGTH); 17928 17929 iteratee = getIteratee(iteratee); 17930 n -= MAX_ARRAY_LENGTH; 17931 17932 var result = baseTimes(length, iteratee); 17933 while (++index < n) { 17934 iteratee(index); 17935 } 17936 return result; 17937 } 17938 17939 /** 17940 * Converts `value` to a property path array. 17941 * 17942 * @static 17943 * @memberOf _ 17944 * @since 4.0.0 17945 * @category Util 17946 * @param {*} value The value to convert. 17947 * @returns {Array} Returns the new property path array. 17948 * @example 17949 * 17950 * _.toPath('a.b.c'); 17951 * // => ['a', 'b', 'c'] 17952 * 17953 * _.toPath('a[0].b.c'); 17954 * // => ['a', '0', 'b', 'c'] 17955 */ 17956 function toPath(value) { 17957 if (isArray(value)) { 17958 return arrayMap(value, toKey); 17959 } 17960 return isSymbol(value) ? [value] : copyArray(stringToPath(toString(value))); 17961 } 17962 17963 /** 17964 * Generates a unique ID. If `prefix` is given, the ID is appended to it. 17965 * 17966 * @static 17967 * @since 0.1.0 17968 * @memberOf _ 17969 * @category Util 17970 * @param {string} [prefix=''] The value to prefix the ID with. 17971 * @returns {string} Returns the unique ID. 17972 * @example 17973 * 17974 * _.uniqueId('contact_'); 17975 * // => 'contact_104' 17976 * 17977 * _.uniqueId(); 17978 * // => '105' 17979 */ 17980 function uniqueId(prefix) { 17981 var id = ++idCounter; 17982 return toString(prefix) + id; 17983 } 17984 17985 /*------------------------------------------------------------------------*/ 17986 17987 /** 17988 * Adds two numbers. 17989 * 17990 * @static 17991 * @memberOf _ 17992 * @since 3.4.0 17993 * @category Math 17994 * @param {number} augend The first number in an addition. 17995 * @param {number} addend The second number in an addition. 17996 * @returns {number} Returns the total. 17997 * @example 17998 * 17999 * _.add(6, 4); 18000 * // => 10 18001 */ 18002 var add = createMathOperation(function(augend, addend) { 18003 return augend + addend; 18004 }, 0); 18005 18006 /** 18007 * Computes `number` rounded up to `precision`. 18008 * 18009 * @static 18010 * @memberOf _ 18011 * @since 3.10.0 18012 * @category Math 18013 * @param {number} number The number to round up. 18014 * @param {number} [precision=0] The precision to round up to. 18015 * @returns {number} Returns the rounded up number. 18016 * @example 18017 * 18018 * _.ceil(4.006); 18019 * // => 5 18020 * 18021 * _.ceil(6.004, 2); 18022 * // => 6.01 18023 * 18024 * _.ceil(6040, -2); 18025 * // => 6100 18026 */ 18027 var ceil = createRound('ceil'); 18028 18029 /** 18030 * Divide two numbers. 18031 * 18032 * @static 18033 * @memberOf _ 18034 * @since 4.7.0 18035 * @category Math 18036 * @param {number} dividend The first number in a division. 18037 * @param {number} divisor The second number in a division. 18038 * @returns {number} Returns the quotient. 18039 * @example 18040 * 18041 * _.divide(6, 4); 18042 * // => 1.5 18043 */ 18044 var divide = createMathOperation(function(dividend, divisor) { 18045 return dividend / divisor; 18046 }, 1); 18047 18048 /** 18049 * Computes `number` rounded down to `precision`. 18050 * 18051 * @static 18052 * @memberOf _ 18053 * @since 3.10.0 18054 * @category Math 18055 * @param {number} number The number to round down. 18056 * @param {number} [precision=0] The precision to round down to. 18057 * @returns {number} Returns the rounded down number. 18058 * @example 18059 * 18060 * _.floor(4.006); 18061 * // => 4 18062 * 18063 * _.floor(0.046, 2); 18064 * // => 0.04 18065 * 18066 * _.floor(4060, -2); 18067 * // => 4000 18068 */ 18069 var floor = createRound('floor'); 18070 18071 /** 18072 * Computes the maximum value of `array`. If `array` is empty or falsey, 18073 * `undefined` is returned. 18074 * 18075 * @static 18076 * @since 0.1.0 18077 * @memberOf _ 18078 * @category Math 18079 * @param {Array} array The array to iterate over. 18080 * @returns {*} Returns the maximum value. 18081 * @example 18082 * 18083 * _.max([4, 2, 8, 6]); 18084 * // => 8 18085 * 18086 * _.max([]); 18087 * // => undefined 18088 */ 18089 function max(array) { 18090 return (array && array.length) 18091 ? baseExtremum(array, identity, baseGt) 18092 : undefined; 18093 } 18094 18095 /** 18096 * This method is like `_.max` except that it accepts `iteratee` which is 18097 * invoked for each element in `array` to generate the criterion by which 18098 * the value is ranked. The iteratee is invoked with one argument: (value). 18099 * 18100 * @static 18101 * @memberOf _ 18102 * @since 4.0.0 18103 * @category Math 18104 * @param {Array} array The array to iterate over. 18105 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18106 * @returns {*} Returns the maximum value. 18107 * @example 18108 * 18109 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 18110 * 18111 * _.maxBy(objects, function(o) { return o.n; }); 18112 * // => { 'n': 2 } 18113 * 18114 * // The `_.property` iteratee shorthand. 18115 * _.maxBy(objects, 'n'); 18116 * // => { 'n': 2 } 18117 */ 18118 function maxBy(array, iteratee) { 18119 return (array && array.length) 18120 ? baseExtremum(array, getIteratee(iteratee, 2), baseGt) 18121 : undefined; 18122 } 18123 18124 /** 18125 * Computes the mean of the values in `array`. 18126 * 18127 * @static 18128 * @memberOf _ 18129 * @since 4.0.0 18130 * @category Math 18131 * @param {Array} array The array to iterate over. 18132 * @returns {number} Returns the mean. 18133 * @example 18134 * 18135 * _.mean([4, 2, 8, 6]); 18136 * // => 5 18137 */ 18138 function mean(array) { 18139 return baseMean(array, identity); 18140 } 18141 18142 /** 18143 * This method is like `_.mean` except that it accepts `iteratee` which is 18144 * invoked for each element in `array` to generate the value to be averaged. 18145 * The iteratee is invoked with one argument: (value). 18146 * 18147 * @static 18148 * @memberOf _ 18149 * @since 4.7.0 18150 * @category Math 18151 * @param {Array} array The array to iterate over. 18152 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18153 * @returns {number} Returns the mean. 18154 * @example 18155 * 18156 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 18157 * 18158 * _.meanBy(objects, function(o) { return o.n; }); 18159 * // => 5 18160 * 18161 * // The `_.property` iteratee shorthand. 18162 * _.meanBy(objects, 'n'); 18163 * // => 5 18164 */ 18165 function meanBy(array, iteratee) { 18166 return baseMean(array, getIteratee(iteratee, 2)); 18167 } 18168 18169 /** 18170 * Computes the minimum value of `array`. If `array` is empty or falsey, 18171 * `undefined` is returned. 18172 * 18173 * @static 18174 * @since 0.1.0 18175 * @memberOf _ 18176 * @category Math 18177 * @param {Array} array The array to iterate over. 18178 * @returns {*} Returns the minimum value. 18179 * @example 18180 * 18181 * _.min([4, 2, 8, 6]); 18182 * // => 2 18183 * 18184 * _.min([]); 18185 * // => undefined 18186 */ 18187 function min(array) { 18188 return (array && array.length) 18189 ? baseExtremum(array, identity, baseLt) 18190 : undefined; 18191 } 18192 18193 /** 18194 * This method is like `_.min` except that it accepts `iteratee` which is 18195 * invoked for each element in `array` to generate the criterion by which 18196 * the value is ranked. The iteratee is invoked with one argument: (value). 18197 * 18198 * @static 18199 * @memberOf _ 18200 * @since 4.0.0 18201 * @category Math 18202 * @param {Array} array The array to iterate over. 18203 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18204 * @returns {*} Returns the minimum value. 18205 * @example 18206 * 18207 * var objects = [{ 'n': 1 }, { 'n': 2 }]; 18208 * 18209 * _.minBy(objects, function(o) { return o.n; }); 18210 * // => { 'n': 1 } 18211 * 18212 * // The `_.property` iteratee shorthand. 18213 * _.minBy(objects, 'n'); 18214 * // => { 'n': 1 } 18215 */ 18216 function minBy(array, iteratee) { 18217 return (array && array.length) 18218 ? baseExtremum(array, getIteratee(iteratee, 2), baseLt) 18219 : undefined; 18220 } 18221 18222 /** 18223 * Multiply two numbers. 18224 * 18225 * @static 18226 * @memberOf _ 18227 * @since 4.7.0 18228 * @category Math 18229 * @param {number} multiplier The first number in a multiplication. 18230 * @param {number} multiplicand The second number in a multiplication. 18231 * @returns {number} Returns the product. 18232 * @example 18233 * 18234 * _.multiply(6, 4); 18235 * // => 24 18236 */ 18237 var multiply = createMathOperation(function(multiplier, multiplicand) { 18238 return multiplier * multiplicand; 18239 }, 1); 18240 18241 /**
vendor: 13,137 bytes, lines 18242-18680
18242 * Computes `number` rounded to `precision`. 18243 * 18244 * @static 18245 * @memberOf _ 18246 * @since 3.10.0 18247 * @category Math 18248 * @param {number} number The number to round. 18249 * @param {number} [precision=0] The precision to round to. 18250 * @returns {number} Returns the rounded number. 18251 * @example 18252 * 18253 * _.round(4.006); 18254 * // => 4 18255 * 18256 * _.round(4.006, 2); 18257 * // => 4.01 18258 * 18259 * _.round(4060, -2); 18260 * // => 4100 18261 */ 18262 var round = createRound('round'); 18263 18264 /** 18265 * Subtract two numbers. 18266 * 18267 * @static 18268 * @memberOf _ 18269 * @since 4.0.0 18270 * @category Math 18271 * @param {number} minuend The first number in a subtraction. 18272 * @param {number} subtrahend The second number in a subtraction. 18273 * @returns {number} Returns the difference. 18274 * @example 18275 * 18276 * _.subtract(6, 4); 18277 * // => 2 18278 */ 18279 var subtract = createMathOperation(function(minuend, subtrahend) { 18280 return minuend - subtrahend; 18281 }, 0); 18282 18283 /** 18284 * Computes the sum of the values in `array`. 18285 * 18286 * @static 18287 * @memberOf _ 18288 * @since 3.4.0 18289 * @category Math 18290 * @param {Array} array The array to iterate over. 18291 * @returns {number} Returns the sum. 18292 * @example 18293 * 18294 * _.sum([4, 2, 8, 6]); 18295 * // => 20 18296 */ 18297 function sum(array) { 18298 return (array && array.length) 18299 ? baseSum(array, identity) 18300 : 0; 18301 } 18302 18303 /** 18304 * This method is like `_.sum` except that it accepts `iteratee` which is 18305 * invoked for each element in `array` to generate the value to be summed. 18306 * The iteratee is invoked with one argument: (value). 18307 * 18308 * @static 18309 * @memberOf _ 18310 * @since 4.0.0 18311 * @category Math 18312 * @param {Array} array The array to iterate over. 18313 * @param {Function} [iteratee=_.identity] The iteratee invoked per element. 18314 * @returns {number} Returns the sum. 18315 * @example 18316 * 18317 * var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]; 18318 * 18319 * _.sumBy(objects, function(o) { return o.n; }); 18320 * // => 20 18321 * 18322 * // The `_.property` iteratee shorthand. 18323 * _.sumBy(objects, 'n'); 18324 * // => 20 18325 */ 18326 function sumBy(array, iteratee) { 18327 return (array && array.length) 18328 ? baseSum(array, getIteratee(iteratee, 2)) 18329 : 0; 18330 } 18331 18332 /*------------------------------------------------------------------------*/ 18333 18334 // Add methods that return wrapped values in chain sequences. 18335 lodash.after = after; 18336 lodash.ary = ary; 18337 lodash.assign = assign; 18338 lodash.assignIn = assignIn; 18339 lodash.assignInWith = assignInWith; 18340 lodash.assignWith = assignWith; 18341 lodash.at = at; 18342 lodash.before = before; 18343 lodash.bind = bind; 18344 lodash.bindAll = bindAll; 18345 lodash.bindKey = bindKey; 18346 lodash.castArray = castArray; 18347 lodash.chain = chain; 18348 lodash.chunk = chunk; 18349 lodash.compact = compact; 18350 lodash.concat = concat; 18351 lodash.cond = cond; 18352 lodash.conforms = conforms; 18353 lodash.constant = constant; 18354 lodash.countBy = countBy; 18355 lodash.create = create; 18356 lodash.curry = curry; 18357 lodash.curryRight = curryRight; 18358 lodash.debounce = debounce; 18359 lodash.defaults = defaults; 18360 lodash.defaultsDeep = defaultsDeep; 18361 lodash.defer = defer; 18362 lodash.delay = delay; 18363 lodash.difference = difference; 18364 lodash.differenceBy = differenceBy; 18365 lodash.differenceWith = differenceWith; 18366 lodash.drop = drop; 18367 lodash.dropRight = dropRight; 18368 lodash.dropRightWhile = dropRightWhile; 18369 lodash.dropWhile = dropWhile; 18370 lodash.fill = fill; 18371 lodash.filter = filter; 18372 lodash.flatMap = flatMap; 18373 lodash.flatMapDeep = flatMapDeep; 18374 lodash.flatMapDepth = flatMapDepth; 18375 lodash.flatten = flatten; 18376 lodash.flattenDeep = flattenDeep; 18377 lodash.flattenDepth = flattenDepth; 18378 lodash.flip = flip; 18379 lodash.flow = flow; 18380 lodash.flowRight = flowRight; 18381 lodash.fromPairs = fromPairs; 18382 lodash.functions = functions; 18383 lodash.functionsIn = functionsIn; 18384 lodash.groupBy = groupBy; 18385 lodash.initial = initial; 18386 lodash.intersection = intersection; 18387 lodash.intersectionBy = intersectionBy; 18388 lodash.intersectionWith = intersectionWith; 18389 lodash.invert = invert; 18390 lodash.invertBy = invertBy; 18391 lodash.invokeMap = invokeMap; 18392 lodash.iteratee = iteratee; 18393 lodash.keyBy = keyBy; 18394 lodash.keys = keys; 18395 lodash.keysIn = keysIn; 18396 lodash.map = map; 18397 lodash.mapKeys = mapKeys; 18398 lodash.mapValues = mapValues; 18399 lodash.matches = matches; 18400 lodash.matchesProperty = matchesProperty; 18401 lodash.memoize = memoize; 18402 lodash.merge = merge; 18403 lodash.mergeWith = mergeWith; 18404 lodash.method = method; 18405 lodash.methodOf = methodOf; 18406 lodash.mixin = mixin; 18407 lodash.negate = negate; 18408 lodash.nthArg = nthArg; 18409 lodash.omit = omit; 18410 lodash.omitBy = omitBy; 18411 lodash.once = once; 18412 lodash.orderBy = orderBy; 18413 lodash.over = over; 18414 lodash.overArgs = overArgs; 18415 lodash.overEvery = overEvery; 18416 lodash.overSome = overSome; 18417 lodash.partial = partial; 18418 lodash.partialRight = partialRight; 18419 lodash.partition = partition; 18420 lodash.pick = pick; 18421 lodash.pickBy = pickBy; 18422 lodash.property = property; 18423 lodash.propertyOf = propertyOf; 18424 lodash.pull = pull; 18425 lodash.pullAll = pullAll; 18426 lodash.pullAllBy = pullAllBy; 18427 lodash.pullAllWith = pullAllWith; 18428 lodash.pullAt = pullAt; 18429 lodash.range = range; 18430 lodash.rangeRight = rangeRight; 18431 lodash.rearg = rearg; 18432 lodash.reject = reject; 18433 lodash.remove = remove; 18434 lodash.rest = rest; 18435 lodash.reverse = reverse; 18436 lodash.sampleSize = sampleSize; 18437 lodash.set = set; 18438 lodash.setWith = setWith; 18439 lodash.shuffle = shuffle; 18440 lodash.slice = slice; 18441 lodash.sortBy = sortBy; 18442 lodash.sortedUniq = sortedUniq; 18443 lodash.sortedUniqBy = sortedUniqBy; 18444 lodash.split = split; 18445 lodash.spread = spread; 18446 lodash.tail = tail; 18447 lodash.take = take; 18448 lodash.takeRight = takeRight; 18449 lodash.takeRightWhile = takeRightWhile; 18450 lodash.takeWhile = takeWhile; 18451 lodash.tap = tap; 18452 lodash.throttle = throttle; 18453 lodash.thru = thru; 18454 lodash.toArray = toArray; 18455 lodash.toPairs = toPairs; 18456 lodash.toPairsIn = toPairsIn; 18457 lodash.toPath = toPath; 18458 lodash.toPlainObject = toPlainObject; 18459 lodash.transform = transform; 18460 lodash.unary = unary; 18461 lodash.union = union; 18462 lodash.unionBy = unionBy; 18463 lodash.unionWith = unionWith; 18464 lodash.uniq = uniq; 18465 lodash.uniqBy = uniqBy; 18466 lodash.uniqWith = uniqWith; 18467 lodash.unset = unset; 18468 lodash.unzip = unzip; 18469 lodash.unzipWith = unzipWith; 18470 lodash.update = update; 18471 lodash.updateWith = updateWith; 18472 lodash.values = values; 18473 lodash.valuesIn = valuesIn; 18474 lodash.without = without; 18475 lodash.words = words; 18476 lodash.wrap = wrap; 18477 lodash.xor = xor; 18478 lodash.xorBy = xorBy; 18479 lodash.xorWith = xorWith; 18480 lodash.zip = zip; 18481 lodash.zipObject = zipObject; 18482 lodash.zipObjectDeep = zipObjectDeep; 18483 lodash.zipWith = zipWith; 18484 18485 // Add aliases. 18486 lodash.entries = toPairs; 18487 lodash.entriesIn = toPairsIn; 18488 lodash.extend = assignIn; 18489 lodash.extendWith = assignInWith; 18490 18491 // Add methods to `lodash.prototype`. 18492 mixin(lodash, lodash); 18493 18494 /*------------------------------------------------------------------------*/ 18495 18496 // Add methods that return unwrapped values in chain sequences. 18497 lodash.add = add; 18498 lodash.attempt = attempt; 18499 lodash.camelCase = camelCase; 18500 lodash.capitalize = capitalize; 18501 lodash.ceil = ceil; 18502 lodash.clamp = clamp; 18503 lodash.clone = clone; 18504 lodash.cloneDeep = cloneDeep; 18505 lodash.cloneDeepWith = cloneDeepWith; 18506 lodash.cloneWith = cloneWith; 18507 lodash.conformsTo = conformsTo; 18508 lodash.deburr = deburr; 18509 lodash.defaultTo = defaultTo; 18510 lodash.divide = divide; 18511 lodash.endsWith = endsWith; 18512 lodash.eq = eq; 18513 lodash.escape = escape; 18514 lodash.escapeRegExp = escapeRegExp; 18515 lodash.every = every; 18516 lodash.find = find; 18517 lodash.findIndex = findIndex; 18518 lodash.findKey = findKey; 18519 lodash.findLast = findLast; 18520 lodash.findLastIndex = findLastIndex; 18521 lodash.findLastKey = findLastKey; 18522 lodash.floor = floor; 18523 lodash.forEach = forEach; 18524 lodash.forEachRight = forEachRight; 18525 lodash.forIn = forIn; 18526 lodash.forInRight = forInRight; 18527 lodash.forOwn = forOwn; 18528 lodash.forOwnRight = forOwnRight; 18529 lodash.get = get; 18530 lodash.gt = gt; 18531 lodash.gte = gte; 18532 lodash.has = has; 18533 lodash.hasIn = hasIn; 18534 lodash.head = head; 18535 lodash.identity = identity; 18536 lodash.includes = includes; 18537 lodash.indexOf = indexOf; 18538 lodash.inRange = inRange; 18539 lodash.invoke = invoke; 18540 lodash.isArguments = isArguments; 18541 lodash.isArray = isArray; 18542 lodash.isArrayBuffer = isArrayBuffer; 18543 lodash.isArrayLike = isArrayLike; 18544 lodash.isArrayLikeObject = isArrayLikeObject; 18545 lodash.isBoolean = isBoolean; 18546 lodash.isBuffer = isBuffer; 18547 lodash.isDate = isDate; 18548 lodash.isElement = isElement; 18549 lodash.isEmpty = isEmpty; 18550 lodash.isEqual = isEqual; 18551 lodash.isEqualWith = isEqualWith; 18552 lodash.isError = isError; 18553 lodash.isFinite = isFinite; 18554 lodash.isFunction = isFunction; 18555 lodash.isInteger = isInteger; 18556 lodash.isLength = isLength; 18557 lodash.isMap = isMap; 18558 lodash.isMatch = isMatch; 18559 lodash.isMatchWith = isMatchWith; 18560 lodash.isNaN = isNaN; 18561 lodash.isNative = isNative; 18562 lodash.isNil = isNil; 18563 lodash.isNull = isNull; 18564 lodash.isNumber = isNumber; 18565 lodash.isObject = isObject; 18566 lodash.isObjectLike = isObjectLike; 18567 lodash.isPlainObject = isPlainObject; 18568 lodash.isRegExp = isRegExp; 18569 lodash.isSafeInteger = isSafeInteger; 18570 lodash.isSet = isSet; 18571 lodash.isString = isString; 18572 lodash.isSymbol = isSymbol; 18573 lodash.isTypedArray = isTypedArray; 18574 lodash.isUndefined = isUndefined; 18575 lodash.isWeakMap = isWeakMap; 18576 lodash.isWeakSet = isWeakSet; 18577 lodash.join = join; 18578 lodash.kebabCase = kebabCase; 18579 lodash.last = last; 18580 lodash.lastIndexOf = lastIndexOf; 18581 lodash.lowerCase = lowerCase; 18582 lodash.lowerFirst = lowerFirst; 18583 lodash.lt = lt; 18584 lodash.lte = lte; 18585 lodash.max = max; 18586 lodash.maxBy = maxBy; 18587 lodash.mean = mean; 18588 lodash.meanBy = meanBy; 18589 lodash.min = min; 18590 lodash.minBy = minBy; 18591 lodash.stubArray = stubArray; 18592 lodash.stubFalse = stubFalse; 18593 lodash.stubObject = stubObject; 18594 lodash.stubString = stubString; 18595 lodash.stubTrue = stubTrue; 18596 lodash.multiply = multiply; 18597 lodash.nth = nth; 18598 lodash.noConflict = noConflict; 18599 lodash.noop = noop; 18600 lodash.now = now; 18601 lodash.pad = pad; 18602 lodash.padEnd = padEnd; 18603 lodash.padStart = padStart; 18604 lodash.parseInt = parseInt; 18605 lodash.random = random; 18606 lodash.reduce = reduce; 18607 lodash.reduceRight = reduceRight; 18608 lodash.repeat = repeat; 18609 lodash.replace = replace; 18610 lodash.result = result; 18611 lodash.round = round; 18612 lodash.runInContext = runInContext; 18613 lodash.sample = sample; 18614 lodash.size = size; 18615 lodash.snakeCase = snakeCase; 18616 lodash.some = some; 18617 lodash.sortedIndex = sortedIndex; 18618 lodash.sortedIndexBy = sortedIndexBy; 18619 lodash.sortedIndexOf = sortedIndexOf; 18620 lodash.sortedLastIndex = sortedLastIndex; 18621 lodash.sortedLastIndexBy = sortedLastIndexBy; 18622 lodash.sortedLastIndexOf = sortedLastIndexOf; 18623 lodash.startCase = startCase; 18624 lodash.startsWith = startsWith; 18625 lodash.subtract = subtract; 18626 lodash.sum = sum; 18627 lodash.sumBy = sumBy; 18628 lodash.template = template; 18629 lodash.times = times; 18630 lodash.toFinite = toFinite; 18631 lodash.toInteger = toInteger; 18632 lodash.toLength = toLength; 18633 lodash.toLower = toLower; 18634 lodash.toNumber = toNumber; 18635 lodash.toSafeInteger = toSafeInteger; 18636 lodash.toString = toString; 18637 lodash.toUpper = toUpper; 18638 lodash.trim = trim; 18639 lodash.trimEnd = trimEnd; 18640 lodash.trimStart = trimStart; 18641 lodash.truncate = truncate; 18642 lodash.unescape = unescape; 18643 lodash.uniqueId = uniqueId; 18644 lodash.upperCase = upperCase; 18645 lodash.upperFirst = upperFirst; 18646 18647 // Add aliases. 18648 lodash.each = forEach; 18649 lodash.eachRight = forEachRight; 18650 lodash.first = head; 18651 18652 mixin(lodash, (function() { 18653 var source = {}; 18654 baseForOwn(lodash, function(func, methodName) { 18655 if (!hasOwnProperty.call(lodash.prototype, methodName)) { 18656 source[methodName] = func; 18657 } 18658 }); 18659 return source; 18660 }()), { 'chain': false }); 18661 18662 /*------------------------------------------------------------------------*/ 18663 18664 /** 18665 * The semantic version number. 18666 * 18667 * @static 18668 * @memberOf _ 18669 * @type {string} 18670 */ 18671 lodash.VERSION = VERSION; 18672 18673 // Assign default placeholders. 18674 arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) { 18675 lodash[methodName].placeholder = lodash; 18676 }); 18677 18678 // Add `LazyWrapper` methods for `_.drop` and `_.take` variants. 18679 arrayEach(['drop', 'take'], function(methodName, index) { 18680 LazyWrapper.prototype[methodName] = function(n) {
vendor: 7,434 bytes, lines 18681-18898
18681 n = n === undefined ? 1 : nativeMax(toInteger(n), 0); 18682 18683 var result = (this.__filtered__ && !index) 18684 ? new LazyWrapper(this) 18685 : this.clone(); 18686 18687 if (result.__filtered__) { 18688 result.__takeCount__ = nativeMin(n, result.__takeCount__); 18689 } else { 18690 result.__views__.push({ 18691 'size': nativeMin(n, MAX_ARRAY_LENGTH), 18692 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') 18693 }); 18694 } 18695 return result; 18696 }; 18697 18698 LazyWrapper.prototype[methodName + 'Right'] = function(n) { 18699 return this.reverse()[methodName](n).reverse(); 18700 }; 18701 }); 18702 18703 // Add `LazyWrapper` methods that accept an `iteratee` value. 18704 arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) { 18705 var type = index + 1, 18706 isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG; 18707 18708 LazyWrapper.prototype[methodName] = function(iteratee) { 18709 var result = this.clone(); 18710 result.__iteratees__.push({ 18711 'iteratee': getIteratee(iteratee, 3), 18712 'type': type 18713 }); 18714 result.__filtered__ = result.__filtered__ || isFilter; 18715 return result; 18716 }; 18717 }); 18718 18719 // Add `LazyWrapper` methods for `_.head` and `_.last`. 18720 arrayEach(['head', 'last'], function(methodName, index) { 18721 var takeName = 'take' + (index ? 'Right' : ''); 18722 18723 LazyWrapper.prototype[methodName] = function() { 18724 return this[takeName](1).value()[0]; 18725 }; 18726 }); 18727 18728 // Add `LazyWrapper` methods for `_.initial` and `_.tail`. 18729 arrayEach(['initial', 'tail'], function(methodName, index) { 18730 var dropName = 'drop' + (index ? '' : 'Right'); 18731 18732 LazyWrapper.prototype[methodName] = function() { 18733 return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1); 18734 }; 18735 }); 18736 18737 LazyWrapper.prototype.compact = function() { 18738 return this.filter(identity); 18739 }; 18740 18741 LazyWrapper.prototype.find = function(predicate) { 18742 return this.filter(predicate).head(); 18743 }; 18744 18745 LazyWrapper.prototype.findLast = function(predicate) { 18746 return this.reverse().find(predicate); 18747 }; 18748 18749 LazyWrapper.prototype.invokeMap = baseRest(function(path, args) { 18750 if (typeof path == 'function') { 18751 return new LazyWrapper(this); 18752 } 18753 return this.map(function(value) { 18754 return baseInvoke(value, path, args); 18755 }); 18756 }); 18757 18758 LazyWrapper.prototype.reject = function(predicate) { 18759 return this.filter(negate(getIteratee(predicate))); 18760 }; 18761 18762 LazyWrapper.prototype.slice = function(start, end) { 18763 start = toInteger(start); 18764 18765 var result = this; 18766 if (result.__filtered__ && (start > 0 || end < 0)) { 18767 return new LazyWrapper(result); 18768 } 18769 if (start < 0) { 18770 result = result.takeRight(-start); 18771 } else if (start) { 18772 result = result.drop(start); 18773 } 18774 if (end !== undefined) { 18775 end = toInteger(end); 18776 result = end < 0 ? result.dropRight(-end) : result.take(end - start); 18777 } 18778 return result; 18779 }; 18780 18781 LazyWrapper.prototype.takeRightWhile = function(predicate) { 18782 return this.reverse().takeWhile(predicate).reverse(); 18783 }; 18784 18785 LazyWrapper.prototype.toArray = function() { 18786 return this.take(MAX_ARRAY_LENGTH); 18787 }; 18788 18789 // Add `LazyWrapper` methods to `lodash.prototype`. 18790 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 18791 var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), 18792 isTaker = /^(?:head|last)$/.test(methodName), 18793 lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName], 18794 retUnwrapped = isTaker || /^find/.test(methodName); 18795 18796 if (!lodashFunc) { 18797 return; 18798 } 18799 lodash.prototype[methodName] = function() { 18800 var value = this.__wrapped__, 18801 args = isTaker ? [1] : arguments, 18802 isLazy = value instanceof LazyWrapper, 18803 iteratee = args[0], 18804 useLazy = isLazy || isArray(value); 18805 18806 var interceptor = function(value) { 18807 var result = lodashFunc.apply(lodash, arrayPush([value], args)); 18808 return (isTaker && chainAll) ? result[0] : result; 18809 }; 18810 18811 if (useLazy && checkIteratee && typeof iteratee == 'function' && iteratee.length != 1) { 18812 // Avoid lazy use if the iteratee has a "length" value other than `1`. 18813 isLazy = useLazy = false; 18814 } 18815 var chainAll = this.__chain__, 18816 isHybrid = !!this.__actions__.length, 18817 isUnwrapped = retUnwrapped && !chainAll, 18818 onlyLazy = isLazy && !isHybrid; 18819 18820 if (!retUnwrapped && useLazy) { 18821 value = onlyLazy ? value : new LazyWrapper(this); 18822 var result = func.apply(value, args); 18823 result.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); 18824 return new LodashWrapper(result, chainAll); 18825 } 18826 if (isUnwrapped && onlyLazy) { 18827 return func.apply(this, args); 18828 } 18829 result = this.thru(interceptor); 18830 return isUnwrapped ? (isTaker ? result.value()[0] : result.value()) : result; 18831 }; 18832 }); 18833 18834 // Add `Array` methods to `lodash.prototype`. 18835 arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) { 18836 var func = arrayProto[methodName], 18837 chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru', 18838 retUnwrapped = /^(?:pop|shift)$/.test(methodName); 18839 18840 lodash.prototype[methodName] = function() { 18841 var args = arguments; 18842 if (retUnwrapped && !this.__chain__) { 18843 var value = this.value(); 18844 return func.apply(isArray(value) ? value : [], args); 18845 } 18846 return this[chainName](function(value) { 18847 return func.apply(isArray(value) ? value : [], args); 18848 }); 18849 }; 18850 }); 18851 18852 // Map minified method names to their real names. 18853 baseForOwn(LazyWrapper.prototype, function(func, methodName) { 18854 var lodashFunc = lodash[methodName]; 18855 if (lodashFunc) { 18856 var key = lodashFunc.name + ''; 18857 if (!hasOwnProperty.call(realNames, key)) { 18858 realNames[key] = []; 18859 } 18860 realNames[key].push({ 'name': methodName, 'func': lodashFunc }); 18861 } 18862 }); 18863 18864 realNames[createHybrid(undefined, WRAP_BIND_KEY_FLAG).name] = [{ 18865 'name': 'wrapper', 18866 'func': undefined 18867 }]; 18868 18869 // Add methods to `LazyWrapper`. 18870 LazyWrapper.prototype.clone = lazyClone; 18871 LazyWrapper.prototype.reverse = lazyReverse; 18872 LazyWrapper.prototype.value = lazyValue; 18873 18874 // Add chain sequence methods to the `lodash` wrapper. 18875 lodash.prototype.at = wrapperAt; 18876 lodash.prototype.chain = wrapperChain; 18877 lodash.prototype.commit = wrapperCommit; 18878 lodash.prototype.next = wrapperNext; 18879 lodash.prototype.plant = wrapperPlant; 18880 lodash.prototype.reverse = wrapperReverse; 18881 lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue; 18882 18883 // Add lazy aliases. 18884 lodash.prototype.first = lodash.prototype.head; 18885 18886 if (symIterator) { 18887 lodash.prototype[symIterator] = wrapperToIterator; 18888 } 18889 return lodash; 18890 }); 18891 18892 /*--------------------------------------------------------------------------*/ 18893 18894 // Export lodash. 18895 var _ = runInContext(); 18896 18897 // Some AMD build optimizers, like r.js, check for condition patterns like: 18898 if (t
18898ypeof define == 'function' && typeof define.amd == 'object' && define.amd) { 18899 // Expose Lodash on the global object to prevent errors when Lodash is 18900 // loaded by a script tag in the presence of an AMD loader. 18901 // See http://requirejs.org/docs/errors.html#mismatch for more details. 18902 // Use `_.noConflict` to remove Lodash from the global object. 18903 root._ = _; 18904 18905 // Define as an anonymous module so, through path mapping, it can be 18906 // referenced as the "underscore" module. 18907 define(function() { 18908 return _; 18909 }); 18910 } 18911 // Check for `exports` after `define` in case a build optimizer adds it. 18912 else if (freeModule) { 18913 // Export for Node.js. 18914 (freeModule.exports = _)._ = _; 18915 // Export for CommonJS support. 18916 freeExports._ = _; 18917 } 18918 else { 18919 // Export to the global object. 18920 root._ = _; 18921 } 18922}.call(this)); 18923 18924}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 18925},{}],3:[function(require,module,exports){ 18926//! moment.js 18927//! version : 2.29.4 18928//! authors : Tim Wood, Iskren Chernev, Moment.js contributors 18929//! license : MIT 18930//! momentjs.com 18931 18932;(function (global, factory) { 18933 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 18934 typeof define === 'function' && define.amd ? define(factory) : 18935 global.moment = factory() 18936}(this, (function () { 'use strict'; 18937 18938 var hookCallback; 18939 18940 function hooks() { 18941 return hookCallback.apply(null, arguments); 18942 } 18943 18944 // This is done to register the method called with moment() 18945 // without creating circular dependencies. 18946 function setHookCallback(callback) { 18947 hookCallback = callback; 18948 } 18949 18950 function isArray(input) { 18951 return ( 18952 input instanceof Array || 18953 Object.prototype.toString.call(input) === '[object Array]' 18954 ); 18955 } 18956 18957 function isObject(input) { 18958 // IE8 will treat undefined and null as object if it wasn't for 18959 // input != null 18960 return ( 18961 input != null && 18962 Object.prototype.toString.call(input) === '[object Object]' 18963 ); 18964 } 18965 18966 function hasOwnProp(a, b) { 18967 return Object.prototype.hasOwnProperty.call(a, b); 18968 } 18969 18970 function isObjectEmpty(obj) { 18971 if (Object.getOwnPropertyNames) { 18972 return Object.getOwnPropertyNames(obj).length === 0; 18973 } else { 18974 var k; 18975 for (k in obj) { 18976 if (hasOwnProp(obj, k)) { 18977 return false;
vendor: 11,502 bytes, lines 18978-19380
18978 } 18979 } 18980 return true; 18981 } 18982 } 18983 18984 function isUndefined(input) { 18985 return input === void 0; 18986 } 18987 18988 function isNumber(input) { 18989 return ( 18990 typeof input === 'number' || 18991 Object.prototype.toString.call(input) === '[object Number]' 18992 ); 18993 } 18994 18995 function isDate(input) { 18996 return ( 18997 input instanceof Date || 18998 Object.prototype.toString.call(input) === '[object Date]' 18999 ); 19000 } 19001 19002 function map(arr, fn) { 19003 var res = [], 19004 i, 19005 arrLen = arr.length; 19006 for (i = 0; i < arrLen; ++i) { 19007 res.push(fn(arr[i], i)); 19008 } 19009 return res; 19010 } 19011 19012 function extend(a, b) { 19013 for (var i in b) { 19014 if (hasOwnProp(b, i)) { 19015 a[i] = b[i]; 19016 } 19017 } 19018 19019 if (hasOwnProp(b, 'toString')) { 19020 a.toString = b.toString; 19021 } 19022 19023 if (hasOwnProp(b, 'valueOf')) { 19024 a.valueOf = b.valueOf; 19025 } 19026 19027 return a; 19028 } 19029 19030 function createUTC(input, format, locale, strict) { 19031 return createLocalOrUTC(input, format, locale, strict, true).utc(); 19032 } 19033 19034 function defaultParsingFlags() { 19035 // We need to deep clone this object. 19036 return { 19037 empty: false, 19038 unusedTokens: [], 19039 unusedInput: [], 19040 overflow: -2, 19041 charsLeftOver: 0, 19042 nullInput: false, 19043 invalidEra: null, 19044 invalidMonth: null, 19045 invalidFormat: false, 19046 userInvalidated: false, 19047 iso: false, 19048 parsedDateParts: [], 19049 era: null, 19050 meridiem: null, 19051 rfc2822: false, 19052 weekdayMismatch: false, 19053 }; 19054 } 19055 19056 function getParsingFlags(m) { 19057 if (m._pf == null) { 19058 m._pf = defaultParsingFlags(); 19059 } 19060 return m._pf; 19061 } 19062 19063 var some; 19064 if (Array.prototype.some) { 19065 some = Array.prototype.some; 19066 } else { 19067 some = function (fun) { 19068 var t = Object(this), 19069 len = t.length >>> 0, 19070 i; 19071 19072 for (i = 0; i < len; i++) { 19073 if (i in t && fun.call(this, t[i], i, t)) { 19074 return true; 19075 } 19076 } 19077 19078 return false; 19079 }; 19080 } 19081 19082 function isValid(m) { 19083 if (m._isValid == null) { 19084 var flags = getParsingFlags(m), 19085 parsedParts = some.call(flags.parsedDateParts, function (i) { 19086 return i != null; 19087 }), 19088 isNowValid = 19089 !isNaN(m._d.getTime()) && 19090 flags.overflow < 0 && 19091 !flags.empty && 19092 !flags.invalidEra && 19093 !flags.invalidMonth && 19094 !flags.invalidWeekday && 19095 !flags.weekdayMismatch && 19096 !flags.nullInput && 19097 !flags.invalidFormat && 19098 !flags.userInvalidated && 19099 (!flags.meridiem || (flags.meridiem && parsedParts)); 19100 19101 if (m._strict) { 19102 isNowValid = 19103 isNowValid && 19104 flags.charsLeftOver === 0 && 19105 flags.unusedTokens.length === 0 && 19106 flags.bigHour === undefined; 19107 } 19108 19109 if (Object.isFrozen == null || !Object.isFrozen(m)) { 19110 m._isValid = isNowValid; 19111 } else { 19112 return isNowValid; 19113 } 19114 } 19115 return m._isValid; 19116 } 19117 19118 function createInvalid(flags) { 19119 var m = createUTC(NaN); 19120 if (flags != null) { 19121 extend(getParsingFlags(m), flags); 19122 } else { 19123 getParsingFlags(m).userInvalidated = true; 19124 } 19125 19126 return m; 19127 } 19128 19129 // Plugins that add properties should also add the key here (null value), 19130 // so we can properly clone ourselves. 19131 var momentProperties = (hooks.momentProperties = []), 19132 updateInProgress = false; 19133 19134 function copyConfig(to, from) { 19135 var i, 19136 prop, 19137 val, 19138 momentPropertiesLen = momentProperties.length; 19139 19140 if (!isUndefined(from._isAMomentObject)) { 19141 to._isAMomentObject = from._isAMomentObject; 19142 } 19143 if (!isUndefined(from._i)) { 19144 to._i = from._i; 19145 } 19146 if (!isUndefined(from._f)) { 19147 to._f = from._f; 19148 } 19149 if (!isUndefined(from._l)) { 19150 to._l = from._l; 19151 } 19152 if (!isUndefined(from._strict)) { 19153 to._strict = from._strict; 19154 } 19155 if (!isUndefined(from._tzm)) { 19156 to._tzm = from._tzm; 19157 } 19158 if (!isUndefined(from._isUTC)) { 19159 to._isUTC = from._isUTC; 19160 } 19161 if (!isUndefined(from._offset)) { 19162 to._offset = from._offset; 19163 } 19164 if (!isUndefined(from._pf)) { 19165 to._pf = getParsingFlags(from); 19166 } 19167 if (!isUndefined(from._locale)) { 19168 to._locale = from._locale; 19169 } 19170 19171 if (momentPropertiesLen > 0) { 19172 for (i = 0; i < momentPropertiesLen; i++) { 19173 prop = momentProperties[i]; 19174 val = from[prop]; 19175 if (!isUndefined(val)) { 19176 to[prop] = val; 19177 } 19178 } 19179 } 19180 19181 return to; 19182 } 19183 19184 // Moment prototype object 19185 function Moment(config) { 19186 copyConfig(this, config); 19187 this._d = new Date(config._d != null ? config._d.getTime() : NaN); 19188 if (!this.isValid()) { 19189 this._d = new Date(NaN); 19190 } 19191 // Prevent infinite loop in case updateOffset creates new moment 19192 // objects. 19193 if (updateInProgress === false) { 19194 updateInProgress = true; 19195 hooks.updateOffset(this); 19196 updateInProgress = false; 19197 } 19198 } 19199 19200 function isMoment(obj) { 19201 return ( 19202 obj instanceof Moment || (obj != null && obj._isAMomentObject != null) 19203 ); 19204 } 19205 19206 function warn(msg) { 19207 if ( 19208 hooks.suppressDeprecationWarnings === false && 19209 typeof console !== 'undefined' && 19210 console.warn 19211 ) { 19212 console.warn('Deprecation warning: ' + msg); 19213 } 19214 } 19215 19216 function deprecate(msg, fn) { 19217 var firstTime = true; 19218 19219 return extend(function () { 19220 if (hooks.deprecationHandler != null) { 19221 hooks.deprecationHandler(null, msg); 19222 } 19223 if (firstTime) { 19224 var args = [], 19225 arg, 19226 i, 19227 key, 19228 argLen = arguments.length; 19229 for (i = 0; i < argLen; i++) { 19230 arg = ''; 19231 if (typeof arguments[i] === 'object') { 19232 arg += '\n[' + i + '] '; 19233 for (key in arguments[0]) { 19234 if (hasOwnProp(arguments[0], key)) { 19235 arg += key + ': ' + arguments[0][key] + ', '; 19236 } 19237 } 19238 arg = arg.slice(0, -2); // Remove trailing comma and space 19239 } else { 19240 arg = arguments[i]; 19241 } 19242 args.push(arg); 19243 } 19244 warn( 19245 msg + 19246 '\nArguments: ' + 19247 Array.prototype.slice.call(args).join('') + 19248 '\n' + 19249 new Error().stack 19250 ); 19251 firstTime = false; 19252 } 19253 return fn.apply(this, arguments); 19254 }, fn); 19255 } 19256 19257 var deprecations = {}; 19258 19259 function deprecateSimple(name, msg) { 19260 if (hooks.deprecationHandler != null) { 19261 hooks.deprecationHandler(name, msg); 19262 } 19263 if (!deprecations[name]) { 19264 warn(msg); 19265 deprecations[name] = true; 19266 } 19267 } 19268 19269 hooks.suppressDeprecationWarnings = false; 19270 hooks.deprecationHandler = null; 19271 19272 function isFunction(input) { 19273 return ( 19274 (typeof Function !== 'undefined' && input instanceof Function) || 19275 Object.prototype.toString.call(input) === '[object Function]' 19276 ); 19277 } 19278 19279 function set(config) { 19280 var prop, i; 19281 for (i in config) { 19282 if (hasOwnProp(config, i)) { 19283 prop = config[i]; 19284 if (isFunction(prop)) { 19285 this[i] = prop; 19286 } else { 19287 this['_' + i] = prop; 19288 } 19289 } 19290 } 19291 this._config = config; 19292 // Lenient ordinal parsing accepts just a number in addition to 19293 // number + (possibly) stuff coming from _dayOfMonthOrdinalParse. 19294 // TODO: Remove "ordinalParse" fallback in next major release. 19295 this._dayOfMonthOrdinalParseLenient = new RegExp( 19296 (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + 19297 '|' + 19298 /\d{1,2}/.source 19299 ); 19300 } 19301 19302 function mergeConfigs(parentConfig, childConfig) { 19303 var res = extend({}, parentConfig), 19304 prop; 19305 for (prop in childConfig) { 19306 if (hasOwnProp(childConfig, prop)) { 19307 if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) { 19308 res[prop] = {}; 19309 extend(res[prop], parentConfig[prop]); 19310 extend(res[prop], childConfig[prop]); 19311 } else if (childConfig[prop] != null) { 19312 res[prop] = childConfig[prop]; 19313 } else { 19314 delete res[prop]; 19315 } 19316 } 19317 } 19318 for (prop in parentConfig) { 19319 if ( 19320 hasOwnProp(parentConfig, prop) && 19321 !hasOwnProp(childConfig, prop) && 19322 isObject(parentConfig[prop]) 19323 ) { 19324 // make sure changes to properties don't modify parent config 19325 res[prop] = extend({}, res[prop]); 19326 } 19327 } 19328 return res; 19329 } 19330 19331 function Locale(config) { 19332 if (config != null) { 19333 this.set(config); 19334 } 19335 } 19336 19337 var keys; 19338 19339 if (Object.keys) { 19340 keys = Object.keys; 19341 } else { 19342 keys = function (obj) { 19343 var i, 19344 res = []; 19345 for (i in obj) { 19346 if (hasOwnProp(obj, i)) { 19347 res.push(i); 19348 } 19349 } 19350 return res; 19351 }; 19352 } 19353 19354 var defaultCalendar = { 19355 sameDay: '[Today at] LT', 19356 nextDay: '[Tomorrow at] LT', 19357 nextWeek: 'dddd [at] LT', 19358 lastDay: '[Yesterday at] LT', 19359 lastWeek: '[Last] dddd [at] LT', 19360 sameElse: 'L', 19361 }; 19362 19363 function calendar(key, mom, now) { 19364 var output = this._calendar[key] || this._calendar['sameElse']; 19365 return isFunction(output) ? output.call(mom, now) : output; 19366 } 19367 19368 function zeroFill(number, targetLength, forceSign) { 19369 var absNumber = '' + Math.abs(number), 19370 zerosToFill = targetLength - absNumber.length, 19371 sign = number >= 0; 19372 return ( 19373 (sign ? (forceSign ? '+' : '') : '-') + 19374 Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + 19375 absNumber 19376 ); 19377 } 19378 19379 var formattingTokens = 19380
vendor: 8,563 bytes, lines 19380-19684
19380 /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g, 19381 localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, 19382 formatFunctions = {}, 19383 formatTokenFunctions = {}; 19384 19385 // token: 'M' 19386 // padded: ['MM', 2] 19387 // ordinal: 'Mo' 19388 // callback: function () { this.month() + 1 } 19389 function addFormatToken(token, padded, ordinal, callback) { 19390 var func = callback; 19391 if (typeof callback === 'string') { 19392 func = function () { 19393 return this[callback](); 19394 }; 19395 } 19396 if (token) { 19397 formatTokenFunctions[token] = func; 19398 } 19399 if (padded) { 19400 formatTokenFunctions[padded[0]] = function () { 19401 return zeroFill(func.apply(this, arguments), padded[1], padded[2]); 19402 }; 19403 } 19404 if (ordinal) { 19405 formatTokenFunctions[ordinal] = function () { 19406 return this.localeData().ordinal( 19407 func.apply(this, arguments), 19408 token 19409 ); 19410 }; 19411 } 19412 } 19413 19414 function removeFormattingTokens(input) { 19415 if (input.match(/\[[\s\S]/)) { 19416 return input.replace(/^\[|\]$/g, ''); 19417 } 19418 return input.replace(/\\/g, ''); 19419 } 19420 19421 function makeFormatFunction(format) { 19422 var array = format.match(formattingTokens), 19423 i, 19424 length; 19425 19426 for (i = 0, length = array.length; i < length; i++) { 19427 if (formatTokenFunctions[array[i]]) { 19428 array[i] = formatTokenFunctions[array[i]]; 19429 } else { 19430 array[i] = removeFormattingTokens(array[i]); 19431 } 19432 } 19433 19434 return function (mom) { 19435 var output = '', 19436 i; 19437 for (i = 0; i < length; i++) { 19438 output += isFunction(array[i]) 19439 ? array[i].call(mom, format) 19440 : array[i]; 19441 } 19442 return output; 19443 }; 19444 } 19445 19446 // format date using native date object 19447 function formatMoment(m, format) { 19448 if (!m.isValid()) { 19449 return m.localeData().invalidDate(); 19450 } 19451 19452 format = expandFormat(format, m.localeData()); 19453 formatFunctions[format] = 19454 formatFunctions[format] || makeFormatFunction(format); 19455 19456 return formatFunctions[format](m); 19457 } 19458 19459 function expandFormat(format, locale) { 19460 var i = 5; 19461 19462 function replaceLongDateFormatTokens(input) { 19463 return locale.longDateFormat(input) || input; 19464 } 19465 19466 localFormattingTokens.lastIndex = 0; 19467 while (i >= 0 && localFormattingTokens.test(format)) { 19468 format = format.replace( 19469 localFormattingTokens, 19470 replaceLongDateFormatTokens 19471 ); 19472 localFormattingTokens.lastIndex = 0; 19473 i -= 1; 19474 } 19475 19476 return format; 19477 } 19478 19479 var defaultLongDateFormat = { 19480 LTS: 'h:mm:ss A', 19481 LT: 'h:mm A', 19482 L: 'MM/DD/YYYY', 19483 LL: 'MMMM D, YYYY', 19484 LLL: 'MMMM D, YYYY h:mm A', 19485 LLLL: 'dddd, MMMM D, YYYY h:mm A', 19486 }; 19487 19488 function longDateFormat(key) { 19489 var format = this._longDateFormat[key], 19490 formatUpper = this._longDateFormat[key.toUpperCase()]; 19491 19492 if (format || !formatUpper) { 19493 return format; 19494 } 19495 19496 this._longDateFormat[key] = formatUpper 19497 .match(formattingTokens) 19498 .map(function (tok) { 19499 if ( 19500 tok === 'MMMM' || 19501 tok === 'MM' || 19502 tok === 'DD' || 19503 tok === 'dddd' 19504 ) { 19505 return tok.slice(1); 19506 } 19507 return tok; 19508 }) 19509 .join(''); 19510 19511 return this._longDateFormat[key]; 19512 } 19513 19514 var defaultInvalidDate = 'Invalid date'; 19515 19516 function invalidDate() { 19517 return this._invalidDate; 19518 } 19519 19520 var defaultOrdinal = '%d', 19521 defaultDayOfMonthOrdinalParse = /\d{1,2}/; 19522 19523 function ordinal(number) { 19524 return this._ordinal.replace('%d', number); 19525 } 19526 19527 var defaultRelativeTime = { 19528 future: 'in %s', 19529 past: '%s ago', 19530 s: 'a few seconds', 19531 ss: '%d seconds', 19532 m: 'a minute', 19533 mm: '%d minutes', 19534 h: 'an hour', 19535 hh: '%d hours', 19536 d: 'a day', 19537 dd: '%d days', 19538 w: 'a week', 19539 ww: '%d weeks', 19540 M: 'a month', 19541 MM: '%d months', 19542 y: 'a year', 19543 yy: '%d years', 19544 }; 19545 19546 function relativeTime(number, withoutSuffix, string, isFuture) { 19547 var output = this._relativeTime[string]; 19548 return isFunction(output) 19549 ? output(number, withoutSuffix, string, isFuture) 19550 : output.replace(/%d/i, number); 19551 } 19552 19553 function pastFuture(diff, output) { 19554 var format = this._relativeTime[diff > 0 ? 'future' : 'past']; 19555 return isFunction(format) ? format(output) : format.replace(/%s/i, output); 19556 } 19557 19558 var aliases = {}; 19559 19560 function addUnitAlias(unit, shorthand) { 19561 var lowerCase = unit.toLowerCase(); 19562 aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit; 19563 } 19564 19565 function normalizeUnits(units) { 19566 return typeof units === 'string' 19567 ? aliases[units] || aliases[units.toLowerCase()] 19568 : undefined; 19569 } 19570 19571 function normalizeObjectUnits(inputObject) { 19572 var normalizedInput = {}, 19573 normalizedProp, 19574 prop; 19575 19576 for (prop in inputObject) { 19577 if (hasOwnProp(inputObject, prop)) { 19578 normalizedProp = normalizeUnits(prop); 19579 if (normalizedProp) { 19580 normalizedInput[normalizedProp] = inputObject[prop]; 19581 } 19582 } 19583 } 19584 19585 return normalizedInput; 19586 } 19587 19588 var priorities = {}; 19589 19590 function addUnitPriority(unit, priority) { 19591 priorities[unit] = priority; 19592 } 19593 19594 function getPrioritizedUnits(unitsObj) { 19595 var units = [], 19596 u; 19597 for (u in unitsObj) { 19598 if (hasOwnProp(unitsObj, u)) { 19599 units.push({ unit: u, priority: priorities[u] }); 19600 } 19601 } 19602 units.sort(function (a, b) { 19603 return a.priority - b.priority; 19604 }); 19605 return units; 19606 } 19607 19608 function isLeapYear(year) { 19609 return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; 19610 } 19611 19612 function absFloor(number) { 19613 if (number < 0) { 19614 // -0 -> 0 19615 return Math.ceil(number) || 0; 19616 } else { 19617 return Math.floor(number); 19618 } 19619 } 19620 19621 function toInt(argumentForCoercion) { 19622 var coercedNumber = +argumentForCoercion, 19623 value = 0; 19624 19625 if (coercedNumber !== 0 && isFinite(coercedNumber)) { 19626 value = absFloor(coercedNumber); 19627 } 19628 19629 return value; 19630 } 19631 19632 function makeGetSet(unit, keepTime) { 19633 return function (value) { 19634 if (value != null) { 19635 set$1(this, unit, value); 19636 hooks.updateOffset(this, keepTime); 19637 return this; 19638 } else { 19639 return get(this, unit); 19640 } 19641 }; 19642 } 19643 19644 function get(mom, unit) { 19645 return mom.isValid() 19646 ? mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() 19647 : NaN; 19648 } 19649 19650 function set$1(mom, unit, value) { 19651 if (mom.isValid() && !isNaN(value)) { 19652 if ( 19653 unit === 'FullYear' && 19654 isLeapYear(mom.year()) && 19655 mom.month() === 1 && 19656 mom.date() === 29 19657 ) { 19658 value = toInt(value); 19659 mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit]( 19660 value, 19661 mom.month(), 19662 daysInMonth(value, mom.month()) 19663 ); 19664 } else { 19665 mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value); 19666 } 19667 } 19668 } 19669 19670 // MOMENTS 19671 19672 function stringGet(units) { 19673 units = normalizeUnits(units); 19674 if (isFunction(this[units])) { 19675 return this[units](); 19676 } 19677 return this; 19678 } 19679 19680 function stringSet(units, value) { 19681 if (typeof units === 'object') { 19682 units = normalizeObjectUnits(units); 19683 var prioritized = getPrioritizedUnits(units), 19684 i
vendor: 5,547 bytes, lines 19684-19870
19684, 19685 prioritizedLen = prioritized.length; 19686 for (i = 0; i < prioritizedLen; i++) { 19687 this[prioritized[i].unit](units[prioritized[i].unit]); 19688 } 19689 } else { 19690 units = normalizeUnits(units); 19691 if (isFunction(this[units])) { 19692 return this[units](value); 19693 } 19694 } 19695 return this; 19696 } 19697 19698 var match1 = /\d/, // 0 - 9 19699 match2 = /\d\d/, // 00 - 99 19700 match3 = /\d{3}/, // 000 - 999 19701 match4 = /\d{4}/, // 0000 - 9999 19702 match6 = /[+-]?\d{6}/, // -999999 - 999999 19703 match1to2 = /\d\d?/, // 0 - 99 19704 match3to4 = /\d\d\d\d?/, // 999 - 9999 19705 match5to6 = /\d\d\d\d\d\d?/, // 99999 - 999999 19706 match1to3 = /\d{1,3}/, // 0 - 999 19707 match1to4 = /\d{1,4}/, // 0 - 9999 19708 match1to6 = /[+-]?\d{1,6}/, // -999999 - 999999 19709 matchUnsigned = /\d+/, // 0 - inf 19710 matchSigned = /[+-]?\d+/, // -inf - inf 19711 matchOffset = /Z|[+-]\d\d:?\d\d/gi, // +00:00 -00:00 +0000 -0000 or Z 19712 matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, // +00 -00 +00:00 -00:00 +0000 -0000 or Z 19713 matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, // 123456789 123456789.123 19714 // any word (or two) characters or numbers including two/three word month in arabic. 19715 // includes scottish gaelic two word and hyphenated months 19716 matchWord = 19717 /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i, 19718 regexes; 19719 19720 regexes = {}; 19721 19722 function addRegexToken(token, regex, strictRegex) { 19723 regexes[token] = isFunction(regex) 19724 ? regex 19725 : function (isStrict, localeData) { 19726 return isStrict && strictRegex ? strictRegex : regex; 19727 }; 19728 } 19729 19730 function getParseRegexForToken(token, config) { 19731 if (!hasOwnProp(regexes, token)) { 19732 return new RegExp(unescapeFormat(token)); 19733 } 19734 19735 return regexes[token](config._strict, config._locale); 19736 } 19737 19738 // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript 19739 function unescapeFormat(s) { 19740 return regexEscape( 19741 s 19742 .replace('\\', '') 19743 .replace( 19744 /\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, 19745 function (matched, p1, p2, p3, p4) { 19746 return p1 || p2 || p3 || p4; 19747 } 19748 ) 19749 ); 19750 } 19751 19752 function regexEscape(s) { 19753 return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); 19754 } 19755 19756 var tokens = {}; 19757 19758 function addParseToken(token, callback) { 19759 var i, 19760 func = callback, 19761 tokenLen; 19762 if (typeof token === 'string') { 19763 token = [token]; 19764 } 19765 if (isNumber(callback)) { 19766 func = function (input, array) { 19767 array[callback] = toInt(input); 19768 }; 19769 } 19770 tokenLen = token.length; 19771 for (i = 0; i < tokenLen; i++) { 19772 tokens[token[i]] = func; 19773 } 19774 } 19775 19776 function addWeekParseToken(token, callback) { 19777 addParseToken(token, function (input, array, config, token) { 19778 config._w = config._w || {}; 19779 callback(input, config._w, config, token); 19780 }); 19781 } 19782 19783 function addTimeToArrayFromToken(token, input, config) { 19784 if (input != null && hasOwnProp(tokens, token)) { 19785 tokens[token](input, config._a, config, token); 19786 } 19787 } 19788 19789 var YEAR = 0, 19790 MONTH = 1, 19791 DATE = 2, 19792 HOUR = 3, 19793 MINUTE = 4, 19794 SECOND = 5, 19795 MILLISECOND = 6, 19796 WEEK = 7, 19797 WEEKDAY = 8; 19798 19799 function mod(n, x) { 19800 return ((n % x) + x) % x; 19801 } 19802 19803 var indexOf; 19804 19805 if (Array.prototype.indexOf) { 19806 indexOf = Array.prototype.indexOf; 19807 } else { 19808 indexOf = function (o) { 19809 // I know 19810 var i; 19811 for (i = 0; i < this.length; ++i) { 19812 if (this[i] === o) { 19813 return i; 19814 } 19815 } 19816 return -1; 19817 }; 19818 } 19819 19820 function daysInMonth(year, month) { 19821 if (isNaN(year) || isNaN(month)) { 19822 return NaN; 19823 } 19824 var modMonth = mod(month, 12); 19825 year += (month - modMonth) / 12; 19826 return modMonth === 1 19827 ? isLeapYear(year) 19828 ? 29 19829 : 28 19830 : 31 - ((modMonth % 7) % 2); 19831 } 19832 19833 // FORMATTING 19834 19835 addFormatToken('M', ['MM', 2], 'Mo', function () { 19836 return this.month() + 1; 19837 }); 19838 19839 addFormatToken('MMM', 0, 0, function (format) { 19840 return this.localeData().monthsShort(this, format); 19841 }); 19842 19843 addFormatToken('MMMM', 0, 0, function (format) { 19844 return this.localeData().months(this, format); 19845 }); 19846 19847 // ALIASES 19848 19849 addUnitAlias('month', 'M'); 19850 19851 // PRIORITY 19852 19853 addUnitPriority('month', 8); 19854 19855 // PARSING 19856 19857 addRegexToken('M', match1to2); 19858 addRegexToken('MM', match1to2, match2); 19859 addRegexToken('MMM', function (isStrict, locale) { 19860 return locale.monthsShortRegex(isStrict); 19861 }); 19862 addRegexToken('MMMM', function (isStrict, locale) { 19863 return locale.monthsRegex(isStrict); 19864 }); 19865 19866 addParseToken(['M', 'MM'], function (input, array) { 19867 array[MONTH] = toInt(input) - 1; 19868 }); 19869 19870 addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
19871 var month = config._locale.monthsParse(input, token, config._strict); 19872 // if we didn't find a month name, mark the date as invalid. 19873 if (month != null) { 19874 array[MONTH] = month; 19875 } else { 19876 getParsingFlags(config).invalidMonth = input; 19877 } 19878 }); 19879 19880 // LOCALES 19881 19882 var defaultLocaleMonths = 19883 'January_February_March_April_May_June_July_August_September_October_November_December'.split( 19884 '_' 19885 ), 19886 defaultLocaleMonthsShort = 19887 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'
vendor: 13,773 bytes, lines 19887-20329
19887), 19888 MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/, 19889 defaultMonthsShortRegex = matchWord, 19890 defaultMonthsRegex = matchWord; 19891 19892 function localeMonths(m, format) { 19893 if (!m) { 19894 return isArray(this._months) 19895 ? this._months 19896 : this._months['standalone']; 19897 } 19898 return isArray(this._months) 19899 ? this._months[m.month()] 19900 : this._months[ 19901 (this._months.isFormat || MONTHS_IN_FORMAT).test(format) 19902 ? 'format' 19903 : 'standalone' 19904 ][m.month()]; 19905 } 19906 19907 function localeMonthsShort(m, format) { 19908 if (!m) { 19909 return isArray(this._monthsShort) 19910 ? this._monthsShort 19911 : this._monthsShort['standalone']; 19912 } 19913 return isArray(this._monthsShort) 19914 ? this._monthsShort[m.month()] 19915 : this._monthsShort[ 19916 MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone' 19917 ][m.month()]; 19918 } 19919 19920 function handleStrictParse(monthName, format, strict) { 19921 var i, 19922 ii, 19923 mom, 19924 llc = monthName.toLocaleLowerCase(); 19925 if (!this._monthsParse) { 19926 // this is not used 19927 this._monthsParse = []; 19928 this._longMonthsParse = []; 19929 this._shortMonthsParse = []; 19930 for (i = 0; i < 12; ++i) { 19931 mom = createUTC([2000, i]); 19932 this._shortMonthsParse[i] = this.monthsShort( 19933 mom, 19934 '' 19935 ).toLocaleLowerCase(); 19936 this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase(); 19937 } 19938 } 19939 19940 if (strict) { 19941 if (format === 'MMM') { 19942 ii = indexOf.call(this._shortMonthsParse, llc); 19943 return ii !== -1 ? ii : null; 19944 } else { 19945 ii = indexOf.call(this._longMonthsParse, llc); 19946 return ii !== -1 ? ii : null; 19947 } 19948 } else { 19949 if (format === 'MMM') { 19950 ii = indexOf.call(this._shortMonthsParse, llc); 19951 if (ii !== -1) { 19952 return ii; 19953 } 19954 ii = indexOf.call(this._longMonthsParse, llc); 19955 return ii !== -1 ? ii : null; 19956 } else { 19957 ii = indexOf.call(this._longMonthsParse, llc); 19958 if (ii !== -1) { 19959 return ii; 19960 } 19961 ii = indexOf.call(this._shortMonthsParse, llc); 19962 return ii !== -1 ? ii : null; 19963 } 19964 } 19965 } 19966 19967 function localeMonthsParse(monthName, format, strict) { 19968 var i, mom, regex; 19969 19970 if (this._monthsParseExact) { 19971 return handleStrictParse.call(this, monthName, format, strict); 19972 } 19973 19974 if (!this._monthsParse) { 19975 this._monthsParse = []; 19976 this._longMonthsParse = []; 19977 this._shortMonthsParse = []; 19978 } 19979 19980 // TODO: add sorting 19981 // Sorting makes sure if one month (or abbr) is a prefix of another 19982 // see sorting in computeMonthsParse 19983 for (i = 0; i < 12; i++) { 19984 // make the regex if we don't have it already 19985 mom = createUTC([2000, i]); 19986 if (strict && !this._longMonthsParse[i]) { 19987 this._longMonthsParse[i] = new RegExp( 19988 '^' + this.months(mom, '').replace('.', '') + '$', 19989 'i' 19990 ); 19991 this._shortMonthsParse[i] = new RegExp( 19992 '^' + this.monthsShort(mom, '').replace('.', '') + '$', 19993 'i' 19994 ); 19995 } 19996 if (!strict && !this._monthsParse[i]) { 19997 regex = 19998 '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, ''); 19999 this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i'); 20000 } 20001 // test the regex 20002 if ( 20003 strict && 20004 format === 'MMMM' && 20005 this._longMonthsParse[i].test(monthName) 20006 ) { 20007 return i; 20008 } else if ( 20009 strict && 20010 format === 'MMM' && 20011 this._shortMonthsParse[i].test(monthName) 20012 ) { 20013 return i; 20014 } else if (!strict && this._monthsParse[i].test(monthName)) { 20015 return i; 20016 } 20017 } 20018 } 20019 20020 // MOMENTS 20021 20022 function setMonth(mom, value) { 20023 var dayOfMonth; 20024 20025 if (!mom.isValid()) { 20026 // No op 20027 return mom; 20028 } 20029 20030 if (typeof value === 'string') { 20031 if (/^\d+$/.test(value)) { 20032 value = toInt(value); 20033 } else { 20034 value = mom.localeData().monthsParse(value); 20035 // TODO: Another silent failure? 20036 if (!isNumber(value)) { 20037 return mom; 20038 } 20039 } 20040 } 20041 20042 dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value)); 20043 mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth); 20044 return mom; 20045 } 20046 20047 function getSetMonth(value) { 20048 if (value != null) { 20049 setMonth(this, value); 20050 hooks.updateOffset(this, true); 20051 return this; 20052 } else { 20053 return get(this, 'Month'); 20054 } 20055 } 20056 20057 function getDaysInMonth() { 20058 return daysInMonth(this.year(), this.month()); 20059 } 20060 20061 function monthsShortRegex(isStrict) { 20062 if (this._monthsParseExact) { 20063 if (!hasOwnProp(this, '_monthsRegex')) { 20064 computeMonthsParse.call(this); 20065 } 20066 if (isStrict) { 20067 return this._monthsShortStrictRegex; 20068 } else { 20069 return this._monthsShortRegex; 20070 } 20071 } else { 20072 if (!hasOwnProp(this, '_monthsShortRegex')) { 20073 this._monthsShortRegex = defaultMonthsShortRegex; 20074 } 20075 return this._monthsShortStrictRegex && isStrict 20076 ? this._monthsShortStrictRegex 20077 : this._monthsShortRegex; 20078 } 20079 } 20080 20081 function monthsRegex(isStrict) { 20082 if (this._monthsParseExact) { 20083 if (!hasOwnProp(this, '_monthsRegex')) { 20084 computeMonthsParse.call(this); 20085 } 20086 if (isStrict) { 20087 return this._monthsStrictRegex; 20088 } else { 20089 return this._monthsRegex; 20090 } 20091 } else { 20092 if (!hasOwnProp(this, '_monthsRegex')) { 20093 this._monthsRegex = defaultMonthsRegex; 20094 } 20095 return this._monthsStrictRegex && isStrict 20096 ? this._monthsStrictRegex 20097 : this._monthsRegex; 20098 } 20099 } 20100 20101 function computeMonthsParse() { 20102 function cmpLenRev(a, b) { 20103 return b.length - a.length; 20104 } 20105 20106 var shortPieces = [], 20107 longPieces = [], 20108 mixedPieces = [], 20109 i, 20110 mom; 20111 for (i = 0; i < 12; i++) { 20112 // make the regex if we don't have it already 20113 mom = createUTC([2000, i]); 20114 shortPieces.push(this.monthsShort(mom, '')); 20115 longPieces.push(this.months(mom, '')); 20116 mixedPieces.push(this.months(mom, '')); 20117 mixedPieces.push(this.monthsShort(mom, '')); 20118 } 20119 // Sorting makes sure if one month (or abbr) is a prefix of another it 20120 // will match the longer piece. 20121 shortPieces.sort(cmpLenRev); 20122 longPieces.sort(cmpLenRev); 20123 mixedPieces.sort(cmpLenRev); 20124 for (i = 0; i < 12; i++) { 20125 shortPieces[i] = regexEscape(shortPieces[i]); 20126 longPieces[i] = regexEscape(longPieces[i]); 20127 } 20128 for (i = 0; i < 24; i++) { 20129 mixedPieces[i] = regexEscape(mixedPieces[i]); 20130 } 20131 20132 this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); 20133 this._monthsShortRegex = this._monthsRegex; 20134 this._monthsStrictRegex = new RegExp( 20135 '^(' + longPieces.join('|') + ')', 20136 'i' 20137 ); 20138 this._monthsShortStrictRegex = new RegExp( 20139 '^(' + shortPieces.join('|') + ')', 20140 'i' 20141 ); 20142 } 20143 20144 // FORMATTING 20145 20146 addFormatToken('Y', 0, 0, function () { 20147 var y = this.year(); 20148 return y <= 9999 ? zeroFill(y, 4) : '+' + y; 20149 }); 20150 20151 addFormatToken(0, ['YY', 2], 0, function () { 20152 return this.year() % 100; 20153 }); 20154 20155 addFormatToken(0, ['YYYY', 4], 0, 'year'); 20156 addFormatToken(0, ['YYYYY', 5], 0, 'year'); 20157 addFormatToken(0, ['YYYYYY', 6, true], 0, 'year'); 20158 20159 // ALIASES 20160 20161 addUnitAlias('year', 'y'); 20162 20163 // PRIORITIES 20164 20165 addUnitPriority('year', 1); 20166 20167 // PARSING 20168 20169 addRegexToken('Y', matchSigned); 20170 addRegexToken('YY', match1to2, match2); 20171 addRegexToken('YYYY', match1to4, match4); 20172 addRegexToken('YYYYY', match1to6, match6); 20173 addRegexToken('YYYYYY', match1to6, match6); 20174 20175 addParseToken(['YYYYY', 'YYYYYY'], YEAR); 20176 addParseToken('YYYY', function (input, array) { 20177 array[YEAR] = 20178 input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input); 20179 }); 20180 addParseToken('YY', function (input, array) { 20181 array[YEAR] = hooks.parseTwoDigitYear(input); 20182 }); 20183 addParseToken('Y', function (input, array) { 20184 array[YEAR] = parseInt(input, 10); 20185 }); 20186 20187 // HELPERS 20188 20189 function daysInYear(year) { 20190 return isLeapYear(year) ? 366 : 365; 20191 } 20192 20193 // HOOKS 20194 20195 hooks.parseTwoDigitYear = function (input) { 20196 return toInt(input) + (toInt(input) > 68 ? 1900 : 2000); 20197 }; 20198 20199 // MOMENTS 20200 20201 var getSetYear = makeGetSet('FullYear', true); 20202 20203 function getIsLeapYear() { 20204 return isLeapYear(this.year()); 20205 } 20206 20207 function createDate(y, m, d, h, M, s, ms) { 20208 // can't just apply() to create a date: 20209 // https://stackoverflow.com/q/181348 20210 var date; 20211 // the date constructor remaps years 0-99 to 1900-1999 20212 if (y < 100 && y >= 0) { 20213 // preserve leap years using a full 400 year cycle, then reset 20214 date = new Date(y + 400, m, d, h, M, s, ms); 20215 if (isFinite(date.getFullYear())) { 20216 date.setFullYear(y); 20217 } 20218 } else { 20219 date = new Date(y, m, d, h, M, s, ms); 20220 } 20221 20222 return date; 20223 } 20224 20225 function createUTCDate(y) { 20226 var date, args; 20227 // the Date.UTC function remaps years 0-99 to 1900-1999 20228 if (y < 100 && y >= 0) { 20229 args = Array.prototype.slice.call(arguments); 20230 // preserve leap years using a full 400 year cycle, then reset 20231 args[0] = y + 400; 20232 date = new Date(Date.UTC.apply(null, args)); 20233 if (isFinite(date.getUTCFullYear())) { 20234 date.setUTCFullYear(y); 20235 } 20236 } else { 20237 date = new Date(Date.UTC.apply(null, arguments)); 20238 } 20239 20240 return date; 20241 } 20242 20243 // start-of-first-week - start-of-year 20244 function firstWeekOffset(year, dow, doy) { 20245 var // first-week day -- which january is always in the first week (4 for iso, 1 for other) 20246 fwd = 7 + dow - doy, 20247 // first-week day local weekday -- which local weekday is fwd 20248 fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7; 20249 20250 return -fwdlw + fwd - 1; 20251 } 20252 20253 // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday 20254 function dayOfYearFromWeeks(year, week, weekday, dow, doy) { 20255 var localWeekday = (7 + weekday - dow) % 7, 20256 weekOffset = firstWeekOffset(year, dow, doy), 20257 dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset, 20258 resYear, 20259 resDayOfYear; 20260 20261 if (dayOfYear <= 0) { 20262 resYear = year - 1; 20263 resDayOfYear = daysInYear(resYear) + dayOfYear; 20264 } else if (dayOfYear > daysInYear(year)) { 20265 resYear = year + 1; 20266 resDayOfYear = dayOfYear - daysInYear(year); 20267 } else { 20268 resYear = year; 20269 resDayOfYear = dayOfYear; 20270 } 20271 20272 return { 20273 year: resYear, 20274 dayOfYear: resDayOfYear, 20275 }; 20276 } 20277 20278 function weekOfYear(mom, dow, doy) { 20279 var weekOffset = firstWeekOffset(mom.year(), dow, doy), 20280 week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1, 20281 resWeek, 20282 resYear; 20283 20284 if (week < 1) { 20285 resYear = mom.year() - 1; 20286 resWeek = week + weeksInYear(resYear, dow, doy); 20287 } else if (week > weeksInYear(mom.year(), dow, doy)) { 20288 resWeek = week - weeksInYear(mom.year(), dow, doy); 20289 resYear = mom.year() + 1; 20290 } else { 20291 resYear = mom.year(); 20292 resWeek = week; 20293 } 20294 20295 return { 20296 week: resWeek, 20297 year: resYear, 20298 }; 20299 } 20300 20301 function weeksInYear(year, dow, doy) { 20302 var weekOffset = firstWeekOffset(year, dow, doy), 20303 weekOffsetNext = firstWeekOffset(year + 1, dow, doy); 20304 return (daysInYear(year) - weekOffset + weekOffsetNext) / 7; 20305 } 20306 20307 // FORMATTING 20308 20309 addFormatToken('w', ['ww', 2], 'wo', 'week'); 20310 addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek'); 20311 20312 // ALIASES 20313 20314 addUnitAlias('week', 'w'); 20315 addUnitAlias('isoWeek', 'W'); 20316 20317 // PRIORITIES 20318 20319 addUnitPriority('week', 5); 20320 addUnitPriority('isoWeek', 5); 20321 20322 // PARSING 20323 20324 addRegexToken('w', match1to2); 20325 addRegexToken('ww', match1to2, match2); 20326 addRegexToken('W', match1to2); 20327 addRegexToken('WW', match1to2, match2); 20328 20329 addWeekParseToken(
vendor: 3,487 bytes, lines 20329-20460
20329 20330 ['w', 'ww', 'W', 'WW'], 20331 function (input, week, config, token) { 20332 week[token.substr(0, 1)] = toInt(input); 20333 } 20334 ); 20335 20336 // HELPERS 20337 20338 // LOCALES 20339 20340 function localeWeek(mom) { 20341 return weekOfYear(mom, this._week.dow, this._week.doy).week; 20342 } 20343 20344 var defaultLocaleWeek = { 20345 dow: 0, // Sunday is the first day of the week. 20346 doy: 6, // The week that contains Jan 6th is the first week of the year. 20347 }; 20348 20349 function localeFirstDayOfWeek() { 20350 return this._week.dow; 20351 } 20352 20353 function localeFirstDayOfYear() { 20354 return this._week.doy; 20355 } 20356 20357 // MOMENTS 20358 20359 function getSetWeek(input) { 20360 var week = this.localeData().week(this); 20361 return input == null ? week : this.add((input - week) * 7, 'd'); 20362 } 20363 20364 function getSetISOWeek(input) { 20365 var week = weekOfYear(this, 1, 4).week; 20366 return input == null ? week : this.add((input - week) * 7, 'd'); 20367 } 20368 20369 // FORMATTING 20370 20371 addFormatToken('d', 0, 'do', 'day'); 20372 20373 addFormatToken('dd', 0, 0, function (format) { 20374 return this.localeData().weekdaysMin(this, format); 20375 }); 20376 20377 addFormatToken('ddd', 0, 0, function (format) { 20378 return this.localeData().weekdaysShort(this, format); 20379 }); 20380 20381 addFormatToken('dddd', 0, 0, function (format) { 20382 return this.localeData().weekdays(this, format); 20383 }); 20384 20385 addFormatToken('e', 0, 0, 'weekday'); 20386 addFormatToken('E', 0, 0, 'isoWeekday'); 20387 20388 // ALIASES 20389 20390 addUnitAlias('day', 'd'); 20391 addUnitAlias('weekday', 'e'); 20392 addUnitAlias('isoWeekday', 'E'); 20393 20394 // PRIORITY 20395 addUnitPriority('day', 11); 20396 addUnitPriority('weekday', 11); 20397 addUnitPriority('isoWeekday', 11); 20398 20399 // PARSING 20400 20401 addRegexToken('d', match1to2); 20402 addRegexToken('e', match1to2); 20403 addRegexToken('E', match1to2); 20404 addRegexToken('dd', function (isStrict, locale) { 20405 return locale.weekdaysMinRegex(isStrict); 20406 }); 20407 addRegexToken('ddd', function (isStrict, locale) { 20408 return locale.weekdaysShortRegex(isStrict); 20409 }); 20410 addRegexToken('dddd', function (isStrict, locale) { 20411 return locale.weekdaysRegex(isStrict); 20412 }); 20413 20414 addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) { 20415 var weekday = config._locale.weekdaysParse(input, token, config._strict); 20416 // if we didn't get a weekday name, mark the date as invalid 20417 if (weekday != null) { 20418 week.d = weekday; 20419 } else { 20420 getParsingFlags(config).invalidWeekday = input; 20421 } 20422 }); 20423 20424 addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) { 20425 week[token] = toInt(input); 20426 }); 20427 20428 // HELPERS 20429 20430 function parseWeekday(input, locale) { 20431 if (typeof input !== 'string') { 20432 return input; 20433 } 20434 20435 if (!isNaN(input)) { 20436 return parseInt(input, 10); 20437 } 20438 20439 input = locale.weekdaysParse(input); 20440 if (typeof input === 'number') { 20441 return input; 20442 } 20443 20444 return null; 20445 } 20446 20447 function parseIsoWeekday(input, locale) { 20448 if (typeof input === 'string') { 20449 return locale.weekdaysParse(input) % 7 || 7; 20450 } 20451 return isNaN(input) ? null : input; 20452 } 20453 20454 // LOCALES 20455 function shiftWeekdays(ws, n) { 20456 return ws.slice(n, 7).concat(ws.slice(0, n)); 20457 } 20458 20459 var defaultLocaleWeekdays = 20460 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'
vendor: 17,864 bytes, lines 20460-21008
20460), 20461 defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), 20462 defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'), 20463 defaultWeekdaysRegex = matchWord, 20464 defaultWeekdaysShortRegex = matchWord, 20465 defaultWeekdaysMinRegex = matchWord; 20466 20467 function localeWeekdays(m, format) { 20468 var weekdays = isArray(this._weekdays) 20469 ? this._weekdays 20470 : this._weekdays[ 20471 m && m !== true && this._weekdays.isFormat.test(format) 20472 ? 'format' 20473 : 'standalone' 20474 ]; 20475 return m === true 20476 ? shiftWeekdays(weekdays, this._week.dow) 20477 : m 20478 ? weekdays[m.day()] 20479 : weekdays; 20480 } 20481 20482 function localeWeekdaysShort(m) { 20483 return m === true 20484 ? shiftWeekdays(this._weekdaysShort, this._week.dow) 20485 : m 20486 ? this._weekdaysShort[m.day()] 20487 : this._weekdaysShort; 20488 } 20489 20490 function localeWeekdaysMin(m) { 20491 return m === true 20492 ? shiftWeekdays(this._weekdaysMin, this._week.dow) 20493 : m 20494 ? this._weekdaysMin[m.day()] 20495 : this._weekdaysMin; 20496 } 20497 20498 function handleStrictParse$1(weekdayName, format, strict) { 20499 var i, 20500 ii, 20501 mom, 20502 llc = weekdayName.toLocaleLowerCase(); 20503 if (!this._weekdaysParse) { 20504 this._weekdaysParse = []; 20505 this._shortWeekdaysParse = []; 20506 this._minWeekdaysParse = []; 20507 20508 for (i = 0; i < 7; ++i) { 20509 mom = createUTC([2000, 1]).day(i); 20510 this._minWeekdaysParse[i] = this.weekdaysMin( 20511 mom, 20512 '' 20513 ).toLocaleLowerCase(); 20514 this._shortWeekdaysParse[i] = this.weekdaysShort( 20515 mom, 20516 '' 20517 ).toLocaleLowerCase(); 20518 this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase(); 20519 } 20520 } 20521 20522 if (strict) { 20523 if (format === 'dddd') { 20524 ii = indexOf.call(this._weekdaysParse, llc); 20525 return ii !== -1 ? ii : null; 20526 } else if (format === 'ddd') { 20527 ii = indexOf.call(this._shortWeekdaysParse, llc); 20528 return ii !== -1 ? ii : null; 20529 } else { 20530 ii = indexOf.call(this._minWeekdaysParse, llc); 20531 return ii !== -1 ? ii : null; 20532 } 20533 } else { 20534 if (format === 'dddd') { 20535 ii = indexOf.call(this._weekdaysParse, llc); 20536 if (ii !== -1) { 20537 return ii; 20538 } 20539 ii = indexOf.call(this._shortWeekdaysParse, llc); 20540 if (ii !== -1) { 20541 return ii; 20542 } 20543 ii = indexOf.call(this._minWeekdaysParse, llc); 20544 return ii !== -1 ? ii : null; 20545 } else if (format === 'ddd') { 20546 ii = indexOf.call(this._shortWeekdaysParse, llc); 20547 if (ii !== -1) { 20548 return ii; 20549 } 20550 ii = indexOf.call(this._weekdaysParse, llc); 20551 if (ii !== -1) { 20552 return ii; 20553 } 20554 ii = indexOf.call(this._minWeekdaysParse, llc); 20555 return ii !== -1 ? ii : null; 20556 } else { 20557 ii = indexOf.call(this._minWeekdaysParse, llc); 20558 if (ii !== -1) { 20559 return ii; 20560 } 20561 ii = indexOf.call(this._weekdaysParse, llc); 20562 if (ii !== -1) { 20563 return ii; 20564 } 20565 ii = indexOf.call(this._shortWeekdaysParse, llc); 20566 return ii !== -1 ? ii : null; 20567 } 20568 } 20569 } 20570 20571 function localeWeekdaysParse(weekdayName, format, strict) { 20572 var i, mom, regex; 20573 20574 if (this._weekdaysParseExact) { 20575 return handleStrictParse$1.call(this, weekdayName, format, strict); 20576 } 20577 20578 if (!this._weekdaysParse) { 20579 this._weekdaysParse = []; 20580 this._minWeekdaysParse = []; 20581 this._shortWeekdaysParse = []; 20582 this._fullWeekdaysParse = []; 20583 } 20584 20585 for (i = 0; i < 7; i++) { 20586 // make the regex if we don't have it already 20587 20588 mom = createUTC([2000, 1]).day(i); 20589 if (strict && !this._fullWeekdaysParse[i]) { 20590 this._fullWeekdaysParse[i] = new RegExp( 20591 '^' + this.weekdays(mom, '').replace('.', '\\.?') + '$', 20592 'i' 20593 ); 20594 this._shortWeekdaysParse[i] = new RegExp( 20595 '^' + this.weekdaysShort(mom, '').replace('.', '\\.?') + '$', 20596 'i' 20597 ); 20598 this._minWeekdaysParse[i] = new RegExp( 20599 '^' + this.weekdaysMin(mom, '').replace('.', '\\.?') + '$', 20600 'i' 20601 ); 20602 } 20603 if (!this._weekdaysParse[i]) { 20604 regex = 20605 '^' + 20606 this.weekdays(mom, '') + 20607 '|^' + 20608 this.weekdaysShort(mom, '') + 20609 '|^' + 20610 this.weekdaysMin(mom, ''); 20611 this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i'); 20612 } 20613 // test the regex 20614 if ( 20615 strict && 20616 format === 'dddd' && 20617 this._fullWeekdaysParse[i].test(weekdayName) 20618 ) { 20619 return i; 20620 } else if ( 20621 strict && 20622 format === 'ddd' && 20623 this._shortWeekdaysParse[i].test(weekdayName) 20624 ) { 20625 return i; 20626 } else if ( 20627 strict && 20628 format === 'dd' && 20629 this._minWeekdaysParse[i].test(weekdayName) 20630 ) { 20631 return i; 20632 } else if (!strict && this._weekdaysParse[i].test(weekdayName)) { 20633 return i; 20634 } 20635 } 20636 } 20637 20638 // MOMENTS 20639 20640 function getSetDayOfWeek(input) { 20641 if (!this.isValid()) { 20642 return input != null ? this : NaN; 20643 } 20644 var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay(); 20645 if (input != null) { 20646 input = parseWeekday(input, this.localeData()); 20647 return this.add(input - day, 'd'); 20648 } else { 20649 return day; 20650 } 20651 } 20652 20653 function getSetLocaleDayOfWeek(input) { 20654 if (!this.isValid()) { 20655 return input != null ? this : NaN; 20656 } 20657 var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7; 20658 return input == null ? weekday : this.add(input - weekday, 'd'); 20659 } 20660 20661 function getSetISODayOfWeek(input) { 20662 if (!this.isValid()) { 20663 return input != null ? this : NaN; 20664 } 20665 20666 // behaves the same as moment#day except 20667 // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6) 20668 // as a setter, sunday should belong to the previous week. 20669 20670 if (input != null) { 20671 var weekday = parseIsoWeekday(input, this.localeData()); 20672 return this.day(this.day() % 7 ? weekday : weekday - 7); 20673 } else { 20674 return this.day() || 7; 20675 } 20676 } 20677 20678 function weekdaysRegex(isStrict) { 20679 if (this._weekdaysParseExact) { 20680 if (!hasOwnProp(this, '_weekdaysRegex')) { 20681 computeWeekdaysParse.call(this); 20682 } 20683 if (isStrict) { 20684 return this._weekdaysStrictRegex; 20685 } else { 20686 return this._weekdaysRegex; 20687 } 20688 } else { 20689 if (!hasOwnProp(this, '_weekdaysRegex')) { 20690 this._weekdaysRegex = defaultWeekdaysRegex; 20691 } 20692 return this._weekdaysStrictRegex && isStrict 20693 ? this._weekdaysStrictRegex 20694 : this._weekdaysRegex; 20695 } 20696 } 20697 20698 function weekdaysShortRegex(isStrict) { 20699 if (this._weekdaysParseExact) { 20700 if (!hasOwnProp(this, '_weekdaysRegex')) { 20701 computeWeekdaysParse.call(this); 20702 } 20703 if (isStrict) { 20704 return this._weekdaysShortStrictRegex; 20705 } else { 20706 return this._weekdaysShortRegex; 20707 } 20708 } else { 20709 if (!hasOwnProp(this, '_weekdaysShortRegex')) { 20710 this._weekdaysShortRegex = defaultWeekdaysShortRegex; 20711 } 20712 return this._weekdaysShortStrictRegex && isStrict 20713 ? this._weekdaysShortStrictRegex 20714 : this._weekdaysShortRegex; 20715 } 20716 } 20717 20718 function weekdaysMinRegex(isStrict) { 20719 if (this._weekdaysParseExact) { 20720 if (!hasOwnProp(this, '_weekdaysRegex')) { 20721 computeWeekdaysParse.call(this); 20722 } 20723 if (isStrict) { 20724 return this._weekdaysMinStrictRegex; 20725 } else { 20726 return this._weekdaysMinRegex; 20727 } 20728 } else { 20729 if (!hasOwnProp(this, '_weekdaysMinRegex')) { 20730 this._weekdaysMinRegex = defaultWeekdaysMinRegex; 20731 } 20732 return this._weekdaysMinStrictRegex && isStrict 20733 ? this._weekdaysMinStrictRegex 20734 : this._weekdaysMinRegex; 20735 } 20736 } 20737 20738 function computeWeekdaysParse() { 20739 function cmpLenRev(a, b) { 20740 return b.length - a.length; 20741 } 20742 20743 var minPieces = [], 20744 shortPieces = [], 20745 longPieces = [], 20746 mixedPieces = [], 20747 i, 20748 mom, 20749 minp, 20750 shortp, 20751 longp; 20752 for (i = 0; i < 7; i++) { 20753 // make the regex if we don't have it already 20754 mom = createUTC([2000, 1]).day(i); 20755 minp = regexEscape(this.weekdaysMin(mom, '')); 20756 shortp = regexEscape(this.weekdaysShort(mom, '')); 20757 longp = regexEscape(this.weekdays(mom, '')); 20758 minPieces.push(minp); 20759 shortPieces.push(shortp); 20760 longPieces.push(longp); 20761 mixedPieces.push(minp); 20762 mixedPieces.push(shortp); 20763 mixedPieces.push(longp); 20764 } 20765 // Sorting makes sure if one weekday (or abbr) is a prefix of another it 20766 // will match the longer piece. 20767 minPieces.sort(cmpLenRev); 20768 shortPieces.sort(cmpLenRev); 20769 longPieces.sort(cmpLenRev); 20770 mixedPieces.sort(cmpLenRev); 20771 20772 this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); 20773 this._weekdaysShortRegex = this._weekdaysRegex; 20774 this._weekdaysMinRegex = this._weekdaysRegex; 20775 20776 this._weekdaysStrictRegex = new RegExp( 20777 '^(' + longPieces.join('|') + ')', 20778 'i' 20779 ); 20780 this._weekdaysShortStrictRegex = new RegExp( 20781 '^(' + shortPieces.join('|') + ')', 20782 'i' 20783 ); 20784 this._weekdaysMinStrictRegex = new RegExp( 20785 '^(' + minPieces.join('|') + ')', 20786 'i' 20787 ); 20788 } 20789 20790 // FORMATTING 20791 20792 function hFormat() { 20793 return this.hours() % 12 || 12; 20794 } 20795 20796 function kFormat() { 20797 return this.hours() || 24; 20798 } 20799 20800 addFormatToken('H', ['HH', 2], 0, 'hour'); 20801 addFormatToken('h', ['hh', 2], 0, hFormat); 20802 addFormatToken('k', ['kk', 2], 0, kFormat); 20803 20804 addFormatToken('hmm', 0, 0, function () { 20805 return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2); 20806 }); 20807 20808 addFormatToken('hmmss', 0, 0, function () { 20809 return ( 20810 '' + 20811 hFormat.apply(this) + 20812 zeroFill(this.minutes(), 2) + 20813 zeroFill(this.seconds(), 2) 20814 ); 20815 }); 20816 20817 addFormatToken('Hmm', 0, 0, function () { 20818 return '' + this.hours() + zeroFill(this.minutes(), 2); 20819 }); 20820 20821 addFormatToken('Hmmss', 0, 0, function () { 20822 return ( 20823 '' + 20824 this.hours() + 20825 zeroFill(this.minutes(), 2) + 20826 zeroFill(this.seconds(), 2) 20827 ); 20828 }); 20829 20830 function meridiem(token, lowercase) { 20831 addFormatToken(token, 0, 0, function () { 20832 return this.localeData().meridiem( 20833 this.hours(), 20834 this.minutes(), 20835 lowercase 20836 ); 20837 }); 20838 } 20839 20840 meridiem('a', true); 20841 meridiem('A', false); 20842 20843 // ALIASES 20844 20845 addUnitAlias('hour', 'h'); 20846 20847 // PRIORITY 20848 addUnitPriority('hour', 13); 20849 20850 // PARSING 20851 20852 function matchMeridiem(isStrict, locale) { 20853 return locale._meridiemParse; 20854 } 20855 20856 addRegexToken('a', matchMeridiem); 20857 addRegexToken('A', matchMeridiem); 20858 addRegexToken('H', match1to2); 20859 addRegexToken('h', match1to2); 20860 addRegexToken('k', match1to2); 20861 addRegexToken('HH', match1to2, match2); 20862 addRegexToken('hh', match1to2, match2); 20863 addRegexToken('kk', match1to2, match2); 20864 20865 addRegexToken('hmm', match3to4); 20866 addRegexToken('hmmss', match5to6); 20867 addRegexToken('Hmm', match3to4); 20868 addRegexToken('Hmmss', match5to6); 20869 20870 addParseToken(['H', 'HH'], HOUR); 20871 addParseToken(['k', 'kk'], function (input, array, config) { 20872 var kInput = toInt(input); 20873 array[HOUR] = kInput === 24 ? 0 : kInput; 20874 }); 20875 addParseToken(['a', 'A'], function (input, array, config) { 20876 config._isPm = config._locale.isPM(input); 20877 config._meridiem = input; 20878 }); 20879 addParseToken(['h', 'hh'], function (input, array, config) { 20880 array[HOUR] = toInt(input); 20881 getParsingFlags(config).bigHour = true; 20882 }); 20883 addParseToken('hmm', function (input, array, config) { 20884 var pos = input.length - 2; 20885 array[HOUR] = toInt(input.substr(0, pos)); 20886 array[MINUTE] = toInt(input.substr(pos)); 20887 getParsingFlags(config).bigHour = true; 20888 }); 20889 addParseToken('hmmss', function (input, array, config) { 20890 var pos1 = input.length - 4, 20891 pos2 = input.length - 2; 20892 array[HOUR] = toInt(input.substr(0, pos1)); 20893 array[MINUTE] = toInt(input.substr(pos1, 2)); 20894 array[SECOND] = toInt(input.substr(pos2)); 20895 getParsingFlags(config).bigHour = true; 20896 }); 20897 addParseToken('Hmm', function (input, array, config) { 20898 var pos = input.length - 2; 20899 array[HOUR] = toInt(input.substr(0, pos)); 20900 array[MINUTE] = toInt(input.substr(pos)); 20901 }); 20902 addParseToken('Hmmss', function (input, array, config) { 20903 var pos1 = input.length - 4, 20904 pos2 = input.length - 2; 20905 array[HOUR] = toInt(input.substr(0, pos1)); 20906 array[MINUTE] = toInt(input.substr(pos1, 2)); 20907 array[SECOND] = toInt(input.substr(pos2)); 20908 }); 20909 20910 // LOCALES 20911 20912 function localeIsPM(input) { 20913 // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays 20914 // Using charAt should be more compatible. 20915 return (input + '').toLowerCase().charAt(0) === 'p'; 20916 } 20917 20918 var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i, 20919 // Setting the hour should keep the time, because the user explicitly 20920 // specified which hour they want. So trying to maintain the same hour (in 20921 // a new timezone) makes sense. Adding/subtracting hours does not follow 20922 // this rule. 20923 getSetHour = makeGetSet('Hours', true); 20924 20925 function localeMeridiem(hours, minutes, isLower) { 20926 if (hours > 11) { 20927 return isLower ? 'pm' : 'PM'; 20928 } else { 20929 return isLower ? 'am' : 'AM'; 20930 } 20931 } 20932 20933 var baseConfig = { 20934 calendar: defaultCalendar, 20935 longDateFormat: defaultLongDateFormat, 20936 invalidDate: defaultInvalidDate, 20937 ordinal: defaultOrdinal, 20938 dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse, 20939 relativeTime: defaultRelativeTime, 20940 20941 months: defaultLocaleMonths, 20942 monthsShort: defaultLocaleMonthsShort, 20943 20944 week: defaultLocaleWeek, 20945 20946 weekdays: defaultLocaleWeekdays, 20947 weekdaysMin: defaultLocaleWeekdaysMin, 20948 weekdaysShort: defaultLocaleWeekdaysShort, 20949 20950 meridiemParse: defaultLocaleMeridiemParse, 20951 }; 20952 20953 // internal storage for locale config files 20954 var locales = {}, 20955 localeFamilies = {}, 20956 globalLocale; 20957 20958 function commonPrefix(arr1, arr2) { 20959 var i, 20960 minl = Math.min(arr1.length, arr2.length); 20961 for (i = 0; i < minl; i += 1) { 20962 if (arr1[i] !== arr2[i]) { 20963 return i; 20964 } 20965 } 20966 return minl; 20967 } 20968 20969 function normalizeLocale(key) { 20970 return key ? key.toLowerCase().replace('_', '-') : key; 20971 } 20972 20973 // pick the locale from the array 20974 // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each 20975 // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root 20976 function chooseLocale(names) { 20977 var i = 0, 20978 j, 20979 next, 20980 locale, 20981 split; 20982 20983 while (i < names.length) { 20984 split = normalizeLocale(names[i]).split('-'); 20985 j = split.length; 20986 next = normalizeLocale(names[i + 1]); 20987 next = next ? next.split('-') : null; 20988 while (j > 0) { 20989 locale = loadLocale(split.slice(0, j).join('-')); 20990 if (locale) { 20991 return locale; 20992 } 20993 if ( 20994 next && 20995 next.length >= j && 20996 commonPrefix(split, next) >= j - 1 20997 ) { 20998 //the next array item is better than a shallower substring of this one 20999 break; 21000 } 21001 j--; 21002 } 21003 i++; 21004 } 21005 return globalLocale; 21006 } 21007 21008 function
vendor: 7,449 bytes, lines 21008-21215
21008isLocaleNameSane(name) { 21009 // Prevent names that look like filesystem paths, i.e contain '/' or '\' 21010 return name.match('^[^/\\\\]*$') != null; 21011 } 21012 21013 function loadLocale(name) { 21014 var oldLocale = null, 21015 aliasedRequire; 21016 // TODO: Find a better way to register and load all the locales in Node 21017 if ( 21018 locales[name] === undefined && 21019 typeof module !== 'undefined' && 21020 module && 21021 module.exports && 21022 isLocaleNameSane(name) 21023 ) { 21024 try { 21025 oldLocale = globalLocale._abbr; 21026 aliasedRequire = require; 21027 aliasedRequire('./locale/' + name); 21028 getSetGlobalLocale(oldLocale); 21029 } catch (e) { 21030 // mark as not found to avoid repeating expensive file require call causing high CPU 21031 // when trying to find en-US, en_US, en-us for every format call 21032 locales[name] = null; // null means not found 21033 } 21034 } 21035 return locales[name]; 21036 } 21037 21038 // This function will load locale and then set the global locale. If 21039 // no arguments are passed in, it will simply return the current global 21040 // locale key. 21041 function getSetGlobalLocale(key, values) { 21042 var data; 21043 if (key) { 21044 if (isUndefined(values)) { 21045 data = getLocale(key); 21046 } else { 21047 data = defineLocale(key, values); 21048 } 21049 21050 if (data) { 21051 // moment.duration._locale = moment._locale = data; 21052 globalLocale = data; 21053 } else { 21054 if (typeof console !== 'undefined' && console.warn) { 21055 //warn user if arguments are passed but the locale could not be set 21056 console.warn( 21057 'Locale ' + key + ' not found. Did you forget to load it?' 21058 ); 21059 } 21060 } 21061 } 21062 21063 return globalLocale._abbr; 21064 } 21065 21066 function defineLocale(name, config) { 21067 if (config !== null) { 21068 var locale, 21069 parentConfig = baseConfig; 21070 config.abbr = name; 21071 if (locales[name] != null) { 21072 deprecateSimple( 21073 'defineLocaleOverride', 21074 'use moment.updateLocale(localeName, config) to change ' + 21075 'an existing locale. moment.defineLocale(localeName, ' + 21076 'config) should only be used for creating a new locale ' + 21077 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.' 21078 ); 21079 parentConfig = locales[name]._config; 21080 } else if (config.parentLocale != null) { 21081 if (locales[config.parentLocale] != null) { 21082 parentConfig = locales[config.parentLocale]._config; 21083 } else { 21084 locale = loadLocale(config.parentLocale); 21085 if (locale != null) { 21086 parentConfig = locale._config; 21087 } else { 21088 if (!localeFamilies[config.parentLocale]) { 21089 localeFamilies[config.parentLocale] = []; 21090 } 21091 localeFamilies[config.parentLocale].push({ 21092 name: name, 21093 config: config, 21094 }); 21095 return null; 21096 } 21097 } 21098 } 21099 locales[name] = new Locale(mergeConfigs(parentConfig, config)); 21100 21101 if (localeFamilies[name]) { 21102 localeFamilies[name].forEach(function (x) { 21103 defineLocale(x.name, x.config); 21104 }); 21105 } 21106 21107 // backwards compat for now: also set the locale 21108 // make sure we set the locale AFTER all child locales have been 21109 // created, so we won't end up with the child locale set. 21110 getSetGlobalLocale(name); 21111 21112 return locales[name]; 21113 } else { 21114 // useful for testing 21115 delete locales[name]; 21116 return null; 21117 } 21118 } 21119 21120 function updateLocale(name, config) { 21121 if (config != null) { 21122 var locale, 21123 tmpLocale, 21124 parentConfig = baseConfig; 21125 21126 if (locales[name] != null && locales[name].parentLocale != null) { 21127 // Update existing child locale in-place to avoid memory-leaks 21128 locales[name].set(mergeConfigs(locales[name]._config, config)); 21129 } else { 21130 // MERGE 21131 tmpLocale = loadLocale(name); 21132 if (tmpLocale != null) { 21133 parentConfig = tmpLocale._config; 21134 } 21135 config = mergeConfigs(parentConfig, config); 21136 if (tmpLocale == null) { 21137 // updateLocale is called for creating a new locale 21138 // Set abbr so it will have a name (getters return 21139 // undefined otherwise). 21140 config.abbr = name; 21141 } 21142 locale = new Locale(config); 21143 locale.parentLocale = locales[name]; 21144 locales[name] = locale; 21145 } 21146 21147 // backwards compat for now: also set the locale 21148 getSetGlobalLocale(name); 21149 } else { 21150 // pass null for config to unupdate, useful for tests 21151 if (locales[name] != null) { 21152 if (locales[name].parentLocale != null) { 21153 locales[name] = locales[name].parentLocale; 21154 if (name === getSetGlobalLocale()) { 21155 getSetGlobalLocale(name); 21156 } 21157 } else if (locales[name] != null) { 21158 delete locales[name]; 21159 } 21160 } 21161 } 21162 return locales[name]; 21163 } 21164 21165 // returns locale data 21166 function getLocale(key) { 21167 var locale; 21168 21169 if (key && key._locale && key._locale._abbr) { 21170 key = key._locale._abbr; 21171 } 21172 21173 if (!key) { 21174 return globalLocale; 21175 } 21176 21177 if (!isArray(key)) { 21178 //short-circuit everything else 21179 locale = loadLocale(key); 21180 if (locale) { 21181 return locale; 21182 } 21183 key = [key]; 21184 } 21185 21186 return chooseLocale(key); 21187 } 21188 21189 function listLocales() { 21190 return keys(locales); 21191 } 21192 21193 function checkOverflow(m) { 21194 var overflow, 21195 a = m._a; 21196 21197 if (a && getParsingFlags(m).overflow === -2) { 21198 overflow = 21199 a[MONTH] < 0 || a[MONTH] > 11 21200 ? MONTH 21201 : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) 21202 ? DATE 21203 : a[HOUR] < 0 || 21204 a[HOUR] > 24 || 21205 (a[HOUR] === 24 && 21206 (a[MINUTE] !== 0 || 21207 a[SECOND] !== 0 || 21208 a[MILLISECOND] !== 0)) 21209 ? HOUR 21210 : a[MINUTE] < 0 || a[MINUTE] > 59 21211 ? MINUTE 21212 : a[SECOND] < 0 || a[SECOND] > 59 21213 ? SECOND 21214 : a[MILLISECOND] < 0 || a[MILLISECOND] > 999 21215 ? MILLISECOND
vendor: 9,346 bytes, lines 21216-21499
21216 : -1; 21217 21218 if ( 21219 getParsingFlags(m)._overflowDayOfYear && 21220 (overflow < YEAR || overflow > DATE) 21221 ) { 21222 overflow = DATE; 21223 } 21224 if (getParsingFlags(m)._overflowWeeks && overflow === -1) { 21225 overflow = WEEK; 21226 } 21227 if (getParsingFlags(m)._overflowWeekday && overflow === -1) { 21228 overflow = WEEKDAY; 21229 } 21230 21231 getParsingFlags(m).overflow = overflow; 21232 } 21233 21234 return m; 21235 } 21236 21237 // iso 8601 regex 21238 // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00) 21239 var extendedIsoRegex = 21240 /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, 21241 basicIsoRegex = 21242 /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, 21243 tzRegex = /Z|[+-]\d\d(?::?\d\d)?/, 21244 isoDates = [ 21245 ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/], 21246 ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/], 21247 ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/], 21248 ['GGGG-[W]WW', /\d{4}-W\d\d/, false], 21249 ['YYYY-DDD', /\d{4}-\d{3}/], 21250 ['YYYY-MM', /\d{4}-\d\d/, false], 21251 ['YYYYYYMMDD', /[+-]\d{10}/], 21252 ['YYYYMMDD', /\d{8}/], 21253 ['GGGG[W]WWE', /\d{4}W\d{3}/], 21254 ['GGGG[W]WW', /\d{4}W\d{2}/, false], 21255 ['YYYYDDD', /\d{7}/], 21256 ['YYYYMM', /\d{6}/, false], 21257 ['YYYY', /\d{4}/, false], 21258 ], 21259 // iso time formats and regexes 21260 isoTimes = [ 21261 ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/], 21262 ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/], 21263 ['HH:mm:ss', /\d\d:\d\d:\d\d/], 21264 ['HH:mm', /\d\d:\d\d/], 21265 ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/], 21266 ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/], 21267 ['HHmmss', /\d\d\d\d\d\d/], 21268 ['HHmm', /\d\d\d\d/], 21269 ['HH', /\d\d/], 21270 ], 21271 aspNetJsonRegex = /^\/?Date\((-?\d+)/i, 21272 // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3 21273 rfc2822 = 21274 /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/, 21275 obsOffsets = { 21276 UT: 0, 21277 GMT: 0, 21278 EDT: -4 * 60, 21279 EST: -5 * 60, 21280 CDT: -5 * 60, 21281 CST: -6 * 60, 21282 MDT: -6 * 60, 21283 MST: -7 * 60, 21284 PDT: -7 * 60, 21285 PST: -8 * 60, 21286 }; 21287 21288 // date from iso format 21289 function configFromISO(config) { 21290 var i, 21291 l, 21292 string = config._i, 21293 match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string), 21294 allowTime, 21295 dateFormat, 21296 timeFormat, 21297 tzFormat, 21298 isoDatesLen = isoDates.length, 21299 isoTimesLen = isoTimes.length; 21300 21301 if (match) { 21302 getParsingFlags(config).iso = true; 21303 for (i = 0, l = isoDatesLen; i < l; i++) { 21304 if (isoDates[i][1].exec(match[1])) { 21305 dateFormat = isoDates[i][0]; 21306 allowTime = isoDates[i][2] !== false; 21307 break; 21308 } 21309 } 21310 if (dateFormat == null) { 21311 config._isValid = false; 21312 return; 21313 } 21314 if (match[3]) { 21315 for (i = 0, l = isoTimesLen; i < l; i++) { 21316 if (isoTimes[i][1].exec(match[3])) { 21317 // match[2] should be 'T' or space 21318 timeFormat = (match[2] || ' ') + isoTimes[i][0]; 21319 break; 21320 } 21321 } 21322 if (timeFormat == null) { 21323 config._isValid = false; 21324 return; 21325 } 21326 } 21327 if (!allowTime && timeFormat != null) { 21328 config._isValid = false; 21329 return; 21330 } 21331 if (match[4]) { 21332 if (tzRegex.exec(match[4])) { 21333 tzFormat = 'Z'; 21334 } else { 21335 config._isValid = false; 21336 return; 21337 } 21338 } 21339 config._f = dateFormat + (timeFormat || '') + (tzFormat || ''); 21340 configFromStringAndFormat(config); 21341 } else { 21342 config._isValid = false; 21343 } 21344 } 21345 21346 function extractFromRFC2822Strings( 21347 yearStr, 21348 monthStr, 21349 dayStr, 21350 hourStr, 21351 minuteStr, 21352 secondStr 21353 ) { 21354 var result = [ 21355 untruncateYear(yearStr), 21356 defaultLocaleMonthsShort.indexOf(monthStr), 21357 parseInt(dayStr, 10), 21358 parseInt(hourStr, 10), 21359 parseInt(minuteStr, 10), 21360 ]; 21361 21362 if (secondStr) { 21363 result.push(parseInt(secondStr, 10)); 21364 } 21365 21366 return result; 21367 } 21368 21369 function untruncateYear(yearStr) { 21370 var year = parseInt(yearStr, 10); 21371 if (year <= 49) { 21372 return 2000 + year; 21373 } else if (year <= 999) { 21374 return 1900 + year; 21375 } 21376 return year; 21377 } 21378 21379 function preprocessRFC2822(s) { 21380 // Remove comments and folding whitespace and replace multiple-spaces with a single space 21381 return s 21382 .replace(/\([^()]*\)|[\n\t]/g, ' ') 21383 .replace(/(\s\s+)/g, ' ') 21384 .replace(/^\s\s*/, '') 21385 .replace(/\s\s*$/, ''); 21386 } 21387 21388 function checkWeekday(weekdayStr, parsedInput, config) { 21389 if (weekdayStr) { 21390 // TODO: Replace the vanilla JS Date object with an independent day-of-week check. 21391 var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr), 21392 weekdayActual = new Date( 21393 parsedInput[0], 21394 parsedInput[1], 21395 parsedInput[2] 21396 ).getDay(); 21397 if (weekdayProvided !== weekdayActual) { 21398 getParsingFlags(config).weekdayMismatch = true; 21399 config._isValid = false; 21400 return false; 21401 } 21402 } 21403 return true; 21404 } 21405 21406 function calculateOffset(obsOffset, militaryOffset, numOffset) { 21407 if (obsOffset) { 21408 return obsOffsets[obsOffset]; 21409 } else if (militaryOffset) { 21410 // the only allowed military tz is Z 21411 return 0; 21412 } else { 21413 var hm = parseInt(numOffset, 10), 21414 m = hm % 100, 21415 h = (hm - m) / 100; 21416 return h * 60 + m; 21417 } 21418 } 21419 21420 // date and time from ref 2822 format 21421 function configFromRFC2822(config) { 21422 var match = rfc2822.exec(preprocessRFC2822(config._i)), 21423 parsedArray; 21424 if (match) { 21425 parsedArray = extractFromRFC2822Strings( 21426 match[4], 21427 match[3], 21428 match[2], 21429 match[5], 21430 match[6], 21431 match[7] 21432 ); 21433 if (!checkWeekday(match[1], parsedArray, config)) { 21434 return; 21435 } 21436 21437 config._a = parsedArray; 21438 config._tzm = calculateOffset(match[8], match[9], match[10]); 21439 21440 config._d = createUTCDate.apply(null, config._a); 21441 config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm); 21442 21443 getParsingFlags(config).rfc2822 = true; 21444 } else { 21445 config._isValid = false; 21446 } 21447 } 21448 21449 // date from 1) ASP.NET, 2) ISO, 3) RFC 2822 formats, or 4) optional fallback if parsing isn't strict 21450 function configFromString(config) { 21451 var matched = aspNetJsonRegex.exec(config._i); 21452 if (matched !== null) { 21453 config._d = new Date(+matched[1]); 21454 return; 21455 } 21456 21457 configFromISO(config); 21458 if (config._isValid === false) { 21459 delete config._isValid; 21460 } else { 21461 return; 21462 } 21463 21464 configFromRFC2822(config); 21465 if (config._isValid === false) { 21466 delete config._isValid; 21467 } else { 21468 return; 21469 } 21470 21471 if (config._strict) { 21472 config._isValid = false; 21473 } else { 21474 // Final attempt, use Input Fallback 21475 hooks.createFromInputFallback(config); 21476 } 21477 } 21478 21479 hooks.createFromInputFallback = deprecate( 21480 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' + 21481 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' + 21482 'discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.', 21483 function (config) { 21484 config._d = new Date(config._i + (config._useUTC ? ' UTC' : '')); 21485 } 21486 ); 21487 21488 // Pick the first defined of two or three arguments. 21489 function defaults(a, b, c) { 21490 if (a != null) { 21491 return a; 21492 } 21493 if (b != null) { 21494 return b; 21495 } 21496 return c; 21497 } 21498 21499 function currentDateArray(config
vendor: 17,694 bytes, lines 21499-22060
21499) { 21500 // hooks is actually the exported moment object 21501 var nowValue = new Date(hooks.now()); 21502 if (config._useUTC) { 21503 return [ 21504 nowValue.getUTCFullYear(), 21505 nowValue.getUTCMonth(), 21506 nowValue.getUTCDate(), 21507 ]; 21508 } 21509 return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()]; 21510 } 21511 21512 // convert an array to a date. 21513 // the array should mirror the parameters below 21514 // note: all values past the year are optional and will default to the lowest possible value. 21515 // [year, month, day , hour, minute, second, millisecond] 21516 function configFromArray(config) { 21517 var i, 21518 date, 21519 input = [], 21520 currentDate, 21521 expectedWeekday, 21522 yearToUse; 21523 21524 if (config._d) { 21525 return; 21526 } 21527 21528 currentDate = currentDateArray(config); 21529 21530 //compute day of the year from weeks and weekdays 21531 if (config._w && config._a[DATE] == null && config._a[MONTH] == null) { 21532 dayOfYearFromWeekInfo(config); 21533 } 21534 21535 //if the day of the year is set, figure out what it is 21536 if (config._dayOfYear != null) { 21537 yearToUse = defaults(config._a[YEAR], currentDate[YEAR]); 21538 21539 if ( 21540 config._dayOfYear > daysInYear(yearToUse) || 21541 config._dayOfYear === 0 21542 ) { 21543 getParsingFlags(config)._overflowDayOfYear = true; 21544 } 21545 21546 date = createUTCDate(yearToUse, 0, config._dayOfYear); 21547 config._a[MONTH] = date.getUTCMonth(); 21548 config._a[DATE] = date.getUTCDate(); 21549 } 21550 21551 // Default to current date. 21552 // * if no year, month, day of month are given, default to today 21553 // * if day of month is given, default month and year 21554 // * if month is given, default only year 21555 // * if year is given, don't default anything 21556 for (i = 0; i < 3 && config._a[i] == null; ++i) { 21557 config._a[i] = input[i] = currentDate[i]; 21558 } 21559 21560 // Zero out whatever was not defaulted, including time 21561 for (; i < 7; i++) { 21562 config._a[i] = input[i] = 21563 config._a[i] == null ? (i === 2 ? 1 : 0) : config._a[i]; 21564 } 21565 21566 // Check for 24:00:00.000 21567 if ( 21568 config._a[HOUR] === 24 && 21569 config._a[MINUTE] === 0 && 21570 config._a[SECOND] === 0 && 21571 config._a[MILLISECOND] === 0 21572 ) { 21573 config._nextDay = true; 21574 config._a[HOUR] = 0; 21575 } 21576 21577 config._d = (config._useUTC ? createUTCDate : createDate).apply( 21578 null, 21579 input 21580 ); 21581 expectedWeekday = config._useUTC 21582 ? config._d.getUTCDay() 21583 : config._d.getDay(); 21584 21585 // Apply timezone offset from input. The actual utcOffset can be changed 21586 // with parseZone. 21587 if (config._tzm != null) { 21588 config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm); 21589 } 21590 21591 if (config._nextDay) { 21592 config._a[HOUR] = 24; 21593 } 21594 21595 // check for mismatching day of week 21596 if ( 21597 config._w && 21598 typeof config._w.d !== 'undefined' && 21599 config._w.d !== expectedWeekday 21600 ) { 21601 getParsingFlags(config).weekdayMismatch = true; 21602 } 21603 } 21604 21605 function dayOfYearFromWeekInfo(config) { 21606 var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek; 21607 21608 w = config._w; 21609 if (w.GG != null || w.W != null || w.E != null) { 21610 dow = 1; 21611 doy = 4; 21612 21613 // TODO: We need to take the current isoWeekYear, but that depends on 21614 // how we interpret now (local, utc, fixed offset). So create 21615 // a now version of current config (take local/utc/offset flags, and 21616 // create now). 21617 weekYear = defaults( 21618 w.GG, 21619 config._a[YEAR], 21620 weekOfYear(createLocal(), 1, 4).year 21621 ); 21622 week = defaults(w.W, 1); 21623 weekday = defaults(w.E, 1); 21624 if (weekday < 1 || weekday > 7) { 21625 weekdayOverflow = true; 21626 } 21627 } else { 21628 dow = config._locale._week.dow; 21629 doy = config._locale._week.doy; 21630 21631 curWeek = weekOfYear(createLocal(), dow, doy); 21632 21633 weekYear = defaults(w.gg, config._a[YEAR], curWeek.year); 21634 21635 // Default to current week. 21636 week = defaults(w.w, curWeek.week); 21637 21638 if (w.d != null) { 21639 // weekday -- low day numbers are considered next week 21640 weekday = w.d; 21641 if (weekday < 0 || weekday > 6) { 21642 weekdayOverflow = true; 21643 } 21644 } else if (w.e != null) { 21645 // local weekday -- counting starts from beginning of week 21646 weekday = w.e + dow; 21647 if (w.e < 0 || w.e > 6) { 21648 weekdayOverflow = true; 21649 } 21650 } else { 21651 // default to beginning of week 21652 weekday = dow; 21653 } 21654 } 21655 if (week < 1 || week > weeksInYear(weekYear, dow, doy)) { 21656 getParsingFlags(config)._overflowWeeks = true; 21657 } else if (weekdayOverflow != null) { 21658 getParsingFlags(config)._overflowWeekday = true; 21659 } else { 21660 temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy); 21661 config._a[YEAR] = temp.year; 21662 config._dayOfYear = temp.dayOfYear; 21663 } 21664 } 21665 21666 // constant that refers to the ISO standard 21667 hooks.ISO_8601 = function () {}; 21668 21669 // constant that refers to the RFC 2822 form 21670 hooks.RFC_2822 = function () {}; 21671 21672 // date from string and format string 21673 function configFromStringAndFormat(config) { 21674 // TODO: Move this to another part of the creation flow to prevent circular deps 21675 if (config._f === hooks.ISO_8601) { 21676 configFromISO(config); 21677 return; 21678 } 21679 if (config._f === hooks.RFC_2822) { 21680 configFromRFC2822(config); 21681 return; 21682 } 21683 config._a = []; 21684 getParsingFlags(config).empty = true; 21685 21686 // This array is used to make a Date, either with `new Date` or `Date.UTC` 21687 var string = '' + config._i, 21688 i, 21689 parsedInput, 21690 tokens, 21691 token, 21692 skipped, 21693 stringLength = string.length, 21694 totalParsedInputLength = 0, 21695 era, 21696 tokenLen; 21697 21698 tokens = 21699 expandFormat(config._f, config._locale).match(formattingTokens) || []; 21700 tokenLen = tokens.length; 21701 for (i = 0; i < tokenLen; i++) { 21702 token = tokens[i]; 21703 parsedInput = (string.match(getParseRegexForToken(token, config)) || 21704 [])[0]; 21705 if (parsedInput) { 21706 skipped = string.substr(0, string.indexOf(parsedInput)); 21707 if (skipped.length > 0) { 21708 getParsingFlags(config).unusedInput.push(skipped); 21709 } 21710 string = string.slice( 21711 string.indexOf(parsedInput) + parsedInput.length 21712 ); 21713 totalParsedInputLength += parsedInput.length; 21714 } 21715 // don't parse if it's not a known token 21716 if (formatTokenFunctions[token]) { 21717 if (parsedInput) { 21718 getParsingFlags(config).empty = false; 21719 } else { 21720 getParsingFlags(config).unusedTokens.push(token); 21721 } 21722 addTimeToArrayFromToken(token, parsedInput, config); 21723 } else if (config._strict && !parsedInput) { 21724 getParsingFlags(config).unusedTokens.push(token); 21725 } 21726 } 21727 21728 // add remaining unparsed input length to the string 21729 getParsingFlags(config).charsLeftOver = 21730 stringLength - totalParsedInputLength; 21731 if (string.length > 0) { 21732 getParsingFlags(config).unusedInput.push(string); 21733 } 21734 21735 // clear _12h flag if hour is <= 12 21736 if ( 21737 config._a[HOUR] <= 12 && 21738 getParsingFlags(config).bigHour === true && 21739 config._a[HOUR] > 0 21740 ) { 21741 getParsingFlags(config).bigHour = undefined; 21742 } 21743 21744 getParsingFlags(config).parsedDateParts = config._a.slice(0); 21745 getParsingFlags(config).meridiem = config._meridiem; 21746 // handle meridiem 21747 config._a[HOUR] = meridiemFixWrap( 21748 config._locale, 21749 config._a[HOUR], 21750 config._meridiem 21751 ); 21752 21753 // handle era 21754 era = getParsingFlags(config).era; 21755 if (era !== null) { 21756 config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]); 21757 } 21758 21759 configFromArray(config); 21760 checkOverflow(config); 21761 } 21762 21763 function meridiemFixWrap(locale, hour, meridiem) { 21764 var isPm; 21765 21766 if (meridiem == null) { 21767 // nothing to do 21768 return hour; 21769 } 21770 if (locale.meridiemHour != null) { 21771 return locale.meridiemHour(hour, meridiem); 21772 } else if (locale.isPM != null) { 21773 // Fallback 21774 isPm = locale.isPM(meridiem); 21775 if (isPm && hour < 12) { 21776 hour += 12; 21777 } 21778 if (!isPm && hour === 12) { 21779 hour = 0; 21780 } 21781 return hour; 21782 } else { 21783 // this is not supposed to happen 21784 return hour; 21785 } 21786 } 21787 21788 // date from string and array of format strings 21789 function configFromStringAndArray(config) { 21790 var tempConfig, 21791 bestMoment, 21792 scoreToBeat, 21793 i, 21794 currentScore, 21795 validFormatFound, 21796 bestFormatIsValid = false, 21797 configfLen = config._f.length; 21798 21799 if (configfLen === 0) { 21800 getParsingFlags(config).invalidFormat = true; 21801 config._d = new Date(NaN); 21802 return; 21803 } 21804 21805 for (i = 0; i < configfLen; i++) { 21806 currentScore = 0; 21807 validFormatFound = false; 21808 tempConfig = copyConfig({}, config); 21809 if (config._useUTC != null) { 21810 tempConfig._useUTC = config._useUTC; 21811 } 21812 tempConfig._f = config._f[i]; 21813 configFromStringAndFormat(tempConfig); 21814 21815 if (isValid(tempConfig)) { 21816 validFormatFound = true; 21817 } 21818 21819 // if there is any input that was not parsed add a penalty for that format 21820 currentScore += getParsingFlags(tempConfig).charsLeftOver; 21821 21822 //or tokens 21823 currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10; 21824 21825 getParsingFlags(tempConfig).score = currentScore; 21826 21827 if (!bestFormatIsValid) { 21828 if ( 21829 scoreToBeat == null || 21830 currentScore < scoreToBeat || 21831 validFormatFound 21832 ) { 21833 scoreToBeat = currentScore; 21834 bestMoment = tempConfig; 21835 if (validFormatFound) { 21836 bestFormatIsValid = true; 21837 } 21838 } 21839 } else { 21840 if (currentScore < scoreToBeat) { 21841 scoreToBeat = currentScore; 21842 bestMoment = tempConfig; 21843 } 21844 } 21845 } 21846 21847 extend(config, bestMoment || tempConfig); 21848 } 21849 21850 function configFromObject(config) { 21851 if (config._d) { 21852 return; 21853 } 21854 21855 var i = normalizeObjectUnits(config._i), 21856 dayOrDate = i.day === undefined ? i.date : i.day; 21857 config._a = map( 21858 [i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond], 21859 function (obj) { 21860 return obj && parseInt(obj, 10); 21861 } 21862 ); 21863 21864 configFromArray(config); 21865 } 21866 21867 function createFromConfig(config) { 21868 var res = new Moment(checkOverflow(prepareConfig(config))); 21869 if (res._nextDay) { 21870 // Adding is smart enough around DST 21871 res.add(1, 'd'); 21872 res._nextDay = undefined; 21873 } 21874 21875 return res; 21876 } 21877 21878 function prepareConfig(config) { 21879 var input = config._i, 21880 format = config._f; 21881 21882 config._locale = config._locale || getLocale(config._l); 21883 21884 if (input === null || (format === undefined && input === '')) { 21885 return createInvalid({ nullInput: true }); 21886 } 21887 21888 if (typeof input === 'string') { 21889 config._i = input = config._locale.preparse(input); 21890 } 21891 21892 if (isMoment(input)) { 21893 return new Moment(checkOverflow(input)); 21894 } else if (isDate(input)) { 21895 config._d = input; 21896 } else if (isArray(format)) { 21897 configFromStringAndArray(config); 21898 } else if (format) { 21899 configFromStringAndFormat(config); 21900 } else { 21901 configFromInput(config); 21902 } 21903 21904 if (!isValid(config)) { 21905 config._d = null; 21906 } 21907 21908 return config; 21909 } 21910 21911 function configFromInput(config) { 21912 var input = config._i; 21913 if (isUndefined(input)) { 21914 config._d = new Date(hooks.now()); 21915 } else if (isDate(input)) { 21916 config._d = new Date(input.valueOf()); 21917 } else if (typeof input === 'string') { 21918 configFromString(config); 21919 } else if (isArray(input)) { 21920 config._a = map(input.slice(0), function (obj) { 21921 return parseInt(obj, 10); 21922 }); 21923 configFromArray(config); 21924 } else if (isObject(input)) { 21925 configFromObject(config); 21926 } else if (isNumber(input)) { 21927 // from milliseconds 21928 config._d = new Date(input); 21929 } else { 21930 hooks.createFromInputFallback(config); 21931 } 21932 } 21933 21934 function createLocalOrUTC(input, format, locale, strict, isUTC) { 21935 var c = {}; 21936 21937 if (format === true || format === false) { 21938 strict = format; 21939 format = undefined; 21940 } 21941 21942 if (locale === true || locale === false) { 21943 strict = locale; 21944 locale = undefined; 21945 } 21946 21947 if ( 21948 (isObject(input) && isObjectEmpty(input)) || 21949 (isArray(input) && input.length === 0) 21950 ) { 21951 input = undefined; 21952 } 21953 // object construction must be done this way. 21954 // https://github.com/moment/moment/issues/1423 21955 c._isAMomentObject = true; 21956 c._useUTC = c._isUTC = isUTC; 21957 c._l = locale; 21958 c._i = input; 21959 c._f = format; 21960 c._strict = strict; 21961 21962 return createFromConfig(c); 21963 } 21964 21965 function createLocal(input, format, locale, strict) { 21966 return createLocalOrUTC(input, format, locale, strict, false); 21967 } 21968 21969 var prototypeMin = deprecate( 21970 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/', 21971 function () { 21972 var other = createLocal.apply(null, arguments); 21973 if (this.isValid() && other.isValid()) { 21974 return other < this ? this : other; 21975 } else { 21976 return createInvalid(); 21977 } 21978 } 21979 ), 21980 prototypeMax = deprecate( 21981 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/', 21982 function () { 21983 var other = createLocal.apply(null, arguments); 21984 if (this.isValid() && other.isValid()) { 21985 return other > this ? this : other; 21986 } else { 21987 return createInvalid(); 21988 } 21989 } 21990 ); 21991 21992 // Pick a moment m from moments so that m[fn](other) is true for all 21993 // other. This relies on the function fn to be transitive. 21994 // 21995 // moments should either be an array of moment objects or an array, whose 21996 // first element is an array of moment objects. 21997 function pickBy(fn, moments) { 21998 var res, i; 21999 if (moments.length === 1 && isArray(moments[0])) { 22000 moments = moments[0]; 22001 } 22002 if (!moments.length) { 22003 return createLocal(); 22004 } 22005 res = moments[0]; 22006 for (i = 1; i < moments.length; ++i) { 22007 if (!moments[i].isValid() || moments[i][fn](res)) { 22008 res = moments[i]; 22009 } 22010 } 22011 return res; 22012 } 22013 22014 // TODO: Use [].sort instead? 22015 function min() { 22016 var args = [].slice.call(arguments, 0); 22017 22018 return pickBy('isBefore', args); 22019 } 22020 22021 function max() { 22022 var args = [].slice.call(arguments, 0); 22023 22024 return pickBy('isAfter', args); 22025 } 22026 22027 var now = function () { 22028 return Date.now ? Date.now() : +new Date(); 22029 }; 22030 22031 var ordering = [ 22032 'year', 22033 'quarter', 22034 'month', 22035 'week', 22036 'day', 22037 'hour', 22038 'minute', 22039 'second', 22040 'millisecond', 22041 ]; 22042 22043 function isDurationValid(m) { 22044 var key, 22045 unitHasDecimal = false, 22046 i, 22047 orderLen = ordering.length; 22048 for (key in m) { 22049 if ( 22050 hasOwnProp(m, key) && 22051 !( 22052 indexOf.call(ordering, key) !== -1 && 22053 (m[key] == null || !isNaN(m[key])) 22054 ) 22055 ) { 22056 return false; 22057 } 22058 } 22059 22060 for (i = 0; i < orderLen
vendor: 10,251 bytes, lines 22060-22385
22060; ++i) { 22061 if (m[ordering[i]]) { 22062 if (unitHasDecimal) { 22063 return false; // only allow non-integers for smallest unit 22064 } 22065 if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) { 22066 unitHasDecimal = true; 22067 } 22068 } 22069 } 22070 22071 return true; 22072 } 22073 22074 function isValid$1() { 22075 return this._isValid; 22076 } 22077 22078 function createInvalid$1() { 22079 return createDuration(NaN); 22080 } 22081 22082 function Duration(duration) { 22083 var normalizedInput = normalizeObjectUnits(duration), 22084 years = normalizedInput.year || 0, 22085 quarters = normalizedInput.quarter || 0, 22086 months = normalizedInput.month || 0, 22087 weeks = normalizedInput.week || normalizedInput.isoWeek || 0, 22088 days = normalizedInput.day || 0, 22089 hours = normalizedInput.hour || 0, 22090 minutes = normalizedInput.minute || 0, 22091 seconds = normalizedInput.second || 0, 22092 milliseconds = normalizedInput.millisecond || 0; 22093 22094 this._isValid = isDurationValid(normalizedInput); 22095 22096 // representation for dateAddRemove 22097 this._milliseconds = 22098 +milliseconds + 22099 seconds * 1e3 + // 1000 22100 minutes * 6e4 + // 1000 * 60 22101 hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978 22102 // Because of dateAddRemove treats 24 hours as different from a 22103 // day when working around DST, we need to store them separately 22104 this._days = +days + weeks * 7; 22105 // It is impossible to translate months into days without knowing 22106 // which months you are are talking about, so we have to store 22107 // it separately. 22108 this._months = +months + quarters * 3 + years * 12; 22109 22110 this._data = {}; 22111 22112 this._locale = getLocale(); 22113 22114 this._bubble(); 22115 } 22116 22117 function isDuration(obj) { 22118 return obj instanceof Duration; 22119 } 22120 22121 function absRound(number) { 22122 if (number < 0) { 22123 return Math.round(-1 * number) * -1; 22124 } else { 22125 return Math.round(number); 22126 } 22127 } 22128 22129 // compare two arrays, return the number of differences 22130 function compareArrays(array1, array2, dontConvert) { 22131 var len = Math.min(array1.length, array2.length), 22132 lengthDiff = Math.abs(array1.length - array2.length), 22133 diffs = 0, 22134 i; 22135 for (i = 0; i < len; i++) { 22136 if ( 22137 (dontConvert && array1[i] !== array2[i]) || 22138 (!dontConvert && toInt(array1[i]) !== toInt(array2[i])) 22139 ) { 22140 diffs++; 22141 } 22142 } 22143 return diffs + lengthDiff; 22144 } 22145 22146 // FORMATTING 22147 22148 function offset(token, separator) { 22149 addFormatToken(token, 0, 0, function () { 22150 var offset = this.utcOffset(), 22151 sign = '+'; 22152 if (offset < 0) { 22153 offset = -offset; 22154 sign = '-'; 22155 } 22156 return ( 22157 sign + 22158 zeroFill(~~(offset / 60), 2) + 22159 separator + 22160 zeroFill(~~offset % 60, 2) 22161 ); 22162 }); 22163 } 22164 22165 offset('Z', ':'); 22166 offset('ZZ', ''); 22167 22168 // PARSING 22169 22170 addRegexToken('Z', matchShortOffset); 22171 addRegexToken('ZZ', matchShortOffset); 22172 addParseToken(['Z', 'ZZ'], function (input, array, config) { 22173 config._useUTC = true; 22174 config._tzm = offsetFromString(matchShortOffset, input); 22175 }); 22176 22177 // HELPERS 22178 22179 // timezone chunker 22180 // '+10:00' > ['10', '00'] 22181 // '-1530' > ['-15', '30'] 22182 var chunkOffset = /([\+\-]|\d\d)/gi; 22183 22184 function offsetFromString(matcher, string) { 22185 var matches = (string || '').match(matcher), 22186 chunk, 22187 parts, 22188 minutes; 22189 22190 if (matches === null) { 22191 return null; 22192 } 22193 22194 chunk = matches[matches.length - 1] || []; 22195 parts = (chunk + '').match(chunkOffset) || ['-', 0, 0]; 22196 minutes = +(parts[1] * 60) + toInt(parts[2]); 22197 22198 return minutes === 0 ? 0 : parts[0] === '+' ? minutes : -minutes; 22199 } 22200 22201 // Return a moment from input, that is local/utc/zone equivalent to model. 22202 function cloneWithOffset(input, model) { 22203 var res, diff; 22204 if (model._isUTC) { 22205 res = model.clone(); 22206 diff = 22207 (isMoment(input) || isDate(input) 22208 ? input.valueOf() 22209 : createLocal(input).valueOf()) - res.valueOf(); 22210 // Use low-level api, because this fn is low-level api. 22211 res._d.setTime(res._d.valueOf() + diff); 22212 hooks.updateOffset(res, false); 22213 return res; 22214 } else { 22215 return createLocal(input).local(); 22216 } 22217 } 22218 22219 function getDateOffset(m) { 22220 // On Firefox.24 Date#getTimezoneOffset returns a floating point. 22221 // https://github.com/moment/moment/pull/1871 22222 return -Math.round(m._d.getTimezoneOffset()); 22223 } 22224 22225 // HOOKS 22226 22227 // This function will be called whenever a moment is mutated. 22228 // It is intended to keep the offset in sync with the timezone. 22229 hooks.updateOffset = function () {}; 22230 22231 // MOMENTS 22232 22233 // keepLocalTime = true means only change the timezone, without 22234 // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]--> 22235 // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset 22236 // +0200, so we adjust the time as needed, to be valid. 22237 // 22238 // Keeping the time actually adds/subtracts (one hour) 22239 // from the actual represented time. That is why we call updateOffset 22240 // a second time. In case it wants us to change the offset again 22241 // _changeInProgress == true case, then we have to adjust, because 22242 // there is no such time in the given timezone. 22243 function getSetOffset(input, keepLocalTime, keepMinutes) { 22244 var offset = this._offset || 0, 22245 localAdjust; 22246 if (!this.isValid()) { 22247 return input != null ? this : NaN; 22248 } 22249 if (input != null) { 22250 if (typeof input === 'string') { 22251 input = offsetFromString(matchShortOffset, input); 22252 if (input === null) { 22253 return this; 22254 } 22255 } else if (Math.abs(input) < 16 && !keepMinutes) { 22256 input = input * 60; 22257 } 22258 if (!this._isUTC && keepLocalTime) { 22259 localAdjust = getDateOffset(this); 22260 } 22261 this._offset = input; 22262 this._isUTC = true; 22263 if (localAdjust != null) { 22264 this.add(localAdjust, 'm'); 22265 } 22266 if (offset !== input) { 22267 if (!keepLocalTime || this._changeInProgress) { 22268 addSubtract( 22269 this, 22270 createDuration(input - offset, 'm'), 22271 1, 22272 false 22273 ); 22274 } else if (!this._changeInProgress) { 22275 this._changeInProgress = true; 22276 hooks.updateOffset(this, true); 22277 this._changeInProgress = null; 22278 } 22279 } 22280 return this; 22281 } else { 22282 return this._isUTC ? offset : getDateOffset(this); 22283 } 22284 } 22285 22286 function getSetZone(input, keepLocalTime) { 22287 if (input != null) { 22288 if (typeof input !== 'string') { 22289 input = -input; 22290 } 22291 22292 this.utcOffset(input, keepLocalTime); 22293 22294 return this; 22295 } else { 22296 return -this.utcOffset(); 22297 } 22298 } 22299 22300 function setOffsetToUTC(keepLocalTime) { 22301 return this.utcOffset(0, keepLocalTime); 22302 } 22303 22304 function setOffsetToLocal(keepLocalTime) { 22305 if (this._isUTC) { 22306 this.utcOffset(0, keepLocalTime); 22307 this._isUTC = false; 22308 22309 if (keepLocalTime) { 22310 this.subtract(getDateOffset(this), 'm'); 22311 } 22312 } 22313 return this; 22314 } 22315 22316 function setOffsetToParsedOffset() { 22317 if (this._tzm != null) { 22318 this.utcOffset(this._tzm, false, true); 22319 } else if (typeof this._i === 'string') { 22320 var tZone = offsetFromString(matchOffset, this._i); 22321 if (tZone != null) { 22322 this.utcOffset(tZone); 22323 } else { 22324 this.utcOffset(0, true); 22325 } 22326 } 22327 return this; 22328 } 22329 22330 function hasAlignedHourOffset(input) { 22331 if (!this.isValid()) { 22332 return false; 22333 } 22334 input = input ? createLocal(input).utcOffset() : 0; 22335 22336 return (this.utcOffset() - input) % 60 === 0; 22337 } 22338 22339 function isDaylightSavingTime() { 22340 return ( 22341 this.utcOffset() > this.clone().month(0).utcOffset() || 22342 this.utcOffset() > this.clone().month(5).utcOffset() 22343 ); 22344 } 22345 22346 function isDaylightSavingTimeShifted() { 22347 if (!isUndefined(this._isDSTShifted)) { 22348 return this._isDSTShifted; 22349 } 22350 22351 var c = {}, 22352 other; 22353 22354 copyConfig(c, this); 22355 c = prepareConfig(c); 22356 22357 if (c._a) { 22358 other = c._isUTC ? createUTC(c._a) : createLocal(c._a); 22359 this._isDSTShifted = 22360 this.isValid() && compareArrays(c._a, other.toArray()) > 0; 22361 } else { 22362 this._isDSTShifted = false; 22363 } 22364 22365 return this._isDSTShifted; 22366 } 22367 22368 function isLocal() { 22369 return this.isValid() ? !this._isUTC : false; 22370 } 22371 22372 function isUtcOffset() { 22373 return this.isValid() ? this._isUTC : false; 22374 } 22375 22376 function isUtc() { 22377 return this.isValid() ? this._isUTC && this._offset === 0 : false; 22378 } 22379 22380 // ASP.NET json date format regex 22381 var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/, 22382 // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html 22383 // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere 22384 // and further modified to allow for strings containing both week and day 22385 isoRegex =
vendor: 9,021 bytes, lines 22385-22675
22385 22386 /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/; 22387 22388 function createDuration(input, key) { 22389 var duration = input, 22390 // matching against regexp is expensive, do it on demand 22391 match = null, 22392 sign, 22393 ret, 22394 diffRes; 22395 22396 if (isDuration(input)) { 22397 duration = { 22398 ms: input._milliseconds, 22399 d: input._days, 22400 M: input._months, 22401 }; 22402 } else if (isNumber(input) || !isNaN(+input)) { 22403 duration = {}; 22404 if (key) { 22405 duration[key] = +input; 22406 } else { 22407 duration.milliseconds = +input; 22408 } 22409 } else if ((match = aspNetRegex.exec(input))) { 22410 sign = match[1] === '-' ? -1 : 1; 22411 duration = { 22412 y: 0, 22413 d: toInt(match[DATE]) * sign, 22414 h: toInt(match[HOUR]) * sign, 22415 m: toInt(match[MINUTE]) * sign, 22416 s: toInt(match[SECOND]) * sign, 22417 ms: toInt(absRound(match[MILLISECOND] * 1000)) * sign, // the millisecond decimal point is included in the match 22418 }; 22419 } else if ((match = isoRegex.exec(input))) { 22420 sign = match[1] === '-' ? -1 : 1; 22421 duration = { 22422 y: parseIso(match[2], sign), 22423 M: parseIso(match[3], sign), 22424 w: parseIso(match[4], sign), 22425 d: parseIso(match[5], sign), 22426 h: parseIso(match[6], sign), 22427 m: parseIso(match[7], sign), 22428 s: parseIso(match[8], sign), 22429 }; 22430 } else if (duration == null) { 22431 // checks for null or undefined 22432 duration = {}; 22433 } else if ( 22434 typeof duration === 'object' && 22435 ('from' in duration || 'to' in duration) 22436 ) { 22437 diffRes = momentsDifference( 22438 createLocal(duration.from), 22439 createLocal(duration.to) 22440 ); 22441 22442 duration = {}; 22443 duration.ms = diffRes.milliseconds; 22444 duration.M = diffRes.months; 22445 } 22446 22447 ret = new Duration(duration); 22448 22449 if (isDuration(input) && hasOwnProp(input, '_locale')) { 22450 ret._locale = input._locale; 22451 } 22452 22453 if (isDuration(input) && hasOwnProp(input, '_isValid')) { 22454 ret._isValid = input._isValid; 22455 } 22456 22457 return ret; 22458 } 22459 22460 createDuration.fn = Duration.prototype; 22461 createDuration.invalid = createInvalid$1; 22462 22463 function parseIso(inp, sign) { 22464 // We'd normally use ~~inp for this, but unfortunately it also 22465 // converts floats to ints. 22466 // inp may be undefined, so careful calling replace on it. 22467 var res = inp && parseFloat(inp.replace(',', '.')); 22468 // apply sign while we're at it 22469 return (isNaN(res) ? 0 : res) * sign; 22470 } 22471 22472 function positiveMomentsDifference(base, other) { 22473 var res = {}; 22474 22475 res.months = 22476 other.month() - base.month() + (other.year() - base.year()) * 12; 22477 if (base.clone().add(res.months, 'M').isAfter(other)) { 22478 --res.months; 22479 } 22480 22481 res.milliseconds = +other - +base.clone().add(res.months, 'M'); 22482 22483 return res; 22484 } 22485 22486 function momentsDifference(base, other) { 22487 var res; 22488 if (!(base.isValid() && other.isValid())) { 22489 return { milliseconds: 0, months: 0 }; 22490 } 22491 22492 other = cloneWithOffset(other, base); 22493 if (base.isBefore(other)) { 22494 res = positiveMomentsDifference(base, other); 22495 } else { 22496 res = positiveMomentsDifference(other, base); 22497 res.milliseconds = -res.milliseconds; 22498 res.months = -res.months; 22499 } 22500 22501 return res; 22502 } 22503 22504 // TODO: remove 'name' arg after deprecation is removed 22505 function createAdder(direction, name) { 22506 return function (val, period) { 22507 var dur, tmp; 22508 //invert the arguments, but complain about it 22509 if (period !== null && !isNaN(+period)) { 22510 deprecateSimple( 22511 name, 22512 'moment().' + 22513 name + 22514 '(period, number) is deprecated. Please use moment().' + 22515 name + 22516 '(number, period). ' + 22517 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.' 22518 ); 22519 tmp = val; 22520 val = period; 22521 period = tmp; 22522 } 22523 22524 dur = createDuration(val, period); 22525 addSubtract(this, dur, direction); 22526 return this; 22527 }; 22528 } 22529 22530 function addSubtract(mom, duration, isAdding, updateOffset) { 22531 var milliseconds = duration._milliseconds, 22532 days = absRound(duration._days), 22533 months = absRound(duration._months); 22534 22535 if (!mom.isValid()) { 22536 // No op 22537 return; 22538 } 22539 22540 updateOffset = updateOffset == null ? true : updateOffset; 22541 22542 if (months) { 22543 setMonth(mom, get(mom, 'Month') + months * isAdding); 22544 } 22545 if (days) { 22546 set$1(mom, 'Date', get(mom, 'Date') + days * isAdding); 22547 } 22548 if (milliseconds) { 22549 mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding); 22550 } 22551 if (updateOffset) { 22552 hooks.updateOffset(mom, days || months); 22553 } 22554 } 22555 22556 var add = createAdder(1, 'add'), 22557 subtract = createAdder(-1, 'subtract'); 22558 22559 function isString(input) { 22560 return typeof input === 'string' || input instanceof String; 22561 } 22562 22563 // type MomentInput = Moment | Date | string | number | (number | string)[] | MomentInputObject | void; // null | undefined 22564 function isMomentInput(input) { 22565 return ( 22566 isMoment(input) || 22567 isDate(input) || 22568 isString(input) || 22569 isNumber(input) || 22570 isNumberOrStringArray(input) || 22571 isMomentInputObject(input) || 22572 input === null || 22573 input === undefined 22574 ); 22575 } 22576 22577 function isMomentInputObject(input) { 22578 var objectTest = isObject(input) && !isObjectEmpty(input), 22579 propertyTest = false, 22580 properties = [ 22581 'years', 22582 'year', 22583 'y', 22584 'months', 22585 'month', 22586 'M', 22587 'days', 22588 'day', 22589 'd', 22590 'dates', 22591 'date', 22592 'D', 22593 'hours', 22594 'hour', 22595 'h', 22596 'minutes', 22597 'minute', 22598 'm', 22599 'seconds', 22600 'second', 22601 's', 22602 'milliseconds', 22603 'millisecond', 22604 'ms', 22605 ], 22606 i, 22607 property, 22608 propertyLen = properties.length; 22609 22610 for (i = 0; i < propertyLen; i += 1) { 22611 property = properties[i]; 22612 propertyTest = propertyTest || hasOwnProp(input, property); 22613 } 22614 22615 return objectTest && propertyTest; 22616 } 22617 22618 function isNumberOrStringArray(input) { 22619 var arrayTest = isArray(input), 22620 dataTypeTest = false; 22621 if (arrayTest) { 22622 dataTypeTest = 22623 input.filter(function (item) { 22624 return !isNumber(item) && isString(input); 22625 }).length === 0; 22626 } 22627 return arrayTest && dataTypeTest; 22628 } 22629 22630 function isCalendarSpec(input) { 22631 var objectTest = isObject(input) && !isObjectEmpty(input), 22632 propertyTest = false, 22633 properties = [ 22634 'sameDay', 22635 'nextDay', 22636 'lastDay', 22637 'nextWeek', 22638 'lastWeek', 22639 'sameElse', 22640 ], 22641 i, 22642 property; 22643 22644 for (i = 0; i < properties.length; i += 1) { 22645 property = properties[i]; 22646 propertyTest = propertyTest || hasOwnProp(input, property); 22647 } 22648 22649 return objectTest && propertyTest; 22650 } 22651 22652 function getCalendarFormat(myMoment, now) { 22653 var diff = myMoment.diff(now, 'days', true); 22654 return diff < -6 22655 ? 'sameElse' 22656 : diff < -1 22657 ? 'lastWeek' 22658 : diff < 0 22659 ? 'lastDay' 22660 : diff < 1 22661 ? 'sameDay' 22662 : diff < 2 22663 ? 'nextDay' 22664 : diff < 7 22665 ? 'nextWeek' 22666 : 'sameElse'; 22667 } 22668 22669 function calendar$1(time, formats) { 22670 // Support for single parameter, formats only overload to the calendar function 22671 if (arguments.length === 1) { 22672 if (!arguments[0]) { 22673 time = undefined; 22674 formats = undefined; 22675 } else
vendor: 17,627 bytes, lines 22675-23233
22675 if (isMomentInput(arguments[0])) { 22676 time = arguments[0]; 22677 formats = undefined; 22678 } else if (isCalendarSpec(arguments[0])) { 22679 formats = arguments[0]; 22680 time = undefined; 22681 } 22682 } 22683 // We want to compare the start of today, vs this. 22684 // Getting start-of-today depends on whether we're local/utc/offset or not. 22685 var now = time || createLocal(), 22686 sod = cloneWithOffset(now, this).startOf('day'), 22687 format = hooks.calendarFormat(this, sod) || 'sameElse', 22688 output = 22689 formats && 22690 (isFunction(formats[format]) 22691 ? formats[format].call(this, now) 22692 : formats[format]); 22693 22694 return this.format( 22695 output || this.localeData().calendar(format, this, createLocal(now)) 22696 ); 22697 } 22698 22699 function clone() { 22700 return new Moment(this); 22701 } 22702 22703 function isAfter(input, units) { 22704 var localInput = isMoment(input) ? input : createLocal(input); 22705 if (!(this.isValid() && localInput.isValid())) { 22706 return false; 22707 } 22708 units = normalizeUnits(units) || 'millisecond'; 22709 if (units === 'millisecond') { 22710 return this.valueOf() > localInput.valueOf(); 22711 } else { 22712 return localInput.valueOf() < this.clone().startOf(units).valueOf(); 22713 } 22714 } 22715 22716 function isBefore(input, units) { 22717 var localInput = isMoment(input) ? input : createLocal(input); 22718 if (!(this.isValid() && localInput.isValid())) { 22719 return false; 22720 } 22721 units = normalizeUnits(units) || 'millisecond'; 22722 if (units === 'millisecond') { 22723 return this.valueOf() < localInput.valueOf(); 22724 } else { 22725 return this.clone().endOf(units).valueOf() < localInput.valueOf(); 22726 } 22727 } 22728 22729 function isBetween(from, to, units, inclusivity) { 22730 var localFrom = isMoment(from) ? from : createLocal(from), 22731 localTo = isMoment(to) ? to : createLocal(to); 22732 if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) { 22733 return false; 22734 } 22735 inclusivity = inclusivity || '()'; 22736 return ( 22737 (inclusivity[0] === '(' 22738 ? this.isAfter(localFrom, units) 22739 : !this.isBefore(localFrom, units)) && 22740 (inclusivity[1] === ')' 22741 ? this.isBefore(localTo, units) 22742 : !this.isAfter(localTo, units)) 22743 ); 22744 } 22745 22746 function isSame(input, units) { 22747 var localInput = isMoment(input) ? input : createLocal(input), 22748 inputMs; 22749 if (!(this.isValid() && localInput.isValid())) { 22750 return false; 22751 } 22752 units = normalizeUnits(units) || 'millisecond'; 22753 if (units === 'millisecond') { 22754 return this.valueOf() === localInput.valueOf(); 22755 } else { 22756 inputMs = localInput.valueOf(); 22757 return ( 22758 this.clone().startOf(units).valueOf() <= inputMs && 22759 inputMs <= this.clone().endOf(units).valueOf() 22760 ); 22761 } 22762 } 22763 22764 function isSameOrAfter(input, units) { 22765 return this.isSame(input, units) || this.isAfter(input, units); 22766 } 22767 22768 function isSameOrBefore(input, units) { 22769 return this.isSame(input, units) || this.isBefore(input, units); 22770 } 22771 22772 function diff(input, units, asFloat) { 22773 var that, zoneDelta, output; 22774 22775 if (!this.isValid()) { 22776 return NaN; 22777 } 22778 22779 that = cloneWithOffset(input, this); 22780 22781 if (!that.isValid()) { 22782 return NaN; 22783 } 22784 22785 zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4; 22786 22787 units = normalizeUnits(units); 22788 22789 switch (units) { 22790 case 'year': 22791 output = monthDiff(this, that) / 12; 22792 break; 22793 case 'month': 22794 output = monthDiff(this, that); 22795 break; 22796 case 'quarter': 22797 output = monthDiff(this, that) / 3; 22798 break; 22799 case 'second': 22800 output = (this - that) / 1e3; 22801 break; // 1000 22802 case 'minute': 22803 output = (this - that) / 6e4; 22804 break; // 1000 * 60 22805 case 'hour': 22806 output = (this - that) / 36e5; 22807 break; // 1000 * 60 * 60 22808 case 'day': 22809 output = (this - that - zoneDelta) / 864e5; 22810 break; // 1000 * 60 * 60 * 24, negate dst 22811 case 'week': 22812 output = (this - that - zoneDelta) / 6048e5; 22813 break; // 1000 * 60 * 60 * 24 * 7, negate dst 22814 default: 22815 output = this - that; 22816 } 22817 22818 return asFloat ? output : absFloor(output); 22819 } 22820 22821 function monthDiff(a, b) { 22822 if (a.date() < b.date()) { 22823 // end-of-month calculations work correct when the start month has more 22824 // days than the end month. 22825 return -monthDiff(b, a); 22826 } 22827 // difference in months 22828 var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()), 22829 // b is in (anchor - 1 month, anchor + 1 month) 22830 anchor = a.clone().add(wholeMonthDiff, 'months'), 22831 anchor2, 22832 adjust; 22833 22834 if (b - anchor < 0) { 22835 anchor2 = a.clone().add(wholeMonthDiff - 1, 'months'); 22836 // linear across the month 22837 adjust = (b - anchor) / (anchor - anchor2); 22838 } else { 22839 anchor2 = a.clone().add(wholeMonthDiff + 1, 'months'); 22840 // linear across the month 22841 adjust = (b - anchor) / (anchor2 - anchor); 22842 } 22843 22844 //check for negative zero, return zero if negative zero 22845 return -(wholeMonthDiff + adjust) || 0; 22846 } 22847 22848 hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ'; 22849 hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]'; 22850 22851 function toString() { 22852 return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'); 22853 } 22854 22855 function toISOString(keepOffset) { 22856 if (!this.isValid()) { 22857 return null; 22858 } 22859 var utc = keepOffset !== true, 22860 m = utc ? this.clone().utc() : this; 22861 if (m.year() < 0 || m.year() > 9999) { 22862 return formatMoment( 22863 m, 22864 utc 22865 ? 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]' 22866 : 'YYYYYY-MM-DD[T]HH:mm:ss.SSSZ' 22867 ); 22868 } 22869 if (isFunction(Date.prototype.toISOString)) { 22870 // native implementation is ~50x faster, use it when we can 22871 if (utc) { 22872 return this.toDate().toISOString(); 22873 } else { 22874 return new Date(this.valueOf() + this.utcOffset() * 60 * 1000) 22875 .toISOString() 22876 .replace('Z', formatMoment(m, 'Z')); 22877 } 22878 } 22879 return formatMoment( 22880 m, 22881 utc ? 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]' : 'YYYY-MM-DD[T]HH:mm:ss.SSSZ' 22882 ); 22883 } 22884 22885 /** 22886 * Return a human readable representation of a moment that can 22887 * also be evaluated to get a new moment which is the same 22888 * 22889 * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects 22890 */ 22891 function inspect() { 22892 if (!this.isValid()) { 22893 return 'moment.invalid(/* ' + this._i + ' */)'; 22894 } 22895 var func = 'moment', 22896 zone = '', 22897 prefix, 22898 year, 22899 datetime, 22900 suffix; 22901 if (!this.isLocal()) { 22902 func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone'; 22903 zone = 'Z'; 22904 } 22905 prefix = '[' + func + '("]'; 22906 year = 0 <= this.year() && this.year() <= 9999 ? 'YYYY' : 'YYYYYY'; 22907 datetime = '-MM-DD[T]HH:mm:ss.SSS'; 22908 suffix = zone + '[")]'; 22909 22910 return this.format(prefix + year + datetime + suffix); 22911 } 22912 22913 function format(inputString) { 22914 if (!inputString) { 22915 inputString = this.isUtc() 22916 ? hooks.defaultFormatUtc 22917 : hooks.defaultFormat; 22918 } 22919 var output = formatMoment(this, inputString); 22920 return this.localeData().postformat(output); 22921 } 22922 22923 function from(time, withoutSuffix) { 22924 if ( 22925 this.isValid() && 22926 ((isMoment(time) && time.isValid()) || createLocal(time).isValid()) 22927 ) { 22928 return createDuration({ to: this, from: time }) 22929 .locale(this.locale()) 22930 .humanize(!withoutSuffix); 22931 } else { 22932 return this.localeData().invalidDate(); 22933 } 22934 } 22935 22936 function fromNow(withoutSuffix) { 22937 return this.from(createLocal(), withoutSuffix); 22938 } 22939 22940 function to(time, withoutSuffix) { 22941 if ( 22942 this.isValid() && 22943 ((isMoment(time) && time.isValid()) || createLocal(time).isValid()) 22944 ) { 22945 return createDuration({ from: this, to: time }) 22946 .locale(this.locale()) 22947 .humanize(!withoutSuffix); 22948 } else { 22949 return this.localeData().invalidDate(); 22950 } 22951 } 22952 22953 function toNow(withoutSuffix) { 22954 return this.to(createLocal(), withoutSuffix); 22955 } 22956 22957 // If passed a locale key, it will set the locale for this 22958 // instance. Otherwise, it will return the locale configuration 22959 // variables for this instance. 22960 function locale(key) { 22961 var newLocaleData; 22962 22963 if (key === undefined) { 22964 return this._locale._abbr; 22965 } else { 22966 newLocaleData = getLocale(key); 22967 if (newLocaleData != null) { 22968 this._locale = newLocaleData; 22969 } 22970 return this; 22971 } 22972 } 22973 22974 var lang = deprecate( 22975 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.', 22976 function (key) { 22977 if (key === undefined) { 22978 return this.localeData(); 22979 } else { 22980 return this.locale(key); 22981 } 22982 } 22983 ); 22984 22985 function localeData() { 22986 return this._locale; 22987 } 22988 22989 var MS_PER_SECOND = 1000, 22990 MS_PER_MINUTE = 60 * MS_PER_SECOND, 22991 MS_PER_HOUR = 60 * MS_PER_MINUTE, 22992 MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR; 22993 22994 // actual modulo - handles negative numbers (for dates before 1970): 22995 function mod$1(dividend, divisor) { 22996 return ((dividend % divisor) + divisor) % divisor; 22997 } 22998 22999 function localStartOfDate(y, m, d) { 23000 // the date constructor remaps years 0-99 to 1900-1999 23001 if (y < 100 && y >= 0) { 23002 // preserve leap years using a full 400 year cycle, then reset 23003 return new Date(y + 400, m, d) - MS_PER_400_YEARS; 23004 } else { 23005 return new Date(y, m, d).valueOf(); 23006 } 23007 } 23008 23009 function utcStartOfDate(y, m, d) { 23010 // Date.UTC remaps years 0-99 to 1900-1999 23011 if (y < 100 && y >= 0) { 23012 // preserve leap years using a full 400 year cycle, then reset 23013 return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS; 23014 } else { 23015 return Date.UTC(y, m, d); 23016 } 23017 } 23018 23019 function startOf(units) { 23020 var time, startOfDate; 23021 units = normalizeUnits(units); 23022 if (units === undefined || units === 'millisecond' || !this.isValid()) { 23023 return this; 23024 } 23025 23026 startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate; 23027 23028 switch (units) { 23029 case 'year': 23030 time = startOfDate(this.year(), 0, 1); 23031 break; 23032 case 'quarter': 23033 time = startOfDate( 23034 this.year(), 23035 this.month() - (this.month() % 3), 23036 1 23037 ); 23038 break; 23039 case 'month': 23040 time = startOfDate(this.year(), this.month(), 1); 23041 break; 23042 case 'week': 23043 time = startOfDate( 23044 this.year(), 23045 this.month(), 23046 this.date() - this.weekday() 23047 ); 23048 break; 23049 case 'isoWeek': 23050 time = startOfDate( 23051 this.year(), 23052 this.month(), 23053 this.date() - (this.isoWeekday() - 1) 23054 ); 23055 break; 23056 case 'day': 23057 case 'date': 23058 time = startOfDate(this.year(), this.month(), this.date()); 23059 break; 23060 case 'hour': 23061 time = this._d.valueOf(); 23062 time -= mod$1( 23063 time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), 23064 MS_PER_HOUR 23065 ); 23066 break; 23067 case 'minute': 23068 time = this._d.valueOf(); 23069 time -= mod$1(time, MS_PER_MINUTE); 23070 break; 23071 case 'second': 23072 time = this._d.valueOf(); 23073 time -= mod$1(time, MS_PER_SECOND); 23074 break; 23075 } 23076 23077 this._d.setTime(time); 23078 hooks.updateOffset(this, true); 23079 return this; 23080 } 23081 23082 function endOf(units) { 23083 var time, startOfDate; 23084 units = normalizeUnits(units); 23085 if (units === undefined || units === 'millisecond' || !this.isValid()) { 23086 return this; 23087 } 23088 23089 startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate; 23090 23091 switch (units) { 23092 case 'year': 23093 time = startOfDate(this.year() + 1, 0, 1) - 1; 23094 break; 23095 case 'quarter': 23096 time = 23097 startOfDate( 23098 this.year(), 23099 this.month() - (this.month() % 3) + 3, 23100 1 23101 ) - 1; 23102 break; 23103 case 'month': 23104 time = startOfDate(this.year(), this.month() + 1, 1) - 1; 23105 break; 23106 case 'week': 23107 time = 23108 startOfDate( 23109 this.year(), 23110 this.month(), 23111 this.date() - this.weekday() + 7 23112 ) - 1; 23113 break; 23114 case 'isoWeek': 23115 time = 23116 startOfDate( 23117 this.year(), 23118 this.month(), 23119 this.date() - (this.isoWeekday() - 1) + 7 23120 ) - 1; 23121 break; 23122 case 'day': 23123 case 'date': 23124 time = startOfDate(this.year(), this.month(), this.date() + 1) - 1; 23125 break; 23126 case 'hour': 23127 time = this._d.valueOf(); 23128 time += 23129 MS_PER_HOUR - 23130 mod$1( 23131 time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE), 23132 MS_PER_HOUR 23133 ) - 23134 1; 23135 break; 23136 case 'minute': 23137 time = this._d.valueOf(); 23138 time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1; 23139 break; 23140 case 'second': 23141 time = this._d.valueOf(); 23142 time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1; 23143 break; 23144 } 23145 23146 this._d.setTime(time); 23147 hooks.updateOffset(this, true); 23148 return this; 23149 } 23150 23151 function valueOf() { 23152 return this._d.valueOf() - (this._offset || 0) * 60000; 23153 } 23154 23155 function unix() { 23156 return Math.floor(this.valueOf() / 1000); 23157 } 23158 23159 function toDate() { 23160 return new Date(this.valueOf()); 23161 } 23162 23163 function toArray() { 23164 var m = this; 23165 return [ 23166 m.year(), 23167 m.month(), 23168 m.date(), 23169 m.hour(), 23170 m.minute(), 23171 m.second(), 23172 m.millisecond(), 23173 ]; 23174 } 23175 23176 function toObject() { 23177 var m = this; 23178 return { 23179 years: m.year(), 23180 months: m.month(), 23181 date: m.date(), 23182 hours: m.hours(), 23183 minutes: m.minutes(), 23184 seconds: m.seconds(), 23185 milliseconds: m.milliseconds(), 23186 }; 23187 } 23188 23189 function toJSON() { 23190 // new Date(NaN).toJSON() === null 23191 return this.isValid() ? this.toISOString() : null; 23192 } 23193 23194 function isValid$2() { 23195 return isValid(this); 23196 } 23197 23198 function parsingFlags() { 23199 return extend({}, getParsingFlags(this)); 23200 } 23201 23202 function invalidAt() { 23203 return getParsingFlags(this).overflow; 23204 } 23205 23206 function creationData() { 23207 return { 23208 input: this._i, 23209 format: this._f, 23210 locale: this._locale, 23211 isUTC: this._isUTC, 23212 strict: this._strict, 23213 }; 23214 } 23215 23216 addFormatToken('N', 0, 0, 'eraAbbr'); 23217 addFormatToken('NN', 0, 0, 'eraAbbr'); 23218 addFormatToken('NNN', 0, 0, 'eraAbbr'); 23219 addFormatToken('NNNN', 0, 0, 'eraName'); 23220 addFormatToken('NNNNN', 0, 0, 'eraNarrow'); 23221 23222 addFormatToken('y', ['y', 1], 'yo', 'eraYear'); 23223 addFormatToken('y', ['yy', 2], 0, 'eraYear'); 23224 addFormatToken('y', ['yyy', 3], 0, 'eraYear'); 23225 addFormatToken('y', ['yyyy', 4], 0, 'eraYear'); 23226 23227 addRegexToken('N', matchEraAbbr); 23228 addRegexToken('NN', matchEraAbbr); 23229 addRegexToken('NNN', matchEraAbbr); 23230 addRegexToken('NNNN', matchEraName); 23231 addRegexToken('NNNNN', matchEraNarrow); 23232 23233 addParseToken(
vendor: 8,145 bytes, lines 23233-23508
23233 23234 ['N', 'NN', 'NNN', 'NNNN', 'NNNNN'], 23235 function (input, array, config, token) { 23236 var era = config._locale.erasParse(input, token, config._strict); 23237 if (era) { 23238 getParsingFlags(config).era = era; 23239 } else { 23240 getParsingFlags(config).invalidEra = input; 23241 } 23242 } 23243 ); 23244 23245 addRegexToken('y', matchUnsigned); 23246 addRegexToken('yy', matchUnsigned); 23247 addRegexToken('yyy', matchUnsigned); 23248 addRegexToken('yyyy', matchUnsigned); 23249 addRegexToken('yo', matchEraYearOrdinal); 23250 23251 addParseToken(['y', 'yy', 'yyy', 'yyyy'], YEAR); 23252 addParseToken(['yo'], function (input, array, config, token) { 23253 var match; 23254 if (config._locale._eraYearOrdinalRegex) { 23255 match = input.match(config._locale._eraYearOrdinalRegex); 23256 } 23257 23258 if (config._locale.eraYearOrdinalParse) { 23259 array[YEAR] = config._locale.eraYearOrdinalParse(input, match); 23260 } else { 23261 array[YEAR] = parseInt(input, 10); 23262 } 23263 }); 23264 23265 function localeEras(m, format) { 23266 var i, 23267 l, 23268 date, 23269 eras = this._eras || getLocale('en')._eras; 23270 for (i = 0, l = eras.length; i < l; ++i) { 23271 switch (typeof eras[i].since) { 23272 case 'string': 23273 // truncate time 23274 date = hooks(eras[i].since).startOf('day'); 23275 eras[i].since = date.valueOf(); 23276 break; 23277 } 23278 23279 switch (typeof eras[i].until) { 23280 case 'undefined': 23281 eras[i].until = +Infinity; 23282 break; 23283 case 'string': 23284 // truncate time 23285 date = hooks(eras[i].until).startOf('day').valueOf(); 23286 eras[i].until = date.valueOf(); 23287 break; 23288 } 23289 } 23290 return eras; 23291 } 23292 23293 function localeErasParse(eraName, format, strict) { 23294 var i, 23295 l, 23296 eras = this.eras(), 23297 name, 23298 abbr, 23299 narrow; 23300 eraName = eraName.toUpperCase(); 23301 23302 for (i = 0, l = eras.length; i < l; ++i) { 23303 name = eras[i].name.toUpperCase(); 23304 abbr = eras[i].abbr.toUpperCase(); 23305 narrow = eras[i].narrow.toUpperCase(); 23306 23307 if (strict) { 23308 switch (format) { 23309 case 'N': 23310 case 'NN': 23311 case 'NNN': 23312 if (abbr === eraName) { 23313 return eras[i]; 23314 } 23315 break; 23316 23317 case 'NNNN': 23318 if (name === eraName) { 23319 return eras[i]; 23320 } 23321 break; 23322 23323 case 'NNNNN': 23324 if (narrow === eraName) { 23325 return eras[i]; 23326 } 23327 break; 23328 } 23329 } else if ([name, abbr, narrow].indexOf(eraName) >= 0) { 23330 return eras[i]; 23331 } 23332 } 23333 } 23334 23335 function localeErasConvertYear(era, year) { 23336 var dir = era.since <= era.until ? +1 : -1; 23337 if (year === undefined) { 23338 return hooks(era.since).year(); 23339 } else { 23340 return hooks(era.since).year() + (year - era.offset) * dir; 23341 } 23342 } 23343 23344 function getEraName() { 23345 var i, 23346 l, 23347 val, 23348 eras = this.localeData().eras(); 23349 for (i = 0, l = eras.length; i < l; ++i) { 23350 // truncate time 23351 val = this.clone().startOf('day').valueOf(); 23352 23353 if (eras[i].since <= val && val <= eras[i].until) { 23354 return eras[i].name; 23355 } 23356 if (eras[i].until <= val && val <= eras[i].since) { 23357 return eras[i].name; 23358 } 23359 } 23360 23361 return ''; 23362 } 23363 23364 function getEraNarrow() { 23365 var i, 23366 l, 23367 val, 23368 eras = this.localeData().eras(); 23369 for (i = 0, l = eras.length; i < l; ++i) { 23370 // truncate time 23371 val = this.clone().startOf('day').valueOf(); 23372 23373 if (eras[i].since <= val && val <= eras[i].until) { 23374 return eras[i].narrow; 23375 } 23376 if (eras[i].until <= val && val <= eras[i].since) { 23377 return eras[i].narrow; 23378 } 23379 } 23380 23381 return ''; 23382 } 23383 23384 function getEraAbbr() { 23385 var i, 23386 l, 23387 val, 23388 eras = this.localeData().eras(); 23389 for (i = 0, l = eras.length; i < l; ++i) { 23390 // truncate time 23391 val = this.clone().startOf('day').valueOf(); 23392 23393 if (eras[i].since <= val && val <= eras[i].until) { 23394 return eras[i].abbr; 23395 } 23396 if (eras[i].until <= val && val <= eras[i].since) { 23397 return eras[i].abbr; 23398 } 23399 } 23400 23401 return ''; 23402 } 23403 23404 function getEraYear() { 23405 var i, 23406 l, 23407 dir, 23408 val, 23409 eras = this.localeData().eras(); 23410 for (i = 0, l = eras.length; i < l; ++i) { 23411 dir = eras[i].since <= eras[i].until ? +1 : -1; 23412 23413 // truncate time 23414 val = this.clone().startOf('day').valueOf(); 23415 23416 if ( 23417 (eras[i].since <= val && val <= eras[i].until) || 23418 (eras[i].until <= val && val <= eras[i].since) 23419 ) { 23420 return ( 23421 (this.year() - hooks(eras[i].since).year()) * dir + 23422 eras[i].offset 23423 ); 23424 } 23425 } 23426 23427 return this.year(); 23428 } 23429 23430 function erasNameRegex(isStrict) { 23431 if (!hasOwnProp(this, '_erasNameRegex')) { 23432 computeErasParse.call(this); 23433 } 23434 return isStrict ? this._erasNameRegex : this._erasRegex; 23435 } 23436 23437 function erasAbbrRegex(isStrict) { 23438 if (!hasOwnProp(this, '_erasAbbrRegex')) { 23439 computeErasParse.call(this); 23440 } 23441 return isStrict ? this._erasAbbrRegex : this._erasRegex; 23442 } 23443 23444 function erasNarrowRegex(isStrict) { 23445 if (!hasOwnProp(this, '_erasNarrowRegex')) { 23446 computeErasParse.call(this); 23447 } 23448 return isStrict ? this._erasNarrowRegex : this._erasRegex; 23449 } 23450 23451 function matchEraAbbr(isStrict, locale) { 23452 return locale.erasAbbrRegex(isStrict); 23453 } 23454 23455 function matchEraName(isStrict, locale) { 23456 return locale.erasNameRegex(isStrict); 23457 } 23458 23459 function matchEraNarrow(isStrict, locale) { 23460 return locale.erasNarrowRegex(isStrict); 23461 } 23462 23463 function matchEraYearOrdinal(isStrict, locale) { 23464 return locale._eraYearOrdinalRegex || matchUnsigned; 23465 } 23466 23467 function computeErasParse() { 23468 var abbrPieces = [], 23469 namePieces = [], 23470 narrowPieces = [], 23471 mixedPieces = [], 23472 i, 23473 l, 23474 eras = this.eras(); 23475 23476 for (i = 0, l = eras.length; i < l; ++i) { 23477 namePieces.push(regexEscape(eras[i].name)); 23478 abbrPieces.push(regexEscape(eras[i].abbr)); 23479 narrowPieces.push(regexEscape(eras[i].narrow)); 23480 23481 mixedPieces.push(regexEscape(eras[i].name)); 23482 mixedPieces.push(regexEscape(eras[i].abbr)); 23483 mixedPieces.push(regexEscape(eras[i].narrow)); 23484 } 23485 23486 this._erasRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i'); 23487 this._erasNameRegex = new RegExp('^(' + namePieces.join('|') + ')', 'i'); 23488 this._erasAbbrRegex = new RegExp('^(' + abbrPieces.join('|') + ')', 'i'); 23489 this._erasNarrowRegex = new RegExp( 23490 '^(' + narrowPieces.join('|') + ')', 23491 'i' 23492 ); 23493 } 23494 23495 // FORMATTING 23496 23497 addFormatToken(0, ['gg', 2], 0, function () { 23498 return this.weekYear() % 100; 23499 }); 23500 23501 addFormatToken(0, ['GG', 2], 0, function () { 23502 return this.isoWeekYear() % 100; 23503 }); 23504 23505 function addWeekYearFormatToken(token, getter) { 23506 addFormatToken(0, [token, token.length], 0, getter); 23507 } 23508
23509 addWeekYearFormatToken('gggg', 'weekYear'); 23510 addWeekYearFormatToken('ggggg', 'weekYear'); 23511 addWeekYearFormatToken('GGGG', 'isoWeekYear'); 23512 addWeekYearFormatToken('GGGGG', 'isoWeekYear'); 23513 23514 // ALIASES 23515 23516 addUnitAlias('weekYear', 'gg'); 23517 addUnitAlias('isoWeekYear', 'GG'); 23518 23519 // PRIORITY 23520 23521 addUnitPriority('weekYear', 1); 23522 addUnitPriority('isoWeekYear', 1); 23523 23524 // PARSING 23525 23526 addRegexToken('G', matchSigned); 23527 addRegexToken('g', matchSigned); 23528 addRegexToken('GG', match1to2, match2); 23529 addRegexToken('gg', match1to2, match2); 23530 addRegexToken('GGGG', match1to4, match4); 23531 addRegexToken('gggg', match1to4, match4); 23532 addRegexToken('GGGGG', match1to6, match6); 23533 addRegexToken('ggggg', match1to6, match6); 23534 23535 addWeekParseToken( 23536 ['gggg', 'ggggg', 'GGGG', 'GGGGG'], 23537 function (input, week, config, token) { 23538 week[token.substr(0, 2)] = toInt(input); 23539 } 23540
vendor: 29,543 bytes, lines 23540-24563
23540); 23541 23542 addWeekParseToken(['gg', 'GG'], function (input, week, config, token) { 23543 week[token] = hooks.parseTwoDigitYear(input); 23544 }); 23545 23546 // MOMENTS 23547 23548 function getSetWeekYear(input) { 23549 return getSetWeekYearHelper.call( 23550 this, 23551 input, 23552 this.week(), 23553 this.weekday(), 23554 this.localeData()._week.dow, 23555 this.localeData()._week.doy 23556 ); 23557 } 23558 23559 function getSetISOWeekYear(input) { 23560 return getSetWeekYearHelper.call( 23561 this, 23562 input, 23563 this.isoWeek(), 23564 this.isoWeekday(), 23565 1, 23566 4 23567 ); 23568 } 23569 23570 function getISOWeeksInYear() { 23571 return weeksInYear(this.year(), 1, 4); 23572 } 23573 23574 function getISOWeeksInISOWeekYear() { 23575 return weeksInYear(this.isoWeekYear(), 1, 4); 23576 } 23577 23578 function getWeeksInYear() { 23579 var weekInfo = this.localeData()._week; 23580 return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy); 23581 } 23582 23583 function getWeeksInWeekYear() { 23584 var weekInfo = this.localeData()._week; 23585 return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy); 23586 } 23587 23588 function getSetWeekYearHelper(input, week, weekday, dow, doy) { 23589 var weeksTarget; 23590 if (input == null) { 23591 return weekOfYear(this, dow, doy).year; 23592 } else { 23593 weeksTarget = weeksInYear(input, dow, doy); 23594 if (week > weeksTarget) { 23595 week = weeksTarget; 23596 } 23597 return setWeekAll.call(this, input, week, weekday, dow, doy); 23598 } 23599 } 23600 23601 function setWeekAll(weekYear, week, weekday, dow, doy) { 23602 var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy), 23603 date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear); 23604 23605 this.year(date.getUTCFullYear()); 23606 this.month(date.getUTCMonth()); 23607 this.date(date.getUTCDate()); 23608 return this; 23609 } 23610 23611 // FORMATTING 23612 23613 addFormatToken('Q', 0, 'Qo', 'quarter'); 23614 23615 // ALIASES 23616 23617 addUnitAlias('quarter', 'Q'); 23618 23619 // PRIORITY 23620 23621 addUnitPriority('quarter', 7); 23622 23623 // PARSING 23624 23625 addRegexToken('Q', match1); 23626 addParseToken('Q', function (input, array) { 23627 array[MONTH] = (toInt(input) - 1) * 3; 23628 }); 23629 23630 // MOMENTS 23631 23632 function getSetQuarter(input) { 23633 return input == null 23634 ? Math.ceil((this.month() + 1) / 3) 23635 : this.month((input - 1) * 3 + (this.month() % 3)); 23636 } 23637 23638 // FORMATTING 23639 23640 addFormatToken('D', ['DD', 2], 'Do', 'date'); 23641 23642 // ALIASES 23643 23644 addUnitAlias('date', 'D'); 23645 23646 // PRIORITY 23647 addUnitPriority('date', 9); 23648 23649 // PARSING 23650 23651 addRegexToken('D', match1to2); 23652 addRegexToken('DD', match1to2, match2); 23653 addRegexToken('Do', function (isStrict, locale) { 23654 // TODO: Remove "ordinalParse" fallback in next major release. 23655 return isStrict 23656 ? locale._dayOfMonthOrdinalParse || locale._ordinalParse 23657 : locale._dayOfMonthOrdinalParseLenient; 23658 }); 23659 23660 addParseToken(['D', 'DD'], DATE); 23661 addParseToken('Do', function (input, array) { 23662 array[DATE] = toInt(input.match(match1to2)[0]); 23663 }); 23664 23665 // MOMENTS 23666 23667 var getSetDayOfMonth = makeGetSet('Date', true); 23668 23669 // FORMATTING 23670 23671 addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear'); 23672 23673 // ALIASES 23674 23675 addUnitAlias('dayOfYear', 'DDD'); 23676 23677 // PRIORITY 23678 addUnitPriority('dayOfYear', 4); 23679 23680 // PARSING 23681 23682 addRegexToken('DDD', match1to3); 23683 addRegexToken('DDDD', match3); 23684 addParseToken(['DDD', 'DDDD'], function (input, array, config) { 23685 config._dayOfYear = toInt(input); 23686 }); 23687 23688 // HELPERS 23689 23690 // MOMENTS 23691 23692 function getSetDayOfYear(input) { 23693 var dayOfYear = 23694 Math.round( 23695 (this.clone().startOf('day') - this.clone().startOf('year')) / 864e5 23696 ) + 1; 23697 return input == null ? dayOfYear : this.add(input - dayOfYear, 'd'); 23698 } 23699 23700 // FORMATTING 23701 23702 addFormatToken('m', ['mm', 2], 0, 'minute'); 23703 23704 // ALIASES 23705 23706 addUnitAlias('minute', 'm'); 23707 23708 // PRIORITY 23709 23710 addUnitPriority('minute', 14); 23711 23712 // PARSING 23713 23714 addRegexToken('m', match1to2); 23715 addRegexToken('mm', match1to2, match2); 23716 addParseToken(['m', 'mm'], MINUTE); 23717 23718 // MOMENTS 23719 23720 var getSetMinute = makeGetSet('Minutes', false); 23721 23722 // FORMATTING 23723 23724 addFormatToken('s', ['ss', 2], 0, 'second'); 23725 23726 // ALIASES 23727 23728 addUnitAlias('second', 's'); 23729 23730 // PRIORITY 23731 23732 addUnitPriority('second', 15); 23733 23734 // PARSING 23735 23736 addRegexToken('s', match1to2); 23737 addRegexToken('ss', match1to2, match2); 23738 addParseToken(['s', 'ss'], SECOND); 23739 23740 // MOMENTS 23741 23742 var getSetSecond = makeGetSet('Seconds', false); 23743 23744 // FORMATTING 23745 23746 addFormatToken('S', 0, 0, function () { 23747 return ~~(this.millisecond() / 100); 23748 }); 23749 23750 addFormatToken(0, ['SS', 2], 0, function () { 23751 return ~~(this.millisecond() / 10); 23752 }); 23753 23754 addFormatToken(0, ['SSS', 3], 0, 'millisecond'); 23755 addFormatToken(0, ['SSSS', 4], 0, function () { 23756 return this.millisecond() * 10; 23757 }); 23758 addFormatToken(0, ['SSSSS', 5], 0, function () { 23759 return this.millisecond() * 100; 23760 }); 23761 addFormatToken(0, ['SSSSSS', 6], 0, function () { 23762 return this.millisecond() * 1000; 23763 }); 23764 addFormatToken(0, ['SSSSSSS', 7], 0, function () { 23765 return this.millisecond() * 10000; 23766 }); 23767 addFormatToken(0, ['SSSSSSSS', 8], 0, function () { 23768 return this.millisecond() * 100000; 23769 }); 23770 addFormatToken(0, ['SSSSSSSSS', 9], 0, function () { 23771 return this.millisecond() * 1000000; 23772 }); 23773 23774 // ALIASES 23775 23776 addUnitAlias('millisecond', 'ms'); 23777 23778 // PRIORITY 23779 23780 addUnitPriority('millisecond', 16); 23781 23782 // PARSING 23783 23784 addRegexToken('S', match1to3, match1); 23785 addRegexToken('SS', match1to3, match2); 23786 addRegexToken('SSS', match1to3, match3); 23787 23788 var token, getSetMillisecond; 23789 for (token = 'SSSS'; token.length <= 9; token += 'S') { 23790 addRegexToken(token, matchUnsigned); 23791 } 23792 23793 function parseMs(input, array) { 23794 array[MILLISECOND] = toInt(('0.' + input) * 1000); 23795 } 23796 23797 for (token = 'S'; token.length <= 9; token += 'S') { 23798 addParseToken(token, parseMs); 23799 } 23800 23801 getSetMillisecond = makeGetSet('Milliseconds', false); 23802 23803 // FORMATTING 23804 23805 addFormatToken('z', 0, 0, 'zoneAbbr'); 23806 addFormatToken('zz', 0, 0, 'zoneName'); 23807 23808 // MOMENTS 23809 23810 function getZoneAbbr() { 23811 return this._isUTC ? 'UTC' : ''; 23812 } 23813 23814 function getZoneName() { 23815 return this._isUTC ? 'Coordinated Universal Time' : ''; 23816 } 23817 23818 var proto = Moment.prototype; 23819 23820 proto.add = add; 23821 proto.calendar = calendar$1; 23822 proto.clone = clone; 23823 proto.diff = diff; 23824 proto.endOf = endOf; 23825 proto.format = format; 23826 proto.from = from; 23827 proto.fromNow = fromNow; 23828 proto.to = to; 23829 proto.toNow = toNow; 23830 proto.get = stringGet; 23831 proto.invalidAt = invalidAt; 23832 proto.isAfter = isAfter; 23833 proto.isBefore = isBefore; 23834 proto.isBetween = isBetween; 23835 proto.isSame = isSame; 23836 proto.isSameOrAfter = isSameOrAfter; 23837 proto.isSameOrBefore = isSameOrBefore; 23838 proto.isValid = isValid$2; 23839 proto.lang = lang; 23840 proto.locale = locale; 23841 proto.localeData = localeData; 23842 proto.max = prototypeMax; 23843 proto.min = prototypeMin; 23844 proto.parsingFlags = parsingFlags; 23845 proto.set = stringSet; 23846 proto.startOf = startOf; 23847 proto.subtract = subtract; 23848 proto.toArray = toArray; 23849 proto.toObject = toObject; 23850 proto.toDate = toDate; 23851 proto.toISOString = toISOString; 23852 proto.inspect = inspect; 23853 if (typeof Symbol !== 'undefined' && Symbol.for != null) { 23854 proto[Symbol.for('nodejs.util.inspect.custom')] = function () { 23855 return 'Moment<' + this.format() + '>'; 23856 }; 23857 } 23858 proto.toJSON = toJSON; 23859 proto.toString = toString; 23860 proto.unix = unix; 23861 proto.valueOf = valueOf; 23862 proto.creationData = creationData; 23863 proto.eraName = getEraName; 23864 proto.eraNarrow = getEraNarrow; 23865 proto.eraAbbr = getEraAbbr; 23866 proto.eraYear = getEraYear; 23867 proto.year = getSetYear; 23868 proto.isLeapYear = getIsLeapYear; 23869 proto.weekYear = getSetWeekYear; 23870 proto.isoWeekYear = getSetISOWeekYear; 23871 proto.quarter = proto.quarters = getSetQuarter; 23872 proto.month = getSetMonth; 23873 proto.daysInMonth = getDaysInMonth; 23874 proto.week = proto.weeks = getSetWeek; 23875 proto.isoWeek = proto.isoWeeks = getSetISOWeek; 23876 proto.weeksInYear = getWeeksInYear; 23877 proto.weeksInWeekYear = getWeeksInWeekYear; 23878 proto.isoWeeksInYear = getISOWeeksInYear; 23879 proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear; 23880 proto.date = getSetDayOfMonth; 23881 proto.day = proto.days = getSetDayOfWeek; 23882 proto.weekday = getSetLocaleDayOfWeek; 23883 proto.isoWeekday = getSetISODayOfWeek; 23884 proto.dayOfYear = getSetDayOfYear; 23885 proto.hour = proto.hours = getSetHour; 23886 proto.minute = proto.minutes = getSetMinute; 23887 proto.second = proto.seconds = getSetSecond; 23888 proto.millisecond = proto.milliseconds = getSetMillisecond; 23889 proto.utcOffset = getSetOffset; 23890 proto.utc = setOffsetToUTC; 23891 proto.local = setOffsetToLocal; 23892 proto.parseZone = setOffsetToParsedOffset; 23893 proto.hasAlignedHourOffset = hasAlignedHourOffset; 23894 proto.isDST = isDaylightSavingTime; 23895 proto.isLocal = isLocal; 23896 proto.isUtcOffset = isUtcOffset; 23897 proto.isUtc = isUtc; 23898 proto.isUTC = isUtc; 23899 proto.zoneAbbr = getZoneAbbr; 23900 proto.zoneName = getZoneName; 23901 proto.dates = deprecate( 23902 'dates accessor is deprecated. Use date instead.', 23903 getSetDayOfMonth 23904 ); 23905 proto.months = deprecate( 23906 'months accessor is deprecated. Use month instead', 23907 getSetMonth 23908 ); 23909 proto.years = deprecate( 23910 'years accessor is deprecated. Use year instead', 23911 getSetYear 23912 ); 23913 proto.zone = deprecate( 23914 'moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', 23915 getSetZone 23916 ); 23917 proto.isDSTShifted = deprecate( 23918 'isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', 23919 isDaylightSavingTimeShifted 23920 ); 23921 23922 function createUnix(input) { 23923 return createLocal(input * 1000); 23924 } 23925 23926 function createInZone() { 23927 return createLocal.apply(null, arguments).parseZone(); 23928 } 23929 23930 function preParsePostFormat(string) { 23931 return string; 23932 } 23933 23934 var proto$1 = Locale.prototype; 23935 23936 proto$1.calendar = calendar; 23937 proto$1.longDateFormat = longDateFormat; 23938 proto$1.invalidDate = invalidDate; 23939 proto$1.ordinal = ordinal; 23940 proto$1.preparse = preParsePostFormat; 23941 proto$1.postformat = preParsePostFormat; 23942 proto$1.relativeTime = relativeTime; 23943 proto$1.pastFuture = pastFuture; 23944 proto$1.set = set; 23945 proto$1.eras = localeEras; 23946 proto$1.erasParse = localeErasParse; 23947 proto$1.erasConvertYear = localeErasConvertYear; 23948 proto$1.erasAbbrRegex = erasAbbrRegex; 23949 proto$1.erasNameRegex = erasNameRegex; 23950 proto$1.erasNarrowRegex = erasNarrowRegex; 23951 23952 proto$1.months = localeMonths; 23953 proto$1.monthsShort = localeMonthsShort; 23954 proto$1.monthsParse = localeMonthsParse; 23955 proto$1.monthsRegex = monthsRegex; 23956 proto$1.monthsShortRegex = monthsShortRegex; 23957 proto$1.week = localeWeek; 23958 proto$1.firstDayOfYear = localeFirstDayOfYear; 23959 proto$1.firstDayOfWeek = localeFirstDayOfWeek; 23960 23961 proto$1.weekdays = localeWeekdays; 23962 proto$1.weekdaysMin = localeWeekdaysMin; 23963 proto$1.weekdaysShort = localeWeekdaysShort; 23964 proto$1.weekdaysParse = localeWeekdaysParse; 23965 23966 proto$1.weekdaysRegex = weekdaysRegex; 23967 proto$1.weekdaysShortRegex = weekdaysShortRegex; 23968 proto$1.weekdaysMinRegex = weekdaysMinRegex; 23969 23970 proto$1.isPM = localeIsPM; 23971 proto$1.meridiem = localeMeridiem; 23972 23973 function get$1(format, index, field, setter) { 23974 var locale = getLocale(), 23975 utc = createUTC().set(setter, index); 23976 return locale[field](utc, format); 23977 } 23978 23979 function listMonthsImpl(format, index, field) { 23980 if (isNumber(format)) { 23981 index = format; 23982 format = undefined; 23983 } 23984 23985 format = format || ''; 23986 23987 if (index != null) { 23988 return get$1(format, index, field, 'month'); 23989 } 23990 23991 var i, 23992 out = []; 23993 for (i = 0; i < 12; i++) { 23994 out[i] = get$1(format, i, field, 'month'); 23995 } 23996 return out; 23997 } 23998 23999 // () 24000 // (5) 24001 // (fmt, 5) 24002 // (fmt) 24003 // (true) 24004 // (true, 5) 24005 // (true, fmt, 5) 24006 // (true, fmt) 24007 function listWeekdaysImpl(localeSorted, format, index, field) { 24008 if (typeof localeSorted === 'boolean') { 24009 if (isNumber(format)) { 24010 index = format; 24011 format = undefined; 24012 } 24013 24014 format = format || ''; 24015 } else { 24016 format = localeSorted; 24017 index = format; 24018 localeSorted = false; 24019 24020 if (isNumber(format)) { 24021 index = format; 24022 format = undefined; 24023 } 24024 24025 format = format || ''; 24026 } 24027 24028 var locale = getLocale(), 24029 shift = localeSorted ? locale._week.dow : 0, 24030 i, 24031 out = []; 24032 24033 if (index != null) { 24034 return get$1(format, (index + shift) % 7, field, 'day'); 24035 } 24036 24037 for (i = 0; i < 7; i++) { 24038 out[i] = get$1(format, (i + shift) % 7, field, 'day'); 24039 } 24040 return out; 24041 } 24042 24043 function listMonths(format, index) { 24044 return listMonthsImpl(format, index, 'months'); 24045 } 24046 24047 function listMonthsShort(format, index) { 24048 return listMonthsImpl(format, index, 'monthsShort'); 24049 } 24050 24051 function listWeekdays(localeSorted, format, index) { 24052 return listWeekdaysImpl(localeSorted, format, index, 'weekdays'); 24053 } 24054 24055 function listWeekdaysShort(localeSorted, format, index) { 24056 return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort'); 24057 } 24058 24059 function listWeekdaysMin(localeSorted, format, index) { 24060 return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin'); 24061 } 24062 24063 getSetGlobalLocale('en', { 24064 eras: [ 24065 { 24066 since: '0001-01-01', 24067 until: +Infinity, 24068 offset: 1, 24069 name: 'Anno Domini', 24070 narrow: 'AD', 24071 abbr: 'AD', 24072 }, 24073 { 24074 since: '0000-12-31', 24075 until: -Infinity, 24076 offset: 1, 24077 name: 'Before Christ', 24078 narrow: 'BC', 24079 abbr: 'BC', 24080 }, 24081 ], 24082 dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/, 24083 ordinal: function (number) { 24084 var b = number % 10, 24085 output = 24086 toInt((number % 100) / 10) === 1 24087 ? 'th' 24088 : b === 1 24089 ? 'st' 24090 : b === 2 24091 ? 'nd' 24092 : b === 3 24093 ? 'rd' 24094 : 'th'; 24095 return number + output; 24096 }, 24097 }); 24098 24099 // Side effect imports 24100 24101 hooks.lang = deprecate( 24102 'moment.lang is deprecated. Use moment.locale instead.', 24103 getSetGlobalLocale 24104 ); 24105 hooks.langData = deprecate( 24106 'moment.langData is deprecated. Use moment.localeData instead.', 24107 getLocale 24108 ); 24109 24110 var mathAbs = Math.abs; 24111 24112 function abs() { 24113 var data = this._data; 24114 24115 this._milliseconds = mathAbs(this._milliseconds); 24116 this._days = mathAbs(this._days); 24117 this._months = mathAbs(this._months); 24118 24119 data.milliseconds = mathAbs(data.milliseconds); 24120 data.seconds = mathAbs(data.seconds); 24121 data.minutes = mathAbs(data.minutes); 24122 data.hours = mathAbs(data.hours); 24123 data.months = mathAbs(data.months); 24124 data.years = mathAbs(data.years); 24125 24126 return this; 24127 } 24128 24129 function addSubtract$1(duration, input, value, direction) { 24130 var other = createDuration(input, value); 24131 24132 duration._milliseconds += direction * other._milliseconds; 24133 duration._days += direction * other._days; 24134 duration._months += direction * other._months; 24135 24136 return duration._bubble(); 24137 } 24138 24139 // supports only 2.0-style add(1, 's') or add(duration) 24140 function add$1(input, value) { 24141 return addSubtract$1(this, input, value, 1); 24142 } 24143 24144 // supports only 2.0-style subtract(1, 's') or subtract(duration) 24145 function subtract$1(input, value) { 24146 return addSubtract$1(this, input, value, -1); 24147 } 24148 24149 function absCeil(number) { 24150 if (number < 0) { 24151 return Math.floor(number); 24152 } else { 24153 return Math.ceil(number); 24154 } 24155 } 24156 24157 function bubble() { 24158 var milliseconds = this._milliseconds, 24159 days = this._days, 24160 months = this._months, 24161 data = this._data, 24162 seconds, 24163 minutes, 24164 hours, 24165 years, 24166 monthsFromDays; 24167 24168 // if we have a mix of positive and negative values, bubble down first 24169 // check: https://github.com/moment/moment/issues/2166 24170 if ( 24171 !( 24172 (milliseconds >= 0 && days >= 0 && months >= 0) || 24173 (milliseconds <= 0 && days <= 0 && months <= 0) 24174 ) 24175 ) { 24176 milliseconds += absCeil(monthsToDays(months) + days) * 864e5; 24177 days = 0; 24178 months = 0; 24179 } 24180 24181 // The following code bubbles up values, see the tests for 24182 // examples of what that means. 24183 data.milliseconds = milliseconds % 1000; 24184 24185 seconds = absFloor(milliseconds / 1000); 24186 data.seconds = seconds % 60; 24187 24188 minutes = absFloor(seconds / 60); 24189 data.minutes = minutes % 60; 24190 24191 hours = absFloor(minutes / 60); 24192 data.hours = hours % 24; 24193 24194 days += absFloor(hours / 24); 24195 24196 // convert days to months 24197 monthsFromDays = absFloor(daysToMonths(days)); 24198 months += monthsFromDays; 24199 days -= absCeil(monthsToDays(monthsFromDays)); 24200 24201 // 12 months -> 1 year 24202 years = absFloor(months / 12); 24203 months %= 12; 24204 24205 data.days = days; 24206 data.months = months; 24207 data.years = years; 24208 24209 return this; 24210 } 24211 24212 function daysToMonths(days) { 24213 // 400 years have 146097 days (taking into account leap year rules) 24214 // 400 years have 12 months === 4800 24215 return (days * 4800) / 146097; 24216 } 24217 24218 function monthsToDays(months) { 24219 // the reverse of daysToMonths 24220 return (months * 146097) / 4800; 24221 } 24222 24223 function as(units) { 24224 if (!this.isValid()) { 24225 return NaN; 24226 } 24227 var days, 24228 months, 24229 milliseconds = this._milliseconds; 24230 24231 units = normalizeUnits(units); 24232 24233 if (units === 'month' || units === 'quarter' || units === 'year') { 24234 days = this._days + milliseconds / 864e5; 24235 months = this._months + daysToMonths(days); 24236 switch (units) { 24237 case 'month': 24238 return months; 24239 case 'quarter': 24240 return months / 3; 24241 case 'year': 24242 return months / 12; 24243 } 24244 } else { 24245 // handle milliseconds separately because of floating point math errors (issue #1867) 24246 days = this._days + Math.round(monthsToDays(this._months)); 24247 switch (units) { 24248 case 'week': 24249 return days / 7 + milliseconds / 6048e5; 24250 case 'day': 24251 return days + milliseconds / 864e5; 24252 case 'hour': 24253 return days * 24 + milliseconds / 36e5; 24254 case 'minute': 24255 return days * 1440 + milliseconds / 6e4; 24256 case 'second': 24257 return days * 86400 + milliseconds / 1000; 24258 // Math.floor prevents floating point math errors here 24259 case 'millisecond': 24260 return Math.floor(days * 864e5) + milliseconds; 24261 default: 24262 throw new Error('Unknown unit ' + units); 24263 } 24264 } 24265 } 24266 24267 // TODO: Use this.as('ms')? 24268 function valueOf$1() { 24269 if (!this.isValid()) { 24270 return NaN; 24271 } 24272 return ( 24273 this._milliseconds + 24274 this._days * 864e5 + 24275 (this._months % 12) * 2592e6 + 24276 toInt(this._months / 12) * 31536e6 24277 ); 24278 } 24279 24280 function makeAs(alias) { 24281 return function () { 24282 return this.as(alias); 24283 }; 24284 } 24285 24286 var asMilliseconds = makeAs('ms'), 24287 asSeconds = makeAs('s'), 24288 asMinutes = makeAs('m'), 24289 asHours = makeAs('h'), 24290 asDays = makeAs('d'), 24291 asWeeks = makeAs('w'), 24292 asMonths = makeAs('M'), 24293 asQuarters = makeAs('Q'), 24294 asYears = makeAs('y'); 24295 24296 function clone$1() { 24297 return createDuration(this); 24298 } 24299 24300 function get$2(units) { 24301 units = normalizeUnits(units); 24302 return this.isValid() ? this[units + 's']() : NaN; 24303 } 24304 24305 function makeGetter(name) { 24306 return function () { 24307 return this.isValid() ? this._data[name] : NaN; 24308 }; 24309 } 24310 24311 var milliseconds = makeGetter('milliseconds'), 24312 seconds = makeGetter('seconds'), 24313 minutes = makeGetter('minutes'), 24314 hours = makeGetter('hours'), 24315 days = makeGetter('days'), 24316 months = makeGetter('months'), 24317 years = makeGetter('years'); 24318 24319 function weeks() { 24320 return absFloor(this.days() / 7); 24321 } 24322 24323 var round = Math.round, 24324 thresholds = { 24325 ss: 44, // a few seconds to seconds 24326 s: 45, // seconds to minute 24327 m: 45, // minutes to hour 24328 h: 22, // hours to day 24329 d: 26, // days to month/week 24330 w: null, // weeks to month 24331 M: 11, // months to year 24332 }; 24333 24334 // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize 24335 function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) { 24336 return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture); 24337 } 24338 24339 function relativeTime$1(posNegDuration, withoutSuffix, thresholds, locale) { 24340 var duration = createDuration(posNegDuration).abs(), 24341 seconds = round(duration.as('s')), 24342 minutes = round(duration.as('m')), 24343 hours = round(duration.as('h')), 24344 days = round(duration.as('d')), 24345 months = round(duration.as('M')), 24346 weeks = round(duration.as('w')), 24347 years = round(duration.as('y')), 24348 a = 24349 (seconds <= thresholds.ss && ['s', seconds]) || 24350 (seconds < thresholds.s && ['ss', seconds]) || 24351 (minutes <= 1 && ['m']) || 24352 (minutes < thresholds.m && ['mm', minutes]) || 24353 (hours <= 1 && ['h']) || 24354 (hours < thresholds.h && ['hh', hours]) || 24355 (days <= 1 && ['d']) || 24356 (days < thresholds.d && ['dd', days]); 24357 24358 if (thresholds.w != null) { 24359 a = 24360 a || 24361 (weeks <= 1 && ['w']) || 24362 (weeks < thresholds.w && ['ww', weeks]); 24363 } 24364 a = a || 24365 (months <= 1 && ['M']) || 24366 (months < thresholds.M && ['MM', months]) || 24367 (years <= 1 && ['y']) || ['yy', years]; 24368 24369 a[2] = withoutSuffix; 24370 a[3] = +posNegDuration > 0; 24371 a[4] = locale; 24372 return substituteTimeAgo.apply(null, a); 24373 } 24374 24375 // This function allows you to set the rounding function for relative time strings 24376 function getSetRelativeTimeRounding(roundingFunction) { 24377 if (roundingFunction === undefined) { 24378 return round; 24379 } 24380 if (typeof roundingFunction === 'function') { 24381 round = roundingFunction; 24382 return true; 24383 } 24384 return false; 24385 } 24386 24387 // This function allows you to set a threshold for relative time strings 24388 function getSetRelativeTimeThreshold(threshold, limit) { 24389 if (thresholds[threshold] === undefined) { 24390 return false; 24391 } 24392 if (limit === undefined) { 24393 return thresholds[threshold]; 24394 } 24395 thresholds[threshold] = limit; 24396 if (threshold === 's') { 24397 thresholds.ss = limit - 1; 24398 } 24399 return true; 24400 } 24401 24402 function humanize(argWithSuffix, argThresholds) { 24403 if (!this.isValid()) { 24404 return this.localeData().invalidDate(); 24405 } 24406 24407 var withSuffix = false, 24408 th = thresholds, 24409 locale, 24410 output; 24411 24412 if (typeof argWithSuffix === 'object') { 24413 argThresholds = argWithSuffix; 24414 argWithSuffix = false; 24415 } 24416 if (typeof argWithSuffix === 'boolean') { 24417 withSuffix = argWithSuffix; 24418 } 24419 if (typeof argThresholds === 'object') { 24420 th = Object.assign({}, thresholds, argThresholds); 24421 if (argThresholds.s != null && argThresholds.ss == null) { 24422 th.ss = argThresholds.s - 1; 24423 } 24424 } 24425 24426 locale = this.localeData(); 24427 output = relativeTime$1(this, !withSuffix, th, locale); 24428 24429 if (withSuffix) { 24430 output = locale.pastFuture(+this, output); 24431 } 24432 24433 return locale.postformat(output); 24434 } 24435 24436 var abs$1 = Math.abs; 24437 24438 function sign(x) { 24439 return (x > 0) - (x < 0) || +x; 24440 } 24441 24442 function toISOString$1() { 24443 // for ISO strings we do not use the normal bubbling rules: 24444 // * milliseconds bubble up until they become hours 24445 // * days do not bubble at all 24446 // * months bubble up until they become years 24447 // This is because there is no context-free conversion between hours and days 24448 // (think of clock changes) 24449 // and also not between days and months (28-31 days per month) 24450 if (!this.isValid()) { 24451 return this.localeData().invalidDate(); 24452 } 24453 24454 var seconds = abs$1(this._milliseconds) / 1000, 24455 days = abs$1(this._days), 24456 months = abs$1(this._months), 24457 minutes, 24458 hours, 24459 years, 24460 s, 24461 total = this.asSeconds(), 24462 totalSign, 24463 ymSign, 24464 daysSign, 24465 hmsSign; 24466 24467 if (!total) { 24468 // this is the same as C#'s (Noda) and python (isodate)... 24469 // but not other JS (goog.date) 24470 return 'P0D'; 24471 } 24472 24473 // 3600 seconds -> 60 minutes -> 1 hour 24474 minutes = absFloor(seconds / 60); 24475 hours = absFloor(minutes / 60); 24476 seconds %= 60; 24477 minutes %= 60; 24478 24479 // 12 months -> 1 year 24480 years = absFloor(months / 12); 24481 months %= 12; 24482 24483 // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js 24484 s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : ''; 24485 24486 totalSign = total < 0 ? '-' : ''; 24487 ymSign = sign(this._months) !== sign(total) ? '-' : ''; 24488 daysSign = sign(this._days) !== sign(total) ? '-' : ''; 24489 hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : ''; 24490 24491 return ( 24492 totalSign + 24493 'P' + 24494 (years ? ymSign + years + 'Y' : '') + 24495 (months ? ymSign + months + 'M' : '') + 24496 (days ? daysSign + days + 'D' : '') + 24497 (hours || minutes || seconds ? 'T' : '') + 24498 (hours ? hmsSign + hours + 'H' : '') + 24499 (minutes ? hmsSign + minutes + 'M' : '') + 24500 (seconds ? hmsSign + s + 'S' : '') 24501 ); 24502 } 24503 24504 var proto$2 = Duration.prototype; 24505 24506 proto$2.isValid = isValid$1; 24507 proto$2.abs = abs; 24508 proto$2.add = add$1; 24509 proto$2.subtract = subtract$1; 24510 proto$2.as = as; 24511 proto$2.asMilliseconds = asMilliseconds; 24512 proto$2.asSeconds = asSeconds; 24513 proto$2.asMinutes = asMinutes; 24514 proto$2.asHours = asHours; 24515 proto$2.asDays = asDays; 24516 proto$2.asWeeks = asWeeks; 24517 proto$2.asMonths = asMonths; 24518 proto$2.asQuarters = asQuarters; 24519 proto$2.asYears = asYears; 24520 proto$2.valueOf = valueOf$1; 24521 proto$2._bubble = bubble; 24522 proto$2.clone = clone$1; 24523 proto$2.get = get$2; 24524 proto$2.milliseconds = milliseconds; 24525 proto$2.seconds = seconds; 24526 proto$2.minutes = minutes; 24527 proto$2.hours = hours; 24528 proto$2.days = days; 24529 proto$2.weeks = weeks; 24530 proto$2.months = months; 24531 proto$2.years = years; 24532 proto$2.humanize = humanize; 24533 proto$2.toISOString = toISOString$1; 24534 proto$2.toString = toISOString$1; 24535 proto$2.toJSON = toISOString$1; 24536 proto$2.locale = locale; 24537 proto$2.localeData = localeData; 24538 24539 proto$2.toIsoString = deprecate( 24540 'toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', 24541 toISOString$1 24542 ); 24543 proto$2.lang = lang; 24544 24545 // FORMATTING 24546 24547 addFormatToken('X', 0, 0, 'unix'); 24548 addFormatToken('x', 0, 0, 'valueOf'); 24549 24550 // PARSING 24551 24552 addRegexToken('x', matchSigned); 24553 addRegexToken('X', matchTimestamp); 24554 addParseToken('X', function (input, array, config) { 24555 config._d = new Date(parseFloat(input) * 1000); 24556 }); 24557 addParseToken('x', function (input, array, config) { 24558 config._d = new Date(toInt(input)); 24559 }); 24560 24561 //! moment.js 24562 24563 hooks.version = '2.2
245639.4'; 24564 24565 setHookCallback(createLocal); 24566 24567 hooks.fn = proto; 24568 hooks.min = min; 24569 hooks.max = max; 24570 hooks.now = now; 24571 hooks.utc = createUTC; 24572 hooks.unix = createUnix; 24573 hooks.months = listMonths; 24574 hooks.isDate = isDate; 24575 hooks.locale = getSetGlobalLocale; 24576 hooks.invalid = createInvalid; 24577 hooks.duration = createDuration; 24578 hooks.isMoment = isMoment; 24579 hooks.weekdays = listWeekdays; 24580 hooks.parseZone = createInZone; 24581 hooks.localeData = getLocale; 24582 hooks.isDuration = isDuration; 24583 hooks.monthsShort = listMonthsShort; 24584 hooks.weekdaysMin = listWeekdaysMin; 24585 hooks.defineLocale = defineLocale; 24586 hooks.updateLocale = updateLocale; 24587 hooks.locales = listLocales; 24588 hooks.weekdaysShort = listWeekdaysShort; 24589 hooks.normalizeUnits = normalizeUnits; 24590 hooks.relativeTimeRounding = getSetRelativeTimeRounding; 24591 hooks.relativeTimeThreshold = getSetRelativeTimeThreshold; 24592 hooks.calendarFormat = getCalendarFormat; 24593 hooks.prototype = proto; 24594 24595 // currently HTML5 input type only supports 24-hour formats 24596 hooks.HTML5_FMT = { 24597 DATETIME_LOCAL: 'YYYY-MM-DDTHH:mm', // <input type="datetime-local" /> 24598 DATETIME_LOCAL_SECONDS: 'YYYY-MM-DDTHH:mm:ss', // <input type="datetime-local" step="1" /> 24599 DATETIME_LOCAL_MS: 'YYYY-MM-DDTHH:mm:ss.SSS', // <input type="datetime-local" step="0.001" /> 24600 DATE: 'YYYY-MM-DD', // <input type="date" /> 24601 TIME: 'HH:mm', // <input type="time" /> 24602 TIME_SECONDS: 'HH:mm:ss', // <input type="time" step="1" /> 24603 TIME_MS: 'HH:mm:ss.SSS', // <input type="time" step="0.001" /> 24604 WEEK: 'GGGG-[W]WW', // <input type="week" /> 24605 MONTH: 'YYYY-MM', // <input type="month" /> 24606 }; 24607 24608 return hooks; 24609 24610}))); 24611 24612},{}],4:[function(require,module,exports){
vendor: 18,315 bytes, lines 24613-25215
24613/*! 24614 * Salvattore 1.0.9 by @rnmp and @ppold 24615 * https://github.com/rnmp/salvattore 24616 */ 24617(function(root, factory) { 24618 if (typeof define === 'function' && define.amd) { 24619 define([], factory); 24620 } else if (typeof exports === 'object') { 24621 module.exports = factory(); 24622 } else { 24623 root.salvattore = factory(); 24624 } 24625}(this, function() { 24626/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license */ 24627 24628if (!window.matchMedia) { 24629 window.matchMedia = function() { 24630 "use strict"; 24631 24632 // For browsers that support matchMedium api such as IE 9 and webkit 24633 var styleMedia = (window.styleMedia || window.media); 24634 24635 // For those that don't support matchMedium 24636 if (!styleMedia) { 24637 var style = document.createElement('style'), 24638 script = document.getElementsByTagName('script')[0], 24639 info = null; 24640 24641 style.type = 'text/css'; 24642 style.id = 'matchmediajs-test'; 24643 24644 script.parentNode.insertBefore(style, script); 24645 24646 // 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers 24647 info = ('getComputedStyle' in window) && window.getComputedStyle(style, null) || style.currentStyle; 24648 24649 styleMedia = { 24650 matchMedium: function(media) { 24651 var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }'; 24652 24653 // 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers 24654 if (style.styleSheet) { 24655 style.styleSheet.cssText = text; 24656 } else { 24657 style.textContent = text; 24658 } 24659 24660 // Test if media query is true or false 24661 return info.width === '1px'; 24662 } 24663 }; 24664 } 24665 24666 return function(media) { 24667 return { 24668 matches: styleMedia.matchMedium(media || 'all'), 24669 media: media || 'all' 24670 }; 24671 }; 24672 }(); 24673} 24674 24675/*! matchMedia() polyfill addListener/removeListener extension. Author & copyright (c) 2012: Scott Jehl. Dual MIT/BSD license */ 24676(function(){ 24677 "use strict"; 24678 24679 // Bail out for browsers that have addListener support 24680 if (window.matchMedia && window.matchMedia('all').addListener) { 24681 return false; 24682 } 24683 24684 var localMatchMedia = window.matchMedia, 24685 hasMediaQueries = localMatchMedia('only all').matches, 24686 isListening = false, 24687 timeoutID = 0, // setTimeout for debouncing 'handleChange' 24688 queries = [], // Contains each 'mql' and associated 'listeners' if 'addListener' is used 24689 handleChange = function(evt) { 24690 // Debounce 24691 clearTimeout(timeoutID); 24692 24693 timeoutID = setTimeout(function() { 24694 for (var i = 0, il = queries.length; i < il; i++) { 24695 var mql = queries[i].mql, 24696 listeners = queries[i].listeners || [], 24697 matches = localMatchMedia(mql.media).matches; 24698 24699 // Update mql.matches value and call listeners 24700 // Fire listeners only if transitioning to or from matched state 24701 if (matches !== mql.matches) { 24702 mql.matches = matches; 24703 24704 for (var j = 0, jl = listeners.length; j < jl; j++) { 24705 listeners[j].call(window, mql); 24706 } 24707 } 24708 } 24709 }, 30); 24710 }; 24711 24712 window.matchMedia = function(media) { 24713 var mql = localMatchMedia(media), 24714 listeners = [], 24715 index = 0; 24716 24717 mql.addListener = function(listener) { 24718 // Changes would not occur to css media type so return now (Affects IE <= 8) 24719 if (!hasMediaQueries) { 24720 return; 24721 } 24722 24723 // Set up 'resize' listener for browsers that support CSS3 media queries (Not for IE <= 8) 24724 // There should only ever be 1 resize listener running for performance 24725 if (!isListening) { 24726 isListening = true; 24727 window.addEventListener('resize', handleChange, true); 24728 } 24729 24730 // Push object only if it has not been pushed already 24731 if (index === 0) { 24732 index = queries.push({ 24733 mql : mql, 24734 listeners : listeners 24735 }); 24736 } 24737 24738 listeners.push(listener); 24739 }; 24740 24741 mql.removeListener = function(listener) { 24742 for (var i = 0, il = listeners.length; i < il; i++){ 24743 if (listeners[i] === listener){ 24744 listeners.splice(i, 1); 24745 } 24746 } 24747 }; 24748 24749 return mql; 24750 }; 24751}()); 24752 24753// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ 24754// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating 24755 24756// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel 24757 24758// MIT license 24759 24760(function() { 24761 "use strict"; 24762 24763 var lastTime = 0; 24764 var vendors = ['ms', 'moz', 'webkit', 'o']; 24765 for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { 24766 window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; 24767 window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || 24768 window[vendors[x]+'CancelRequestAnimationFrame']; 24769 } 24770 24771 if (!window.requestAnimationFrame) 24772 window.requestAnimationFrame = function(callback, element) { 24773 var currTime = new Date().getTime(); 24774 var timeToCall = Math.max(0, 16 - (currTime - lastTime)); 24775 var id = window.setTimeout(function() { callback(currTime + timeToCall); }, 24776 timeToCall); 24777 lastTime = currTime + timeToCall; 24778 return id; 24779 }; 24780 24781 if (!window.cancelAnimationFrame) 24782 window.cancelAnimationFrame = function(id) { 24783 clearTimeout(id); 24784 }; 24785}()); 24786 24787// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent 24788 24789if (typeof window.CustomEvent !== "function") { 24790 (function() { 24791 "use strict"; 24792 function CustomEvent(event, params) { 24793 params = params || { bubbles: false, cancelable: false, detail: undefined }; 24794 var evt = document.createEvent('CustomEvent'); 24795 evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); 24796 return evt; 24797 } 24798 24799 CustomEvent.prototype = window.Event.prototype; 24800 24801 window.CustomEvent = CustomEvent; 24802 })(); 24803} 24804 24805/* jshint laxcomma: true */ 24806var salvattore = (function (global, document, undefined) { 24807"use strict"; 24808 24809var self = {}, 24810 grids = [], 24811 mediaRules = [], 24812 mediaQueries = [], 24813 add_to_dataset = function(element, key, value) { 24814 // uses dataset function or a fallback for <ie10 24815 if (element.dataset) { 24816 element.dataset[key] = value; 24817 } else { 24818 element.setAttribute("data-" + key, value); 24819 } 24820 return; 24821 }; 24822 24823self.obtainGridSettings = function obtainGridSettings(element) { 24824 // returns the number of columns and the classes a column should have, 24825 // from computing the style of the ::before pseudo-element of the grid. 24826 24827 var computedStyle = global.getComputedStyle(element, ":before") 24828 , content = computedStyle.getPropertyValue("content").slice(1, -1) 24829 , matchResult = content.match(/^\s*(\d+)(?:\s?\.(.+))?\s*$/) 24830 , numberOfColumns = 1 24831 , columnClasses = [] 24832 ; 24833 24834 if (matchResult) { 24835 numberOfColumns = matchResult[1]; 24836 columnClasses = matchResult[2]; 24837 columnClasses = columnClasses? columnClasses.split(".") : ["column"]; 24838 } else { 24839 matchResult = content.match(/^\s*\.(.+)\s+(\d+)\s*$/); 24840 if (matchResult) { 24841 columnClasses = matchResult[1]; 24842 numberOfColumns = matchResult[2]; 24843 if (numberOfColumns) { 24844 numberOfColumns = numberOfColumns.split("."); 24845 } 24846 } 24847 } 24848 24849 return { 24850 numberOfColumns: numberOfColumns, 24851 columnClasses: columnClasses 24852 }; 24853}; 24854 24855 24856self.addColumns = function addColumns(grid, items) { 24857 // from the settings obtained, it creates columns with 24858 // the configured classes and adds to them a list of items. 24859 24860 var settings = self.obtainGridSettings(grid) 24861 , numberOfColumns = settings.numberOfColumns 24862 , columnClasses = settings.columnClasses 24863 , columnsItems = new Array(+numberOfColumns) 24864 , columnsFragment = document.createDocumentFragment() 24865 , i = numberOfColumns 24866 , selector 24867 ; 24868 24869 while (i-- !== 0) { 24870 selector = "[data-columns] > *:nth-child(" + numberOfColumns + "n-" + i + ")"; 24871 columnsItems.push(items.querySelectorAll(selector)); 24872 } 24873 24874 columnsItems.forEach(function append_to_grid_fragment(rows) { 24875 var column = document.createElement("div") 24876 , rowsFragment = document.createDocumentFragment() 24877 ; 24878 24879 column.className = columnClasses.join(" "); 24880 24881 Array.prototype.forEach.call(rows, function append_to_column(row) { 24882 rowsFragment.appendChild(row); 24883 }); 24884 column.appendChild(rowsFragment); 24885 columnsFragment.appendChild(column); 24886 }); 24887 24888 grid.appendChild(columnsFragment); 24889 add_to_dataset(grid, 'columns', numberOfColumns); 24890}; 24891 24892 24893self.removeColumns = function removeColumns(grid) { 24894 // removes all the columns from a grid, and returns a list 24895 // of items sorted by the ordering of columns. 24896 24897 var range = document.createRange(); 24898 range.selectNodeContents(grid); 24899 24900 var columns = Array.prototype.filter.call(range.extractContents().childNodes, function filter_elements(node) { 24901 return node instanceof global.HTMLElement; 24902 }); 24903 24904 var numberOfColumns = columns.length 24905 , numberOfRowsInFirstColumn = columns[0].childNodes.length 24906 , sortedRows = new Array(numberOfRowsInFirstColumn * numberOfColumns) 24907 ; 24908 24909 Array.prototype.forEach.call(columns, function iterate_columns(column, columnIndex) { 24910 Array.prototype.forEach.call(column.children, function iterate_rows(row, rowIndex) { 24911 sortedRows[rowIndex * numberOfColumns + columnIndex] = row; 24912 }); 24913 }); 24914 24915 var container = document.createElement("div"); 24916 add_to_dataset(container, 'columns', 0); 24917 24918 sortedRows.filter(function filter_non_null(child) { 24919 return !!child; 24920 }).forEach(function append_row(child) { 24921 container.appendChild(child); 24922 }); 24923 24924 return container; 24925}; 24926 24927 24928self.recreateColumns = function recreateColumns(grid) { 24929 // removes all the columns from the grid, and adds them again, 24930 // it is used when the number of columns change. 24931 24932 global.requestAnimationFrame(function render_after_css_mediaQueryChange() { 24933 self.addColumns(grid, self.removeColumns(grid)); 24934 var columnsChange = new CustomEvent("columnsChange"); 24935 grid.dispatchEvent(columnsChange); 24936 }); 24937}; 24938 24939 24940self.mediaQueryChange = function mediaQueryChange(mql) { 24941 // recreates the columns when a media query matches the current state 24942 // of the browser. 24943 24944 if (mql.matches) { 24945 Array.prototype.forEach.call(grids, self.recreateColumns); 24946 } 24947}; 24948 24949 24950self.getCSSRules = function getCSSRules(stylesheet) { 24951 // returns a list of css rules from a stylesheet 24952 24953 var cssRules; 24954 try { 24955 cssRules = stylesheet.sheet.cssRules || stylesheet.sheet.rules; 24956 } catch (e) { 24957 return []; 24958 } 24959 24960 return cssRules || []; 24961}; 24962 24963 24964self.getStylesheets = function getStylesheets() { 24965 // returns a list of all the styles in the document (that are accessible). 24966 24967 var inlineStyleBlocks = Array.prototype.slice.call(document.querySelectorAll("style")); 24968 inlineStyleBlocks.forEach(function(stylesheet, idx) { 24969 if (stylesheet.type !== 'text/css' && stylesheet.type !== '') { 24970 inlineStyleBlocks.splice(idx, 1); 24971 } 24972 }); 24973 24974 return Array.prototype.concat.call( 24975 inlineStyleBlocks, 24976 Array.prototype.slice.call(document.querySelectorAll("link[rel='stylesheet']")) 24977 ); 24978}; 24979 24980 24981self.mediaRuleHasColumnsSelector = function mediaRuleHasColumnsSelector(rules) { 24982 // checks if a media query css rule has in its contents a selector that 24983 // styles the grid. 24984 24985 var i, rule; 24986 24987 try { 24988 i = rules.length; 24989 } 24990 catch (e) { 24991 i = 0; 24992 } 24993 24994 while (i--) { 24995 rule = rules[i]; 24996 if (rule.selectorText && rule.selectorText.match(/\[data-columns\](.*)::?before$/)) { 24997 return true; 24998 } 24999 } 25000 25001 return false; 25002}; 25003 25004 25005self.scanMediaQueries = function scanMediaQueries() { 25006 // scans all the stylesheets for selectors that style grids, 25007 // if the matchMedia API is supported. 25008 25009 var newMediaRules = []; 25010 25011 if (!global.matchMedia) { 25012 return; 25013 } 25014 25015 self.getStylesheets().forEach(function extract_rules(stylesheet) { 25016 Array.prototype.forEach.call(self.getCSSRules(stylesheet), function filter_by_column_selector(rule) { 25017 // rule.media throws an 'not implemented error' in ie9 for import rules occasionally 25018 try { 25019 if (rule.media && rule.cssRules && self.mediaRuleHasColumnsSelector(rule.cssRules)) { 25020 newMediaRules.push(rule); 25021 } 25022 } catch (e) {} 25023 }); 25024 }); 25025 25026 // remove matchMedia listeners from the old rules 25027 var oldRules = mediaRules.filter(function (el) { 25028 return newMediaRules.indexOf(el) === -1; 25029 }); 25030 mediaQueries.filter(function (el) { 25031 return oldRules.indexOf(el.rule) !== -1; 25032 }).forEach(function (el) { 25033 el.mql.removeListener(self.mediaQueryChange); 25034 }); 25035 mediaQueries = mediaQueries.filter(function (el) { 25036 return oldRules.indexOf(el.rule) === -1; 25037 }); 25038 25039 // add matchMedia listeners to the new rules 25040 newMediaRules.filter(function (el) { 25041 return mediaRules.indexOf(el) == -1; 25042 }).forEach(function (rule) { 25043 var mql = global.matchMedia(rule.media.mediaText); 25044 mql.addListener(self.mediaQueryChange); 25045 mediaQueries.push({rule: rule, mql:mql}); 25046 }); 25047 25048 // swap mediaRules with the new set 25049 mediaRules.length = 0; 25050 mediaRules = newMediaRules; 25051}; 25052 25053 25054self.rescanMediaQueries = function rescanMediaQueries() { 25055 self.scanMediaQueries(); 25056 Array.prototype.forEach.call(grids, self.recreateColumns); 25057}; 25058 25059 25060self.nextElementColumnIndex = function nextElementColumnIndex(grid, fragments) { 25061 // returns the index of the column where the given element must be added. 25062 25063 var children = grid.children 25064 , m = children.length 25065 , lowestRowCount = 0 25066 , child 25067 , currentRowCount 25068 , i 25069 , index = 0 25070 ; 25071 for (i = 0; i < m; i++) { 25072 child = children[i]; 25073 currentRowCount = child.children.length + (fragments[i].children || fragments[i].childNodes).length; 25074 if(lowestRowCount === 0) { 25075 lowestRowCount = currentRowCount; 25076 } 25077 if(currentRowCount < lowestRowCount) { 25078 index = i; 25079 lowestRowCount = currentRowCount; 25080 } 25081 } 25082 25083 return index; 25084}; 25085 25086 25087self.createFragmentsList = function createFragmentsList(quantity) { 25088 // returns a list of fragments 25089 25090 var fragments = new Array(quantity) 25091 , i = 0 25092 ; 25093 25094 while (i !== quantity) { 25095 fragments[i] = document.createDocumentFragment(); 25096 i++; 25097 } 25098 25099 return fragments; 25100}; 25101 25102 25103self.appendElements = function appendElements(grid, elements) { 25104 // adds a list of elements to the end of a grid 25105 25106 var columns = grid.children 25107 , numberOfColumns = columns.length 25108 , fragments = self.createFragmentsList(numberOfColumns) 25109 ; 25110 25111 Array.prototype.forEach.call(elements, function append_to_next_fragment(element) { 25112 var columnIndex = self.nextElementColumnIndex(grid, fragments); 25113 fragments[columnIndex].appendChild(element); 25114 }); 25115 25116 Array.prototype.forEach.call(columns, function insert_column(column, index) { 25117 column.appendChild(fragments[index]); 25118 }); 25119}; 25120 25121 25122self.prependElements = function prependElements(grid, elements) { 25123 // adds a list of elements to the start of a grid 25124 25125 var columns = grid.children 25126 , numberOfColumns = columns.length 25127 , fragments = self.createFragmentsList(numberOfColumns) 25128 , columnIndex = numberOfColumns - 1 25129 ; 25130 25131 elements.forEach(function append_to_next_fragment(element) { 25132 var fragment = fragments[columnIndex]; 25133 fragment.insertBefore(element, fragment.firstChild); 25134 if (columnIndex === 0) { 25135 columnIndex = numberOfColumns - 1; 25136 } else { 25137 columnIndex--; 25138 } 25139 }); 25140 25141 Array.prototype.forEach.call(columns, function insert_column(column, index) { 25142 column.insertBefore(fragments[index], column.firstChild); 25143 }); 25144 25145 // populates a fragment with n columns till the right 25146 var fragment = document.createDocumentFragment() 25147 , numberOfColumnsToExtract = elements.length % numberOfColumns 25148 ; 25149 25150 while (numberOfColumnsToExtract-- !== 0) { 25151 fragment.appendChild(grid.lastChild); 25152 } 25153 25154 // adds the fragment to the left 25155 grid.insertBefore(fragment, grid.firstChild); 25156}; 25157 25158 25159self.registerGrid = function registerGrid (grid) { 25160 if (global.getComputedStyle(grid).display === "none") { 25161 return; 25162 } 25163 25164 // retrieve the list of items from the grid itself 25165 var range = document.createRange(); 25166 range.selectNodeContents(grid); 25167 25168 var items = document.createElement("div"); 25169 items.appendChild(range.extractContents()); 25170 25171 25172 add_to_dataset(items, 'columns', 0); 25173 self.addColumns(grid, items); 25174 grids.push(grid); 25175}; 25176 25177 25178self.init = function init() { 25179 // adds required CSS rule to hide 'content' based 25180 // configuration. 25181 25182 var css = document.createElement("style"); 25183 css.innerHTML = "[data-columns]::before{display:block;visibility:hidden;position:absolute;font-size:1px;}"; 25184 document.head.appendChild(css); 25185 25186 // scans all the grids in the document and generates 25187 // columns from their configuration. 25188 25189 var gridElements = document.querySelectorAll("[data-columns]"); 25190 Array.prototype.forEach.call(gridElements, self.registerGrid); 25191 self.scanMediaQueries(); 25192}; 25193 25194self.init(); 25195 25196return { 25197 appendElements: self.appendElements, 25198 prependElements: self.prependElements, 25199 registerGrid: self.registerGrid, 25200 recreateColumns: self.recreateColumns, 25201 rescanMediaQueries: self.rescanMediaQueries, 25202 init: self.init, 25203 25204 // maintains backwards compatibility with underscore style method names 25205 append_elements: self.appendElements, 25206 prepend_elements: self.prependElements, 25207 register_grid: self.registerGrid, 25208 recreate_columns: self.recreateColumns, 25209 rescan_media_queries: self.rescanMediaQueries 25210}; 25211 25212})(window, window.document); 25213 25214return salvattore; 25215}));
vendor: 193,754 bytes, lines 25216-29763
25216 25217},{}],5:[function(require,module,exports){ 25218/*! VelocityJS.org (1.4.0). (C) 2014 Julian Shapiro. MIT @license: en.wikipedia.org/wiki/MIT_License */ 25219 25220/************************* 25221 Velocity jQuery Shim 25222 *************************/ 25223 25224/*! VelocityJS.org jQuery Shim (1.0.1). (C) 2014 The jQuery Foundation. MIT @license: en.wikipedia.org/wiki/MIT_License. */ 25225 25226/* This file contains the jQuery functions that Velocity relies on, thereby removing Velocity's dependency on a full copy of jQuery, and allowing it to work in any environment. */ 25227/* These shimmed functions are only used if jQuery isn't present. If both this shim and jQuery are loaded, Velocity defaults to jQuery proper. */ 25228/* Browser support: Using this shim instead of jQuery proper removes support for IE8. */ 25229 25230(function(window) { 25231 "use strict"; 25232 /*************** 25233 Setup 25234 ***************/ 25235 25236 /* If jQuery is already loaded, there's no point in loading this shim. */ 25237 if (window.jQuery) { 25238 return; 25239 } 25240 25241 /* jQuery base. */ 25242 var $ = function(selector, context) { 25243 return new $.fn.init(selector, context); 25244 }; 25245 25246 /******************** 25247 Private Methods 25248 ********************/ 25249 25250 /* jQuery */ 25251 $.isWindow = function(obj) { 25252 /* jshint eqeqeq: false */ 25253 return obj && obj === obj.window; 25254 }; 25255 25256 /* jQuery */ 25257 $.type = function(obj) { 25258 if (!obj) { 25259 return obj + ""; 25260 } 25261 25262 return typeof obj === "object" || typeof obj === "function" ? 25263 class2type[toString.call(obj)] || "object" : 25264 typeof obj; 25265 }; 25266 25267 /* jQuery */ 25268 $.isArray = Array.isArray || function(obj) { 25269 return $.type(obj) === "array"; 25270 }; 25271 25272 /* jQuery */ 25273 function isArraylike(obj) { 25274 var length = obj.length, 25275 type = $.type(obj); 25276 25277 if (type === "function" || $.isWindow(obj)) { 25278 return false; 25279 } 25280 25281 if (obj.nodeType === 1 && length) { 25282 return true; 25283 } 25284 25285 return type === "array" || length === 0 || typeof length === "number" && length > 0 && (length - 1) in obj; 25286 } 25287 25288 /*************** 25289 $ Methods 25290 ***************/ 25291 25292 /* jQuery: Support removed for IE<9. */ 25293 $.isPlainObject = function(obj) { 25294 var key; 25295 25296 if (!obj || $.type(obj) !== "object" || obj.nodeType || $.isWindow(obj)) { 25297 return false; 25298 } 25299 25300 try { 25301 if (obj.constructor && 25302 !hasOwn.call(obj, "constructor") && 25303 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) { 25304 return false; 25305 } 25306 } catch (e) { 25307 return false; 25308 } 25309 25310 for (key in obj) { 25311 } 25312 25313 return key === undefined || hasOwn.call(obj, key); 25314 }; 25315 25316 /* jQuery */ 25317 $.each = function(obj, callback, args) { 25318 var value, 25319 i = 0, 25320 length = obj.length, 25321 isArray = isArraylike(obj); 25322 25323 if (args) { 25324 if (isArray) { 25325 for (; i < length; i++) { 25326 value = callback.apply(obj[i], args); 25327 25328 if (value === false) { 25329 break; 25330 } 25331 } 25332 } else { 25333 for (i in obj) { 25334 if (!obj.hasOwnProperty(i)) { 25335 continue; 25336 } 25337 value = callback.apply(obj[i], args); 25338 25339 if (value === false) { 25340 break; 25341 } 25342 } 25343 } 25344 25345 } else { 25346 if (isArray) { 25347 for (; i < length; i++) { 25348 value = callback.call(obj[i], i, obj[i]); 25349 25350 if (value === false) { 25351 break; 25352 } 25353 } 25354 } else { 25355 for (i in obj) { 25356 if (!obj.hasOwnProperty(i)) { 25357 continue; 25358 } 25359 value = callback.call(obj[i], i, obj[i]); 25360 25361 if (value === false) { 25362 break; 25363 } 25364 } 25365 } 25366 } 25367 25368 return obj; 25369 }; 25370 25371 /* Custom */ 25372 $.data = function(node, key, value) { 25373 /* $.getData() */ 25374 if (value === undefined) { 25375 var getId = node[$.expando], 25376 store = getId && cache[getId]; 25377 25378 if (key === undefined) { 25379 return store; 25380 } else if (store) { 25381 if (key in store) { 25382 return store[key]; 25383 } 25384 } 25385 /* $.setData() */ 25386 } else if (key !== undefined) { 25387 var setId = node[$.expando] || (node[$.expando] = ++$.uuid); 25388 25389 cache[setId] = cache[setId] || {}; 25390 cache[setId][key] = value; 25391 25392 return value; 25393 } 25394 }; 25395 25396 /* Custom */ 25397 $.removeData = function(node, keys) { 25398 var id = node[$.expando], 25399 store = id && cache[id]; 25400 25401 if (store) { 25402 // Cleanup the entire store if no keys are provided. 25403 if (!keys) { 25404 delete cache[id]; 25405 } else { 25406 $.each(keys, function(_, key) { 25407 delete store[key]; 25408 }); 25409 } 25410 } 25411 }; 25412 25413 /* jQuery */ 25414 $.extend = function() { 25415 var src, copyIsArray, copy, name, options, clone, 25416 target = arguments[0] || {}, 25417 i = 1, 25418 length = arguments.length, 25419 deep = false; 25420 25421 if (typeof target === "boolean") { 25422 deep = target; 25423 25424 target = arguments[i] || {}; 25425 i++; 25426 } 25427 25428 if (typeof target !== "object" && $.type(target) !== "function") { 25429 target = {}; 25430 } 25431 25432 if (i === length) { 25433 target = this; 25434 i--; 25435 } 25436 25437 for (; i < length; i++) { 25438 if ((options = arguments[i])) { 25439 for (name in options) { 25440 if (!options.hasOwnProperty(name)) { 25441 continue; 25442 } 25443 src = target[name]; 25444 copy = options[name]; 25445 25446 if (target === copy) { 25447 continue; 25448 } 25449 25450 if (deep && copy && ($.isPlainObject(copy) || (copyIsArray = $.isArray(copy)))) { 25451 if (copyIsArray) { 25452 copyIsArray = false; 25453 clone = src && $.isArray(src) ? src : []; 25454 25455 } else { 25456 clone = src && $.isPlainObject(src) ? src : {}; 25457 } 25458 25459 target[name] = $.extend(deep, clone, copy); 25460 25461 } else if (copy !== undefined) { 25462 target[name] = copy; 25463 } 25464 } 25465 } 25466 } 25467 25468 return target; 25469 }; 25470 25471 /* jQuery 1.4.3 */ 25472 $.queue = function(elem, type, data) { 25473 function $makeArray(arr, results) { 25474 var ret = results || []; 25475 25476 if (arr) { 25477 if (isArraylike(Object(arr))) { 25478 /* $.merge */ 25479 (function(first, second) { 25480 var len = +second.length, 25481 j = 0, 25482 i = first.length; 25483 25484 while (j < len) { 25485 first[i++] = second[j++]; 25486 } 25487 25488 if (len !== len) { 25489 while (second[j] !== undefined) { 25490 first[i++] = second[j++]; 25491 } 25492 } 25493 25494 first.length = i; 25495 25496 return first; 25497 })(ret, typeof arr === "string" ? [arr] : arr); 25498 } else { 25499 [].push.call(ret, arr); 25500 } 25501 } 25502 25503 return ret; 25504 } 25505 25506 if (!elem) { 25507 return; 25508 } 25509 25510 type = (type || "fx") + "queue"; 25511 25512 var q = $.data(elem, type); 25513 25514 if (!data) { 25515 return q || []; 25516 } 25517 25518 if (!q || $.isArray(data)) { 25519 q = $.data(elem, type, $makeArray(data)); 25520 } else { 25521 q.push(data); 25522 } 25523 25524 return q; 25525 }; 25526 25527 /* jQuery 1.4.3 */ 25528 $.dequeue = function(elems, type) { 25529 /* Custom: Embed element iteration. */ 25530 $.each(elems.nodeType ? [elems] : elems, function(i, elem) { 25531 type = type || "fx"; 25532 25533 var queue = $.queue(elem, type), 25534 fn = queue.shift(); 25535 25536 if (fn === "inprogress") { 25537 fn = queue.shift(); 25538 } 25539 25540 if (fn) { 25541 if (type === "fx") { 25542 queue.unshift("inprogress"); 25543 } 25544 25545 fn.call(elem, function() { 25546 $.dequeue(elem, type); 25547 }); 25548 } 25549 }); 25550 }; 25551 25552 /****************** 25553 $.fn Methods 25554 ******************/ 25555 25556 /* jQuery */ 25557 $.fn = $.prototype = { 25558 init: function(selector) { 25559 /* Just return the element wrapped inside an array; don't proceed with the actual jQuery node wrapping process. */ 25560 if (selector.nodeType) { 25561 this[0] = selector; 25562 25563 return this; 25564 } else { 25565 throw new Error("Not a DOM node."); 25566 } 25567 }, 25568 offset: function() { 25569 /* jQuery altered code: Dropped disconnected DOM node checking. */ 25570 var box = this[0].getBoundingClientRect ? this[0].getBoundingClientRect() : {top: 0, left: 0}; 25571 25572 return { 25573 top: box.top + (window.pageYOffset || document.scrollTop || 0) - (document.clientTop || 0), 25574 left: box.left + (window.pageXOffset || document.scrollLeft || 0) - (document.clientLeft || 0) 25575 }; 25576 }, 25577 position: function() { 25578 /* jQuery */ 25579 function offsetParentFn(elem) { 25580 var offsetParent = elem.offsetParent; 25581 25582 while (offsetParent && offsetParent.nodeName.toLowerCase() !== "html" && offsetParent.style && offsetParent.style.position === "static") { 25583 offsetParent = offsetParent.offsetParent; 25584 } 25585 25586 return offsetParent || document; 25587 } 25588 25589 /* Zepto */ 25590 var elem = this[0], 25591 offsetParent = offsetParentFn(elem), 25592 offset = this.offset(), 25593 parentOffset = /^(?:body|html)$/i.test(offsetParent.nodeName) ? {top: 0, left: 0} : $(offsetParent).offset(); 25594 25595 offset.top -= parseFloat(elem.style.marginTop) || 0; 25596 offset.left -= parseFloat(elem.style.marginLeft) || 0; 25597 25598 if (offsetParent.style) { 25599 parentOffset.top += parseFloat(offsetParent.style.borderTopWidth) || 0; 25600 parentOffset.left += parseFloat(offsetParent.style.borderLeftWidth) || 0; 25601 } 25602 25603 return { 25604 top: offset.top - parentOffset.top, 25605 left: offset.left - parentOffset.left 25606 }; 25607 } 25608 }; 25609 25610 /********************** 25611 Private Variables 25612 **********************/ 25613 25614 /* For $.data() */ 25615 var cache = {}; 25616 $.expando = "velocity" + (new Date().getTime()); 25617 $.uuid = 0; 25618 25619 /* For $.queue() */ 25620 var class2type = {}, 25621 hasOwn = class2type.hasOwnProperty, 25622 toString = class2type.toString; 25623 25624 var types = "Boolean Number String Function Array Date RegExp Object Error".split(" "); 25625 for (var i = 0; i < types.length; i++) { 25626 class2type["[object " + types[i] + "]"] = types[i].toLowerCase(); 25627 } 25628 25629 /* Makes $(node) possible, without having to call init. */ 25630 $.fn.init.prototype = $.fn; 25631 25632 /* Globalize Velocity onto the window, and assign its Utilities property. */ 25633 window.Velocity = {Utilities: $}; 25634})(window); 25635 25636/****************** 25637 Velocity.js 25638 ******************/ 25639 25640(function(factory) { 25641 "use strict"; 25642 /* CommonJS module. */ 25643 if (typeof module === "object" && typeof module.exports === "object") { 25644 module.exports = factory(); 25645 /* AMD module. */ 25646 } else if (typeof define === "function" && define.amd) { 25647 define(factory); 25648 /* Browser globals. */ 25649 } else { 25650 factory(); 25651 } 25652}(function() { 25653 "use strict"; 25654 return function(global, window, document, undefined) { 25655 25656 /*************** 25657 Summary 25658 ***************/ 25659 25660 /* 25661 - CSS: CSS stack that works independently from the rest of Velocity. 25662 - animate(): Core animation method that iterates over the targeted elements and queues the incoming call onto each element individually. 25663 - Pre-Queueing: Prepare the element for animation by instantiating its data cache and processing the call's options. 25664 - Queueing: The logic that runs once the call has reached its point of execution in the element's $.queue() stack. 25665 Most logic is placed here to avoid risking it becoming stale (if the element's properties have changed). 25666 - Pushing: Consolidation of the tween data followed by its push onto the global in-progress calls container. 25667 - tick(): The single requestAnimationFrame loop responsible for tweening all in-progress calls. 25668 - completeCall(): Handles the cleanup process for each Velocity call. 25669 */ 25670 25671 /********************* 25672 Helper Functions 25673 *********************/ 25674 25675 /* IE detection. Gist: https://gist.github.com/julianshapiro/9098609 */ 25676 var IE = (function() { 25677 if (document.documentMode) { 25678 return document.documentMode; 25679 } else { 25680 for (var i = 7; i > 4; i--) { 25681 var div = document.createElement("div"); 25682 25683 div.innerHTML = "<!--[if IE " + i + "]><span></span><![endif]-->"; 25684 25685 if (div.getElementsByTagName("span").length) { 25686 div = null; 25687 25688 return i; 25689 } 25690 } 25691 } 25692 25693 return undefined; 25694 })(); 25695 25696 /* rAF shim. Gist: https://gist.github.com/julianshapiro/9497513 */ 25697 var rAFShim = (function() { 25698 var timeLast = 0; 25699 25700 return window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { 25701 var timeCurrent = (new Date()).getTime(), 25702 timeDelta; 25703 25704 /* Dynamically set delay on a per-tick basis to match 60fps. */ 25705 /* Technique by Erik Moller. MIT license: https://gist.github.com/paulirish/1579671 */ 25706 timeDelta = Math.max(0, 16 - (timeCurrent - timeLast)); 25707 timeLast = timeCurrent + timeDelta; 25708 25709 return setTimeout(function() { 25710 callback(timeCurrent + timeDelta); 25711 }, timeDelta); 25712 }; 25713 })(); 25714 25715 var performance = (function() { 25716 var perf = window.performance || {}; 25717 25718 if (!perf.hasOwnProperty("now")) { 25719 var nowOffset = perf.timing && perf.timing.domComplete ? perf.timing.domComplete : (new Date()).getTime(); 25720 25721 perf.now = function() { 25722 return (new Date()).getTime() - nowOffset; 25723 }; 25724 } 25725 return perf; 25726 })(); 25727 25728 /* Array compacting. Copyright Lo-Dash. MIT License: https://github.com/lodash/lodash/blob/master/LICENSE.txt */ 25729 function compactSparseArray(array) { 25730 var index = -1, 25731 length = array ? array.length : 0, 25732 result = []; 25733 25734 while (++index < length) { 25735 var value = array[index]; 25736 25737 if (value) { 25738 result.push(value); 25739 } 25740 } 25741 25742 return result; 25743 } 25744 25745 function sanitizeElements(elements) { 25746 /* Unwrap jQuery/Zepto objects. */ 25747 if (Type.isWrapped(elements)) { 25748 elements = [].slice.call(elements); 25749 /* Wrap a single element in an array so that $.each() can iterate with the element instead of its node's children. */ 25750 } else if (Type.isNode(elements)) { 25751 elements = [elements]; 25752 } 25753 25754 return elements; 25755 } 25756 25757 var Type = { 25758 isNumber: function(variable) { 25759 return (typeof variable === "number"); 25760 }, 25761 isString: function(variable) { 25762 return (typeof variable === "string"); 25763 }, 25764 isArray: Array.isArray || function(variable) { 25765 return Object.prototype.toString.call(variable) === "[object Array]"; 25766 }, 25767 isFunction: function(variable) { 25768 return Object.prototype.toString.call(variable) === "[object Function]"; 25769 }, 25770 isNode: function(variable) { 25771 return variable && variable.nodeType; 25772 }, 25773 /* Copyright Martin Bohm. MIT License: https://gist.github.com/Tomalak/818a78a226a0738eaade */ 25774 isNodeList: function(variable) { 25775 return typeof variable === "object" && 25776 /^\[object (HTMLCollection|NodeList|Object)\]$/.test(Object.prototype.toString.call(variable)) && 25777 variable.length !== undefined && 25778 (variable.length === 0 || (typeof variable[0] === "object" && variable[0].nodeType > 0)); 25779 }, 25780 /* Determine if variable is an array-like wrapped jQuery, Zepto or similar element. */ 25781 isWrapped: function(variable) { 25782 return variable && (Type.isArray(variable) || (Type.isNumber(variable.length) && !Type.isString(variable) && !Type.isFunction(variable))); 25783 }, 25784 isSVG: function(variable) { 25785 return window.SVGElement && (variable instanceof window.SVGElement); 25786 }, 25787 isEmptyObject: function(variable) { 25788 for (var name in variable) { 25789 if (variable.hasOwnProperty(name)) { 25790 return false; 25791 } 25792 } 25793 25794 return true; 25795 } 25796 }; 25797 25798 /***************** 25799 Dependencies 25800 *****************/ 25801 25802 var $, 25803 isJQuery = false; 25804 25805 if (global.fn && global.fn.jquery) { 25806 $ = global; 25807 isJQuery = true; 25808 } else { 25809 $ = window.Velocity.Utilities; 25810 } 25811 25812 if (IE <= 8 && !isJQuery) { 25813 throw new Error("Velocity: IE8 and below require jQuery to be loaded before Velocity."); 25814 } else if (IE <= 7) { 25815 /* Revert to jQuery's $.animate(), and lose Velocity's extra features. */ 25816 jQuery.fn.velocity = jQuery.fn.animate; 25817 25818 /* Now that $.fn.velocity is aliased, abort this Velocity declaration. */ 25819 return; 25820 } 25821 25822 /***************** 25823 Constants 25824 *****************/ 25825 25826 var DURATION_DEFAULT = 400, 25827 EASING_DEFAULT = "swing"; 25828 25829 /************* 25830 State 25831 *************/ 25832 25833 var Velocity = { 25834 /* Container for page-wide Velocity state data. */ 25835 State: { 25836 /* Detect mobile devices to determine if mobileHA should be turned on. */ 25837 isMobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), 25838 /* The mobileHA option's behavior changes on older Android devices (Gingerbread, versions 2.3.3-2.3.7). */ 25839 isAndroid: /Android/i.test(navigator.userAgent), 25840 isGingerbread: /Android 2\.3\.[3-7]/i.test(navigator.userAgent), 25841 isChrome: window.chrome, 25842 isFirefox: /Firefox/i.test(navigator.userAgent), 25843 /* Create a cached element for re-use when checking for CSS property prefixes. */ 25844 prefixElement: document.createElement("div"), 25845 /* Cache every prefix match to avoid repeating lookups. */ 25846 prefixMatches: {}, 25847 /* Cache the anchor used for animating window scrolling. */ 25848 scrollAnchor: null, 25849 /* Cache the browser-specific property names associated with the scroll anchor. */ 25850 scrollPropertyLeft: null, 25851 scrollPropertyTop: null, 25852 /* Keep track of whether our RAF tick is running. */ 25853 isTicking: false, 25854 /* Container for every in-progress call to Velocity. */ 25855 calls: [], 25856 delayedElements: { 25857 count: 0 25858 } 25859 }, 25860 /* Velocity's custom CSS stack. Made global for unit testing. */ 25861 CSS: {/* Defined below. */}, 25862 /* A shim of the jQuery utility functions used by Velocity -- provided by Velocity's optional jQuery shim. */ 25863 Utilities: $, 25864 /* Container for the user's custom animation redirects that are referenced by name in place of the properties map argument. */ 25865 Redirects: {/* Manually registered by the user. */}, 25866 Easings: {/* Defined below. */}, 25867 /* Attempt to use ES6 Promises by default. Users can override this with a third-party promises library. */ 25868 Promise: window.Promise, 25869 /* Velocity option defaults, which can be overriden by the user. */ 25870 defaults: { 25871 queue: "", 25872 duration: DURATION_DEFAULT, 25873 easing: EASING_DEFAULT, 25874 begin: undefined, 25875 complete: undefined, 25876 progress: undefined, 25877 display: undefined, 25878 visibility: undefined, 25879 loop: false, 25880 delay: false, 25881 mobileHA: true, 25882 /* Advanced: Set to false to prevent property values from being cached between consecutive Velocity-initiated chain calls. */ 25883 _cacheValues: true, 25884 /* Advanced: Set to false if the promise should always resolve on empty element lists. */ 25885 promiseRejectEmpty: true 25886 }, 25887 /* A design goal of Velocity is to cache data wherever possible in order to avoid DOM requerying. Accordingly, each element has a data cache. */ 25888 init: function(element) { 25889 $.data(element, "velocity", { 25890 /* Store whether this is an SVG element, since its properties are retrieved and updated differently than standard HTML elements. */ 25891 isSVG: Type.isSVG(element), 25892 /* Keep track of whether the element is currently being animated by Velocity. 25893 This is used to ensure that property values are not transferred between non-consecutive (stale) calls. */ 25894 isAnimating: false, 25895 /* A reference to the element's live computedStyle object. Learn more here: https://developer.mozilla.org/en/docs/Web/API/window.getComputedStyle */ 25896 computedStyle: null, 25897 /* Tween data is cached for each animation on the element so that data can be passed across calls -- 25898 in particular, end values are used as subsequent start values in consecutive Velocity calls. */ 25899 tweensContainer: null, 25900 /* The full root property values of each CSS hook being animated on this element are cached so that: 25901 1) Concurrently-animating hooks sharing the same root can have their root values' merged into one while tweening. 25902 2) Post-hook-injection root values can be transferred over to consecutively chained Velocity calls as starting root values. */ 25903 rootPropertyValueCache: {}, 25904 /* A cache for transform updates, which must be manually flushed via CSS.flushTransformCache(). */ 25905 transformCache: {} 25906 }); 25907 }, 25908 /* A parallel to jQuery's $.css(), used for getting/setting Velocity's hooked CSS properties. */ 25909 hook: null, /* Defined below. */ 25910 /* Velocity-wide animation time remapping for testing purposes. */ 25911 mock: false, 25912 version: {major: 1, minor: 4, patch: 0}, 25913 /* Set to 1 or 2 (most verbose) to output debug info to console. */ 25914 debug: false, 25915 /* Use rAF high resolution timestamp when available */ 25916 timestamp: true, 25917 /* Pause all animations */ 25918 pauseAll: function(queueName) { 25919 var currentTime = (new Date()).getTime(); 25920 25921 $.each(Velocity.State.calls, function(i, activeCall) { 25922 25923 if (activeCall) { 25924 25925 /* If we have a queueName and this call is not on that queue, skip */ 25926 if (queueName !== undefined && ((activeCall[2].queue !== queueName) || (activeCall[2].queue === false))) { 25927 return true; 25928 } 25929 25930 /* Set call to paused */ 25931 activeCall[5] = { 25932 resume: false 25933 }; 25934 } 25935 }); 25936 25937 /* Pause timers on any currently delayed calls */ 25938 $.each(Velocity.State.delayedElements, function(k, element) { 25939 if (!element) { 25940 return; 25941 } 25942 pauseDelayOnElement(element, currentTime); 25943 }); 25944 }, 25945 /* Resume all animations */ 25946 resumeAll: function(queueName) { 25947 var currentTime = (new Date()).getTime(); 25948 25949 $.each(Velocity.State.calls, function(i, activeCall) { 25950 25951 if (activeCall) { 25952 25953 /* If we have a queueName and this call is not on that queue, skip */ 25954 if (queueName !== undefined && ((activeCall[2].queue !== queueName) || (activeCall[2].queue === false))) { 25955 return true; 25956 } 25957 25958 /* Set call to resumed if it was paused */ 25959 if (activeCall[5]) { 25960 activeCall[5].resume = true; 25961 } 25962 } 25963 }); 25964 /* Resume timers on any currently delayed calls */ 25965 $.each(Velocity.State.delayedElements, function(k, element) { 25966 if (!element) { 25967 return; 25968 } 25969 resumeDelayOnElement(element, currentTime); 25970 }); 25971 } 25972 }; 25973 25974 /* Retrieve the appropriate scroll anchor and property name for the browser: https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollY */ 25975 if (window.pageYOffset !== undefined) { 25976 Velocity.State.scrollAnchor = window; 25977 Velocity.State.scrollPropertyLeft = "pageXOffset"; 25978 Velocity.State.scrollPropertyTop = "pageYOffset"; 25979 } else { 25980 Velocity.State.scrollAnchor = document.documentElement || document.body.parentNode || document.body; 25981 Velocity.State.scrollPropertyLeft = "scrollLeft"; 25982 Velocity.State.scrollPropertyTop = "scrollTop"; 25983 } 25984 25985 /* Shorthand alias for jQuery's $.data() utility. */ 25986 function Data(element) { 25987 /* Hardcode a reference to the plugin name. */ 25988 var response = $.data(element, "velocity"); 25989 25990 /* jQuery <=1.4.2 returns null instead of undefined when no match is found. We normalize this behavior. */ 25991 return response === null ? undefined : response; 25992 } 25993 25994 /************** 25995 Delay Timer 25996 **************/ 25997 25998 function pauseDelayOnElement(element, currentTime) { 25999 /* Check for any delay timers, and pause the set timeouts (while preserving time data) 26000 to be resumed when the "resume" command is issued */ 26001 var data = Data(element); 26002 if (data && data.delayTimer && !data.delayPaused) { 26003 data.delayRemaining = data.delay - currentTime + data.delayBegin; 26004 data.delayPaused = true; 26005 clearTimeout(data.delayTimer.setTimeout); 26006 } 26007 } 26008 26009 function resumeDelayOnElement(element, currentTime) { 26010 /* Check for any paused timers and resume */ 26011 var data = Data(element); 26012 if (data && data.delayTimer && data.delayPaused) { 26013 /* If the element was mid-delay, re initiate the timeout with the remaining delay */ 26014 data.delayPaused = false; 26015 data.delayTimer.setTimeout = setTimeout(data.delayTimer.next, data.delayRemaining); 26016 } 26017 } 26018 26019 26020 26021 /************** 26022 Easing 26023 **************/ 26024 26025 /* Step easing generator. */ 26026 function generateStep(steps) { 26027 return function(p) { 26028 return Math.round(p * steps) * (1 / steps); 26029 }; 26030 } 26031 26032 /* Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */ 26033 function generateBezier(mX1, mY1, mX2, mY2) { 26034 var NEWTON_ITERATIONS = 4, 26035 NEWTON_MIN_SLOPE = 0.001, 26036 SUBDIVISION_PRECISION = 0.0000001, 26037 SUBDIVISION_MAX_ITERATIONS = 10, 26038 kSplineTableSize = 11, 26039 kSampleStepSize = 1.0 / (kSplineTableSize - 1.0), 26040 float32ArraySupported = "Float32Array" in window; 26041 26042 /* Must contain four arguments. */ 26043 if (arguments.length !== 4) { 26044 return false; 26045 } 26046 26047 /* Arguments must be numbers. */ 26048 for (var i = 0; i < 4; ++i) { 26049 if (typeof arguments[i] !== "number" || isNaN(arguments[i]) || !isFinite(arguments[i])) { 26050 return false; 26051 } 26052 } 26053 26054 /* X values must be in the [0, 1] range. */ 26055 mX1 = Math.min(mX1, 1); 26056 mX2 = Math.min(mX2, 1); 26057 mX1 = Math.max(mX1, 0); 26058 mX2 = Math.max(mX2, 0); 26059 26060 var mSampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize); 26061 26062 function A(aA1, aA2) { 26063 return 1.0 - 3.0 * aA2 + 3.0 * aA1; 26064 } 26065 function B(aA1, aA2) { 26066 return 3.0 * aA2 - 6.0 * aA1; 26067 } 26068 function C(aA1) { 26069 return 3.0 * aA1; 26070 } 26071 26072 function calcBezier(aT, aA1, aA2) { 26073 return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT; 26074 } 26075 26076 function getSlope(aT, aA1, aA2) { 26077 return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1); 26078 } 26079 26080 function newtonRaphsonIterate(aX, aGuessT) { 26081 for (var i = 0; i < NEWTON_ITERATIONS; ++i) { 26082 var currentSlope = getSlope(aGuessT, mX1, mX2); 26083 26084 if (currentSlope === 0.0) { 26085 return aGuessT; 26086 } 26087 26088 var currentX = calcBezier(aGuessT, mX1, mX2) - aX; 26089 aGuessT -= currentX / currentSlope; 26090 } 26091 26092 return aGuessT; 26093 } 26094 26095 function calcSampleValues() { 26096 for (var i = 0; i < kSplineTableSize; ++i) { 26097 mSampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2); 26098 } 26099 } 26100 26101 function binarySubdivide(aX, aA, aB) { 26102 var currentX, currentT, i = 0; 26103 26104 do { 26105 currentT = aA + (aB - aA) / 2.0; 26106 currentX = calcBezier(currentT, mX1, mX2) - aX; 26107 if (currentX > 0.0) { 26108 aB = currentT; 26109 } else { 26110 aA = currentT; 26111 } 26112 } while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS); 26113 26114 return currentT; 26115 } 26116 26117 function getTForX(aX) { 26118 var intervalStart = 0.0, 26119 currentSample = 1, 26120 lastSample = kSplineTableSize - 1; 26121 26122 for (; currentSample !== lastSample && mSampleValues[currentSample] <= aX; ++currentSample) { 26123 intervalStart += kSampleStepSize; 26124 } 26125 26126 --currentSample; 26127 26128 var dist = (aX - mSampleValues[currentSample]) / (mSampleValues[currentSample + 1] - mSampleValues[currentSample]), 26129 guessForT = intervalStart + dist * kSampleStepSize, 26130 initialSlope = getSlope(guessForT, mX1, mX2); 26131 26132 if (initialSlope >= NEWTON_MIN_SLOPE) { 26133 return newtonRaphsonIterate(aX, guessForT); 26134 } else if (initialSlope === 0.0) { 26135 return guessForT; 26136 } else { 26137 return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize); 26138 } 26139 } 26140 26141 var _precomputed = false; 26142 26143 function precompute() { 26144 _precomputed = true; 26145 if (mX1 !== mY1 || mX2 !== mY2) { 26146 calcSampleValues(); 26147 } 26148 } 26149 26150 var f = function(aX) { 26151 if (!_precomputed) { 26152 precompute(); 26153 } 26154 if (mX1 === mY1 && mX2 === mY2) { 26155 return aX; 26156 } 26157 if (aX === 0) { 26158 return 0; 26159 } 26160 if (aX === 1) { 26161 return 1; 26162 } 26163 26164 return calcBezier(getTForX(aX), mY1, mY2); 26165 }; 26166 26167 f.getControlPoints = function() { 26168 return [{x: mX1, y: mY1}, {x: mX2, y: mY2}]; 26169 }; 26170 26171 var str = "generateBezier(" + [mX1, mY1, mX2, mY2] + ")"; 26172 f.toString = function() { 26173 return str; 26174 }; 26175 26176 return f; 26177 } 26178 26179 /* Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */ 26180 /* Given a tension, friction, and duration, a simulation at 60FPS will first run without a defined duration in order to calculate the full path. A second pass 26181 then adjusts the time delta -- using the relation between actual time and duration -- to calculate the path for the duration-constrained animation. */ 26182 var generateSpringRK4 = (function() { 26183 function springAccelerationForState(state) { 26184 return (-state.tension * state.x) - (state.friction * state.v); 26185 } 26186 26187 function springEvaluateStateWithDerivative(initialState, dt, derivative) { 26188 var state = { 26189 x: initialState.x + derivative.dx * dt, 26190 v: initialState.v + derivative.dv * dt, 26191 tension: initialState.tension, 26192 friction: initialState.friction 26193 }; 26194 26195 return {dx: state.v, dv: springAccelerationForState(state)}; 26196 } 26197 26198 function springIntegrateState(state, dt) { 26199 var a = { 26200 dx: state.v, 26201 dv: springAccelerationForState(state) 26202 }, 26203 b = springEvaluateStateWithDerivative(state, dt * 0.5, a), 26204 c = springEvaluateStateWithDerivative(state, dt * 0.5, b), 26205 d = springEvaluateStateWithDerivative(state, dt, c), 26206 dxdt = 1.0 / 6.0 * (a.dx + 2.0 * (b.dx + c.dx) + d.dx), 26207 dvdt = 1.0 / 6.0 * (a.dv + 2.0 * (b.dv + c.dv) + d.dv); 26208 26209 state.x = state.x + dxdt * dt; 26210 state.v = state.v + dvdt * dt; 26211 26212 return state; 26213 } 26214 26215 return function springRK4Factory(tension, friction, duration) { 26216 26217 var initState = { 26218 x: -1, 26219 v: 0, 26220 tension: null, 26221 friction: null 26222 }, 26223 path = [0], 26224 time_lapsed = 0, 26225 tolerance = 1 / 10000, 26226 DT = 16 / 1000, 26227 have_duration, dt, last_state; 26228 26229 tension = parseFloat(tension) || 500; 26230 friction = parseFloat(friction) || 20; 26231 duration = duration || null; 26232 26233 initState.tension = tension; 26234 initState.friction = friction; 26235 26236 have_duration = duration !== null; 26237 26238 /* Calculate the actual time it takes for this animation to complete with the provided conditions. */ 26239 if (have_duration) { 26240 /* Run the simulation without a duration. */ 26241 time_lapsed = springRK4Factory(tension, friction); 26242 /* Compute the adjusted time delta. */ 26243 dt = time_lapsed / duration * DT; 26244 } else { 26245 dt = DT; 26246 } 26247 26248 while (true) { 26249 /* Next/step function .*/ 26250 last_state = springIntegrateState(last_state || initState, dt); 26251 /* Store the position. */ 26252 path.push(1 + last_state.x); 26253 time_lapsed += 16; 26254 /* If the change threshold is reached, break. */ 26255 if (!(Math.abs(last_state.x) > tolerance && Math.abs(last_state.v) > tolerance)) { 26256 break; 26257 } 26258 } 26259 26260 /* If duration is not defined, return the actual time required for completing this animation. Otherwise, return a closure that holds the 26261 computed path and returns a snapshot of the position according to a given percentComplete. */ 26262 return !have_duration ? time_lapsed : function(percentComplete) { 26263 return path[ (percentComplete * (path.length - 1)) | 0 ]; 26264 }; 26265 }; 26266 }()); 26267 26268 /* jQuery easings. */ 26269 Velocity.Easings = { 26270 linear: function(p) { 26271 return p; 26272 }, 26273 swing: function(p) { 26274 return 0.5 - Math.cos(p * Math.PI) / 2; 26275 }, 26276 /* Bonus "spring" easing, which is a less exaggerated version of easeInOutElastic. */ 26277 spring: function(p) { 26278 return 1 - (Math.cos(p * 4.5 * Math.PI) * Math.exp(-p * 6)); 26279 } 26280 }; 26281 26282 /* CSS3 and Robert Penner easings. */ 26283 $.each( 26284 [ 26285 ["ease", [0.25, 0.1, 0.25, 1.0]], 26286 ["ease-in", [0.42, 0.0, 1.00, 1.0]], 26287 ["ease-out", [0.00, 0.0, 0.58, 1.0]], 26288 ["ease-in-out", [0.42, 0.0, 0.58, 1.0]], 26289 ["easeInSine", [0.47, 0, 0.745, 0.715]], 26290 ["easeOutSine", [0.39, 0.575, 0.565, 1]], 26291 ["easeInOutSine", [0.445, 0.05, 0.55, 0.95]], 26292 ["easeInQuad", [0.55, 0.085, 0.68, 0.53]], 26293 ["easeOutQuad", [0.25, 0.46, 0.45, 0.94]], 26294 ["easeInOutQuad", [0.455, 0.03, 0.515, 0.955]], 26295 ["easeInCubic", [0.55, 0.055, 0.675, 0.19]], 26296 ["easeOutCubic", [0.215, 0.61, 0.355, 1]], 26297 ["easeInOutCubic", [0.645, 0.045, 0.355, 1]], 26298 ["easeInQuart", [0.895, 0.03, 0.685, 0.22]], 26299 ["easeOutQuart", [0.165, 0.84, 0.44, 1]], 26300 ["easeInOutQuart", [0.77, 0, 0.175, 1]], 26301 ["easeInQuint", [0.755, 0.05, 0.855, 0.06]], 26302 ["easeOutQuint", [0.23, 1, 0.32, 1]], 26303 ["easeInOutQuint", [0.86, 0, 0.07, 1]], 26304 ["easeInExpo", [0.95, 0.05, 0.795, 0.035]], 26305 ["easeOutExpo", [0.19, 1, 0.22, 1]], 26306 ["easeInOutExpo", [1, 0, 0, 1]], 26307 ["easeInCirc", [0.6, 0.04, 0.98, 0.335]], 26308 ["easeOutCirc", [0.075, 0.82, 0.165, 1]], 26309 ["easeInOutCirc", [0.785, 0.135, 0.15, 0.86]] 26310 ], function(i, easingArray) { 26311 Velocity.Easings[easingArray[0]] = generateBezier.apply(null, easingArray[1]); 26312 }); 26313 26314 /* Determine the appropriate easing type given an easing input. */ 26315 function getEasing(value, duration) { 26316 var easing = value; 26317 26318 /* The easing option can either be a string that references a pre-registered easing, 26319 or it can be a two-/four-item array of integers to be converted into a bezier/spring function. */ 26320 if (Type.isString(value)) { 26321 /* Ensure that the easing has been assigned to jQuery's Velocity.Easings object. */ 26322 if (!Velocity.Easings[value]) { 26323 easing = false; 26324 } 26325 } else if (Type.isArray(value) && value.length === 1) { 26326 easing = generateStep.apply(null, value); 26327 } else if (Type.isArray(value) && value.length === 2) { 26328 /* springRK4 must be passed the animation's duration. */ 26329 /* Note: If the springRK4 array contains non-numbers, generateSpringRK4() returns an easing 26330 function generated with default tension and friction values. */ 26331 easing = generateSpringRK4.apply(null, value.concat([duration])); 26332 } else if (Type.isArray(value) && value.length === 4) { 26333 /* Note: If the bezier array contains non-numbers, generateBezier() returns false. */ 26334 easing = generateBezier.apply(null, value); 26335 } else { 26336 easing = false; 26337 } 26338 26339 /* Revert to the Velocity-wide default easing type, or fall back to "swing" (which is also jQuery's default) 26340 if the Velocity-wide default has been incorrectly modified. */ 26341 if (easing === false) { 26342 if (Velocity.Easings[Velocity.defaults.easing]) { 26343 easing = Velocity.defaults.easing; 26344 } else { 26345 easing = EASING_DEFAULT; 26346 } 26347 } 26348 26349 return easing; 26350 } 26351 26352 /***************** 26353 CSS Stack 26354 *****************/ 26355 26356 /* The CSS object is a highly condensed and performant CSS stack that fully replaces jQuery's. 26357 It handles the validation, getting, and setting of both standard CSS properties and CSS property hooks. */ 26358 /* Note: A "CSS" shorthand is aliased so that our code is easier to read. */ 26359 var CSS = Velocity.CSS = { 26360 /************* 26361 RegEx 26362 *************/ 26363 26364 RegEx: { 26365 isHex: /^#([A-f\d]{3}){1,2}$/i, 26366 /* Unwrap a property value's surrounding text, e.g. "rgba(4, 3, 2, 1)" ==> "4, 3, 2, 1" and "rect(4px 3px 2px 1px)" ==> "4px 3px 2px 1px". */ 26367 valueUnwrap: /^[A-z]+\((.*)\)$/i, 26368 wrappedValueAlreadyExtracted: /[0-9.]+ [0-9.]+ [0-9.]+( [0-9.]+)?/, 26369 /* Split a multi-value property into an array of subvalues, e.g. "rgba(4, 3, 2, 1) 4px 3px 2px 1px" ==> [ "rgba(4, 3, 2, 1)", "4px", "3px", "2px", "1px" ]. */ 26370 valueSplit: /([A-z]+\(.+\))|(([A-z0-9#-.]+?)(?=\s|$))/ig 26371 }, 26372 /************ 26373 Lists 26374 ************/ 26375 26376 Lists: { 26377 colors: ["fill", "stroke", "stopColor", "color", "backgroundColor", "borderColor", "borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor", "outlineColor"], 26378 transformsBase: ["translateX", "translateY", "scale", "scaleX", "scaleY", "skewX", "skewY", "rotateZ"], 26379 transforms3D: ["transformPerspective", "translateZ", "scaleZ", "rotateX", "rotateY"], 26380 units: [ 26381 "%", // relative 26382 "em", "ex", "ch", "rem", // font relative 26383 "vw", "vh", "vmin", "vmax", // viewport relative 26384 "cm", "mm", "Q", "in", "pc", "pt", "px", // absolute lengths 26385 "deg", "grad", "rad", "turn", // angles 26386 "s", "ms" // time 26387 ], 26388 colorNames: { 26389 "aliceblue": "240,248,255", 26390 "antiquewhite": "250,235,215", 26391 "aquamarine": "127,255,212", 26392 "aqua": "0,255,255", 26393 "azure": "240,255,255", 26394 "beige": "245,245,220", 26395 "bisque": "255,228,196", 26396 "black": "0,0,0", 26397 "blanchedalmond": "255,235,205", 26398 "blueviolet": "138,43,226", 26399 "blue": "0,0,255", 26400 "brown": "165,42,42", 26401 "burlywood": "222,184,135", 26402 "cadetblue": "95,158,160", 26403 "chartreuse": "127,255,0", 26404 "chocolate": "210,105,30", 26405 "coral": "255,127,80", 26406 "cornflowerblue": "100,149,237", 26407 "cornsilk": "255,248,220", 26408 "crimson": "220,20,60", 26409 "cyan": "0,255,255", 26410 "darkblue": "0,0,139", 26411 "darkcyan": "0,139,139", 26412 "darkgoldenrod": "184,134,11", 26413 "darkgray": "169,169,169", 26414 "darkgrey": "169,169,169", 26415 "darkgreen": "0,100,0", 26416 "darkkhaki": "189,183,107", 26417 "darkmagenta": "139,0,139", 26418 "darkolivegreen": "85,107,47", 26419 "darkorange": "255,140,0", 26420 "darkorchid": "153,50,204", 26421 "darkred": "139,0,0", 26422 "darksalmon": "233,150,122", 26423 "darkseagreen": "143,188,143", 26424 "darkslateblue": "72,61,139", 26425 "darkslategray": "47,79,79", 26426 "darkturquoise": "0,206,209", 26427 "darkviolet": "148,0,211", 26428 "deeppink": "255,20,147", 26429 "deepskyblue": "0,191,255", 26430 "dimgray": "105,105,105", 26431 "dimgrey": "105,105,105", 26432 "dodgerblue": "30,144,255", 26433 "firebrick": "178,34,34", 26434 "floralwhite": "255,250,240", 26435 "forestgreen": "34,139,34", 26436 "fuchsia": "255,0,255", 26437 "gainsboro": "220,220,220", 26438 "ghostwhite": "248,248,255", 26439 "gold": "255,215,0", 26440 "goldenrod": "218,165,32", 26441 "gray": "128,128,128", 26442 "grey": "128,128,128", 26443 "greenyellow": "173,255,47", 26444 "green": "0,128,0", 26445 "honeydew": "240,255,240", 26446 "hotpink": "255,105,180", 26447 "indianred": "205,92,92", 26448 "indigo": "75,0,130", 26449 "ivory": "255,255,240", 26450 "khaki": "240,230,140", 26451 "lavenderblush": "255,240,245", 26452 "lavender": "230,230,250", 26453 "lawngreen": "124,252,0", 26454 "lemonchiffon": "255,250,205", 26455 "lightblue": "173,216,230", 26456 "lightcoral": "240,128,128", 26457 "lightcyan": "224,255,255", 26458 "lightgoldenrodyellow": "250,250,210", 26459 "lightgray": "211,211,211", 26460 "lightgrey": "211,211,211", 26461 "lightgreen": "144,238,144", 26462 "lightpink": "255,182,193", 26463 "lightsalmon": "255,160,122", 26464 "lightseagreen": "32,178,170", 26465 "lightskyblue": "135,206,250", 26466 "lightslategray": "119,136,153", 26467 "lightsteelblue": "176,196,222", 26468 "lightyellow": "255,255,224", 26469 "limegreen": "50,205,50", 26470 "lime": "0,255,0", 26471 "linen": "250,240,230", 26472 "magenta": "255,0,255", 26473 "maroon": "128,0,0", 26474 "mediumaquamarine": "102,205,170", 26475 "mediumblue": "0,0,205", 26476 "mediumorchid": "186,85,211", 26477 "mediumpurple": "147,112,219", 26478 "mediumseagreen": "60,179,113", 26479 "mediumslateblue": "123,104,238", 26480 "mediumspringgreen": "0,250,154", 26481 "mediumturquoise": "72,209,204", 26482 "mediumvioletred": "199,21,133", 26483 "midnightblue": "25,25,112", 26484 "mintcream": "245,255,250", 26485 "mistyrose": "255,228,225", 26486 "moccasin": "255,228,181", 26487 "navajowhite": "255,222,173", 26488 "navy": "0,0,128", 26489 "oldlace": "253,245,230", 26490 "olivedrab": "107,142,35", 26491 "olive": "128,128,0", 26492 "orangered": "255,69,0", 26493 "orange": "255,165,0", 26494 "orchid": "218,112,214", 26495 "palegoldenrod": "238,232,170", 26496 "palegreen": "152,251,152", 26497 "paleturquoise": "175,238,238", 26498 "palevioletred": "219,112,147", 26499 "papayawhip": "255,239,213", 26500 "peachpuff": "255,218,185", 26501 "peru": "205,133,63", 26502 "pink": "255,192,203", 26503 "plum": "221,160,221", 26504 "powderblue": "176,224,230", 26505 "purple": "128,0,128", 26506 "red": "255,0,0", 26507 "rosybrown": "188,143,143", 26508 "royalblue": "65,105,225", 26509 "saddlebrown": "139,69,19", 26510 "salmon": "250,128,114", 26511 "sandybrown": "244,164,96", 26512 "seagreen": "46,139,87", 26513 "seashell": "255,245,238", 26514 "sienna": "160,82,45", 26515 "silver": "192,192,192", 26516 "skyblue": "135,206,235", 26517 "slateblue": "106,90,205", 26518 "slategray": "112,128,144", 26519 "snow": "255,250,250", 26520 "springgreen": "0,255,127", 26521 "steelblue": "70,130,180", 26522 "tan": "210,180,140", 26523 "teal": "0,128,128", 26524 "thistle": "216,191,216", 26525 "tomato": "255,99,71", 26526 "turquoise": "64,224,208", 26527 "violet": "238,130,238", 26528 "wheat": "245,222,179", 26529 "whitesmoke": "245,245,245", 26530 "white": "255,255,255", 26531 "yellowgreen": "154,205,50", 26532 "yellow": "255,255,0" 26533 } 26534 }, 26535 /************ 26536 Hooks 26537 ************/ 26538 26539 /* Hooks allow a subproperty (e.g. "boxShadowBlur") of a compound-value CSS property 26540 (e.g. "boxShadow: X Y Blur Spread Color") to be animated as if it were a discrete property. */ 26541 /* Note: Beyond enabling fine-grained property animation, hooking is necessary since Velocity only 26542 tweens properties with single numeric values; unlike CSS transitions, Velocity does not interpolate compound-values. */ 26543 Hooks: { 26544 /******************** 26545 Registration 26546 ********************/ 26547 26548 /* Templates are a concise way of indicating which subproperties must be individually registered for each compound-value CSS property. */ 26549 /* Each template consists of the compound-value's base name, its constituent subproperty names, and those subproperties' default values. */ 26550 templates: { 26551 "textShadow": ["Color X Y Blur", "black 0px 0px 0px"], 26552 "boxShadow": ["Color X Y Blur Spread", "black 0px 0px 0px 0px"], 26553 "clip": ["Top Right Bottom Left", "0px 0px 0px 0px"], 26554 "backgroundPosition": ["X Y", "0% 0%"], 26555 "transformOrigin": ["X Y Z", "50% 50% 0px"], 26556 "perspectiveOrigin": ["X Y", "50% 50%"] 26557 }, 26558 /* A "registered" hook is one that has been converted from its template form into a live, 26559 tweenable property. It contains data to associate it with its root property. */ 26560 registered: { 26561 /* Note: A registered hook looks like this ==> textShadowBlur: [ "textShadow", 3 ], 26562 which consists of the subproperty's name, the associated root property's name, 26563 and the subproperty's position in the root's value. */ 26564 }, 26565 /* Convert the templates into individual hooks then append them to the registered object above. */ 26566 register: function() { 26567 /* Color hooks registration: Colors are defaulted to white -- as opposed to black -- since colors that are 26568 currently set to "transparent" default to their respective template below when color-animated, 26569 and white is typically a closer match to transparent than black is. An exception is made for text ("color"), 26570 which is almost always set closer to black than white. */ 26571 for (var i = 0; i < CSS.Lists.colors.length; i++) { 26572 var rgbComponents = (CSS.Lists.colors[i] === "color") ? "0 0 0 1" : "255 255 255 1"; 26573 CSS.Hooks.templates[CSS.Lists.colors[i]] = ["Red Green Blue Alpha", rgbComponents]; 26574 } 26575 26576 var rootProperty, 26577 hookTemplate, 26578 hookNames; 26579 26580 /* In IE, color values inside compound-value properties are positioned at the end the value instead of at the beginning. 26581 Thus, we re-arrange the templates accordingly. */ 26582 if (IE) { 26583 for (rootProperty in CSS.Hooks.templates) { 26584 if (!CSS.Hooks.templates.hasOwnProperty(rootProperty)) { 26585 continue; 26586 } 26587 hookTemplate = CSS.Hooks.templates[rootProperty]; 26588 hookNames = hookTemplate[0].split(" "); 26589 26590 var defaultValues = hookTemplate[1].match(CSS.RegEx.valueSplit); 26591 26592 if (hookNames[0] === "Color") { 26593 /* Reposition both the hook's name and its default value to the end of their respective strings. */ 26594 hookNames.push(hookNames.shift()); 26595 defaultValues.push(defaultValues.shift()); 26596 26597 /* Replace the existing template for the hook's root property. */ 26598 CSS.Hooks.templates[rootProperty] = [hookNames.join(" "), defaultValues.join(" ")]; 26599 } 26600 } 26601 } 26602 26603 /* Hook registration. */ 26604 for (rootProperty in CSS.Hooks.templates) { 26605 if (!CSS.Hooks.templates.hasOwnProperty(rootProperty)) { 26606 continue; 26607 } 26608 hookTemplate = CSS.Hooks.templates[rootProperty]; 26609 hookNames = hookTemplate[0].split(" "); 26610 26611 for (var j in hookNames) { 26612 if (!hookNames.hasOwnProperty(j)) { 26613 continue; 26614 } 26615 var fullHookName = rootProperty + hookNames[j], 26616 hookPosition = j; 26617 26618 /* For each hook, register its full name (e.g. textShadowBlur) with its root property (e.g. textShadow) 26619 and the hook's position in its template's default value string. */ 26620 CSS.Hooks.registered[fullHookName] = [rootProperty, hookPosition]; 26621 } 26622 } 26623 }, 26624 /***************************** 26625 Injection and Extraction 26626 *****************************/ 26627 26628 /* Look up the root property associated with the hook (e.g. return "textShadow" for "textShadowBlur"). */ 26629 /* Since a hook cannot be set directly (the browser won't recognize it), style updating for hooks is routed through the hook's root property. */ 26630 getRoot: function(property) { 26631 var hookData = CSS.Hooks.registered[property]; 26632 26633 if (hookData) { 26634 return hookData[0]; 26635 } else { 26636 /* If there was no hook match, return the property name untouched. */ 26637 return property; 26638 } 26639 }, 26640 getUnit: function(str, start) { 26641 var unit = (str.substr(start || 0, 5).match(/^[a-z%]+/) || [])[0] || ""; 26642 26643 if (unit && CSS.Lists.units.indexOf(unit) >= 0) { 26644 return unit; 26645 } 26646 return ""; 26647 }, 26648 fixColors: function(str) { 26649 return str.replace(/(rgba?\(\s*)?(\b[a-z]+\b)/g, function($0, $1, $2) { 26650 if (CSS.Lists.colorNames.hasOwnProperty($2)) { 26651 return ($1 ? $1 : "rgba(") + CSS.Lists.colorNames[$2] + ($1 ? "" : ",1)"); 26652 } 26653 return $1 + $2; 26654 }); 26655 }, 26656 /* Convert any rootPropertyValue, null or otherwise, into a space-delimited list of hook values so that 26657 the targeted hook can be injected or extracted at its standard position. */ 26658 cleanRootPropertyValue: function(rootProperty, rootPropertyValue) { 26659 /* If the rootPropertyValue is wrapped with "rgb()", "clip()", etc., remove the wrapping to normalize the value before manipulation. */ 26660 if (CSS.RegEx.valueUnwrap.test(rootPropertyValue)) { 26661 rootPropertyValue = rootPropertyValue.match(CSS.RegEx.valueUnwrap)[1]; 26662 } 26663 26664 /* If rootPropertyValue is a CSS null-value (from which there's inherently no hook value to extract), 26665 default to the root's default value as defined in CSS.Hooks.templates. */ 26666 /* Note: CSS null-values include "none", "auto", and "transparent". They must be converted into their 26667 zero-values (e.g. textShadow: "none" ==> textShadow: "0px 0px 0px black") for hook manipulation to proceed. */ 26668 if (CSS.Values.isCSSNullValue(rootPropertyValue)) { 26669 rootPropertyValue = CSS.Hooks.templates[rootProperty][1]; 26670 } 26671 26672 return rootPropertyValue; 26673 }, 26674 /* Extracted the hook's value from its root property's value. This is used to get the starting value of an animating hook. */ 26675 extractValue: function(fullHookName, rootPropertyValue) { 26676 var hookData = CSS.Hooks.registered[fullHookName]; 26677 26678 if (hookData) { 26679 var hookRoot = hookData[0], 26680 hookPosition = hookData[1]; 26681 26682 rootPropertyValue = CSS.Hooks.cleanRootPropertyValue(hookRoot, rootPropertyValue); 26683 26684 /* Split rootPropertyValue into its constituent hook values then grab the desired hook at its standard position. */ 26685 return rootPropertyValue.toString().match(CSS.RegEx.valueSplit)[hookPosition]; 26686 } else { 26687 /* If the provided fullHookName isn't a registered hook, return the rootPropertyValue that was passed in. */ 26688 return rootPropertyValue; 26689 } 26690 }, 26691 /* Inject the hook's value into its root property's value. This is used to piece back together the root property 26692 once Velocity has updated one of its individually hooked values through tweening. */ 26693 injectValue: function(fullHookName, hookValue, rootPropertyValue) { 26694 var hookData = CSS.Hooks.registered[fullHookName]; 26695 26696 if (hookData) { 26697 var hookRoot = hookData[0], 26698 hookPosition = hookData[1], 26699 rootPropertyValueParts, 26700 rootPropertyValueUpdated; 26701 26702 rootPropertyValue = CSS.Hooks.cleanRootPropertyValue(hookRoot, rootPropertyValue); 26703 26704 /* Split rootPropertyValue into its individual hook values, replace the targeted value with hookValue, 26705 then reconstruct the rootPropertyValue string. */ 26706 rootPropertyValueParts = rootPropertyValue.toString().match(CSS.RegEx.valueSplit); 26707 rootPropertyValueParts[hookPosition] = hookValue; 26708 rootPropertyValueUpdated = rootPropertyValueParts.join(" "); 26709 26710 return rootPropertyValueUpdated; 26711 } else { 26712 /* If the provided fullHookName isn't a registered hook, return the rootPropertyValue that was passed in. */ 26713 return rootPropertyValue; 26714 } 26715 } 26716 }, 26717 /******************* 26718 Normalizations 26719 *******************/ 26720 26721 /* Normalizations standardize CSS property manipulation by pollyfilling browser-specific implementations (e.g. opacity) 26722 and reformatting special properties (e.g. clip, rgba) to look like standard ones. */ 26723 Normalizations: { 26724 /* Normalizations are passed a normalization target (either the property's name, its extracted value, or its injected value), 26725 the targeted element (which may need to be queried), and the targeted property value. */ 26726 registered: { 26727 clip: function(type, element, propertyValue) { 26728 switch (type) { 26729 case "name": 26730 return "clip"; 26731 /* Clip needs to be unwrapped and stripped of its commas during extraction. */ 26732 case "extract": 26733 var extracted; 26734 26735 /* If Velocity also extracted this value, skip extraction. */ 26736 if (CSS.RegEx.wrappedValueAlreadyExtracted.test(propertyValue)) { 26737 extracted = propertyValue; 26738 } else { 26739 /* Remove the "rect()" wrapper. */ 26740 extracted = propertyValue.toString().match(CSS.RegEx.valueUnwrap); 26741 26742 /* Strip off commas. */ 26743 extracted = extracted ? extracted[1].replace(/,(\s+)?/g, " ") : propertyValue; 26744 } 26745 26746 return extracted; 26747 /* Clip needs to be re-wrapped during injection. */ 26748 case "inject": 26749 return "rect(" + propertyValue + ")"; 26750 } 26751 }, 26752 blur: function(type, element, propertyValue) { 26753 switch (type) { 26754 case "name": 26755 return Velocity.State.isFirefox ? "filter" : "-webkit-filter"; 26756 case "extract": 26757 var extracted = parseFloat(propertyValue); 26758 26759 /* If extracted is NaN, meaning the value isn't already extracted. */ 26760 if (!(extracted || extracted === 0)) { 26761 var blurComponent = propertyValue.toString().match(/blur\(([0-9]+[A-z]+)\)/i); 26762 26763 /* If the filter string had a blur component, return just the blur value and unit type. */ 26764 if (blurComponent) { 26765 extracted = blurComponent[1]; 26766 /* If the component doesn't exist, default blur to 0. */ 26767 } else { 26768 extracted = 0; 26769 } 26770 } 26771 26772 return extracted; 26773 /* Blur needs to be re-wrapped during injection. */ 26774 case "inject": 26775 /* For the blur effect to be fully de-applied, it needs to be set to "none" instead of 0. */ 26776 if (!parseFloat(propertyValue)) { 26777 return "none"; 26778 } else { 26779 return "blur(" + propertyValue + ")"; 26780 } 26781 } 26782 }, 26783 /* <=IE8 do not support the standard opacity property. They use filter:alpha(opacity=INT) instead. */ 26784 opacity: function(type, element, propertyValue) { 26785 if (IE <= 8) { 26786 switch (type) { 26787 case "name": 26788 return "filter"; 26789 case "extract": 26790 /* <=IE8 return a "filter" value of "alpha(opacity=\d{1,3})". 26791 Extract the value and convert it to a decimal value to match the standard CSS opacity property's formatting. */ 26792 var extracted = propertyValue.toString().match(/alpha\(opacity=(.*)\)/i); 26793 26794 if (extracted) { 26795 /* Convert to decimal value. */ 26796 propertyValue = extracted[1] / 100; 26797 } else { 26798 /* When extracting opacity, default to 1 since a null value means opacity hasn't been set. */ 26799 propertyValue = 1; 26800 } 26801 26802 return propertyValue; 26803 case "inject": 26804 /* Opacified elements are required to have their zoom property set to a non-zero value. */ 26805 element.style.zoom = 1; 26806 26807 /* Setting the filter property on elements with certain font property combinations can result in a 26808 highly unappealing ultra-bolding effect. There's no way to remedy this throughout a tween, but dropping the 26809 value altogether (when opacity hits 1) at leasts ensures that the glitch is gone post-tweening. */ 26810 if (parseFloat(propertyValue) >= 1) { 26811 return ""; 26812 } else { 26813 /* As per the filter property's spec, convert the decimal value to a whole number and wrap the value. */ 26814 return "alpha(opacity=" + parseInt(parseFloat(propertyValue) * 100, 10) + ")"; 26815 } 26816 } 26817 /* With all other browsers, normalization is not required; return the same values that were passed in. */ 26818 } else { 26819 switch (type) { 26820 case "name": 26821 return "opacity"; 26822 case "extract": 26823 return propertyValue; 26824 case "inject": 26825 return propertyValue; 26826 } 26827 } 26828 } 26829 }, 26830 /***************************** 26831 Batched Registrations 26832 *****************************/ 26833 26834 /* Note: Batched normalizations extend the CSS.Normalizations.registered object. */ 26835 register: function() { 26836 26837 /***************** 26838 Transforms 26839 *****************/ 26840 26841 /* Transforms are the subproperties contained by the CSS "transform" property. Transforms must undergo normalization 26842 so that they can be referenced in a properties map by their individual names. */ 26843 /* Note: When transforms are "set", they are actually assigned to a per-element transformCache. When all transform 26844 setting is complete complete, CSS.flushTransformCache() must be manually called to flush the values to the DOM. 26845 Transform setting is batched in this way to improve performance: the transform style only needs to be updated 26846 once when multiple transform subproperties are being animated simultaneously. */ 26847 /* Note: IE9 and Android Gingerbread have support for 2D -- but not 3D -- transforms. Since animating unsupported 26848 transform properties results in the browser ignoring the *entire* transform string, we prevent these 3D values 26849 from being normalized for these browsers so that tweening skips these properties altogether 26850 (since it will ignore them as being unsupported by the browser.) */ 26851 if ((!IE || IE > 9) && !Velocity.State.isGingerbread) { 26852 /* Note: Since the standalone CSS "perspective" property and the CSS transform "perspective" subproperty 26853 share the same name, the latter is given a unique token within Velocity: "transformPerspective". */ 26854 CSS.Lists.transformsBase = CSS.Lists.transformsBase.concat(CSS.Lists.transforms3D); 26855 } 26856 26857 for (var i = 0; i < CSS.Lists.transformsBase.length; i++) { 26858 /* Wrap the dynamically generated normalization function in a new scope so that transformName's value is 26859 paired with its respective function. (Otherwise, all functions would take the final for loop's transformName.) */ 26860 (function() { 26861 var transformName = CSS.Lists.transformsBase[i]; 26862 26863 CSS.Normalizations.registered[transformName] = function(type, element, propertyValue) { 26864 switch (type) { 26865 /* The normalized property name is the parent "transform" property -- the property that is actually set in CSS. */ 26866 case "name": 26867 return "transform"; 26868 /* Transform values are cached onto a per-element transformCache object. */ 26869 case "extract": 26870 /* If this transform has yet to be assigned a value, return its null value. */ 26871 if (Data(element) === undefined || Data(element).transformCache[transformName] === undefined) { 26872 /* Scale CSS.Lists.transformsBase default to 1 whereas all other transform properties default to 0. */ 26873 return /^scale/i.test(transformName) ? 1 : 0; 26874 /* When transform values are set, they are wrapped in parentheses as per the CSS spec. 26875 Thus, when extracting their values (for tween calculations), we strip off the parentheses. */ 26876 } 26877 return Data(element).transformCache[transformName].replace(/[()]/g, ""); 26878 case "inject": 26879 var invalid = false; 26880 26881 /* If an individual transform property contains an unsupported unit type, the browser ignores the *entire* transform property. 26882 Thus, protect users from themselves by skipping setting for transform values supplied with invalid unit types. */ 26883 /* Switch on the base transform type; ignore the axis by removing the last letter from the transform's name. */ 26884 switch (transformName.substr(0, transformName.length - 1)) { 26885 /* Whitelist unit types for each transform. */ 26886 case "translate": 26887 invalid = !/(%|px|em|rem|vw|vh|\d)$/i.test(propertyValue); 26888 break; 26889 /* Since an axis-free "scale" property is supported as well, a little hack is used here to detect it by chopping off its last letter. */ 26890 case "scal": 26891 case "scale": 26892 /* Chrome on Android has a bug in which scaled elements blur if their initial scale 26893 value is below 1 (which can happen with forcefeeding). Thus, we detect a yet-unset scale property 26894 and ensure that its first value is always 1. More info: http://stackoverflow.com/questions/10417890/css3-animations-with-transform-causes-blurred-elements-on-webkit/10417962#10417962 */ 26895 if (Velocity.State.isAndroid && Data(element).transformCache[transformName] === undefined && propertyValue < 1) { 26896 propertyValue = 1; 26897 } 26898 26899 invalid = !/(\d)$/i.test(propertyValue); 26900 break; 26901 case "skew": 26902 invalid = !/(deg|\d)$/i.test(propertyValue); 26903 break; 26904 case "rotate": 26905 invalid = !/(deg|\d)$/i.test(propertyValue); 26906 break; 26907 } 26908 26909 if (!invalid) { 26910 /* As per the CSS spec, wrap the value in parentheses. */ 26911 Data(element).transformCache[transformName] = "(" + propertyValue + ")"; 26912 } 26913 26914 /* Although the value is set on the transformCache object, return the newly-updated value for the calling code to process as normal. */ 26915 return Data(element).transformCache[transformName]; 26916 } 26917 }; 26918 })(); 26919 } 26920 26921 /************* 26922 Colors 26923 *************/ 26924 26925 /* Since Velocity only animates a single numeric value per property, color animation is achieved by hooking the individual RGBA components of CSS color properties. 26926 Accordingly, color values must be normalized (e.g. "#ff0000", "red", and "rgb(255, 0, 0)" ==> "255 0 0 1") so that their components can be injected/extracted by CSS.Hooks logic. */ 26927 for (var j = 0; j < CSS.Lists.colors.length; j++) { 26928 /* Wrap the dynamically generated normalization function in a new scope so that colorName's value is paired with its respective function. 26929 (Otherwise, all functions would take the final for loop's colorName.) */ 26930 (function() { 26931 var colorName = CSS.Lists.colors[j]; 26932 26933 /* Note: In IE<=8, which support rgb but not rgba, color properties are reverted to rgb by stripping off the alpha component. */ 26934 CSS.Normalizations.registered[colorName] = function(type, element, propertyValue) { 26935 switch (type) { 26936 case "name": 26937 return colorName; 26938 /* Convert all color values into the rgb format. (Old IE can return hex values and color names instead of rgb/rgba.) */ 26939 case "extract": 26940 var extracted; 26941 26942 /* If the color is already in its hookable form (e.g. "255 255 255 1") due to having been previously extracted, skip extraction. */ 26943 if (CSS.RegEx.wrappedValueAlreadyExtracted.test(propertyValue)) { 26944 extracted = propertyValue; 26945 } else { 26946 var converted, 26947 colorNames = { 26948 black: "rgb(0, 0, 0)", 26949 blue: "rgb(0, 0, 255)", 26950 gray: "rgb(128, 128, 128)", 26951 green: "rgb(0, 128, 0)", 26952 red: "rgb(255, 0, 0)", 26953 white: "rgb(255, 255, 255)" 26954 }; 26955 26956 /* Convert color names to rgb. */ 26957 if (/^[A-z]+$/i.test(propertyValue)) { 26958 if (colorNames[propertyValue] !== undefined) { 26959 converted = colorNames[propertyValue]; 26960 } else { 26961 /* If an unmatched color name is provided, default to black. */ 26962 converted = colorNames.black; 26963 } 26964 /* Convert hex values to rgb. */ 26965 } else if (CSS.RegEx.isHex.test(propertyValue)) { 26966 converted = "rgb(" + CSS.Values.hexToRgb(propertyValue).join(" ") + ")"; 26967 /* If the provided color doesn't match any of the accepted color formats, default to black. */ 26968 } else if (!(/^rgba?\(/i.test(propertyValue))) { 26969 converted = colorNames.black; 26970 } 26971 26972 /* Remove the surrounding "rgb/rgba()" string then replace commas with spaces and strip 26973 repeated spaces (in case the value included spaces to begin with). */ 26974 extracted = (converted || propertyValue).toString().match(CSS.RegEx.valueUnwrap)[1].replace(/,(\s+)?/g, " "); 26975 } 26976 26977 /* So long as this isn't <=IE8, add a fourth (alpha) component if it's missing and default it to 1 (visible). */ 26978 if ((!IE || IE > 8) && extracted.split(" ").length === 3) { 26979 extracted += " 1"; 26980 } 26981 26982 return extracted; 26983 case "inject": 26984 /* If we have a pattern then it might already have the right values */ 26985 if (/^rgb/.test(propertyValue)) { 26986 return propertyValue; 26987 } 26988 26989 /* If this is IE<=8 and an alpha component exists, strip it off. */ 26990 if (IE <= 8) { 26991 if (propertyValue.split(" ").length === 4) { 26992 propertyValue = propertyValue.split(/\s+/).slice(0, 3).join(" "); 26993 } 26994 /* Otherwise, add a fourth (alpha) component if it's missing and default it to 1 (visible). */ 26995 } else if (propertyValue.split(" ").length === 3) { 26996 propertyValue += " 1"; 26997 } 26998 26999 /* Re-insert the browser-appropriate wrapper("rgb/rgba()"), insert commas, and strip off decimal units 27000 on all values but the fourth (R, G, and B only accept whole numbers). */ 27001 return (IE <= 8 ? "rgb" : "rgba") + "(" + propertyValue.replace(/\s+/g, ",").replace(/\.(\d)+(?=,)/g, "") + ")"; 27002 } 27003 }; 27004 })(); 27005 } 27006 27007 /************** 27008 Dimensions 27009 **************/ 27010 function augmentDimension(name, element, wantInner) { 27011 var isBorderBox = CSS.getPropertyValue(element, "boxSizing").toString().toLowerCase() === "border-box"; 27012 27013 if (isBorderBox === (wantInner || false)) { 27014 /* in box-sizing mode, the CSS width / height accessors already give the outerWidth / outerHeight. */ 27015 var i, 27016 value, 27017 augment = 0, 27018 sides = name === "width" ? ["Left", "Right"] : ["Top", "Bottom"], 27019 fields = ["padding" + sides[0], "padding" + sides[1], "border" + sides[0] + "Width", "border" + sides[1] + "Width"]; 27020 27021 for (i = 0; i < fields.length; i++) { 27022 value = parseFloat(CSS.getPropertyValue(element, fields[i])); 27023 if (!isNaN(value)) { 27024 augment += value; 27025 } 27026 } 27027 return wantInner ? -augment : augment; 27028 } 27029 return 0; 27030 } 27031 function getDimension(name, wantInner) { 27032 return function(type, element, propertyValue) { 27033 switch (type) { 27034 case "name": 27035 return name; 27036 case "extract": 27037 return parseFloat(propertyValue) + augmentDimension(name, element, wantInner); 27038 case "inject": 27039 return (parseFloat(propertyValue) - augmentDimension(name, element, wantInner)) + "px"; 27040 } 27041 }; 27042 } 27043 CSS.Normalizations.registered.innerWidth = getDimension("width", true); 27044 CSS.Normalizations.registered.innerHeight = getDimension("height", true); 27045 CSS.Normalizations.registered.outerWidth = getDimension("width"); 27046 CSS.Normalizations.registered.outerHeight = getDimension("height"); 27047 } 27048 }, 27049 /************************ 27050 CSS Property Names 27051 ************************/ 27052 27053 Names: { 27054 /* Camelcase a property name into its JavaScript notation (e.g. "background-color" ==> "backgroundColor"). 27055 Camelcasing is used to normalize property names between and across calls. */ 27056 camelCase: function(property) { 27057 return property.replace(/-(\w)/g, function(match, subMatch) { 27058 return subMatch.toUpperCase(); 27059 }); 27060 }, 27061 /* For SVG elements, some properties (namely, dimensional ones) are GET/SET via the element's HTML attributes (instead of via CSS styles). */ 27062 SVGAttribute: function(property) { 27063 var SVGAttributes = "width|height|x|y|cx|cy|r|rx|ry|x1|x2|y1|y2"; 27064 27065 /* Certain browsers require an SVG transform to be applied as an attribute. (Otherwise, application via CSS is preferable due to 3D support.) */ 27066 if (IE || (Velocity.State.isAndroid && !Velocity.State.isChrome)) { 27067 SVGAttributes += "|transform"; 27068 } 27069 27070 return new RegExp("^(" + SVGAttributes + ")$", "i").test(property); 27071 }, 27072 /* Determine whether a property should be set with a vendor prefix. */ 27073 /* If a prefixed version of the property exists, return it. Otherwise, return the original property name. 27074 If the property is not at all supported by the browser, return a false flag. */ 27075 prefixCheck: function(property) { 27076 /* If this property has already been checked, return the cached value. */ 27077 if (Velocity.State.prefixMatches[property]) { 27078 return [Velocity.State.prefixMatches[property], true]; 27079 } else { 27080 var vendors = ["", "Webkit", "Moz", "ms", "O"]; 27081 27082 for (var i = 0, vendorsLength = vendors.length; i < vendorsLength; i++) { 27083 var propertyPrefixed; 27084 27085 if (i === 0) { 27086 propertyPrefixed = property; 27087 } else { 27088 /* Capitalize the first letter of the property to conform to JavaScript vendor prefix notation (e.g. webkitFilter). */ 27089 propertyPrefixed = vendors[i] + property.replace(/^\w/, function(match) { 27090 return match.toUpperCase(); 27091 }); 27092 } 27093 27094 /* Check if the browser supports this property as prefixed. */ 27095 if (Type.isString(Velocity.State.prefixElement.style[propertyPrefixed])) { 27096 /* Cache the match. */ 27097 Velocity.State.prefixMatches[property] = propertyPrefixed; 27098 27099 return [propertyPrefixed, true]; 27100 } 27101 } 27102 27103 /* If the browser doesn't support this property in any form, include a false flag so that the caller can decide how to proceed. */ 27104 return [property, false]; 27105 } 27106 } 27107 }, 27108 /************************ 27109 CSS Property Values 27110 ************************/ 27111 27112 Values: { 27113 /* Hex to RGB conversion. Copyright Tim Down: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb */ 27114 hexToRgb: function(hex) { 27115 var shortformRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, 27116 longformRegex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i, 27117 rgbParts; 27118 27119 hex = hex.replace(shortformRegex, function(m, r, g, b) { 27120 return r + r + g + g + b + b; 27121 }); 27122 27123 rgbParts = longformRegex.exec(hex); 27124 27125 return rgbParts ? [parseInt(rgbParts[1], 16), parseInt(rgbParts[2], 16), parseInt(rgbParts[3], 16)] : [0, 0, 0]; 27126 }, 27127 isCSSNullValue: function(value) { 27128 /* The browser defaults CSS values that have not been set to either 0 or one of several possible null-value strings. 27129 Thus, we check for both falsiness and these special strings. */ 27130 /* Null-value checking is performed to default the special strings to 0 (for the sake of tweening) or their hook 27131 templates as defined as CSS.Hooks (for the sake of hook injection/extraction). */ 27132 /* Note: Chrome returns "rgba(0, 0, 0, 0)" for an undefined color whereas IE returns "transparent". */ 27133 return (!value || /^(none|auto|transparent|(rgba\(0, ?0, ?0, ?0\)))$/i.test(value)); 27134 }, 27135 /* Retrieve a property's default unit type. Used for assigning a unit type when one is not supplied by the user. */ 27136 getUnitType: function(property) { 27137 if (/^(rotate|skew)/i.test(property)) { 27138 return "deg"; 27139 } else if (/(^(scale|scaleX|scaleY|scaleZ|alpha|flexGrow|flexHeight|zIndex|fontWeight)$)|((opacity|red|green|blue|alpha)$)/i.test(property)) { 27140 /* The above properties are unitless. */ 27141 return ""; 27142 } else { 27143 /* Default to px for all other properties. */ 27144 return "px"; 27145 } 27146 }, 27147 /* HTML elements default to an associated display type when they're not set to display:none. */ 27148 /* Note: This function is used for correctly setting the non-"none" display value in certain Velocity redirects, such as fadeIn/Out. */ 27149 getDisplayType: function(element) { 27150 var tagName = element && element.tagName.toString().toLowerCase(); 27151 27152 if (/^(b|big|i|small|tt|abbr|acronym|cite|code|dfn|em|kbd|strong|samp|var|a|bdo|br|img|map|object|q|script|span|sub|sup|button|input|label|select|textarea)$/i.test(tagName)) { 27153 return "inline"; 27154 } else if (/^(li)$/i.test(tagName)) { 27155 return "list-item"; 27156 } else if (/^(tr)$/i.test(tagName)) { 27157 return "table-row"; 27158 } else if (/^(table)$/i.test(tagName)) { 27159 return "table"; 27160 } else if (/^(tbody)$/i.test(tagName)) { 27161 return "table-row-group"; 27162 /* Default to "block" when no match is found. */ 27163 } else { 27164 return "block"; 27165 } 27166 }, 27167 /* The class add/remove functions are used to temporarily apply a "velocity-animating" class to elements while they're animating. */ 27168 addClass: function(element, className) { 27169 if (element) { 27170 if (element.classList) { 27171 element.classList.add(className); 27172 } else if (Type.isString(element.className)) { 27173 // Element.className is around 15% faster then set/getAttribute 27174 element.className += (element.className.length ? " " : "") + className; 27175 } else { 27176 // Work around for IE strict mode animating SVG - and anything else that doesn't behave correctly - the same way jQuery does it 27177 var currentClass = element.getAttribute(IE <= 7 ? "className" : "class") || ""; 27178 27179 element.setAttribute("class", currentClass + (currentClass ? " " : "") + className); 27180 } 27181 } 27182 }, 27183 removeClass: function(element, className) { 27184 if (element) { 27185 if (element.classList) { 27186 element.classList.remove(className); 27187 } else if (Type.isString(element.className)) { 27188 // Element.className is around 15% faster then set/getAttribute 27189 // TODO: Need some jsperf tests on performance - can we get rid of the regex and maybe use split / array manipulation? 27190 element.className = element.className.toString().replace(new RegExp("(^|\\s)" + className.split(" ").join("|") + "(\\s|$)", "gi"), " "); 27191 } else { 27192 // Work around for IE strict mode animating SVG - and anything else that doesn't behave correctly - the same way jQuery does it 27193 var currentClass = element.getAttribute(IE <= 7 ? "className" : "class") || ""; 27194 27195 element.setAttribute("class", currentClass.replace(new RegExp("(^|\s)" + className.split(" ").join("|") + "(\s|$)", "gi"), " ")); 27196 } 27197 } 27198 } 27199 }, 27200 /**************************** 27201 Style Getting & Setting 27202 ****************************/ 27203 27204 /* The singular getPropertyValue, which routes the logic for all normalizations, hooks, and standard CSS properties. */ 27205 getPropertyValue: function(element, property, rootPropertyValue, forceStyleLookup) { 27206 /* Get an element's computed property value. */ 27207 /* Note: Retrieving the value of a CSS property cannot simply be performed by checking an element's 27208 style attribute (which only reflects user-defined values). Instead, the browser must be queried for a property's 27209 *computed* value. You can read more about getComputedStyle here: https://developer.mozilla.org/en/docs/Web/API/window.getComputedStyle */ 27210 function computePropertyValue(element, property) { 27211 /* When box-sizing isn't set to border-box, height and width style values are incorrectly computed when an 27212 element's scrollbars are visible (which expands the element's dimensions). Thus, we defer to the more accurate 27213 offsetHeight/Width property, which includes the total dimensions for interior, border, padding, and scrollbar. 27214 We subtract border and padding to get the sum of interior + scrollbar. */ 27215 var computedValue = 0; 27216 27217 /* IE<=8 doesn't support window.getComputedStyle, thus we defer to jQuery, which has an extensive array 27218 of hacks to accurately retrieve IE8 property values. Re-implementing that logic here is not worth bloating the 27219 codebase for a dying browser. The performance repercussions of using jQuery here are minimal since 27220 Velocity is optimized to rarely (and sometimes never) query the DOM. Further, the $.css() codepath isn't that slow. */ 27221 if (IE <= 8) { 27222 computedValue = $.css(element, property); /* GET */ 27223 /* All other browsers support getComputedStyle. The returned live object reference is cached onto its 27224 associated element so that it does not need to be refetched upon every GET. */ 27225 } else { 27226 /* Browsers do not return height and width values for elements that are set to display:"none". Thus, we temporarily 27227 toggle display to the element type's default value. */ 27228 var toggleDisplay = false; 27229 27230 if (/^(width|height)$/.test(property) && CSS.getPropertyValue(element, "display") === 0) { 27231 toggleDisplay = true; 27232 CSS.setPropertyValue(element, "display", CSS.Values.getDisplayType(element)); 27233 } 27234 27235 var revertDisplay = function() { 27236 if (toggleDisplay) { 27237 CSS.setPropertyValue(element, "display", "none"); 27238 } 27239 }; 27240 27241 if (!forceStyleLookup) { 27242 if (property === "height" && CSS.getPropertyValue(element, "boxSizing").toString().toLowerCase() !== "border-box") { 27243 var contentBoxHeight = element.offsetHeight - (parseFloat(CSS.getPropertyValue(element, "borderTopWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "borderBottomWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingTop")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingBottom")) || 0); 27244 revertDisplay(); 27245 27246 return contentBoxHeight; 27247 } else if (property === "width" && CSS.getPropertyValue(element, "boxSizing").toString().toLowerCase() !== "border-box") { 27248 var contentBoxWidth = element.offsetWidth - (parseFloat(CSS.getPropertyValue(element, "borderLeftWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "borderRightWidth")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingLeft")) || 0) - (parseFloat(CSS.getPropertyValue(element, "paddingRight")) || 0); 27249 revertDisplay(); 27250 27251 return contentBoxWidth; 27252 } 27253 } 27254 27255 var computedStyle; 27256 27257 /* For elements that Velocity hasn't been called on directly (e.g. when Velocity queries the DOM on behalf 27258 of a parent of an element its animating), perform a direct getComputedStyle lookup since the object isn't cached. */ 27259 if (Data(element) === undefined) { 27260 computedStyle = window.getComputedStyle(element, null); /* GET */ 27261 /* If the computedStyle object has yet to be cached, do so now. */ 27262 } else if (!Data(element).computedStyle) { 27263 computedStyle = Data(element).computedStyle = window.getComputedStyle(element, null); /* GET */ 27264 /* If computedStyle is cached, use it. */ 27265 } else { 27266 computedStyle = Data(element).computedStyle; 27267 } 27268 27269 /* IE and Firefox do not return a value for the generic borderColor -- they only return individual values for each border side's color. 27270 Also, in all browsers, when border colors aren't all the same, a compound value is returned that Velocity isn't setup to parse. 27271 So, as a polyfill for querying individual border side colors, we just return the top border's color and animate all borders from that value. */ 27272 if (property === "borderColor") { 27273 property = "borderTopColor"; 27274 } 27275 27276 /* IE9 has a bug in which the "filter" property must be accessed from computedStyle using the getPropertyValue method 27277 instead of a direct property lookup. The getPropertyValue method is slower than a direct lookup, which is why we avoid it by default. */ 27278 if (IE === 9 && property === "filter") { 27279 computedValue = computedStyle.getPropertyValue(property); /* GET */ 27280 } else { 27281 computedValue = computedStyle[property]; 27282 } 27283 27284 /* Fall back to the property's style value (if defined) when computedValue returns nothing, 27285 which can happen when the element hasn't been painted. */ 27286 if (computedValue === "" || computedValue === null) { 27287 computedValue = element.style[property]; 27288 } 27289 27290 revertDisplay(); 27291 } 27292 27293 /* For top, right, bottom, and left (TRBL) values that are set to "auto" on elements of "fixed" or "absolute" position, 27294 defer to jQuery for converting "auto" to a numeric value. (For elements with a "static" or "relative" position, "auto" has the same 27295 effect as being set to 0, so no conversion is necessary.) */ 27296 /* An example of why numeric conversion is necessary: When an element with "position:absolute" has an untouched "left" 27297 property, which reverts to "auto", left's value is 0 relative to its parent element, but is often non-zero relative 27298 to its *containing* (not parent) element, which is the nearest "position:relative" ancestor or the viewport (and always the viewport in the case of "position:fixed"). */ 27299 if (computedValue === "auto" && /^(top|right|bottom|left)$/i.test(property)) { 27300 var position = computePropertyValue(element, "position"); /* GET */ 27301 27302 /* For absolute positioning, jQuery's $.position() only returns values for top and left; 27303 right and bottom will have their "auto" value reverted to 0. */ 27304 /* Note: A jQuery object must be created here since jQuery doesn't have a low-level alias for $.position(). 27305 Not a big deal since we're currently in a GET batch anyway. */ 27306 if (position === "fixed" || (position === "absolute" && /top|left/i.test(property))) { 27307 /* Note: jQuery strips the pixel unit from its returned values; we re-add it here to conform with computePropertyValue's behavior. */ 27308 computedValue = $(element).position()[property] + "px"; /* GET */ 27309 } 27310 } 27311 27312 return computedValue; 27313 } 27314 27315 var propertyValue; 27316 27317 /* If this is a hooked property (e.g. "clipLeft" instead of the root property of "clip"), 27318 extract the hook's value from a normalized rootPropertyValue using CSS.Hooks.extractValue(). */ 27319 if (CSS.Hooks.registered[property]) { 27320 var hook = property, 27321 hookRoot = CSS.Hooks.getRoot(hook); 27322 27323 /* If a cached rootPropertyValue wasn't passed in (which Velocity always attempts to do in order to avoid requerying the DOM), 27324 query the DOM for the root property's value. */ 27325 if (rootPropertyValue === undefined) { 27326 /* Since the browser is now being directly queried, use the official post-prefixing property name for this lookup. */ 27327 rootPropertyValue = CSS.getPropertyValue(element, CSS.Names.prefixCheck(hookRoot)[0]); /* GET */ 27328 } 27329 27330 /* If this root has a normalization registered, peform the associated normalization extraction. */ 27331 if (CSS.Normalizations.registered[hookRoot]) { 27332 rootPropertyValue = CSS.Normalizations.registered[hookRoot]("extract", element, rootPropertyValue); 27333 } 27334 27335 /* Extract the hook's value. */ 27336 propertyValue = CSS.Hooks.extractValue(hook, rootPropertyValue); 27337 27338 /* If this is a normalized property (e.g. "opacity" becomes "filter" in <=IE8) or "translateX" becomes "transform"), 27339 normalize the property's name and value, and handle the special case of transforms. */ 27340 /* Note: Normalizing a property is mutually exclusive from hooking a property since hook-extracted values are strictly 27341 numerical and therefore do not require normalization extraction. */ 27342 } else if (CSS.Normalizations.registered[property]) { 27343 var normalizedPropertyName, 27344 normalizedPropertyValue; 27345 27346 normalizedPropertyName = CSS.Normalizations.registered[property]("name", element); 27347 27348 /* Transform values are calculated via normalization extraction (see below), which checks against the element's transformCache. 27349 At no point do transform GETs ever actually query the DOM; initial stylesheet values are never processed. 27350 This is because parsing 3D transform matrices is not always accurate and would bloat our codebase; 27351 thus, normalization extraction defaults initial transform values to their zero-values (e.g. 1 for scaleX and 0 for translateX). */ 27352 if (normalizedPropertyName !== "transform") { 27353 normalizedPropertyValue = computePropertyValue(element, CSS.Names.prefixCheck(normalizedPropertyName)[0]); /* GET */ 27354 27355 /* If the value is a CSS null-value and this property has a hook template, use that zero-value template so that hooks can be extracted from it. */ 27356 if (CSS.Values.isCSSNullValue(normalizedPropertyValue) && CSS.Hooks.templates[property]) { 27357 normalizedPropertyValue = CSS.Hooks.templates[property][1]; 27358 } 27359 } 27360 27361 propertyValue = CSS.Normalizations.registered[property]("extract", element, normalizedPropertyValue); 27362 } 27363 27364 /* If a (numeric) value wasn't produced via hook extraction or normalization, query the DOM. */ 27365 if (!/^[\d-]/.test(propertyValue)) { 27366 /* For SVG elements, dimensional properties (which SVGAttribute() detects) are tweened via 27367 their HTML attribute values instead of their CSS style values. */ 27368 var data = Data(element); 27369 27370 if (data && data.isSVG && CSS.Names.SVGAttribute(property)) { 27371 /* Since the height/width attribute values must be set manually, they don't reflect computed values. 27372 Thus, we use use getBBox() to ensure we always get values for elements with undefined height/width attributes. */ 27373 if (/^(height|width)$/i.test(property)) { 27374 /* Firefox throws an error if .getBBox() is called on an SVG that isn't attached to the DOM. */ 27375 try { 27376 propertyValue = element.getBBox()[property]; 27377 } catch (error) { 27378 propertyValue = 0; 27379 } 27380 /* Otherwise, access the attribute value directly. */ 27381 } else { 27382 propertyValue = element.getAttribute(property); 27383 } 27384 } else { 27385 propertyValue = computePropertyValue(element, CSS.Names.prefixCheck(property)[0]); /* GET */ 27386 } 27387 } 27388 27389 /* Since property lookups are for animation purposes (which entails computing the numeric delta between start and end values), 27390 convert CSS null-values to an integer of value 0. */ 27391 if (CSS.Values.isCSSNullValue(propertyValue)) { 27392 propertyValue = 0; 27393 } 27394 27395 if (Velocity.debug >= 2) { 27396 console.log("Get " + property + ": " + propertyValue); 27397 } 27398 27399 return propertyValue; 27400 }, 27401 /* The singular setPropertyValue, which routes the logic for all normalizations, hooks, and standard CSS properties. */ 27402 setPropertyValue: function(element, property, propertyValue, rootPropertyValue, scrollData) { 27403 var propertyName = property; 27404 27405 /* In order to be subjected to call options and element queueing, scroll animation is routed through Velocity as if it were a standard CSS property. */ 27406 if (property === "scroll") { 27407 /* If a container option is present, scroll the container instead of the browser window. */ 27408 if (scrollData.container) { 27409 scrollData.container["scroll" + scrollData.direction] = propertyValue; 27410 /* Otherwise, Velocity defaults to scrolling the browser window. */ 27411 } else { 27412 if (scrollData.direction === "Left") { 27413 window.scrollTo(propertyValue, scrollData.alternateValue); 27414 } else { 27415 window.scrollTo(scrollData.alternateValue, propertyValue); 27416 } 27417 } 27418 } else { 27419 /* Transforms (translateX, rotateZ, etc.) are applied to a per-element transformCache object, which is manually flushed via flushTransformCache(). 27420 Thus, for now, we merely cache transforms being SET. */ 27421 if (CSS.Normalizations.registered[property] && CSS.Normalizations.registered[property]("name", element) === "transform") { 27422 /* Perform a normalization injection. */ 27423 /* Note: The normalization logic handles the transformCache updating. */ 27424 CSS.Normalizations.registered[property]("inject", element, propertyValue); 27425 27426 propertyName = "transform"; 27427 propertyValue = Data(element).transformCache[property]; 27428 } else { 27429 /* Inject hooks. */ 27430 if (CSS.Hooks.registered[property]) { 27431 var hookName = property, 27432 hookRoot = CSS.Hooks.getRoot(property); 27433 27434 /* If a cached rootPropertyValue was not provided, query the DOM for the hookRoot's current value. */ 27435 rootPropertyValue = rootPropertyValue || CSS.getPropertyValue(element, hookRoot); /* GET */ 27436 27437 propertyValue = CSS.Hooks.injectValue(hookName, propertyValue, rootPropertyValue); 27438 property = hookRoot; 27439 } 27440 27441 /* Normalize names and values. */ 27442 if (CSS.Normalizations.registered[property]) { 27443 propertyValue = CSS.Normalizations.registered[property]("inject", element, propertyValue); 27444 property = CSS.Normalizations.registered[property]("name", element); 27445 } 27446 27447 /* Assign the appropriate vendor prefix before performing an official style update. */ 27448 propertyName = CSS.Names.prefixCheck(property)[0]; 27449 27450 /* A try/catch is used for IE<=8, which throws an error when "invalid" CSS values are set, e.g. a negative width. 27451 Try/catch is avoided for other browsers since it incurs a performance overhead. */ 27452 if (IE <= 8) { 27453 try { 27454 element.style[propertyName] = propertyValue; 27455 } catch (error) { 27456 if (Velocity.debug) { 27457 console.log("Browser does not support [" + propertyValue + "] for [" + propertyName + "]"); 27458 } 27459 } 27460 /* SVG elements have their dimensional properties (width, height, x, y, cx, etc.) applied directly as attributes instead of as styles. */ 27461 /* Note: IE8 does not support SVG elements, so it's okay that we skip it for SVG animation. */ 27462 } else { 27463 var data = Data(element); 27464 27465 if (data && data.isSVG && CSS.Names.SVGAttribute(property)) { 27466 /* Note: For SVG attributes, vendor-prefixed property names are never used. */ 27467 /* Note: Not all CSS properties can be animated via attributes, but the browser won't throw an error for unsupported properties. */ 27468 element.setAttribute(property, propertyValue); 27469 } else { 27470 element.style[propertyName] = propertyValue; 27471 } 27472 } 27473 27474 if (Velocity.debug >= 2) { 27475 console.log("Set " + property + " (" + propertyName + "): " + propertyValue); 27476 } 27477 } 27478 } 27479 27480 /* Return the normalized property name and value in case the caller wants to know how these values were modified before being applied to the DOM. */ 27481 return [propertyName, propertyValue]; 27482 }, 27483 /* To increase performance by batching transform updates into a single SET, transforms are not directly applied to an element until flushTransformCache() is called. */ 27484 /* Note: Velocity applies transform properties in the same order that they are chronogically introduced to the element's CSS styles. */ 27485 flushTransformCache: function(element) { 27486 var transformString = "", 27487 data = Data(element); 27488 27489 /* Certain browsers require that SVG transforms be applied as an attribute. However, the SVG transform attribute takes a modified version of CSS's transform string 27490 (units are dropped and, except for skewX/Y, subproperties are merged into their master property -- e.g. scaleX and scaleY are merged into scale(X Y). */ 27491 if ((IE || (Velocity.State.isAndroid && !Velocity.State.isChrome)) && data && data.isSVG) { 27492 /* Since transform values are stored in their parentheses-wrapped form, we use a helper function to strip out their numeric values. 27493 Further, SVG transform properties only take unitless (representing pixels) values, so it's okay that parseFloat() strips the unit suffixed to the float value. */ 27494 var getTransformFloat = function(transformProperty) { 27495 return parseFloat(CSS.getPropertyValue(element, transformProperty)); 27496 }; 27497 27498 /* Create an object to organize all the transforms that we'll apply to the SVG element. To keep the logic simple, 27499 we process *all* transform properties -- even those that may not be explicitly applied (since they default to their zero-values anyway). */ 27500 var SVGTransforms = { 27501 translate: [getTransformFloat("translateX"), getTransformFloat("translateY")], 27502 skewX: [getTransformFloat("skewX")], skewY: [getTransformFloat("skewY")], 27503 /* If the scale property is set (non-1), use that value for the scaleX and scaleY values 27504 (this behavior mimics the result of animating all these properties at once on HTML elements). */ 27505 scale: getTransformFloat("scale") !== 1 ? [getTransformFloat("scale"), getTransformFloat("scale")] : [getTransformFloat("scaleX"), getTransformFloat("scaleY")], 27506 /* Note: SVG's rotate transform takes three values: rotation degrees followed by the X and Y values 27507 defining the rotation's origin point. We ignore the origin values (default them to 0). */ 27508 rotate: [getTransformFloat("rotateZ"), 0, 0] 27509 }; 27510 27511 /* Iterate through the transform properties in the user-defined property map order. 27512 (This mimics the behavior of non-SVG transform animation.) */ 27513 $.each(Data(element).transformCache, function(transformName) { 27514 /* Except for with skewX/Y, revert the axis-specific transform subproperties to their axis-free master 27515 properties so that they match up with SVG's accepted transform properties. */ 27516 if (/^translate/i.test(transformName)) { 27517 transformName = "translate"; 27518 } else if (/^scale/i.test(transformName)) { 27519 transformName = "scale"; 27520 } else if (/^rotate/i.test(transformName)) { 27521 transformName = "rotate"; 27522 } 27523 27524 /* Check that we haven't yet deleted the property from the SVGTransforms container. */ 27525 if (SVGTransforms[transformName]) { 27526 /* Append the transform property in the SVG-supported transform format. As per the spec, surround the space-delimited values in parentheses. */ 27527 transformString += transformName + "(" + SVGTransforms[transformName].join(" ") + ")" + " "; 27528 27529 /* After processing an SVG transform property, delete it from the SVGTransforms container so we don't 27530 re-insert the same master property if we encounter another one of its axis-specific properties. */ 27531 delete SVGTransforms[transformName]; 27532 } 27533 }); 27534 } else { 27535 var transformValue, 27536 perspective; 27537 27538 /* Transform properties are stored as members of the transformCache object. Concatenate all the members into a string. */ 27539 $.each(Data(element).transformCache, function(transformName) { 27540 transformValue = Data(element).transformCache[transformName]; 27541 27542 /* Transform's perspective subproperty must be set first in order to take effect. Store it temporarily. */ 27543 if (transformName === "transformPerspective") { 27544 perspective = transformValue; 27545 return true; 27546 } 27547 27548 /* IE9 only supports one rotation type, rotateZ, which it refers to as "rotate". */ 27549 if (IE === 9 && transformName === "rotateZ") { 27550 transformName = "rotate"; 27551 } 27552 27553 transformString += transformName + transformValue + " "; 27554 }); 27555 27556 /* If present, set the perspective subproperty first. */ 27557 if (perspective) { 27558 transformString = "perspective" + perspective + " " + transformString; 27559 } 27560 } 27561 27562 CSS.setPropertyValue(element, "transform", transformString); 27563 } 27564 }; 27565 27566 /* Register hooks and normalizations. */ 27567 CSS.Hooks.register(); 27568 CSS.Normalizations.register(); 27569 27570 /* Allow hook setting in the same fashion as jQuery's $.css(). */ 27571 Velocity.hook = function(elements, arg2, arg3) { 27572 var value; 27573 27574 elements = sanitizeElements(elements); 27575 27576 $.each(elements, function(i, element) { 27577 /* Initialize Velocity's per-element data cache if this element hasn't previously been animated. */ 27578 if (Data(element) === undefined) { 27579 Velocity.init(element); 27580 } 27581 27582 /* Get property value. If an element set was passed in, only return the value for the first element. */ 27583 if (arg3 === undefined) { 27584 if (value === undefined) { 27585 value = CSS.getPropertyValue(element, arg2); 27586 } 27587 /* Set property value. */ 27588 } else { 27589 /* sPV returns an array of the normalized propertyName/propertyValue pair used to update the DOM. */ 27590 var adjustedSet = CSS.setPropertyValue(element, arg2, arg3); 27591 27592 /* Transform properties don't automatically set. They have to be flushed to the DOM. */ 27593 if (adjustedSet[0] === "transform") { 27594 Velocity.CSS.flushTransformCache(element); 27595 } 27596 27597 value = adjustedSet; 27598 } 27599 }); 27600 27601 return value; 27602 }; 27603 27604 /***************** 27605 Animation 27606 *****************/ 27607 27608 var animate = function() { 27609 var opts; 27610 27611 /****************** 27612 Call Chain 27613 ******************/ 27614 27615 /* Logic for determining what to return to the call stack when exiting out of Velocity. */ 27616 function getChain() { 27617 /* If we are using the utility function, attempt to return this call's promise. If no promise library was detected, 27618 default to null instead of returning the targeted elements so that utility function's return value is standardized. */ 27619 if (isUtility) { 27620 return promiseData.promise || null; 27621 /* Otherwise, if we're using $.fn, return the jQuery-/Zepto-wrapped element set. */ 27622 } else { 27623 return elementsWrapped; 27624 } 27625 } 27626 27627 /************************* 27628 Arguments Assignment 27629 *************************/ 27630 27631 /* To allow for expressive CoffeeScript code, Velocity supports an alternative syntax in which "elements" (or "e"), "properties" (or "p"), and "options" (or "o") 27632 objects are defined on a container object that's passed in as Velocity's sole argument. */ 27633 /* Note: Some browsers automatically populate arguments with a "properties" object. We detect it by checking for its default "names" property. */ 27634 var syntacticSugar = (arguments[0] && (arguments[0].p || (($.isPlainObject(arguments[0].properties) && !arguments[0].properties.names) || Type.isString(arguments[0].properties)))), 27635 /* Whether Velocity was called via the utility function (as opposed to on a jQuery/Zepto object). */ 27636 isUtility, 27637 /* When Velocity is called via the utility function ($.Velocity()/Velocity()), elements are explicitly 27638 passed in as the first parameter. Thus, argument positioning varies. We normalize them here. */ 27639 elementsWrapped, 27640 argumentIndex; 27641 27642 var elements, 27643 propertiesMap, 27644 options; 27645 27646 /* Detect jQuery/Zepto elements being animated via the $.fn method. */ 27647 if (Type.isWrapped(this)) { 27648 isUtility = false; 27649 27650 argumentIndex = 0; 27651 elements = this; 27652 elementsWrapped = this; 27653 /* Otherwise, raw elements are being animated via the utility function. */ 27654 } else { 27655 isUtility = true; 27656 27657 argumentIndex = 1; 27658 elements = syntacticSugar ? (arguments[0].elements || arguments[0].e) : arguments[0]; 27659 } 27660 27661 /*************** 27662 Promises 27663 ***************/ 27664 27665 var promiseData = { 27666 promise: null, 27667 resolver: null, 27668 rejecter: null 27669 }; 27670 27671 /* If this call was made via the utility function (which is the default method of invocation when jQuery/Zepto are not being used), and if 27672 promise support was detected, create a promise object for this call and store references to its resolver and rejecter methods. The resolve 27673 method is used when a call completes naturally or is prematurely stopped by the user. In both cases, completeCall() handles the associated 27674 call cleanup and promise resolving logic. The reject method is used when an invalid set of arguments is passed into a Velocity call. */ 27675 /* Note: Velocity employs a call-based queueing architecture, which means that stopping an animating element actually stops the full call that 27676 triggered it -- not that one element exclusively. Similarly, there is one promise per call, and all elements targeted by a Velocity call are 27677 grouped together for the purposes of resolving and rejecting a promise. */ 27678 if (isUtility && Velocity.Promise) { 27679 promiseData.promise = new Velocity.Promise(function(resolve, reject) { 27680 promiseData.resolver = resolve; 27681 promiseData.rejecter = reject; 27682 }); 27683 } 27684 27685 if (syntacticSugar) { 27686 propertiesMap = arguments[0].properties || arguments[0].p; 27687 options = arguments[0].options || arguments[0].o; 27688 } else { 27689 propertiesMap = arguments[argumentIndex]; 27690 options = arguments[argumentIndex + 1]; 27691 } 27692 27693 elements = sanitizeElements(elements); 27694 27695 if (!elements) { 27696 if (promiseData.promise) { 27697 if (!propertiesMap || !options || options.promiseRejectEmpty !== false) { 27698 promiseData.rejecter(); 27699 } else { 27700 promiseData.resolver(); 27701 } 27702 } 27703 return; 27704 } 27705 27706 /* The length of the element set (in the form of a nodeList or an array of elements) is defaulted to 1 in case a 27707 single raw DOM element is passed in (which doesn't contain a length property). */ 27708 var elementsLength = elements.length, 27709 elementsIndex = 0; 27710 27711 /*************************** 27712 Argument Overloading 27713 ***************************/ 27714 27715 /* Support is included for jQuery's argument overloading: $.animate(propertyMap [, duration] [, easing] [, complete]). 27716 Overloading is detected by checking for the absence of an object being passed into options. */ 27717 /* Note: The stop/finish/pause/resume actions do not accept animation options, and are therefore excluded from this check. */ 27718 if (!/^(stop|finish|finishAll|pause|resume)$/i.test(propertiesMap) && !$.isPlainObject(options)) { 27719 /* The utility function shifts all arguments one position to the right, so we adjust for that offset. */ 27720 var startingArgumentPosition = argumentIndex + 1; 27721 27722 options = {}; 27723 27724 /* Iterate through all options arguments */ 27725 for (var i = startingArgumentPosition; i < arguments.length; i++) { 27726 /* Treat a number as a duration. Parse it out. */ 27727 /* Note: The following RegEx will return true if passed an array with a number as its first item. 27728 Thus, arrays are skipped from this check. */ 27729 if (!Type.isArray(arguments[i]) && (/^(fast|normal|slow)$/i.test(arguments[i]) || /^\d/.test(arguments[i]))) { 27730 options.duration = arguments[i]; 27731 /* Treat strings and arrays as easings. */ 27732 } else if (Type.isString(arguments[i]) || Type.isArray(arguments[i])) { 27733 options.easing = arguments[i]; 27734 /* Treat a function as a complete callback. */ 27735 } else if (Type.isFunction(arguments[i])) { 27736 options.complete = arguments[i]; 27737 } 27738 } 27739 } 27740 27741 /********************* 27742 Action Detection 27743 *********************/ 27744 27745 /* Velocity's behavior is categorized into "actions": Elements can either be specially scrolled into view, 27746 or they can be started, stopped, paused, resumed, or reversed . If a literal or referenced properties map is passed in as Velocity's 27747 first argument, the associated action is "start". Alternatively, "scroll", "reverse", "pause", "resume" or "stop" can be passed in 27748 instead of a properties map. */ 27749 var action; 27750 27751 switch (propertiesMap) { 27752 case "scroll": 27753 action = "scroll"; 27754 break; 27755 27756 case "reverse": 27757 action = "reverse"; 27758 break; 27759 27760 case "pause": 27761 27762 /******************* 27763 Action: Pause 27764 *******************/ 27765 27766 var currentTime = (new Date()).getTime(); 27767 27768 /* Handle delay timers */ 27769 $.each(elements, function(i, element) { 27770 pauseDelayOnElement(element, currentTime); 27771 }); 27772 27773 /* Pause and Resume are call-wide (not on a per element basis). Thus, calling pause or resume on a 27774 single element will cause any calls that containt tweens for that element to be paused/resumed 27775 as well. */ 27776 27777 /* Iterate through all calls and pause any that contain any of our elements */ 27778 $.each(Velocity.State.calls, function(i, activeCall) { 27779 27780 var found = false; 27781 /* Inactive calls are set to false by the logic inside completeCall(). Skip them. */ 27782 if (activeCall) { 27783 /* Iterate through the active call's targeted elements. */ 27784 $.each(activeCall[1], function(k, activeElement) { 27785 var queueName = (options === undefined) ? "" : options; 27786 27787 if (queueName !== true && (activeCall[2].queue !== queueName) && !(options === undefined && activeCall[2].queue === false)) { 27788 return true; 27789 } 27790 27791 /* Iterate through the calls targeted by the stop command. */ 27792 $.each(elements, function(l, element) { 27793 /* Check that this call was applied to the target element. */ 27794 if (element === activeElement) { 27795 27796 /* Set call to paused */ 27797 activeCall[5] = { 27798 resume: false 27799 }; 27800 27801 /* Once we match an element, we can bounce out to the next call entirely */ 27802 found = true; 27803 return false; 27804 } 27805 }); 27806 27807 /* Proceed to check next call if we have already matched */ 27808 if (found) { 27809 return false; 27810 } 27811 }); 27812 } 27813 27814 }); 27815 27816 /* Since pause creates no new tweens, exit out of Velocity. */ 27817 return getChain(); 27818 27819 case "resume": 27820 27821 /******************* 27822 Action: Resume 27823 *******************/ 27824 27825 /* Handle delay timers */ 27826 $.each(elements, function(i, element) { 27827 resumeDelayOnElement(element, currentTime); 27828 }); 27829 27830 /* Pause and Resume are call-wide (not on a per elemnt basis). Thus, calling pause or resume on a 27831 single element will cause any calls that containt tweens for that element to be paused/resumed 27832 as well. */ 27833 27834 /* Iterate through all calls and pause any that contain any of our elements */ 27835 $.each(Velocity.State.calls, function(i, activeCall) { 27836 var found = false; 27837 /* Inactive calls are set to false by the logic inside completeCall(). Skip them. */ 27838 if (activeCall) { 27839 /* Iterate through the active call's targeted elements. */ 27840 $.each(activeCall[1], function(k, activeElement) { 27841 var queueName = (options === undefined) ? "" : options; 27842 27843 if (queueName !== true && (activeCall[2].queue !== queueName) && !(options === undefined && activeCall[2].queue === false)) { 27844 return true; 27845 } 27846 27847 /* Skip any calls that have never been paused */ 27848 if (!activeCall[5]) { 27849 return true; 27850 } 27851 27852 /* Iterate through the calls targeted by the stop command. */ 27853 $.each(elements, function(l, element) { 27854 /* Check that this call was applied to the target element. */ 27855 if (element === activeElement) { 27856 27857 /* Flag a pause object to be resumed, which will occur during the next tick. In 27858 addition, the pause object will at that time be deleted */ 27859 activeCall[5].resume = true; 27860 27861 /* Once we match an element, we can bounce out to the next call entirely */ 27862 found = true; 27863 return false; 27864 } 27865 }); 27866 27867 /* Proceed to check next call if we have already matched */ 27868 if (found) { 27869 return false; 27870 } 27871 }); 27872 } 27873 27874 }); 27875 27876 /* Since resume creates no new tweens, exit out of Velocity. */ 27877 return getChain(); 27878 27879 case "finish": 27880 case "finishAll": 27881 case "stop": 27882 /******************* 27883 Action: Stop 27884 *******************/ 27885 27886 /* Clear the currently-active delay on each targeted element. */ 27887 $.each(elements, function(i, element) { 27888 if (Data(element) && Data(element).delayTimer) { 27889 /* Stop the timer from triggering its cached next() function. */ 27890 clearTimeout(Data(element).delayTimer.setTimeout); 27891 27892 /* Manually call the next() function so that the subsequent queue items can progress. */ 27893 if (Data(element).delayTimer.next) { 27894 Data(element).delayTimer.next(); 27895 } 27896 27897 delete Data(element).delayTimer; 27898 } 27899 27900 /* If we want to finish everything in the queue, we have to iterate through it 27901 and call each function. This will make them active calls below, which will 27902 cause them to be applied via the duration setting. */ 27903 if (propertiesMap === "finishAll" && (options === true || Type.isString(options))) { 27904 /* Iterate through the items in the element's queue. */ 27905 $.each($.queue(element, Type.isString(options) ? options : ""), function(_, item) { 27906 /* The queue array can contain an "inprogress" string, which we skip. */ 27907 if (Type.isFunction(item)) { 27908 item(); 27909 } 27910 }); 27911 27912 /* Clearing the $.queue() array is achieved by resetting it to []. */ 27913 $.queue(element, Type.isString(options) ? options : "", []); 27914 } 27915 }); 27916 27917 var callsToStop = []; 27918 27919 /* When the stop action is triggered, the elements' currently active call is immediately stopped. The active call might have 27920 been applied to multiple elements, in which case all of the call's elements will be stopped. When an element 27921 is stopped, the next item in its animation queue is immediately triggered. */ 27922 /* An additional argument may be passed in to clear an element's remaining queued calls. Either true (which defaults to the "fx" queue) 27923 or a custom queue string can be passed in. */ 27924 /* Note: The stop command runs prior to Velocity's Queueing phase since its behavior is intended to take effect *immediately*, 27925 regardless of the element's current queue state. */ 27926 27927 /* Iterate through every active call. */ 27928 $.each(Velocity.State.calls, function(i, activeCall) { 27929 /* Inactive calls are set to false by the logic inside completeCall(). Skip them. */ 27930 if (activeCall) { 27931 /* Iterate through the active call's targeted elements. */ 27932 $.each(activeCall[1], function(k, activeElement) { 27933 /* If true was passed in as a secondary argument, clear absolutely all calls on this element. Otherwise, only 27934 clear calls associated with the relevant queue. */ 27935 /* Call stopping logic works as follows: 27936 - options === true --> stop current default queue calls (and queue:false calls), including remaining queued ones. 27937 - options === undefined --> stop current queue:"" call and all queue:false calls. 27938 - options === false --> stop only queue:false calls. 27939 - options === "custom" --> stop current queue:"custom" call, including remaining queued ones (there is no functionality to only clear the currently-running queue:"custom" call). */ 27940 var queueName = (options === undefined) ? "" : options; 27941 27942 if (queueName !== true && (activeCall[2].queue !== queueName) && !(options === undefined && activeCall[2].queue === false)) { 27943 return true; 27944 } 27945 27946 /* Iterate through the calls targeted by the stop command. */ 27947 $.each(elements, function(l, element) { 27948 /* Check that this call was applied to the target element. */ 27949 if (element === activeElement) { 27950 /* Optionally clear the remaining queued calls. If we're doing "finishAll" this won't find anything, 27951 due to the queue-clearing above. */ 27952 if (options === true || Type.isString(options)) { 27953 /* Iterate through the items in the element's queue. */ 27954 $.each($.queue(element, Type.isString(options) ? options : ""), function(_, item) { 27955 /* The queue array can contain an "inprogress" string, which we skip. */ 27956 if (Type.isFunction(item)) { 27957 /* Pass the item's callback a flag indicating that we want to abort from the queue call. 27958 (Specifically, the queue will resolve the call's associated promise then abort.) */ 27959 item(null, true); 27960 } 27961 }); 27962 27963 /* Clearing the $.queue() array is achieved by resetting it to []. */ 27964 $.queue(element, Type.isString(options) ? options : "", []); 27965 } 27966 27967 if (propertiesMap === "stop") { 27968 /* Since "reverse" uses cached start values (the previous call's endValues), these values must be 27969 changed to reflect the final value that the elements were actually tweened to. */ 27970 /* Note: If only queue:false animations are currently running on an element, it won't have a tweensContainer 27971 object. Also, queue:false animations can't be reversed. */ 27972 var data = Data(element); 27973 if (data && data.tweensContainer && queueName !== false) { 27974 $.each(data.tweensContainer, function(m, activeTween) { 27975 activeTween.endValue = activeTween.currentValue; 27976 }); 27977 } 27978 27979 callsToStop.push(i); 27980 } else if (propertiesMap === "finish" || propertiesMap === "finishAll") { 27981 /* To get active tweens to finish immediately, we forcefully shorten their durations to 1ms so that 27982 they finish upon the next rAf tick then proceed with normal call completion logic. */ 27983 activeCall[2].duration = 1; 27984 } 27985 } 27986 }); 27987 }); 27988 } 27989 }); 27990 27991 /* Prematurely call completeCall() on each matched active call. Pass an additional flag for "stop" to indicate 27992 that the complete callback and display:none setting should be skipped since we're completing prematurely. */ 27993 if (propertiesMap === "stop") { 27994 $.each(callsToStop, function(i, j) { 27995 completeCall(j, true); 27996 }); 27997 27998 if (promiseData.promise) { 27999 /* Immediately resolve the promise associated with this stop call since stop runs synchronously. */ 28000 promiseData.resolver(elements); 28001 } 28002 } 28003 28004 /* Since we're stopping, and not proceeding with queueing, exit out of Velocity. */ 28005 return getChain(); 28006 28007 default: 28008 /* Treat a non-empty plain object as a literal properties map. */ 28009 if ($.isPlainObject(propertiesMap) && !Type.isEmptyObject(propertiesMap)) { 28010 action = "start"; 28011 28012 /**************** 28013 Redirects 28014 ****************/ 28015 28016 /* Check if a string matches a registered redirect (see Redirects above). */ 28017 } else if (Type.isString(propertiesMap) && Velocity.Redirects[propertiesMap]) { 28018 opts = $.extend({}, options); 28019 28020 var durationOriginal = opts.duration, 28021 delayOriginal = opts.delay || 0; 28022 28023 /* If the backwards option was passed in, reverse the element set so that elements animate from the last to the first. */ 28024 if (opts.backwards === true) { 28025 elements = $.extend(true, [], elements).reverse(); 28026 } 28027 28028 /* Individually trigger the redirect for each element in the set to prevent users from having to handle iteration logic in their redirect. */ 28029 $.each(elements, function(elementIndex, element) { 28030 /* If the stagger option was passed in, successively delay each element by the stagger value (in ms). Retain the original delay value. */ 28031 if (parseFloat(opts.stagger)) { 28032 opts.delay = delayOriginal + (parseFloat(opts.stagger) * elementIndex); 28033 } else if (Type.isFunction(opts.stagger)) { 28034 opts.delay = delayOriginal + opts.stagger.call(element, elementIndex, elementsLength); 28035 } 28036 28037 /* If the drag option was passed in, successively increase/decrease (depending on the presense of opts.backwards) 28038 the duration of each element's animation, using floors to prevent producing very short durations. */ 28039 if (opts.drag) { 28040 /* Default the duration of UI pack effects (callouts and transitions) to 1000ms instead of the usual default duration of 400ms. */ 28041 opts.duration = parseFloat(durationOriginal) || (/^(callout|transition)/.test(propertiesMap) ? 1000 : DURATION_DEFAULT); 28042 28043 /* For each element, take the greater duration of: A) animation completion percentage relative to the original duration, 28044 B) 75% of the original duration, or C) a 200ms fallback (in case duration is already set to a low value). 28045 The end result is a baseline of 75% of the redirect's duration that increases/decreases as the end of the element set is approached. */ 28046 opts.duration = Math.max(opts.duration * (opts.backwards ? 1 - elementIndex / elementsLength : (elementIndex + 1) / elementsLength), opts.duration * 0.75, 200); 28047 } 28048 28049 /* Pass in the call's opts object so that the redirect can optionally extend it. It defaults to an empty object instead of null to 28050 reduce the opts checking logic required inside the redirect. */ 28051 Velocity.Redirects[propertiesMap].call(element, element, opts || {}, elementIndex, elementsLength, elements, promiseData.promise ? promiseData : undefined); 28052 }); 28053 28054 /* Since the animation logic resides within the redirect's own code, abort the remainder of this call. 28055 (The performance overhead up to this point is virtually non-existant.) */ 28056 /* Note: The jQuery call chain is kept intact by returning the complete element set. */ 28057 return getChain(); 28058 } else { 28059 var abortError = "Velocity: First argument (" + propertiesMap + ") was not a property map, a known action, or a registered redirect. Aborting."; 28060 28061 if (promiseData.promise) { 28062 promiseData.rejecter(new Error(abortError)); 28063 } else { 28064 console.log(abortError); 28065 } 28066 28067 return getChain(); 28068 } 28069 } 28070 28071 /************************** 28072 Call-Wide Variables 28073 **************************/ 28074 28075 /* A container for CSS unit conversion ratios (e.g. %, rem, and em ==> px) that is used to cache ratios across all elements 28076 being animated in a single Velocity call. Calculating unit ratios necessitates DOM querying and updating, and is therefore 28077 avoided (via caching) wherever possible. This container is call-wide instead of page-wide to avoid the risk of using stale 28078 conversion metrics across Velocity animations that are not immediately consecutively chained. */ 28079 var callUnitConversionData = { 28080 lastParent: null, 28081 lastPosition: null, 28082 lastFontSize: null, 28083 lastPercentToPxWidth: null, 28084 lastPercentToPxHeight: null, 28085 lastEmToPx: null, 28086 remToPx: null, 28087 vwToPx: null, 28088 vhToPx: null 28089 }; 28090 28091 /* A container for all the ensuing tween data and metadata associated with this call. This container gets pushed to the page-wide 28092 Velocity.State.calls array that is processed during animation ticking. */ 28093 var call = []; 28094 28095 /************************ 28096 Element Processing 28097 ************************/ 28098 28099 /* Element processing consists of three parts -- data processing that cannot go stale and data processing that *can* go stale (i.e. third-party style modifications): 28100 1) Pre-Queueing: Element-wide variables, including the element's data storage, are instantiated. Call options are prepared. If triggered, the Stop action is executed. 28101 2) Queueing: The logic that runs once this call has reached its point of execution in the element's $.queue() stack. Most logic is placed here to avoid risking it becoming stale. 28102 3) Pushing: Consolidation of the tween data followed by its push onto the global in-progress calls container. 28103 `elementArrayIndex` allows passing index of the element in the original array to value functions. 28104 If `elementsIndex` were used instead the index would be determined by the elements' per-element queue. 28105 */ 28106 function processElement(element, elementArrayIndex) { 28107 28108 /************************* 28109 Part I: Pre-Queueing 28110 *************************/ 28111 28112 /*************************** 28113 Element-Wide Variables 28114 ***************************/ 28115 28116 var /* The runtime opts object is the extension of the current call's options and Velocity's page-wide option defaults. */ 28117 opts = $.extend({}, Velocity.defaults, options), 28118 /* A container for the processed data associated with each property in the propertyMap. 28119 (Each property in the map produces its own "tween".) */ 28120 tweensContainer = {}, 28121 elementUnitConversionData; 28122 28123 /****************** 28124 Element Init 28125 ******************/ 28126 28127 if (Data(element) === undefined) { 28128 Velocity.init(element); 28129 } 28130 28131 /****************** 28132 Option: Delay 28133 ******************/ 28134 28135 /* Since queue:false doesn't respect the item's existing queue, we avoid injecting its delay here (it's set later on). */ 28136 /* Note: Velocity rolls its own delay function since jQuery doesn't have a utility alias for $.fn.delay() 28137 (and thus requires jQuery element creation, which we avoid since its overhead includes DOM querying). */ 28138 if (parseFloat(opts.delay) && opts.queue !== false) { 28139 $.queue(element, opts.queue, function(next) { 28140 /* This is a flag used to indicate to the upcoming completeCall() function that this queue entry was initiated by Velocity. See completeCall() for further details. */ 28141 Velocity.velocityQueueEntryFlag = true; 28142 28143 /* The ensuing queue item (which is assigned to the "next" argument that $.queue() automatically passes in) will be triggered after a setTimeout delay. 28144 The setTimeout is stored so that it can be subjected to clearTimeout() if this animation is prematurely stopped via Velocity's "stop" command, and 28145 delayBegin/delayTime is used to ensure we can "pause" and "resume" a tween that is still mid-delay. */ 28146 28147 /* Temporarily store delayed elements to facilite access for global pause/resume */ 28148 var callIndex = Velocity.State.delayedElements.count++; 28149 Velocity.State.delayedElements[callIndex] = element; 28150 28151 var delayComplete = (function(index) { 28152 return function() { 28153 /* Clear the temporary element */ 28154 Velocity.State.delayedElements[index] = false; 28155 28156 /* Finally, issue the call */ 28157 next(); 28158 }; 28159 })(callIndex); 28160 28161 28162 Data(element).delayBegin = (new Date()).getTime(); 28163 Data(element).delay = parseFloat(opts.delay); 28164 Data(element).delayTimer = { 28165 setTimeout: setTimeout(next, parseFloat(opts.delay)), 28166 next: delayComplete 28167 }; 28168 }); 28169 } 28170 28171 /********************* 28172 Option: Duration 28173 *********************/ 28174 28175 /* Support for jQuery's named durations. */ 28176 switch (opts.duration.toString().toLowerCase()) { 28177 case "fast": 28178 opts.duration = 200; 28179 break; 28180 28181 case "normal": 28182 opts.duration = DURATION_DEFAULT; 28183 break; 28184 28185 case "slow": 28186 opts.duration = 600; 28187 break; 28188 28189 default: 28190 /* Remove the potential "ms" suffix and default to 1 if the user is attempting to set a duration of 0 (in order to produce an immediate style change). */ 28191 opts.duration = parseFloat(opts.duration) || 1; 28192 } 28193 28194 /************************ 28195 Global Option: Mock 28196 ************************/ 28197 28198 if (Velocity.mock !== false) { 28199 /* In mock mode, all animations are forced to 1ms so that they occur immediately upon the next rAF tick. 28200 Alternatively, a multiplier can be passed in to time remap all delays and durations. */ 28201 if (Velocity.mock === true) { 28202 opts.duration = opts.delay = 1; 28203 } else { 28204 opts.duration *= parseFloat(Velocity.mock) || 1; 28205 opts.delay *= parseFloat(Velocity.mock) || 1; 28206 } 28207 } 28208 28209 /******************* 28210 Option: Easing 28211 *******************/ 28212 28213 opts.easing = getEasing(opts.easing, opts.duration); 28214 28215 /********************** 28216 Option: Callbacks 28217 **********************/ 28218 28219 /* Callbacks must functions. Otherwise, default to null. */ 28220 if (opts.begin && !Type.isFunction(opts.begin)) { 28221 opts.begin = null; 28222 } 28223 28224 if (opts.progress && !Type.isFunction(opts.progress)) { 28225 opts.progress = null; 28226 } 28227 28228 if (opts.complete && !Type.isFunction(opts.complete)) { 28229 opts.complete = null; 28230 } 28231 28232 /********************************* 28233 Option: Display & Visibility 28234 *********************************/ 28235 28236 /* Refer to Velocity's documentation (VelocityJS.org/#displayAndVisibility) for a description of the display and visibility options' behavior. */ 28237 /* Note: We strictly check for undefined instead of falsiness because display accepts an empty string value. */ 28238 if (opts.display !== undefined && opts.display !== null) { 28239 opts.display = opts.display.toString().toLowerCase(); 28240 28241 /* Users can pass in a special "auto" value to instruct Velocity to set the element to its default display value. */ 28242 if (opts.display === "auto") { 28243 opts.display = Velocity.CSS.Values.getDisplayType(element); 28244 } 28245 } 28246 28247 if (opts.visibility !== undefined && opts.visibility !== null) { 28248 opts.visibility = opts.visibility.toString().toLowerCase(); 28249 } 28250 28251 /********************** 28252 Option: mobileHA 28253 **********************/ 28254 28255 /* When set to true, and if this is a mobile device, mobileHA automatically enables hardware acceleration (via a null transform hack) 28256 on animating elements. HA is removed from the element at the completion of its animation. */ 28257 /* Note: Android Gingerbread doesn't support HA. If a null transform hack (mobileHA) is in fact set, it will prevent other tranform subproperties from taking effect. */ 28258 /* Note: You can read more about the use of mobileHA in Velocity's documentation: VelocityJS.org/#mobileHA. */ 28259 opts.mobileHA = (opts.mobileHA && Velocity.State.isMobile && !Velocity.State.isGingerbread); 28260 28261 /*********************** 28262 Part II: Queueing 28263 ***********************/ 28264 28265 /* When a set of elements is targeted by a Velocity call, the set is broken up and each element has the current Velocity call individually queued onto it. 28266 In this way, each element's existing queue is respected; some elements may already be animating and accordingly should not have this current Velocity call triggered immediately. */ 28267 /* In each queue, tween data is processed for each animating property then pushed onto the call-wide calls array. When the last element in the set has had its tweens processed, 28268 the call array is pushed to Velocity.State.calls for live processing by the requestAnimationFrame tick. */ 28269 function buildQueue(next) { 28270 var data, lastTweensContainer; 28271 28272 /******************* 28273 Option: Begin 28274 *******************/ 28275 28276 /* The begin callback is fired once per call -- not once per elemenet -- and is passed the full raw DOM element set as both its context and its first argument. */ 28277 if (opts.begin && elementsIndex === 0) { 28278 /* We throw callbacks in a setTimeout so that thrown errors don't halt the execution of Velocity itself. */ 28279 try { 28280 opts.begin.call(elements, elements); 28281 } catch (error) { 28282 setTimeout(function() { 28283 throw error; 28284 }, 1); 28285 } 28286 } 28287 28288 /***************************************** 28289 Tween Data Construction (for Scroll) 28290 *****************************************/ 28291 28292 /* Note: In order to be subjected to chaining and animation options, scroll's tweening is routed through Velocity as if it were a standard CSS property animation. */ 28293 if (action === "scroll") { 28294 /* The scroll action uniquely takes an optional "offset" option -- specified in pixels -- that offsets the targeted scroll position. */ 28295 var scrollDirection = (/^x$/i.test(opts.axis) ? "Left" : "Top"), 28296 scrollOffset = parseFloat(opts.offset) || 0, 28297 scrollPositionCurrent, 28298 scrollPositionCurrentAlternate, 28299 scrollPositionEnd; 28300 28301 /* Scroll also uniquely takes an optional "container" option, which indicates the parent element that should be scrolled -- 28302 as opposed to the browser window itself. This is useful for scrolling toward an element that's inside an overflowing parent element. */ 28303 if (opts.container) { 28304 /* Ensure that either a jQuery object or a raw DOM element was passed in. */ 28305 if (Type.isWrapped(opts.container) || Type.isNode(opts.container)) { 28306 /* Extract the raw DOM element from the jQuery wrapper. */ 28307 opts.container = opts.container[0] || opts.container; 28308 /* Note: Unlike other properties in Velocity, the browser's scroll position is never cached since it so frequently changes 28309 (due to the user's natural interaction with the page). */ 28310 scrollPositionCurrent = opts.container["scroll" + scrollDirection]; /* GET */ 28311 28312 /* $.position() values are relative to the container's currently viewable area (without taking into account the container's true dimensions 28313 -- say, for example, if the container was not overflowing). Thus, the scroll end value is the sum of the child element's position *and* 28314 the scroll container's current scroll position. */ 28315 scrollPositionEnd = (scrollPositionCurrent + $(element).position()[scrollDirection.toLowerCase()]) + scrollOffset; /* GET */ 28316 /* If a value other than a jQuery object or a raw DOM element was passed in, default to null so that this option is ignored. */ 28317 } else { 28318 opts.container = null; 28319 } 28320 } else { 28321 /* If the window itself is being scrolled -- not a containing element -- perform a live scroll position lookup using 28322 the appropriate cached property names (which differ based on browser type). */ 28323 scrollPositionCurrent = Velocity.State.scrollAnchor[Velocity.State["scrollProperty" + scrollDirection]]; /* GET */ 28324 /* When scrolling the browser window, cache the alternate axis's current value since window.scrollTo() doesn't let us change only one value at a time. */ 28325 scrollPositionCurrentAlternate = Velocity.State.scrollAnchor[Velocity.State["scrollProperty" + (scrollDirection === "Left" ? "Top" : "Left")]]; /* GET */ 28326 28327 /* Unlike $.position(), $.offset() values are relative to the browser window's true dimensions -- not merely its currently viewable area -- 28328 and therefore end values do not need to be compounded onto current values. */ 28329 scrollPositionEnd = $(element).offset()[scrollDirection.toLowerCase()] + scrollOffset; /* GET */ 28330 } 28331 28332 /* Since there's only one format that scroll's associated tweensContainer can take, we create it manually. */ 28333 tweensContainer = { 28334 scroll: { 28335 rootPropertyValue: false, 28336 startValue: scrollPositionCurrent, 28337 currentValue: scrollPositionCurrent, 28338 endValue: scrollPositionEnd, 28339 unitType: "", 28340 easing: opts.easing, 28341 scrollData: { 28342 container: opts.container, 28343 direction: scrollDirection, 28344 alternateValue: scrollPositionCurrentAlternate 28345 } 28346 }, 28347 element: element 28348 }; 28349 28350 if (Velocity.debug) { 28351 console.log("tweensContainer (scroll): ", tweensContainer.scroll, element); 28352 } 28353 28354 /****************************************** 28355 Tween Data Construction (for Reverse) 28356 ******************************************/ 28357 28358 /* Reverse acts like a "start" action in that a property map is animated toward. The only difference is 28359 that the property map used for reverse is the inverse of the map used in the previous call. Thus, we manipulate 28360 the previous call to construct our new map: use the previous map's end values as our new map's start values. Copy over all other data. */ 28361 /* Note: Reverse can be directly called via the "reverse" parameter, or it can be indirectly triggered via the loop option. (Loops are composed of multiple reverses.) */ 28362 /* Note: Reverse calls do not need to be consecutively chained onto a currently-animating element in order to operate on cached values; 28363 there is no harm to reverse being called on a potentially stale data cache since reverse's behavior is simply defined 28364 as reverting to the element's values as they were prior to the previous *Velocity* call. */ 28365 } else if (action === "reverse") { 28366 data = Data(element); 28367 28368 /* Abort if there is no prior animation data to reverse to. */ 28369 if (!data) { 28370 return; 28371 } 28372 28373 if (!data.tweensContainer) { 28374 /* Dequeue the element so that this queue entry releases itself immediately, allowing subsequent queue entries to run. */ 28375 $.dequeue(element, opts.queue); 28376 28377 return; 28378 } else { 28379 /********************* 28380 Options Parsing 28381 *********************/ 28382 28383 /* If the element was hidden via the display option in the previous call, 28384 revert display to "auto" prior to reversal so that the element is visible again. */ 28385 if (data.opts.display === "none") { 28386 data.opts.display = "auto"; 28387 } 28388 28389 if (data.opts.visibility === "hidden") { 28390 data.opts.visibility = "visible"; 28391 } 28392 28393 /* If the loop option was set in the previous call, disable it so that "reverse" calls aren't recursively generated. 28394 Further, remove the previous call's callback options; typically, users do not want these to be refired. */ 28395 data.opts.loop = false; 28396 data.opts.begin = null; 28397 data.opts.complete = null; 28398 28399 /* Since we're extending an opts object that has already been extended with the defaults options object, 28400 we remove non-explicitly-defined properties that are auto-assigned values. */ 28401 if (!options.easing) { 28402 delete opts.easing; 28403 } 28404 28405 if (!options.duration) { 28406 delete opts.duration; 28407 } 28408 28409 /* The opts object used for reversal is an extension of the options object optionally passed into this 28410 reverse call plus the options used in the previous Velocity call. */ 28411 opts = $.extend({}, data.opts, opts); 28412 28413 /************************************* 28414 Tweens Container Reconstruction 28415 *************************************/ 28416 28417 /* Create a deepy copy (indicated via the true flag) of the previous call's tweensContainer. */ 28418 lastTweensContainer = $.extend(true, {}, data ? data.tweensContainer : null); 28419 28420 /* Manipulate the previous tweensContainer by replacing its end values and currentValues with its start values. */ 28421 for (var lastTween in lastTweensContainer) { 28422 /* In addition to tween data, tweensContainers contain an element property that we ignore here. */ 28423 if (lastTweensContainer.hasOwnProperty(lastTween) && lastTween !== "element") { 28424 var lastStartValue = lastTweensContainer[lastTween].startValue; 28425 28426 lastTweensContainer[lastTween].startValue = lastTweensContainer[lastTween].currentValue = lastTweensContainer[lastTween].endValue; 28427 lastTweensContainer[lastTween].endValue = lastStartValue; 28428 28429 /* Easing is the only option that embeds into the individual tween data (since it can be defined on a per-property basis). 28430 Accordingly, every property's easing value must be updated when an options object is passed in with a reverse call. 28431 The side effect of this extensibility is that all per-property easing values are forcefully reset to the new value. */ 28432 if (!Type.isEmptyObject(options)) { 28433 lastTweensContainer[lastTween].easing = opts.easing; 28434 } 28435 28436 if (Velocity.debug) { 28437 console.log("reverse tweensContainer (" + lastTween + "): " + JSON.stringify(lastTweensContainer[lastTween]), element); 28438 } 28439 } 28440 } 28441 28442 tweensContainer = lastTweensContainer; 28443 } 28444 28445 /***************************************** 28446 Tween Data Construction (for Start) 28447 *****************************************/ 28448 28449 } else if (action === "start") { 28450 28451 /************************* 28452 Value Transferring 28453 *************************/ 28454 28455 /* If this queue entry follows a previous Velocity-initiated queue entry *and* if this entry was created 28456 while the element was in the process of being animated by Velocity, then this current call is safe to use 28457 the end values from the prior call as its start values. Velocity attempts to perform this value transfer 28458 process whenever possible in order to avoid requerying the DOM. */ 28459 /* If values aren't transferred from a prior call and start values were not forcefed by the user (more on this below), 28460 then the DOM is queried for the element's current values as a last resort. */ 28461 /* Note: Conversely, animation reversal (and looping) *always* perform inter-call value transfers; they never requery the DOM. */ 28462 28463 data = Data(element); 28464 28465 /* The per-element isAnimating flag is used to indicate whether it's safe (i.e. the data isn't stale) 28466 to transfer over end values to use as start values. If it's set to true and there is a previous 28467 Velocity call to pull values from, do so. */ 28468 if (data && data.tweensContainer && data.isAnimating === true) { 28469 lastTweensContainer = data.tweensContainer; 28470 } 28471 28472 /*************************** 28473 Tween Data Calculation 28474 ***************************/ 28475 28476 /* This function parses property data and defaults endValue, easing, and startValue as appropriate. */ 28477 /* Property map values can either take the form of 1) a single value representing the end value, 28478 or 2) an array in the form of [ endValue, [, easing] [, startValue] ]. 28479 The optional third parameter is a forcefed startValue to be used instead of querying the DOM for 28480 the element's current value. Read Velocity's docmentation to learn more about forcefeeding: VelocityJS.org/#forcefeeding */ 28481 var parsePropertyValue = function(valueData, skipResolvingEasing) { 28482 var endValue, easing, startValue; 28483 28484 /* If we have a function as the main argument then resolve it first, in case it returns an array that needs to be split */ 28485 if (Type.isFunction(valueData)) { 28486 valueData = valueData.call(element, elementArrayIndex, elementsLength); 28487 } 28488 28489 /* Handle the array format, which can be structured as one of three potential overloads: 28490 A) [ endValue, easing, startValue ], B) [ endValue, easing ], or C) [ endValue, startValue ] */ 28491 if (Type.isArray(valueData)) { 28492 /* endValue is always the first item in the array. Don't bother validating endValue's value now 28493 since the ensuing property cycling logic does that. */ 28494 endValue = valueData[0]; 28495 28496 /* Two-item array format: If the second item is a number, function, or hex string, treat it as a 28497 start value since easings can only be non-hex strings or arrays. */ 28498 if ((!Type.isArray(valueData[1]) && /^[\d-]/.test(valueData[1])) || Type.isFunction(valueData[1]) || CSS.RegEx.isHex.test(valueData[1])) { 28499 startValue = valueData[1]; 28500 /* Two or three-item array: If the second item is a non-hex string easing name or an array, treat it as an easing. */ 28501 } else if ((Type.isString(valueData[1]) && !CSS.RegEx.isHex.test(valueData[1]) && Velocity.Easings[valueData[1]]) || Type.isArray(valueData[1])) { 28502 easing = skipResolvingEasing ? valueData[1] : getEasing(valueData[1], opts.duration); 28503 28504 /* Don't bother validating startValue's value now since the ensuing property cycling logic inherently does that. */ 28505 startValue = valueData[2]; 28506 } else { 28507 startValue = valueData[1] || valueData[2]; 28508 } 28509 /* Handle the single-value format. */ 28510 } else { 28511 endValue = valueData; 28512 } 28513 28514 /* Default to the call's easing if a per-property easing type was not defined. */ 28515 if (!skipResolvingEasing) { 28516 easing = easing || opts.easing; 28517 } 28518 28519 /* If functions were passed in as values, pass the function the current element as its context, 28520 plus the element's index and the element set's size as arguments. Then, assign the returned value. */ 28521 if (Type.isFunction(endValue)) { 28522 endValue = endValue.call(element, elementArrayIndex, elementsLength); 28523 } 28524 28525 if (Type.isFunction(startValue)) { 28526 startValue = startValue.call(element, elementArrayIndex, elementsLength); 28527 } 28528 28529 /* Allow startValue to be left as undefined to indicate to the ensuing code that its value was not forcefed. */ 28530 return [endValue || 0, easing, startValue]; 28531 }; 28532 28533 var fixPropertyValue = function(property, valueData) { 28534 /* In case this property is a hook, there are circumstances where we will intend to work on the hook's root property and not the hooked subproperty. */ 28535 var rootProperty = CSS.Hooks.getRoot(property), 28536 rootPropertyValue = false, 28537 /* Parse out endValue, easing, and startValue from the property's data. */ 28538 endValue = valueData[0], 28539 easing = valueData[1], 28540 startValue = valueData[2], 28541 pattern; 28542 28543 /************************** 28544 Start Value Sourcing 28545 **************************/ 28546 28547 /* Other than for the dummy tween property, properties that are not supported by the browser (and do not have an associated normalization) will 28548 inherently produce no style changes when set, so they are skipped in order to decrease animation tick overhead. 28549 Property support is determined via prefixCheck(), which returns a false flag when no supported is detected. */ 28550 /* Note: Since SVG elements have some of their properties directly applied as HTML attributes, 28551 there is no way to check for their explicit browser support, and so we skip skip this check for them. */ 28552 if ((!data || !data.isSVG) && rootProperty !== "tween" && CSS.Names.prefixCheck(rootProperty)[1] === false && CSS.Normalizations.registered[rootProperty] === undefined) { 28553 if (Velocity.debug) { 28554 console.log("Skipping [" + rootProperty + "] due to a lack of browser support."); 28555 } 28556 return; 28557 } 28558 28559 /* If the display option is being set to a non-"none" (e.g. "block") and opacity (filter on IE<=8) is being 28560 animated to an endValue of non-zero, the user's intention is to fade in from invisible, thus we forcefeed opacity 28561 a startValue of 0 if its startValue hasn't already been sourced by value transferring or prior forcefeeding. */ 28562 if (((opts.display !== undefined && opts.display !== null && opts.display !== "none") || (opts.visibility !== undefined && opts.visibility !== "hidden")) && /opacity|filter/.test(property) && !startValue && endValue !== 0) { 28563 startValue = 0; 28564 } 28565 28566 /* If values have been transferred from the previous Velocity call, extract the endValue and rootPropertyValue 28567 for all of the current call's properties that were *also* animated in the previous call. */ 28568 /* Note: Value transferring can optionally be disabled by the user via the _cacheValues option. */ 28569 if (opts._cacheValues && lastTweensContainer && lastTweensContainer[property]) { 28570 if (startValue === undefined) { 28571 startValue = lastTweensContainer[property].endValue + lastTweensContainer[property].unitType; 28572 } 28573 28574 /* The previous call's rootPropertyValue is extracted from the element's data cache since that's the 28575 instance of rootPropertyValue that gets freshly updated by the tweening process, whereas the rootPropertyValue 28576 attached to the incoming lastTweensContainer is equal to the root property's value prior to any tweening. */ 28577 rootPropertyValue = data.rootPropertyValueCache[rootProperty]; 28578 /* If values were not transferred from a previous Velocity call, query the DOM as needed. */ 28579 } else { 28580 /* Handle hooked properties. */ 28581 if (CSS.Hooks.registered[property]) { 28582 if (startValue === undefined) { 28583 rootPropertyValue = CSS.getPropertyValue(element, rootProperty); /* GET */ 28584 /* Note: The following getPropertyValue() call does not actually trigger a DOM query; 28585 getPropertyValue() will extract the hook from rootPropertyValue. */ 28586 startValue = CSS.getPropertyValue(element, property, rootPropertyValue); 28587 /* If startValue is already defined via forcefeeding, do not query the DOM for the root property's value; 28588 just grab rootProperty's zero-value template from CSS.Hooks. This overwrites the element's actual 28589 root property value (if one is set), but this is acceptable since the primary reason users forcefeed is 28590 to avoid DOM queries, and thus we likewise avoid querying the DOM for the root property's value. */ 28591 } else { 28592 /* Grab this hook's zero-value template, e.g. "0px 0px 0px black". */ 28593 rootPropertyValue = CSS.Hooks.templates[rootProperty][1]; 28594 } 28595 /* Handle non-hooked properties that haven't already been defined via forcefeeding. */ 28596 } else if (startValue === undefined) { 28597 startValue = CSS.getPropertyValue(element, property); /* GET */ 28598 } 28599 } 28600 28601 /************************** 28602 Value Data Extraction 28603 **************************/ 28604 28605 var separatedValue, 28606 endValueUnitType, 28607 startValueUnitType, 28608 operator = false; 28609 28610 /* Separates a property value into its numeric value and its unit type. */ 28611 var separateValue = function(property, value) { 28612 var unitType, 28613 numericValue; 28614 28615 numericValue = (value || "0") 28616 .toString() 28617 .toLowerCase() 28618 /* Match the unit type at the end of the value. */ 28619 .replace(/[%A-z]+$/, function(match) { 28620 /* Grab the unit type. */ 28621 unitType = match; 28622 28623 /* Strip the unit type off of value. */ 28624 return ""; 28625 }); 28626 28627 /* If no unit type was supplied, assign one that is appropriate for this property (e.g. "deg" for rotateZ or "px" for width). */ 28628 if (!unitType) { 28629 unitType = CSS.Values.getUnitType(property); 28630 } 28631 28632 return [numericValue, unitType]; 28633 }; 28634 28635 if (startValue !== endValue && Type.isString(startValue) && Type.isString(endValue)) { 28636 pattern = ""; 28637 var iStart = 0, // index in startValue 28638 iEnd = 0, // index in endValue 28639 aStart = [], // array of startValue numbers 28640 aEnd = [], // array of endValue numbers 28641 inCalc = 0, // Keep track of being inside a "calc()" so we don't duplicate it 28642 inRGB = 0, // Keep track of being inside an RGB as we can't use fractional values 28643 inRGBA = 0; // Keep track of being inside an RGBA as we must pass fractional for the alpha channel 28644 28645 startValue = CSS.Hooks.fixColors(startValue); 28646 endValue = CSS.Hooks.fixColors(endValue); 28647 while (iStart < startValue.length && iEnd < endValue.length) { 28648 var cStart = startValue[iStart], 28649 cEnd = endValue[iEnd]; 28650 28651 if (/[\d\.]/.test(cStart) && /[\d\.]/.test(cEnd)) { 28652 var tStart = cStart, // temporary character buffer 28653 tEnd = cEnd, // temporary character buffer 28654 dotStart = ".", // Make sure we can only ever match a single dot in a decimal 28655 dotEnd = "."; // Make sure we can only ever match a single dot in a decimal 28656 28657 while (++iStart < startValue.length) { 28658 cStart = startValue[iStart]; 28659 if (cStart === dotStart) { 28660 dotStart = ".."; // Can never match two characters 28661 } else if (!/\d/.test(cStart)) { 28662 break; 28663 } 28664 tStart += cStart; 28665 } 28666 while (++iEnd < endValue.length) { 28667 cEnd = endValue[iEnd]; 28668 if (cEnd === dotEnd) { 28669 dotEnd = ".."; // Can never match two characters 28670 } else if (!/\d/.test(cEnd)) { 28671 break; 28672 } 28673 tEnd += cEnd; 28674 } 28675 var uStart = CSS.Hooks.getUnit(startValue, iStart), // temporary unit type 28676 uEnd = CSS.Hooks.getUnit(endValue, iEnd); // temporary unit type 28677 28678 iStart += uStart.length; 28679 iEnd += uEnd.length; 28680 if (uStart === uEnd) { 28681 // Same units 28682 if (tStart === tEnd) { 28683 // Same numbers, so just copy over 28684 pattern += tStart + uStart; 28685 } else { 28686 // Different numbers, so store them 28687 pattern += "{" + aStart.length + (inRGB ? "!" : "") + "}" + uStart; 28688 aStart.push(parseFloat(tStart)); 28689 aEnd.push(parseFloat(tEnd)); 28690 } 28691 } else { 28692 // Different units, so put into a "calc(from + to)" and animate each side to/from zero 28693 var nStart = parseFloat(tStart), 28694 nEnd = parseFloat(tEnd); 28695 28696 pattern += (inCalc < 5 ? "calc" : "") + "(" 28697 + (nStart ? "{" + aStart.length + (inRGB ? "!" : "") + "}" : "0") + uStart 28698 + " + " 28699 + (nEnd ? "{" + (aStart.length + 1) + (inRGB ? "!" : "") + "}" : "0") + uEnd 28700 + ")"; 28701 if (nStart) { 28702 aStart.push(parseFloat(tStart)); 28703 aStart.push(parseFloat(0)); 28704 } 28705 if (nEnd) { 28706 aEnd.push(parseFloat(0)); 28707 aEnd.push(parseFloat(tEnd)); 28708 } 28709 } 28710 } else if (cStart === cEnd) { 28711 pattern += cStart; 28712 iStart++; 28713 iEnd++; 28714 // Keep track of being inside a calc() 28715 if (inCalc === 0 && cStart === "c" 28716 || inCalc === 1 && cStart === "a" 28717 || inCalc === 2 && cStart === "l" 28718 || inCalc === 3 && cStart === "c" 28719 || inCalc >= 4 && cStart === "(" 28720 ) { 28721 inCalc++; 28722 } else if ((inCalc && inCalc < 5) 28723 || inCalc >= 4 && cStart === ")" && --inCalc < 5) { 28724 inCalc = 0; 28725 } 28726 // Keep track of being inside an rgb() / rgba() 28727 if (inRGB === 0 && cStart === "r" 28728 || inRGB === 1 && cStart === "g" 28729 || inRGB === 2 && cStart === "b" 28730 || inRGB === 3 && cStart === "a" 28731 || inRGB >= 3 && cStart === "(" 28732 ) { 28733 if (inRGB === 3 && cStart === "a") { 28734 inRGBA = 1; 28735 } 28736 inRGB++; 28737 } else if (inRGBA && cStart === ",") { 28738 if (++inRGBA > 3) { 28739 inRGB = inRGBA = 0; 28740 } 28741 } else if ((inRGBA && inRGB < (inRGBA ? 5 : 4)) 28742 || inRGB >= (inRGBA ? 4 : 3) && cStart === ")" && --inRGB < (inRGBA ? 5 : 4)) { 28743 inRGB = inRGBA = 0; 28744 } 28745 } else { 28746 inCalc = 0; 28747 // TODO: changing units, fixing colours 28748 break; 28749 } 28750 } 28751 if (iStart !== startValue.length || iEnd !== endValue.length) { 28752 if (Velocity.debug) { 28753 console.error("Trying to pattern match mis-matched strings [\"" + endValue + "\", \"" + startValue + "\"]"); 28754 } 28755 pattern = undefined; 28756 } 28757 if (pattern) { 28758 if (aStart.length) { 28759 if (Velocity.debug) { 28760 console.log("Pattern found \"" + pattern + "\" -> ", aStart, aEnd, "[" + startValue + "," + endValue + "]"); 28761 } 28762 startValue = aStart; 28763 endValue = aEnd; 28764 endValueUnitType = startValueUnitType = ""; 28765 } else { 28766 pattern = undefined; 28767 } 28768 } 28769 } 28770 28771 if (!pattern) { 28772 /* Separate startValue. */ 28773 separatedValue = separateValue(property, startValue); 28774 startValue = separatedValue[0]; 28775 startValueUnitType = separatedValue[1]; 28776 28777 /* Separate endValue, and extract a value operator (e.g. "+=", "-=") if one exists. */ 28778 separatedValue = separateValue(property, endValue); 28779 endValue = separatedValue[0].replace(/^([+-\/*])=/, function(match, subMatch) { 28780 operator = subMatch; 28781 28782 /* Strip the operator off of the value. */ 28783 return ""; 28784 }); 28785 endValueUnitType = separatedValue[1]; 28786 28787 /* Parse float values from endValue and startValue. Default to 0 if NaN is returned. */ 28788 startValue = parseFloat(startValue) || 0; 28789 endValue = parseFloat(endValue) || 0; 28790 28791 /*************************************** 28792 Property-Specific Value Conversion 28793 ***************************************/ 28794 28795 /* Custom support for properties that don't actually accept the % unit type, but where pollyfilling is trivial and relatively foolproof. */ 28796 if (endValueUnitType === "%") { 28797 /* A %-value fontSize/lineHeight is relative to the parent's fontSize (as opposed to the parent's dimensions), 28798 which is identical to the em unit's behavior, so we piggyback off of that. */ 28799 if (/^(fontSize|lineHeight)$/.test(property)) { 28800 /* Convert % into an em decimal value. */ 28801 endValue = endValue / 100; 28802 endValueUnitType = "em"; 28803 /* For scaleX and scaleY, convert the value into its decimal format and strip off the unit type. */ 28804 } else if (/^scale/.test(property)) { 28805 endValue = endValue / 100; 28806 endValueUnitType = ""; 28807 /* For RGB components, take the defined percentage of 255 and strip off the unit type. */ 28808 } else if (/(Red|Green|Blue)$/i.test(property)) { 28809 endValue = (endValue / 100) * 255; 28810 endValueUnitType = ""; 28811 } 28812 } 28813 } 28814 28815 /*************************** 28816 Unit Ratio Calculation 28817 ***************************/ 28818 28819 /* When queried, the browser returns (most) CSS property values in pixels. Therefore, if an endValue with a unit type of 28820 %, em, or rem is animated toward, startValue must be converted from pixels into the same unit type as endValue in order 28821 for value manipulation logic (increment/decrement) to proceed. Further, if the startValue was forcefed or transferred 28822 from a previous call, startValue may also not be in pixels. Unit conversion logic therefore consists of two steps: 28823 1) Calculating the ratio of %/em/rem/vh/vw relative to pixels 28824 2) Converting startValue into the same unit of measurement as endValue based on these ratios. */ 28825 /* Unit conversion ratios are calculated by inserting a sibling node next to the target node, copying over its position property, 28826 setting values with the target unit type then comparing the returned pixel value. */ 28827 /* Note: Even if only one of these unit types is being animated, all unit ratios are calculated at once since the overhead 28828 of batching the SETs and GETs together upfront outweights the potential overhead 28829 of layout thrashing caused by re-querying for uncalculated ratios for subsequently-processed properties. */ 28830 /* Todo: Shift this logic into the calls' first tick instance so that it's synced with RAF. */ 28831 var calculateUnitRatios = function() { 28832 28833 /************************ 28834 Same Ratio Checks 28835 ************************/ 28836 28837 /* The properties below are used to determine whether the element differs sufficiently from this call's 28838 previously iterated element to also differ in its unit conversion ratios. If the properties match up with those 28839 of the prior element, the prior element's conversion ratios are used. Like most optimizations in Velocity, 28840 this is done to minimize DOM querying. */ 28841 var sameRatioIndicators = { 28842 myParent: element.parentNode || document.body, /* GET */ 28843 position: CSS.getPropertyValue(element, "position"), /* GET */ 28844 fontSize: CSS.getPropertyValue(element, "fontSize") /* GET */ 28845 }, 28846 /* Determine if the same % ratio can be used. % is based on the element's position value and its parent's width and height dimensions. */ 28847 samePercentRatio = ((sameRatioIndicators.position === callUnitConversionData.lastPosition) && (sameRatioIndicators.myParent === callUnitConversionData.lastParent)), 28848 /* Determine if the same em ratio can be used. em is relative to the element's fontSize. */ 28849 sameEmRatio = (sameRatioIndicators.fontSize === callUnitConversionData.lastFontSize); 28850 28851 /* Store these ratio indicators call-wide for the next element to compare against. */ 28852 callUnitConversionData.lastParent = sameRatioIndicators.myParent; 28853 callUnitConversionData.lastPosition = sameRatioIndicators.position; 28854 callUnitConversionData.lastFontSize = sameRatioIndicators.fontSize; 28855 28856 /*************************** 28857 Element-Specific Units 28858 ***************************/ 28859 28860 /* Note: IE8 rounds to the nearest pixel when returning CSS values, thus we perform conversions using a measurement 28861 of 100 (instead of 1) to give our ratios a precision of at least 2 decimal values. */ 28862 var measurement = 100, 28863 unitRatios = {}; 28864 28865 if (!sameEmRatio || !samePercentRatio) { 28866 var dummy = data && data.isSVG ? document.createElementNS("http://www.w3.org/2000/svg", "rect") : document.createElement("div"); 28867 28868 Velocity.init(dummy); 28869 sameRatioIndicators.myParent.appendChild(dummy); 28870 28871 /* To accurately and consistently calculate conversion ratios, the element's cascaded overflow and box-sizing are stripped. 28872 Similarly, since width/height can be artificially constrained by their min-/max- equivalents, these are controlled for as well. */ 28873 /* Note: Overflow must be also be controlled for per-axis since the overflow property overwrites its per-axis values. */ 28874 $.each(["overflow", "overflowX", "overflowY"], function(i, property) { 28875 Velocity.CSS.setPropertyValue(dummy, property, "hidden"); 28876 }); 28877 Velocity.CSS.setPropertyValue(dummy, "position", sameRatioIndicators.position); 28878 Velocity.CSS.setPropertyValue(dummy, "fontSize", sameRatioIndicators.fontSize); 28879 Velocity.CSS.setPropertyValue(dummy, "boxSizing", "content-box"); 28880 28881 /* width and height act as our proxy properties for measuring the horizontal and vertical % ratios. */ 28882 $.each(["minWidth", "maxWidth", "width", "minHeight", "maxHeight", "height"], function(i, property) { 28883 Velocity.CSS.setPropertyValue(dummy, property, measurement + "%"); 28884 }); 28885 /* paddingLeft arbitrarily acts as our proxy property for the em ratio. */ 28886 Velocity.CSS.setPropertyValue(dummy, "paddingLeft", measurement + "em"); 28887 28888 /* Divide the returned value by the measurement to get the ratio between 1% and 1px. Default to 1 since working with 0 can produce Infinite. */ 28889 unitRatios.percentToPxWidth = callUnitConversionData.lastPercentToPxWidth = (parseFloat(CSS.getPropertyValue(dummy, "width", null, true)) || 1) / measurement; /* GET */ 28890 unitRatios.percentToPxHeight = callUnitConversionData.lastPercentToPxHeight = (parseFloat(CSS.getPropertyValue(dummy, "height", null, true)) || 1) / measurement; /* GET */ 28891 unitRatios.emToPx = callUnitConversionData.lastEmToPx = (parseFloat(CSS.getPropertyValue(dummy, "paddingLeft")) || 1) / measurement; /* GET */ 28892 28893 sameRatioIndicators.myParent.removeChild(dummy); 28894 } else { 28895 unitRatios.emToPx = callUnitConversionData.lastEmToPx; 28896 unitRatios.percentToPxWidth = callUnitConversionData.lastPercentToPxWidth; 28897 unitRatios.percentToPxHeight = callUnitConversionData.lastPercentToPxHeight; 28898 } 28899 28900 /*************************** 28901 Element-Agnostic Units 28902 ***************************/ 28903 28904 /* Whereas % and em ratios are determined on a per-element basis, the rem unit only needs to be checked 28905 once per call since it's exclusively dependant upon document.body's fontSize. If this is the first time 28906 that calculateUnitRatios() is being run during this call, remToPx will still be set to its default value of null, 28907 so we calculate it now. */ 28908 if (callUnitConversionData.remToPx === null) { 28909 /* Default to browsers' default fontSize of 16px in the case of 0. */ 28910 callUnitConversionData.remToPx = parseFloat(CSS.getPropertyValue(document.body, "fontSize")) || 16; /* GET */ 28911 } 28912 28913 /* Similarly, viewport units are %-relative to the window's inner dimensions. */ 28914 if (callUnitConversionData.vwToPx === null) { 28915 callUnitConversionData.vwToPx = parseFloat(window.innerWidth) / 100; /* GET */ 28916 callUnitConversionData.vhToPx = parseFloat(window.innerHeight) / 100; /* GET */ 28917 } 28918 28919 unitRatios.remToPx = callUnitConversionData.remToPx; 28920 unitRatios.vwToPx = callUnitConversionData.vwToPx; 28921 unitRatios.vhToPx = callUnitConversionData.vhToPx; 28922 28923 if (Velocity.debug >= 1) { 28924 console.log("Unit ratios: " + JSON.stringify(unitRatios), element); 28925 } 28926 return unitRatios; 28927 }; 28928 28929 /******************** 28930 Unit Conversion 28931 ********************/ 28932 28933 /* The * and / operators, which are not passed in with an associated unit, inherently use startValue's unit. Skip value and unit conversion. */ 28934 if (/[\/*]/.test(operator)) { 28935 endValueUnitType = startValueUnitType; 28936 /* If startValue and endValue differ in unit type, convert startValue into the same unit type as endValue so that if endValueUnitType 28937 is a relative unit (%, em, rem), the values set during tweening will continue to be accurately relative even if the metrics they depend 28938 on are dynamically changing during the course of the animation. Conversely, if we always normalized into px and used px for setting values, the px ratio 28939 would become stale if the original unit being animated toward was relative and the underlying metrics change during the animation. */ 28940 /* Since 0 is 0 in any unit type, no conversion is necessary when startValue is 0 -- we just start at 0 with endValueUnitType. */ 28941 } else if ((startValueUnitType !== endValueUnitType) && startValue !== 0) { 28942 /* Unit conversion is also skipped when endValue is 0, but *startValueUnitType* must be used for tween values to remain accurate. */ 28943 /* Note: Skipping unit conversion here means that if endValueUnitType was originally a relative unit, the animation won't relatively 28944 match the underlying metrics if they change, but this is acceptable since we're animating toward invisibility instead of toward visibility, 28945 which remains past the point of the animation's completion. */ 28946 if (endValue === 0) { 28947 endValueUnitType = startValueUnitType; 28948 } else { 28949 /* By this point, we cannot avoid unit conversion (it's undesirable since it causes layout thrashing). 28950 If we haven't already, we trigger calculateUnitRatios(), which runs once per element per call. */ 28951 elementUnitConversionData = elementUnitConversionData || calculateUnitRatios(); 28952 28953 /* The following RegEx matches CSS properties that have their % values measured relative to the x-axis. */ 28954 /* Note: W3C spec mandates that all of margin and padding's properties (even top and bottom) are %-relative to the *width* of the parent element. */ 28955 var axis = (/margin|padding|left|right|width|text|word|letter/i.test(property) || /X$/.test(property) || property === "x") ? "x" : "y"; 28956 28957 /* In order to avoid generating n^2 bespoke conversion functions, unit conversion is a two-step process: 28958 1) Convert startValue into pixels. 2) Convert this new pixel value into endValue's unit type. */ 28959 switch (startValueUnitType) { 28960 case "%": 28961 /* Note: translateX and translateY are the only properties that are %-relative to an element's own dimensions -- not its parent's dimensions. 28962 Velocity does not include a special conversion process to account for this behavior. Therefore, animating translateX/Y from a % value 28963 to a non-% value will produce an incorrect start value. Fortunately, this sort of cross-unit conversion is rarely done by users in practice. */ 28964 startValue *= (axis === "x" ? elementUnitConversionData.percentToPxWidth : elementUnitConversionData.percentToPxHeight); 28965 break; 28966 28967 case "px": 28968 /* px acts as our midpoint in the unit conversion process; do nothing. */ 28969 break; 28970 28971 default: 28972 startValue *= elementUnitConversionData[startValueUnitType + "ToPx"]; 28973 } 28974 28975 /* Invert the px ratios to convert into to the target unit. */ 28976 switch (endValueUnitType) { 28977 case "%": 28978 startValue *= 1 / (axis === "x" ? elementUnitConversionData.percentToPxWidth : elementUnitConversionData.percentToPxHeight); 28979 break; 28980 28981 case "px": 28982 /* startValue is already in px, do nothing; we're done. */ 28983 break; 28984 28985 default: 28986 startValue *= 1 / elementUnitConversionData[endValueUnitType + "ToPx"]; 28987 } 28988 } 28989 } 28990 28991 /********************* 28992 Relative Values 28993 *********************/ 28994 28995 /* Operator logic must be performed last since it requires unit-normalized start and end values. */ 28996 /* Note: Relative *percent values* do not behave how most people think; while one would expect "+=50%" 28997 to increase the property 1.5x its current value, it in fact increases the percent units in absolute terms: 28998 50 points is added on top of the current % value. */ 28999 switch (operator) { 29000 case "+": 29001 endValue = startValue + endValue; 29002 break; 29003 29004 case "-": 29005 endValue = startValue - endValue; 29006 break; 29007 29008 case "*": 29009 endValue = startValue * endValue; 29010 break; 29011 29012 case "/": 29013 endValue = startValue / endValue; 29014 break; 29015 } 29016 29017 /************************** 29018 tweensContainer Push 29019 **************************/ 29020 29021 /* Construct the per-property tween object, and push it to the element's tweensContainer. */ 29022 tweensContainer[property] = { 29023 rootPropertyValue: rootPropertyValue, 29024 startValue: startValue, 29025 currentValue: startValue, 29026 endValue: endValue, 29027 unitType: endValueUnitType, 29028 easing: easing 29029 }; 29030 if (pattern) { 29031 tweensContainer[property].pattern = pattern; 29032 } 29033 29034 if (Velocity.debug) { 29035 console.log("tweensContainer (" + property + "): " + JSON.stringify(tweensContainer[property]), element); 29036 } 29037 }; 29038 29039 /* Create a tween out of each property, and append its associated data to tweensContainer. */ 29040 for (var property in propertiesMap) { 29041 29042 if (!propertiesMap.hasOwnProperty(property)) { 29043 continue; 29044 } 29045 /* The original property name's format must be used for the parsePropertyValue() lookup, 29046 but we then use its camelCase styling to normalize it for manipulation. */ 29047 var propertyName = CSS.Names.camelCase(property), 29048 valueData = parsePropertyValue(propertiesMap[property]); 29049 29050 /* Find shorthand color properties that have been passed a hex string. */ 29051 /* Would be quicker to use CSS.Lists.colors.includes() if possible */ 29052 if (CSS.Lists.colors.indexOf(propertyName) >= 0) { 29053 /* Parse the value data for each shorthand. */ 29054 var endValue = valueData[0], 29055 easing = valueData[1], 29056 startValue = valueData[2]; 29057 29058 if (CSS.RegEx.isHex.test(endValue)) { 29059 /* Convert the hex strings into their RGB component arrays. */ 29060 var colorComponents = ["Red", "Green", "Blue"], 29061 endValueRGB = CSS.Values.hexToRgb(endValue), 29062 startValueRGB = startValue ? CSS.Values.hexToRgb(startValue) : undefined; 29063 29064 /* Inject the RGB component tweens into propertiesMap. */ 29065 for (var i = 0; i < colorComponents.length; i++) { 29066 var dataArray = [endValueRGB[i]]; 29067 29068 if (easing) { 29069 dataArray.push(easing); 29070 } 29071 29072 if (startValueRGB !== undefined) { 29073 dataArray.push(startValueRGB[i]); 29074 } 29075 29076 fixPropertyValue(propertyName + colorComponents[i], dataArray); 29077 } 29078 /* If we have replaced a shortcut color value then don't update the standard property name */ 29079 continue; 29080 } 29081 } 29082 fixPropertyValue(propertyName, valueData); 29083 } 29084 29085 /* Along with its property data, store a reference to the element itself onto tweensContainer. */ 29086 tweensContainer.element = element; 29087 } 29088 29089 /***************** 29090 Call Push 29091 *****************/ 29092 29093 /* Note: tweensContainer can be empty if all of the properties in this call's property map were skipped due to not 29094 being supported by the browser. The element property is used for checking that the tweensContainer has been appended to. */ 29095 if (tweensContainer.element) { 29096 /* Apply the "velocity-animating" indicator class. */ 29097 CSS.Values.addClass(element, "velocity-animating"); 29098 29099 /* The call array houses the tweensContainers for each element being animated in the current call. */ 29100 call.push(tweensContainer); 29101 29102 data = Data(element); 29103 29104 if (data) { 29105 /* Store the tweensContainer and options if we're working on the default effects queue, so that they can be used by the reverse command. */ 29106 if (opts.queue === "") { 29107 29108 data.tweensContainer = tweensContainer; 29109 data.opts = opts; 29110 } 29111 29112 /* Switch on the element's animating flag. */ 29113 data.isAnimating = true; 29114 } 29115 29116 /* Once the final element in this call's element set has been processed, push the call array onto 29117 Velocity.State.calls for the animation tick to immediately begin processing. */ 29118 if (elementsIndex === elementsLength - 1) { 29119 /* Add the current call plus its associated metadata (the element set and the call's options) onto the global call container. 29120 Anything on this call container is subjected to tick() processing. */ 29121 Velocity.State.calls.push([call, elements, opts, null, promiseData.resolver, null, 0]); 29122 29123 /* If the animation tick isn't running, start it. (Velocity shuts it off when there are no active calls to process.) */ 29124 if (Velocity.State.isTicking === false) { 29125 Velocity.State.isTicking = true; 29126 29127 /* Start the tick loop. */ 29128 tick(); 29129 } 29130 } else { 29131 elementsIndex++; 29132 } 29133 } 29134 } 29135 29136 /* When the queue option is set to false, the call skips the element's queue and fires immediately. */ 29137 if (opts.queue === false) { 29138 /* Since this buildQueue call doesn't respect the element's existing queue (which is where a delay option would have been appended), 29139 we manually inject the delay property here with an explicit setTimeout. */ 29140 if (opts.delay) { 29141 29142 /* Temporarily store delayed elements to facilitate access for global pause/resume */ 29143 var callIndex = Velocity.State.delayedElements.count++; 29144 Velocity.State.delayedElements[callIndex] = element; 29145 29146 var delayComplete = (function(index) { 29147 return function() { 29148 /* Clear the temporary element */ 29149 Velocity.State.delayedElements[index] = false; 29150 29151 /* Finally, issue the call */ 29152 buildQueue(); 29153 }; 29154 })(callIndex); 29155 29156 Data(element).delayBegin = (new Date()).getTime(); 29157 Data(element).delay = parseFloat(opts.delay); 29158 Data(element).delayTimer = { 29159 setTimeout: setTimeout(buildQueue, parseFloat(opts.delay)), 29160 next: delayComplete 29161 }; 29162 } else { 29163 buildQueue(); 29164 } 29165 /* Otherwise, the call undergoes element queueing as normal. */ 29166 /* Note: To interoperate with jQuery, Velocity uses jQuery's own $.queue() stack for queuing logic. */ 29167 } else { 29168 $.queue(element, opts.queue, function(next, clearQueue) { 29169 /* If the clearQueue flag was passed in by the stop command, resolve this call's promise. (Promises can only be resolved once, 29170 so it's fine if this is repeatedly triggered for each element in the associated call.) */ 29171 if (clearQueue === true) { 29172 if (promiseData.promise) { 29173 promiseData.resolver(elements); 29174 } 29175 29176 /* Do not continue with animation queueing. */ 29177 return true; 29178 } 29179 29180 /* This flag indicates to the upcoming completeCall() function that this queue entry was initiated by Velocity. 29181 See completeCall() for further details. */ 29182 Velocity.velocityQueueEntryFlag = true; 29183 29184 buildQueue(next); 29185 }); 29186 } 29187 29188 /********************* 29189 Auto-Dequeuing 29190 *********************/ 29191 29192 /* As per jQuery's $.queue() behavior, to fire the first non-custom-queue entry on an element, the element 29193 must be dequeued if its queue stack consists *solely* of the current call. (This can be determined by checking 29194 for the "inprogress" item that jQuery prepends to active queue stack arrays.) Regardless, whenever the element's 29195 queue is further appended with additional items -- including $.delay()'s or even $.animate() calls, the queue's 29196 first entry is automatically fired. This behavior contrasts that of custom queues, which never auto-fire. */ 29197 /* Note: When an element set is being subjected to a non-parallel Velocity call, the animation will not begin until 29198 each one of the elements in the set has reached the end of its individually pre-existing queue chain. */ 29199 /* Note: Unfortunately, most people don't fully grasp jQuery's powerful, yet quirky, $.queue() function. 29200 Lean more here: http://stackoverflow.com/questions/1058158/can-somebody-explain-jquery-queue-to-me */ 29201 if ((opts.queue === "" || opts.queue === "fx") && $.queue(element)[0] !== "inprogress") { 29202 $.dequeue(element); 29203 } 29204 } 29205 29206 /************************** 29207 Element Set Iteration 29208 **************************/ 29209 29210 /* If the "nodeType" property exists on the elements variable, we're animating a single element. 29211 Place it in an array so that $.each() can iterate over it. */ 29212 $.each(elements, function(i, element) { 29213 /* Ensure each element in a set has a nodeType (is a real element) to avoid throwing errors. */ 29214 if (Type.isNode(element)) { 29215 processElement(element, i); 29216 } 29217 }); 29218 29219 /****************** 29220 Option: Loop 29221 ******************/ 29222 29223 /* The loop option accepts an integer indicating how many times the element should loop between the values in the 29224 current call's properties map and the element's property values prior to this call. */ 29225 /* Note: The loop option's logic is performed here -- after element processing -- because the current call needs 29226 to undergo its queue insertion prior to the loop option generating its series of constituent "reverse" calls, 29227 which chain after the current call. Two reverse calls (two "alternations") constitute one loop. */ 29228 opts = $.extend({}, Velocity.defaults, options); 29229 opts.loop = parseInt(opts.loop, 10); 29230 var reverseCallsCount = (opts.loop * 2) - 1; 29231 29232 if (opts.loop) { 29233 /* Double the loop count to convert it into its appropriate number of "reverse" calls. 29234 Subtract 1 from the resulting value since the current call is included in the total alternation count. */ 29235 for (var x = 0; x < reverseCallsCount; x++) { 29236 /* Since the logic for the reverse action occurs inside Queueing and therefore this call's options object 29237 isn't parsed until then as well, the current call's delay option must be explicitly passed into the reverse 29238 call so that the delay logic that occurs inside *Pre-Queueing* can process it. */ 29239 var reverseOptions = { 29240 delay: opts.delay, 29241 progress: opts.progress 29242 }; 29243 29244 /* If a complete callback was passed into this call, transfer it to the loop redirect's final "reverse" call 29245 so that it's triggered when the entire redirect is complete (and not when the very first animation is complete). */ 29246 if (x === reverseCallsCount - 1) { 29247 reverseOptions.display = opts.display; 29248 reverseOptions.visibility = opts.visibility; 29249 reverseOptions.complete = opts.complete; 29250 } 29251 29252 animate(elements, "reverse", reverseOptions); 29253 } 29254 } 29255 29256 /*************** 29257 Chaining 29258 ***************/ 29259 29260 /* Return the elements back to the call chain, with wrapped elements taking precedence in case Velocity was called via the $.fn. extension. */ 29261 return getChain(); 29262 }; 29263 29264 /* Turn Velocity into the animation function, extended with the pre-existing Velocity object. */ 29265 Velocity = $.extend(animate, Velocity); 29266 /* For legacy support, also expose the literal animate method. */ 29267 Velocity.animate = animate; 29268 29269 /************** 29270 Timing 29271 **************/ 29272 29273 /* Ticker function. */ 29274 var ticker = window.requestAnimationFrame || rAFShim; 29275 29276 /* Inactive browser tabs pause rAF, which results in all active animations immediately sprinting to their completion states when the tab refocuses. 29277 To get around this, we dynamically switch rAF to setTimeout (which the browser *doesn't* pause) when the tab loses focus. We skip this for mobile 29278 devices to avoid wasting battery power on inactive tabs. */ 29279 /* Note: Tab focus detection doesn't work on older versions of IE, but that's okay since they don't support rAF to begin with. */ 29280 if (!Velocity.State.isMobile && document.hidden !== undefined) { 29281 var updateTicker = function() { 29282 /* Reassign the rAF function (which the global tick() function uses) based on the tab's focus state. */ 29283 if (document.hidden) { 29284 ticker = function(callback) { 29285 /* The tick function needs a truthy first argument in order to pass its internal timestamp check. */ 29286 return setTimeout(function() { 29287 callback(true); 29288 }, 16); 29289 }; 29290 29291 /* The rAF loop has been paused by the browser, so we manually restart the tick. */ 29292 tick(); 29293 } else { 29294 ticker = window.requestAnimationFrame || rAFShim; 29295 } 29296 }; 29297 29298 /* Page could be sitting in the background at this time (i.e. opened as new tab) so making sure we use correct ticker from the start */ 29299 updateTicker(); 29300 29301 /* And then run check again every time visibility changes */ 29302 document.addEventListener("visibilitychange", updateTicker); 29303 } 29304 29305 /************ 29306 Tick 29307 ************/ 29308 29309 /* Note: All calls to Velocity are pushed to the Velocity.State.calls array, which is fully iterated through upon each tick. */ 29310 function tick(timestamp) { 29311 /* An empty timestamp argument indicates that this is the first tick occurence since ticking was turned on. 29312 We leverage this metadata to fully ignore the first tick pass since RAF's initial pass is fired whenever 29313 the browser's next tick sync time occurs, which results in the first elements subjected to Velocity 29314 calls being animated out of sync with any elements animated immediately thereafter. In short, we ignore 29315 the first RAF tick pass so that elements being immediately consecutively animated -- instead of simultaneously animated 29316 by the same Velocity call -- are properly batched into the same initial RAF tick and consequently remain in sync thereafter. */ 29317 if (timestamp) { 29318 /* We normally use RAF's high resolution timestamp but as it can be significantly offset when the browser is 29319 under high stress we give the option for choppiness over allowing the browser to drop huge chunks of frames. 29320 We use performance.now() and shim it if it doesn't exist for when the tab is hidden. */ 29321 var timeCurrent = Velocity.timestamp && timestamp !== true ? timestamp : performance.now(); 29322 29323 /******************** 29324 Call Iteration 29325 ********************/ 29326 29327 var callsLength = Velocity.State.calls.length; 29328 29329 /* To speed up iterating over this array, it is compacted (falsey items -- calls that have completed -- are removed) 29330 when its length has ballooned to a point that can impact tick performance. This only becomes necessary when animation 29331 has been continuous with many elements over a long period of time; whenever all active calls are completed, completeCall() clears Velocity.State.calls. */ 29332 if (callsLength > 10000) { 29333 Velocity.State.calls = compactSparseArray(Velocity.State.calls); 29334 callsLength = Velocity.State.calls.length; 29335 } 29336 29337 /* Iterate through each active call. */ 29338 for (var i = 0; i < callsLength; i++) { 29339 /* When a Velocity call is completed, its Velocity.State.calls entry is set to false. Continue on to the next call. */ 29340 if (!Velocity.State.calls[i]) { 29341 continue; 29342 } 29343 29344 /************************ 29345 Call-Wide Variables 29346 ************************/ 29347 29348 var callContainer = Velocity.State.calls[i], 29349 call = callContainer[0], 29350 opts = callContainer[2], 29351 timeStart = callContainer[3], 29352 firstTick = !!timeStart, 29353 tweenDummyValue = null, 29354 pauseObject = callContainer[5], 29355 millisecondsEllapsed = callContainer[6]; 29356 29357 29358 29359 /* If timeStart is undefined, then this is the first time that this call has been processed by tick(). 29360 We assign timeStart now so that its value is as close to the real animation start time as possible. 29361 (Conversely, had timeStart been defined when this call was added to Velocity.State.calls, the delay 29362 between that time and now would cause the first few frames of the tween to be skipped since 29363 percentComplete is calculated relative to timeStart.) */ 29364 /* Further, subtract 16ms (the approximate resolution of RAF) from the current time value so that the 29365 first tick iteration isn't wasted by animating at 0% tween completion, which would produce the 29366 same style value as the element's current value. */ 29367 if (!timeStart) { 29368 timeStart = Velocity.State.calls[i][3] = timeCurrent - 16; 29369 } 29370 29371 /* If a pause object is present, skip processing unless it has been set to resume */ 29372 if (pauseObject) { 29373 if (pauseObject.resume === true) { 29374 /* Update the time start to accomodate the paused completion amount */ 29375 timeStart = callContainer[3] = Math.round(timeCurrent - millisecondsEllapsed - 16); 29376 29377 /* Remove pause object after processing */ 29378 callContainer[5] = null; 29379 } else { 29380 continue; 29381 } 29382 } 29383 29384 millisecondsEllapsed = callContainer[6] = timeCurrent - timeStart; 29385 29386 /* The tween's completion percentage is relative to the tween's start time, not the tween's start value 29387 (which would result in unpredictable tween durations since JavaScript's timers are not particularly accurate). 29388 Accordingly, we ensure that percentComplete does not exceed 1. */ 29389 var percentComplete = Math.min((millisecondsEllapsed) / opts.duration, 1); 29390 29391 /********************** 29392 Element Iteration 29393 **********************/ 29394 29395 /* For every call, iterate through each of the elements in its set. */ 29396 for (var j = 0, callLength = call.length; j < callLength; j++) { 29397 var tweensContainer = call[j], 29398 element = tweensContainer.element; 29399 29400 /* Check to see if this element has been deleted midway through the animation by checking for the 29401 continued existence of its data cache. If it's gone, or the element is currently paused, skip animating this element. */ 29402 if (!Data(element)) { 29403 continue; 29404 } 29405 29406 var transformPropertyExists = false; 29407 29408 /********************************** 29409 Display & Visibility Toggling 29410 **********************************/ 29411 29412 /* If the display option is set to non-"none", set it upfront so that the element can become visible before tweening begins. 29413 (Otherwise, display's "none" value is set in completeCall() once the animation has completed.) */ 29414 if (opts.display !== undefined && opts.display !== null && opts.display !== "none") { 29415 if (opts.display === "flex") { 29416 var flexValues = ["-webkit-box", "-moz-box", "-ms-flexbox", "-webkit-flex"]; 29417 29418 $.each(flexValues, function(i, flexValue) { 29419 CSS.setPropertyValue(element, "display", flexValue); 29420 }); 29421 } 29422 29423 CSS.setPropertyValue(element, "display", opts.display); 29424 } 29425 29426 /* Same goes with the visibility option, but its "none" equivalent is "hidden". */ 29427 if (opts.visibility !== undefined && opts.visibility !== "hidden") { 29428 CSS.setPropertyValue(element, "visibility", opts.visibility); 29429 } 29430 29431 /************************ 29432 Property Iteration 29433 ************************/ 29434 29435 /* For every element, iterate through each property. */ 29436 for (var property in tweensContainer) { 29437 /* Note: In addition to property tween data, tweensContainer contains a reference to its associated element. */ 29438 if (tweensContainer.hasOwnProperty(property) && property !== "element") { 29439 var tween = tweensContainer[property], 29440 currentValue, 29441 /* Easing can either be a pre-genereated function or a string that references a pre-registered easing 29442 on the Velocity.Easings object. In either case, return the appropriate easing *function*. */ 29443 easing = Type.isString(tween.easing) ? Velocity.Easings[tween.easing] : tween.easing; 29444 29445 /****************************** 29446 Current Value Calculation 29447 ******************************/ 29448 29449 if (Type.isString(tween.pattern)) { 29450 var patternReplace = percentComplete === 1 ? 29451 function($0, index, round) { 29452 var result = tween.endValue[index]; 29453 29454 return round ? Math.round(result) : result; 29455 } : 29456 function($0, index, round) { 29457 var startValue = tween.startValue[index], 29458 tweenDelta = tween.endValue[index] - startValue, 29459 result = startValue + (tweenDelta * easing(percentComplete, opts, tweenDelta)); 29460 29461 return round ? Math.round(result) : result; 29462 }; 29463 29464 currentValue = tween.pattern.replace(/{(\d+)(!)?}/g, patternReplace); 29465 } else if (percentComplete === 1) { 29466 /* If this is the last tick pass (if we've reached 100% completion for this tween), 29467 ensure that currentValue is explicitly set to its target endValue so that it's not subjected to any rounding. */ 29468 currentValue = tween.endValue; 29469 } else { 29470 /* Otherwise, calculate currentValue based on the current delta from startValue. */ 29471 var tweenDelta = tween.endValue - tween.startValue; 29472 29473 currentValue = tween.startValue + (tweenDelta * easing(percentComplete, opts, tweenDelta)); 29474 /* If no value change is occurring, don't proceed with DOM updating. */ 29475 } 29476 if (!firstTick && (currentValue === tween.currentValue)) { 29477 continue; 29478 } 29479 29480 tween.currentValue = currentValue; 29481 29482 /* If we're tweening a fake 'tween' property in order to log transition values, update the one-per-call variable so that 29483 it can be passed into the progress callback. */ 29484 if (property === "tween") { 29485 tweenDummyValue = currentValue; 29486 } else { 29487 /****************** 29488 Hooks: Part I 29489 ******************/ 29490 var hookRoot; 29491 29492 /* For hooked properties, the newly-updated rootPropertyValueCache is cached onto the element so that it can be used 29493 for subsequent hooks in this call that are associated with the same root property. If we didn't cache the updated 29494 rootPropertyValue, each subsequent update to the root property in this tick pass would reset the previous hook's 29495 updates to rootPropertyValue prior to injection. A nice performance byproduct of rootPropertyValue caching is that 29496 subsequently chained animations using the same hookRoot but a different hook can use this cached rootPropertyValue. */ 29497 if (CSS.Hooks.registered[property]) { 29498 hookRoot = CSS.Hooks.getRoot(property); 29499 29500 var rootPropertyValueCache = Data(element).rootPropertyValueCache[hookRoot]; 29501 29502 if (rootPropertyValueCache) { 29503 tween.rootPropertyValue = rootPropertyValueCache; 29504 } 29505 } 29506 29507 /***************** 29508 DOM Update 29509 *****************/ 29510 29511 /* setPropertyValue() returns an array of the property name and property value post any normalization that may have been performed. */ 29512 /* Note: To solve an IE<=8 positioning bug, the unit type is dropped when setting a property value of 0. */ 29513 var adjustedSetData = CSS.setPropertyValue(element, /* SET */ 29514 property, 29515 tween.currentValue + (IE < 9 && parseFloat(currentValue) === 0 ? "" : tween.unitType), 29516 tween.rootPropertyValue, 29517 tween.scrollData); 29518 29519 /******************* 29520 Hooks: Part II 29521 *******************/ 29522 29523 /* Now that we have the hook's updated rootPropertyValue (the post-processed value provided by adjustedSetData), cache it onto the element. */ 29524 if (CSS.Hooks.registered[property]) { 29525 /* Since adjustedSetData contains normalized data ready for DOM updating, the rootPropertyValue needs to be re-extracted from its normalized form. ?? */ 29526 if (CSS.Normalizations.registered[hookRoot]) { 29527 Data(element).rootPropertyValueCache[hookRoot] = CSS.Normalizations.registered[hookRoot]("extract", null, adjustedSetData[1]); 29528 } else { 29529 Data(element).rootPropertyValueCache[hookRoot] = adjustedSetData[1]; 29530 } 29531 } 29532 29533 /*************** 29534 Transforms 29535 ***************/ 29536 29537 /* Flag whether a transform property is being animated so that flushTransformCache() can be triggered once this tick pass is complete. */ 29538 if (adjustedSetData[0] === "transform") { 29539 transformPropertyExists = true; 29540 } 29541 29542 } 29543 } 29544 } 29545 29546 /**************** 29547 mobileHA 29548 ****************/ 29549 29550 /* If mobileHA is enabled, set the translate3d transform to null to force hardware acceleration. 29551 It's safe to override this property since Velocity doesn't actually support its animation (hooks are used in its place). */ 29552 if (opts.mobileHA) { 29553 /* Don't set the null transform hack if we've already done so. */ 29554 if (Data(element).transformCache.translate3d === undefined) { 29555 /* All entries on the transformCache object are later concatenated into a single transform string via flushTransformCache(). */ 29556 Data(element).transformCache.translate3d = "(0px, 0px, 0px)"; 29557 29558 transformPropertyExists = true; 29559 } 29560 } 29561 29562 if (transformPropertyExists) { 29563 CSS.flushTransformCache(element); 29564 } 29565 } 29566 29567 /* The non-"none" display value is only applied to an element once -- when its associated call is first ticked through. 29568 Accordingly, it's set to false so that it isn't re-processed by this call in the next tick. */ 29569 if (opts.display !== undefined && opts.display !== "none") { 29570 Velocity.State.calls[i][2].display = false; 29571 } 29572 if (opts.visibility !== undefined && opts.visibility !== "hidden") { 29573 Velocity.State.calls[i][2].visibility = false; 29574 } 29575 29576 /* Pass the elements and the timing data (percentComplete, msRemaining, timeStart, tweenDummyValue) into the progress callback. */ 29577 if (opts.progress) { 29578 opts.progress.call(callContainer[1], 29579 callContainer[1], 29580 percentComplete, 29581 Math.max(0, (timeStart + opts.duration) - timeCurrent), 29582 timeStart, 29583 tweenDummyValue); 29584 } 29585 29586 /* If this call has finished tweening, pass its index to completeCall() to handle call cleanup. */ 29587 if (percentComplete === 1) { 29588 completeCall(i); 29589 } 29590 } 29591 } 29592 29593 /* Note: completeCall() sets the isTicking flag to false when the last call on Velocity.State.calls has completed. */ 29594 if (Velocity.State.isTicking) { 29595 ticker(tick); 29596 } 29597 } 29598 29599 /********************** 29600 Call Completion 29601 **********************/ 29602 29603 /* Note: Unlike tick(), which processes all active calls at once, call completion is handled on a per-call basis. */ 29604 function completeCall(callIndex, isStopped) { 29605 /* Ensure the call exists. */ 29606 if (!Velocity.State.calls[callIndex]) { 29607 return false; 29608 } 29609 29610 /* Pull the metadata from the call. */ 29611 var call = Velocity.State.calls[callIndex][0], 29612 elements = Velocity.State.calls[callIndex][1], 29613 opts = Velocity.State.calls[callIndex][2], 29614 resolver = Velocity.State.calls[callIndex][4]; 29615 29616 var remainingCallsExist = false; 29617 29618 /************************* 29619 Element Finalization 29620 *************************/ 29621 29622 for (var i = 0, callLength = call.length; i < callLength; i++) { 29623 var element = call[i].element; 29624 29625 /* If the user set display to "none" (intending to hide the element), set it now that the animation has completed. */ 29626 /* Note: display:none isn't set when calls are manually stopped (via Velocity("stop"). */ 29627 /* Note: Display gets ignored with "reverse" calls and infinite loops, since this behavior would be undesirable. */ 29628 if (!isStopped && !opts.loop) { 29629 if (opts.display === "none") { 29630 CSS.setPropertyValue(element, "display", opts.display); 29631 } 29632 29633 if (opts.visibility === "hidden") { 29634 CSS.setPropertyValue(element, "visibility", opts.visibility); 29635 } 29636 } 29637 29638 /* If the element's queue is empty (if only the "inprogress" item is left at position 0) or if its queue is about to run 29639 a non-Velocity-initiated entry, turn off the isAnimating flag. A non-Velocity-initiatied queue entry's logic might alter 29640 an element's CSS values and thereby cause Velocity's cached value data to go stale. To detect if a queue entry was initiated by Velocity, 29641 we check for the existence of our special Velocity.queueEntryFlag declaration, which minifiers won't rename since the flag 29642 is assigned to jQuery's global $ object and thus exists out of Velocity's own scope. */ 29643 var data = Data(element); 29644 29645 if (opts.loop !== true && ($.queue(element)[1] === undefined || !/\.velocityQueueEntryFlag/i.test($.queue(element)[1]))) { 29646 /* The element may have been deleted. Ensure that its data cache still exists before acting on it. */ 29647 if (data) { 29648 data.isAnimating = false; 29649 /* Clear the element's rootPropertyValueCache, which will become stale. */ 29650 data.rootPropertyValueCache = {}; 29651 29652 var transformHAPropertyExists = false; 29653 /* If any 3D transform subproperty is at its default value (regardless of unit type), remove it. */ 29654 $.each(CSS.Lists.transforms3D, function(i, transformName) { 29655 var defaultValue = /^scale/.test(transformName) ? 1 : 0, 29656 currentValue = data.transformCache[transformName]; 29657 29658 if (data.transformCache[transformName] !== undefined && new RegExp("^\\(" + defaultValue + "[^.]").test(currentValue)) { 29659 transformHAPropertyExists = true; 29660 29661 delete data.transformCache[transformName]; 29662 } 29663 }); 29664 29665 /* Mobile devices have hardware acceleration removed at the end of the animation in order to avoid hogging the GPU's memory. */ 29666 if (opts.mobileHA) { 29667 transformHAPropertyExists = true; 29668 delete data.transformCache.translate3d; 29669 } 29670 29671 /* Flush the subproperty removals to the DOM. */ 29672 if (transformHAPropertyExists) { 29673 CSS.flushTransformCache(element); 29674 } 29675 29676 /* Remove the "velocity-animating" indicator class. */ 29677 CSS.Values.removeClass(element, "velocity-animating"); 29678 } 29679 } 29680 29681 /********************* 29682 Option: Complete 29683 *********************/ 29684 29685 /* Complete is fired once per call (not once per element) and is passed the full raw DOM element set as both its context and its first argument. */ 29686 /* Note: Callbacks aren't fired when calls are manually stopped (via Velocity("stop"). */ 29687 if (!isStopped && opts.complete && !opts.loop && (i === callLength - 1)) { 29688 /* We throw callbacks in a setTimeout so that thrown errors don't halt the execution of Velocity itself. */ 29689 try { 29690 opts.complete.call(elements, elements); 29691 } catch (error) { 29692 setTimeout(function() { 29693 throw error; 29694 }, 1); 29695 } 29696 } 29697 29698 /********************** 29699 Promise Resolving 29700 **********************/ 29701 29702 /* Note: Infinite loops don't return promises. */ 29703 if (resolver && opts.loop !== true) { 29704 resolver(elements); 29705 } 29706 29707 /**************************** 29708 Option: Loop (Infinite) 29709 ****************************/ 29710 29711 if (data && opts.loop === true && !isStopped) { 29712 /* If a rotateX/Y/Z property is being animated by 360 deg with loop:true, swap tween start/end values to enable 29713 continuous iterative rotation looping. (Otherise, the element would just rotate back and forth.) */ 29714 $.each(data.tweensContainer, function(propertyName, tweenContainer) { 29715 if (/^rotate/.test(propertyName) && ((parseFloat(tweenContainer.startValue) - parseFloat(tweenContainer.endValue)) % 360 === 0)) { 29716 var oldStartValue = tweenContainer.startValue; 29717 29718 tweenContainer.startValue = tweenContainer.endValue; 29719 tweenContainer.endValue = oldStartValue; 29720 } 29721 29722 if (/^backgroundPosition/.test(propertyName) && parseFloat(tweenContainer.endValue) === 100 && tweenContainer.unitType === "%") { 29723 tweenContainer.endValue = 0; 29724 tweenContainer.startValue = 100; 29725 } 29726 }); 29727 29728 Velocity(element, "reverse", {loop: true, delay: opts.delay}); 29729 } 29730 29731 /*************** 29732 Dequeueing 29733 ***************/ 29734 29735 /* Fire the next call in the queue so long as this call's queue wasn't set to false (to trigger a parallel animation), 29736 which would have already caused the next call to fire. Note: Even if the end of the animation queue has been reached, 29737 $.dequeue() must still be called in order to completely clear jQuery's animation queue. */ 29738 if (opts.queue !== false) { 29739 $.dequeue(element, opts.queue); 29740 } 29741 } 29742 29743 /************************ 29744 Calls Array Cleanup 29745 ************************/ 29746 29747 /* Since this call is complete, set it to false so that the rAF tick skips it. This array is later compacted via compactSparseArray(). 29748 (For performance reasons, the call is set to false instead of being deleted from the array: http://www.html5rocks.com/en/tutorials/speed/v8/) */ 29749 Velocity.State.calls[callIndex] = false; 29750 29751 /* Iterate through the calls array to determine if this was the final in-progress animation. 29752 If so, set a flag to end ticking and clear the calls array. */ 29753 for (var j = 0, callsLength = Velocity.State.calls.length; j < callsLength; j++) { 29754 if (Velocity.State.calls[j] !== false) { 29755 remainingCallsExist = true; 29756 29757 break; 29758 } 29759 } 29760 29761 if (remainingCallsExist === false) { 29762 /* tick() will detect this flag upon its next iteration and subsequently turn itself off. */ 29763 Velocity.State.isTicking = false;
29764 29765 /* Clear the calls array so that its length is reset. */ 29766 delete Velocity.State.calls; 29767 Velocity.State.calls = []; 29768 } 29769 } 29770 29771 /****************** 29772 Frameworks 29773 ******************/ 29774 29775 /* Both jQuery and Zepto allow their $.fn object to be extended to allow wrapped elements to be subjected to plugin calls. 29776 If either framework is loaded, register a "velocity" extension pointing to Velocity's core animate() method. Velocity 29777 also registers itself onto a global container (window.jQuery || window.Zepto || window) so that certain features are 29778 accessible beyond just a per-element scope. This master object contains an .animate() method, which is later assigned to $.fn 29779 (if jQuery or Zepto are present). Accordingly, Velocity can both act on wrapped DOM elements and stand alone for targeting raw DOM elements. */ 29780 global.Velocity = Velocity; 29781 29782 if (global !== window) { 29783 /* Assign the element function to Velocity's core animate() method. */ 29784 global.fn.velocity = animate; 29785 /* Assign the object function's defaults to Velocity's global defaults object. */ 29786 global.fn.velocity.defaults = Velocity.defaults; 29787 } 29788 29789 /*********************** 29790 Packaged Redirects 29791 ***********************/ 29792 29793 /* slideUp, slideDown */ 29794 $.each(["Down", "Up"], function(i, direction) { 29795 Velocity.Redirects["slide" + direction] = function(element, options, elementsIndex, elementsSize, elements, promiseData) { 29796 var opts = $.extend({}, options), 29797 begin = opts.begin, 29798 complete = opts.complete, 29799 inlineValues = {}, 29800 computedValues = {height: "", marginTop: "", marginBottom: "", paddingTop: "", paddingBottom: ""}; 29801 29802 if (opts.display === undefined) { 29803 /* Show the element before slideDown begins and hide the element after slideUp completes. */ 29804 /* Note: Inline elements cannot have dimensions animated, so they're reverted to inline-block. */ 29805 opts.display = (direction === "Down" ? (Velocity.CSS.Values.getDisplayType(element) === "inline" ? "inline-block" : "block") : "none"); 29806 } 29807 29808 opts.begin = function() { 29809 /* If the user passed in a begin callback, fire it now. */ 29810 if (elementsIndex === 0 && begin) { 29811 begin.call(elements, elements); 29812 } 29813 29814 /* Cache the elements' original vertical dimensional property values so that we can animate back to them. */ 29815 for (var property in computedValues) { 29816 if (!computedValues.hasOwnProperty(property)) { 29817 continue; 29818 } 29819 inlineValues[property] = element.style[property]; 29820 29821 /* For slideDown, use forcefeeding to animate all vertical properties from 0. For slideUp, 29822 use forcefeeding to start from computed values and animate down to 0. */ 29823 var propertyValue = CSS.getPropertyValue(element, property); 29824 computedValues[property] = (direction === "Down") ? [propertyValue, 0] : [0, propertyValue]; 29825 } 29826 29827 /* Force vertical overflow content to clip so that sliding works as expected. */ 29828 inlineValues.overflow = element.style.overflow; 29829 element.style.overflow = "hidden"; 29830 }; 29831 29832 opts.complete = function() { 29833 /* Reset element to its pre-slide inline values once its slide animation is complete. */ 29834 for (var property in inlineValues) { 29835 if (inlineValues.hasOwnProperty(property)) { 29836 element.style[property] = inlineValues[property]; 29837 } 29838 } 29839 29840 /* If the user passed in a complete callback, fire it now. */ 29841 if (elementsIndex === elementsSize - 1) { 29842 if (complete) { 29843 complete.call(elements, elements); 29844 } 29845 if (promiseData) { 29846 promiseData.resolver(elements); 29847 } 29848 } 29849 }; 29850 29851 Velocity(element, computedValues, opts); 29852 }; 29853 }); 29854 29855 /* fadeIn, fadeOut */ 29856 $.each(["In", "Out"], function(i, direction) { 29857 Velocity.Redirects["fade" + direction] = function(element, options, elementsIndex, elementsSize, elements, promiseData) { 29858 var opts = $.extend({}, options), 29859 complete = opts.complete, 29860 propertiesMap = {opacity: (direction === "In") ? 1 : 0}; 29861 29862 /* Since redirects are triggered individually for each element in the animated set, avoid repeatedly triggering 29863 callbacks by firing them only when the final element has been reached. */ 29864 if (elementsIndex !== 0) { 29865 opts.begin = null; 29866 } 29867 if (elementsIndex !== elementsSize - 1) { 29868 opts.complete = null; 29869 } else { 29870 opts.complete = function() { 29871 if (complete) { 29872 complete.call(elements, elements); 29873 } 29874 if (promiseData) { 29875 promiseData.resolver(elements); 29876 } 29877 }; 29878 } 29879 29880 /* If a display was passed in, use it. Otherwise, default to "none" for fadeOut or the element-specific default for fadeIn. */ 29881 /* Note: We allow users to pass in "null" to skip display setting altogether. */ 29882 if (opts.display === undefined) { 29883 opts.display = (direction === "In" ? "auto" : "none"); 29884 } 29885 29886 Velocity(this, propertiesMap, opts); 29887 }; 29888 }); 29889 29890 return Velocity; 29891 }((window.jQuery || window.Zepto || window), window, (window ? window.document : undefined)); 29892})); 29893 29894/****************** 29895 Known Issues 29896 ******************/ 29897 29898/* The CSS spec mandates that the translateX/Y/Z transforms are %-relative to the element itself -- not its parent. 29899 Velocity, however, doesn't make this distinction. Thus, converting to or from the % unit with these subproperties 29900 will produce an inaccurate conversion value. The same issue exists with the cx/cy attributes of SVG circles and ellipses. */ 29901 29902},{}],6:[function(require,module,exports){ 29903(function (global){(function (){ 29904'use strict'; 29905 29906var moment = require('moment'); 29907var _ = require('lodash'); 29908var salvattore = require('salvattore'); 29909 29910var current_page = null; 29911$('.load-posts').on('click', function (e) { 29912 e.preventDefault(); 29913 var domain = window.location.protocol + '//' + window.location.host, 29914 $btn = $(this), 29915 load = { 29916 slug: $btn.data('url'), 29917 text: $btn.text(), 29918 width: $btn.width(), 29919 current: parseInt($btn.data('current-page')), 29920 total: parseInt($btn.data('total-pages')) 29921 }; 29922 29923 if (!current_page) { 29924 current_page = load.current; 29925 } 29926 29927 if (current_page >= load.total) { 29928 return; 29929 } 29930 29931 $btn.addClass('loading').width(load.width).text('Loading Posts'); 29932 $.ajax({ 29933 url: domain + load.slug + '/page/' + (parseInt(current_page) + 1), 29934 method: 'GET', 29935 success: function success(response) { 29936 current_page++; 29937 var grid = document.querySelector('#posts-list'); 29938 salvattore.appendElements(grid, $(response).find('#posts-list article')); 29939 if (current_page >= load.total) { 29940 $('.pagination').velocity('slideUp', 800, 'easeInOutExpo', function () { 29941 $btn.addClass('is-hidden'); 29942 }); 29943 } else { 29944 $btn.removeClass('loading').text(load.text).css('width', ''); 29945 } 29946 } 29947 }); 29948}); 29949 29950$('.posts-list').each(function () { 29951 29952 var $blogList = $(this); 29953 var showImage = $blogList.data('show-image'); 29954 var postCount = $blogList.data('count'); 29955 var feedType = $blogList.data('type'); 29956 var feedURL = $blogList.data('feed'); 29957 var grid = this; 29958 29959 if (!global.suppress || !$blogList.parents('.editable').length) { 29960 29961 $.ajax({ 29962 url: global.appUrl + '/feed_api?url=' + encodeURIComponent(feedType == 'internal' ? global.siteUrl + feedURL : feedURL), 29963 method: 'GET', 29964 timeout: 10000, 29965 success: function success(response) { 29966 $blogList.find('.loading').remove(); 29967 if (response.length) { 29968 if (postCount) response = response.slice(0, postCount); 29969 29970 response.forEach(function (item) { 29971 29972 var categories = '';
29973 item.categories.forEach(function (category) { 29974 categories += '<span class="category">' + category + '</span>'; 29975 }); 29976 29977 if (categories.length) { 29978 categories = '<span class="bullet"></span> <span class="post-categories">' + categories + '</span>'; 29979 } 29980 29981 var image = item.image.url && showImage ? '<figure class="post-thumbnail"><img src="' + item.image.url + '" alt="' + item.title + ' thumbnail"></figure>' : ''; 29982 var excerpt = item.description ? '<div class="post-excerpt">' + item.description + '</div>' : ''; 29983 var date = item.date ? '<time datetime="' + moment(item.date).format('YYYY-MM-DD') + '">' + moment(item.date).format('MMMM D, YYYY') + '</time>' : ''; 29984 29985 var article = $('<article class="post-link">\n <a href="' + item.link + '">\n ' + image + '\n <header class="post-header">\n <h3>' + item.title + '</h3>\n </header>\n </a>\n <div class="post-meta">\n ' + date + '\n ' + categories + '\n </div>\n ' + excerpt + '\n </article>\n '); 29986 29987 salvattore.appendElements(grid, article); 29988 }); 29989 } else { 29990 $blogList.append('<p class="loading">No Posts Found</p>'); 29991 } 29992 }, 29993 error: function error(_error) { 29994 console.log(_error); 29995 $blogList.find('.loading').remove(); 29996 $blogList.append('<p class="loading">' + _error + '</p>'); 29997 } 29998 }); 29999 } 30000}); 30001 30002}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 30003},{"lodash":2,"moment":3,"salvattore":4}],7:[function(require,module,exports){ 30004'use strict'; 30005 30006require('salvattore'); 30007var Barba = require('barba.js'); 30008require('./blogs'); 30009require('velocity-animate'); 30010 30011function headerPush() { 30012 var height = document.getElementById('header').offsetHeight; 30013 document.getElementsByClassName('header-push')[0].style.height = height + 'px'; 30014} 30015 30016$(function () { 30017 if ($('.header-push').length) { 30018 headerPush(); 30019 $(window).on('resize', headerPush); 30020 } 30021}); 30022 30023//reveal mobile nav 30024$('.menu-toggle').on('click', function (e) { 30025 e.preventDefault(); 30026 if ($(this).hasClass('nav-open')) { 30027 $(this).removeClass('nav-open'); 30028 30029 $('.pull-out-overlay').velocity('fadeOut', { duration: 400 }); 30030 $('#main-navigation').velocity({ 30031 scale: [0.95, 1], 30032 opacity: [0, 1] 30033 }, 500, 'easeOutExpo', function () { 30034 $('html').removeClass('pull-out-open'); 30035 }); 30036 } else { 30037 $('html').addClass('pull-out-open'); 30038 $(this).addClass('nav-open'); 30039 30040 $('.pull-out-overlay').velocity('fadeIn', { duration: 400 }); 30041 $('#main-navigation').velocity({ 30042 scale: [1, 0.95], 30043 opacity: [1, 0] 30044 }, 500, 'easeOutExpo'); 30045 } 30046}); 30047 30048// overlays 30049$('.open-overlay').on('click', function (e) { 30050 e.preventDefault(); 30051 var modal = $(this).data('target'); 30052 $('html').addClass('overlay-open'); 30053 if (modal) { 30054 $('#' + modal).addClass('is-showing'); 30055 } else { 30056 $(this).parent().find('.overlay-content').addClass('is-showing'); 30057 } 30058}); 30059 30060$('.close-overlay').on('click', function (e) { 30061 e.preventDefault(); 30062 $('html').removeClass('overlay-open'); 30063 $('.overlay-content').removeClass('is-showing'); 30064}); 30065 30066// accordions 30067$('.toggle-accordion').on('click', function (e) { 30068 e.preventDefault(); 30069 var $accordion = $(this).parent().find('.accordion-content'); 30070 if ($(this).hasClass('open')) { 30071 $accordion.velocity('slideUp', 500, 'easeInOutExpo', function () {}); 30072 } else { 30073 $accordion.velocity('slideDown', 500, 'easeInOutExpo', function () {}); 30074 } 30075 $(this).toggleClass('open'); 30076}); 30077 30078},{"./blogs":6,"barba.js":1,"salvattore":4,"velocity-animate":5}]},{},[7]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.