enhance-npm-community

一个用于增强npm官网的GM脚本

  1. // ==UserScript==
  2. // @name enhance-npm-community
  3. // @author Axetroy
  4. // @description 一个用于增强npm官网的GM脚本
  5. // @version 0.2.1
  6. // @grant GM_xmlhttpRequest
  7. // @include *www.npmjs.com*
  8. // @connect *
  9. // @compatible chrome 完美运行
  10. // @compatible firefox 完美运行
  11. // @supportURL http://www.burningall.com
  12. // @run-at document-end
  13. // @contributionURL troy450409405@gmail.com|alipay.com
  14. // @namespace https://greasyfork.org/zh-CN/users/3400-axetroy
  15. // @license The MIT License (MIT); http://opensource.org/licenses/MIT
  16. // ==/UserScript==
  17.  
  18. // Github源码: https://github.com/axetroy/enhance-npm-community
  19.  
  20. /**
  21. The MIT License (MIT)
  22.  
  23. Copyright (c) 2017 axetroy
  24.  
  25. Permission is hereby granted, free of charge, to any person obtaining a copy
  26. of this software and associated documentation files (the "Software"), to deal
  27. in the Software without restriction, including without limitation the rights
  28. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  29. copies of the Software, and to permit persons to whom the Software is
  30. furnished to do so, subject to the following conditions:
  31.  
  32. The above copyright notice and this permission notice shall be included in all
  33. copies or substantial portions of the Software.
  34.  
  35. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  36. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  37. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  38. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  39. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  40. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  41. SOFTWARE.
  42. **/
  43.  
  44. /******/ (function(modules) { // webpackBootstrap
  45. /******/ // The module cache
  46. /******/ var installedModules = {};
  47. /******/
  48. /******/ // The require function
  49. /******/ function __webpack_require__(moduleId) {
  50. /******/
  51. /******/ // Check if module is in cache
  52. /******/ if(installedModules[moduleId])
  53. /******/ return installedModules[moduleId].exports;
  54. /******/
  55. /******/ // Create a new module (and put it into the cache)
  56. /******/ var module = installedModules[moduleId] = {
  57. /******/ i: moduleId,
  58. /******/ l: false,
  59. /******/ exports: {}
  60. /******/ };
  61. /******/
  62. /******/ // Execute the module function
  63. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  64. /******/
  65. /******/ // Flag the module as loaded
  66. /******/ module.l = true;
  67. /******/
  68. /******/ // Return the exports of the module
  69. /******/ return module.exports;
  70. /******/ }
  71. /******/
  72. /******/
  73. /******/ // expose the modules object (__webpack_modules__)
  74. /******/ __webpack_require__.m = modules;
  75. /******/
  76. /******/ // expose the module cache
  77. /******/ __webpack_require__.c = installedModules;
  78. /******/
  79. /******/ // identity function for calling harmony imports with the correct context
  80. /******/ __webpack_require__.i = function(value) { return value; };
  81. /******/
  82. /******/ // define getter function for harmony exports
  83. /******/ __webpack_require__.d = function(exports, name, getter) {
  84. /******/ if(!__webpack_require__.o(exports, name)) {
  85. /******/ Object.defineProperty(exports, name, {
  86. /******/ configurable: false,
  87. /******/ enumerable: true,
  88. /******/ get: getter
  89. /******/ });
  90. /******/ }
  91. /******/ };
  92. /******/
  93. /******/ // getDefaultExport function for compatibility with non-harmony modules
  94. /******/ __webpack_require__.n = function(module) {
  95. /******/ var getter = module && module.__esModule ?
  96. /******/ function getDefault() { return module['default']; } :
  97. /******/ function getModuleExports() { return module; };
  98. /******/ __webpack_require__.d(getter, 'a', getter);
  99. /******/ return getter;
  100. /******/ };
  101. /******/
  102. /******/ // Object.prototype.hasOwnProperty.call
  103. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  104. /******/
  105. /******/ // __webpack_public_path__
  106. /******/ __webpack_require__.p = "";
  107. /******/
  108. /******/ // Load entry module and return exports
  109. /******/ return __webpack_require__(__webpack_require__.s = 117);
  110. /******/ })
  111. /************************************************************************/
  112. /******/ ([
  113. /* 0 */
  114. /***/ (function(module, exports, __webpack_require__) {
  115.  
  116. var store = __webpack_require__(43)('wks')
  117. , uid = __webpack_require__(46)
  118. , Symbol = __webpack_require__(1).Symbol
  119. , USE_SYMBOL = typeof Symbol == 'function';
  120.  
  121. var $exports = module.exports = function(name){
  122. return store[name] || (store[name] =
  123. USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
  124. };
  125.  
  126. $exports.store = store;
  127.  
  128. /***/ }),
  129. /* 1 */
  130. /***/ (function(module, exports) {
  131.  
  132. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  133. var global = module.exports = typeof window != 'undefined' && window.Math == Math
  134. ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
  135. if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef
  136.  
  137. /***/ }),
  138. /* 2 */
  139. /***/ (function(module, exports) {
  140.  
  141. var core = module.exports = {version: '2.4.0'};
  142. if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef
  143.  
  144. /***/ }),
  145. /* 3 */
  146. /***/ (function(module, exports, __webpack_require__) {
  147.  
  148. /* WEBPACK VAR INJECTION */(function(process, global, setImmediate) {/* @preserve
  149. * The MIT License (MIT)
  150. *
  151. * Copyright (c) 2013-2017 Petka Antonov
  152. *
  153. * Permission is hereby granted, free of charge, to any person obtaining a copy
  154. * of this software and associated documentation files (the "Software"), to deal
  155. * in the Software without restriction, including without limitation the rights
  156. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  157. * copies of the Software, and to permit persons to whom the Software is
  158. * furnished to do so, subject to the following conditions:
  159. *
  160. * The above copyright notice and this permission notice shall be included in
  161. * all copies or substantial portions of the Software.
  162. *
  163. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  164. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  165. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  166. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  167. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  168. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  169. * THE SOFTWARE.
  170. *
  171. */
  172. /**
  173. * bluebird build version 3.5.0
  174. * Features enabled: core, race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each
  175. */
  176. !function(e){if(true)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Promise=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof _dereq_=="function"&&_dereq_;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof _dereq_=="function"&&_dereq_;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
  177. "use strict";
  178. module.exports = function(Promise) {
  179. var SomePromiseArray = Promise._SomePromiseArray;
  180. function any(promises) {
  181. var ret = new SomePromiseArray(promises);
  182. var promise = ret.promise();
  183. ret.setHowMany(1);
  184. ret.setUnwrap();
  185. ret.init();
  186. return promise;
  187. }
  188.  
  189. Promise.any = function (promises) {
  190. return any(promises);
  191. };
  192.  
  193. Promise.prototype.any = function () {
  194. return any(this);
  195. };
  196.  
  197. };
  198.  
  199. },{}],2:[function(_dereq_,module,exports){
  200. "use strict";
  201. var firstLineError;
  202. try {throw new Error(); } catch (e) {firstLineError = e;}
  203. var schedule = _dereq_("./schedule");
  204. var Queue = _dereq_("./queue");
  205. var util = _dereq_("./util");
  206.  
  207. function Async() {
  208. this._customScheduler = false;
  209. this._isTickUsed = false;
  210. this._lateQueue = new Queue(16);
  211. this._normalQueue = new Queue(16);
  212. this._haveDrainedQueues = false;
  213. this._trampolineEnabled = true;
  214. var self = this;
  215. this.drainQueues = function () {
  216. self._drainQueues();
  217. };
  218. this._schedule = schedule;
  219. }
  220.  
  221. Async.prototype.setScheduler = function(fn) {
  222. var prev = this._schedule;
  223. this._schedule = fn;
  224. this._customScheduler = true;
  225. return prev;
  226. };
  227.  
  228. Async.prototype.hasCustomScheduler = function() {
  229. return this._customScheduler;
  230. };
  231.  
  232. Async.prototype.enableTrampoline = function() {
  233. this._trampolineEnabled = true;
  234. };
  235.  
  236. Async.prototype.disableTrampolineIfNecessary = function() {
  237. if (util.hasDevTools) {
  238. this._trampolineEnabled = false;
  239. }
  240. };
  241.  
  242. Async.prototype.haveItemsQueued = function () {
  243. return this._isTickUsed || this._haveDrainedQueues;
  244. };
  245.  
  246.  
  247. Async.prototype.fatalError = function(e, isNode) {
  248. if (isNode) {
  249. process.stderr.write("Fatal " + (e instanceof Error ? e.stack : e) +
  250. "\n");
  251. process.exit(2);
  252. } else {
  253. this.throwLater(e);
  254. }
  255. };
  256.  
  257. Async.prototype.throwLater = function(fn, arg) {
  258. if (arguments.length === 1) {
  259. arg = fn;
  260. fn = function () { throw arg; };
  261. }
  262. if (typeof setTimeout !== "undefined") {
  263. setTimeout(function() {
  264. fn(arg);
  265. }, 0);
  266. } else try {
  267. this._schedule(function() {
  268. fn(arg);
  269. });
  270. } catch (e) {
  271. throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  272. }
  273. };
  274.  
  275. function AsyncInvokeLater(fn, receiver, arg) {
  276. this._lateQueue.push(fn, receiver, arg);
  277. this._queueTick();
  278. }
  279.  
  280. function AsyncInvoke(fn, receiver, arg) {
  281. this._normalQueue.push(fn, receiver, arg);
  282. this._queueTick();
  283. }
  284.  
  285. function AsyncSettlePromises(promise) {
  286. this._normalQueue._pushOne(promise);
  287. this._queueTick();
  288. }
  289.  
  290. if (!util.hasDevTools) {
  291. Async.prototype.invokeLater = AsyncInvokeLater;
  292. Async.prototype.invoke = AsyncInvoke;
  293. Async.prototype.settlePromises = AsyncSettlePromises;
  294. } else {
  295. Async.prototype.invokeLater = function (fn, receiver, arg) {
  296. if (this._trampolineEnabled) {
  297. AsyncInvokeLater.call(this, fn, receiver, arg);
  298. } else {
  299. this._schedule(function() {
  300. setTimeout(function() {
  301. fn.call(receiver, arg);
  302. }, 100);
  303. });
  304. }
  305. };
  306.  
  307. Async.prototype.invoke = function (fn, receiver, arg) {
  308. if (this._trampolineEnabled) {
  309. AsyncInvoke.call(this, fn, receiver, arg);
  310. } else {
  311. this._schedule(function() {
  312. fn.call(receiver, arg);
  313. });
  314. }
  315. };
  316.  
  317. Async.prototype.settlePromises = function(promise) {
  318. if (this._trampolineEnabled) {
  319. AsyncSettlePromises.call(this, promise);
  320. } else {
  321. this._schedule(function() {
  322. promise._settlePromises();
  323. });
  324. }
  325. };
  326. }
  327.  
  328. Async.prototype._drainQueue = function(queue) {
  329. while (queue.length() > 0) {
  330. var fn = queue.shift();
  331. if (typeof fn !== "function") {
  332. fn._settlePromises();
  333. continue;
  334. }
  335. var receiver = queue.shift();
  336. var arg = queue.shift();
  337. fn.call(receiver, arg);
  338. }
  339. };
  340.  
  341. Async.prototype._drainQueues = function () {
  342. this._drainQueue(this._normalQueue);
  343. this._reset();
  344. this._haveDrainedQueues = true;
  345. this._drainQueue(this._lateQueue);
  346. };
  347.  
  348. Async.prototype._queueTick = function () {
  349. if (!this._isTickUsed) {
  350. this._isTickUsed = true;
  351. this._schedule(this.drainQueues);
  352. }
  353. };
  354.  
  355. Async.prototype._reset = function () {
  356. this._isTickUsed = false;
  357. };
  358.  
  359. module.exports = Async;
  360. module.exports.firstLineError = firstLineError;
  361.  
  362. },{"./queue":26,"./schedule":29,"./util":36}],3:[function(_dereq_,module,exports){
  363. "use strict";
  364. module.exports = function(Promise, INTERNAL, tryConvertToPromise, debug) {
  365. var calledBind = false;
  366. var rejectThis = function(_, e) {
  367. this._reject(e);
  368. };
  369.  
  370. var targetRejected = function(e, context) {
  371. context.promiseRejectionQueued = true;
  372. context.bindingPromise._then(rejectThis, rejectThis, null, this, e);
  373. };
  374.  
  375. var bindingResolved = function(thisArg, context) {
  376. if (((this._bitField & 50397184) === 0)) {
  377. this._resolveCallback(context.target);
  378. }
  379. };
  380.  
  381. var bindingRejected = function(e, context) {
  382. if (!context.promiseRejectionQueued) this._reject(e);
  383. };
  384.  
  385. Promise.prototype.bind = function (thisArg) {
  386. if (!calledBind) {
  387. calledBind = true;
  388. Promise.prototype._propagateFrom = debug.propagateFromFunction();
  389. Promise.prototype._boundValue = debug.boundValueFunction();
  390. }
  391. var maybePromise = tryConvertToPromise(thisArg);
  392. var ret = new Promise(INTERNAL);
  393. ret._propagateFrom(this, 1);
  394. var target = this._target();
  395. ret._setBoundTo(maybePromise);
  396. if (maybePromise instanceof Promise) {
  397. var context = {
  398. promiseRejectionQueued: false,
  399. promise: ret,
  400. target: target,
  401. bindingPromise: maybePromise
  402. };
  403. target._then(INTERNAL, targetRejected, undefined, ret, context);
  404. maybePromise._then(
  405. bindingResolved, bindingRejected, undefined, ret, context);
  406. ret._setOnCancel(maybePromise);
  407. } else {
  408. ret._resolveCallback(target);
  409. }
  410. return ret;
  411. };
  412.  
  413. Promise.prototype._setBoundTo = function (obj) {
  414. if (obj !== undefined) {
  415. this._bitField = this._bitField | 2097152;
  416. this._boundTo = obj;
  417. } else {
  418. this._bitField = this._bitField & (~2097152);
  419. }
  420. };
  421.  
  422. Promise.prototype._isBound = function () {
  423. return (this._bitField & 2097152) === 2097152;
  424. };
  425.  
  426. Promise.bind = function (thisArg, value) {
  427. return Promise.resolve(value).bind(thisArg);
  428. };
  429. };
  430.  
  431. },{}],4:[function(_dereq_,module,exports){
  432. "use strict";
  433. var old;
  434. if (typeof Promise !== "undefined") old = Promise;
  435. function noConflict() {
  436. try { if (Promise === bluebird) Promise = old; }
  437. catch (e) {}
  438. return bluebird;
  439. }
  440. var bluebird = _dereq_("./promise")();
  441. bluebird.noConflict = noConflict;
  442. module.exports = bluebird;
  443.  
  444. },{"./promise":22}],5:[function(_dereq_,module,exports){
  445. "use strict";
  446. var cr = Object.create;
  447. if (cr) {
  448. var callerCache = cr(null);
  449. var getterCache = cr(null);
  450. callerCache[" size"] = getterCache[" size"] = 0;
  451. }
  452.  
  453. module.exports = function(Promise) {
  454. var util = _dereq_("./util");
  455. var canEvaluate = util.canEvaluate;
  456. var isIdentifier = util.isIdentifier;
  457.  
  458. var getMethodCaller;
  459. var getGetter;
  460. if (false) {
  461. var makeMethodCaller = function (methodName) {
  462. return new Function("ensureMethod", " \n\
  463. return function(obj) { \n\
  464. 'use strict' \n\
  465. var len = this.length; \n\
  466. ensureMethod(obj, 'methodName'); \n\
  467. switch(len) { \n\
  468. case 1: return obj.methodName(this[0]); \n\
  469. case 2: return obj.methodName(this[0], this[1]); \n\
  470. case 3: return obj.methodName(this[0], this[1], this[2]); \n\
  471. case 0: return obj.methodName(); \n\
  472. default: \n\
  473. return obj.methodName.apply(obj, this); \n\
  474. } \n\
  475. }; \n\
  476. ".replace(/methodName/g, methodName))(ensureMethod);
  477. };
  478.  
  479. var makeGetter = function (propertyName) {
  480. return new Function("obj", " \n\
  481. 'use strict'; \n\
  482. return obj.propertyName; \n\
  483. ".replace("propertyName", propertyName));
  484. };
  485.  
  486. var getCompiled = function(name, compiler, cache) {
  487. var ret = cache[name];
  488. if (typeof ret !== "function") {
  489. if (!isIdentifier(name)) {
  490. return null;
  491. }
  492. ret = compiler(name);
  493. cache[name] = ret;
  494. cache[" size"]++;
  495. if (cache[" size"] > 512) {
  496. var keys = Object.keys(cache);
  497. for (var i = 0; i < 256; ++i) delete cache[keys[i]];
  498. cache[" size"] = keys.length - 256;
  499. }
  500. }
  501. return ret;
  502. };
  503.  
  504. getMethodCaller = function(name) {
  505. return getCompiled(name, makeMethodCaller, callerCache);
  506. };
  507.  
  508. getGetter = function(name) {
  509. return getCompiled(name, makeGetter, getterCache);
  510. };
  511. }
  512.  
  513. function ensureMethod(obj, methodName) {
  514. var fn;
  515. if (obj != null) fn = obj[methodName];
  516. if (typeof fn !== "function") {
  517. var message = "Object " + util.classString(obj) + " has no method '" +
  518. util.toString(methodName) + "'";
  519. throw new Promise.TypeError(message);
  520. }
  521. return fn;
  522. }
  523.  
  524. function caller(obj) {
  525. var methodName = this.pop();
  526. var fn = ensureMethod(obj, methodName);
  527. return fn.apply(obj, this);
  528. }
  529. Promise.prototype.call = function (methodName) {
  530. var args = [].slice.call(arguments, 1);;
  531. if (false) {
  532. if (canEvaluate) {
  533. var maybeCaller = getMethodCaller(methodName);
  534. if (maybeCaller !== null) {
  535. return this._then(
  536. maybeCaller, undefined, undefined, args, undefined);
  537. }
  538. }
  539. }
  540. args.push(methodName);
  541. return this._then(caller, undefined, undefined, args, undefined);
  542. };
  543.  
  544. function namedGetter(obj) {
  545. return obj[this];
  546. }
  547. function indexedGetter(obj) {
  548. var index = +this;
  549. if (index < 0) index = Math.max(0, index + obj.length);
  550. return obj[index];
  551. }
  552. Promise.prototype.get = function (propertyName) {
  553. var isIndex = (typeof propertyName === "number");
  554. var getter;
  555. if (!isIndex) {
  556. if (canEvaluate) {
  557. var maybeGetter = getGetter(propertyName);
  558. getter = maybeGetter !== null ? maybeGetter : namedGetter;
  559. } else {
  560. getter = namedGetter;
  561. }
  562. } else {
  563. getter = indexedGetter;
  564. }
  565. return this._then(getter, undefined, undefined, propertyName, undefined);
  566. };
  567. };
  568.  
  569. },{"./util":36}],6:[function(_dereq_,module,exports){
  570. "use strict";
  571. module.exports = function(Promise, PromiseArray, apiRejection, debug) {
  572. var util = _dereq_("./util");
  573. var tryCatch = util.tryCatch;
  574. var errorObj = util.errorObj;
  575. var async = Promise._async;
  576.  
  577. Promise.prototype["break"] = Promise.prototype.cancel = function() {
  578. if (!debug.cancellation()) return this._warn("cancellation is disabled");
  579.  
  580. var promise = this;
  581. var child = promise;
  582. while (promise._isCancellable()) {
  583. if (!promise._cancelBy(child)) {
  584. if (child._isFollowing()) {
  585. child._followee().cancel();
  586. } else {
  587. child._cancelBranched();
  588. }
  589. break;
  590. }
  591.  
  592. var parent = promise._cancellationParent;
  593. if (parent == null || !parent._isCancellable()) {
  594. if (promise._isFollowing()) {
  595. promise._followee().cancel();
  596. } else {
  597. promise._cancelBranched();
  598. }
  599. break;
  600. } else {
  601. if (promise._isFollowing()) promise._followee().cancel();
  602. promise._setWillBeCancelled();
  603. child = promise;
  604. promise = parent;
  605. }
  606. }
  607. };
  608.  
  609. Promise.prototype._branchHasCancelled = function() {
  610. this._branchesRemainingToCancel--;
  611. };
  612.  
  613. Promise.prototype._enoughBranchesHaveCancelled = function() {
  614. return this._branchesRemainingToCancel === undefined ||
  615. this._branchesRemainingToCancel <= 0;
  616. };
  617.  
  618. Promise.prototype._cancelBy = function(canceller) {
  619. if (canceller === this) {
  620. this._branchesRemainingToCancel = 0;
  621. this._invokeOnCancel();
  622. return true;
  623. } else {
  624. this._branchHasCancelled();
  625. if (this._enoughBranchesHaveCancelled()) {
  626. this._invokeOnCancel();
  627. return true;
  628. }
  629. }
  630. return false;
  631. };
  632.  
  633. Promise.prototype._cancelBranched = function() {
  634. if (this._enoughBranchesHaveCancelled()) {
  635. this._cancel();
  636. }
  637. };
  638.  
  639. Promise.prototype._cancel = function() {
  640. if (!this._isCancellable()) return;
  641. this._setCancelled();
  642. async.invoke(this._cancelPromises, this, undefined);
  643. };
  644.  
  645. Promise.prototype._cancelPromises = function() {
  646. if (this._length() > 0) this._settlePromises();
  647. };
  648.  
  649. Promise.prototype._unsetOnCancel = function() {
  650. this._onCancelField = undefined;
  651. };
  652.  
  653. Promise.prototype._isCancellable = function() {
  654. return this.isPending() && !this._isCancelled();
  655. };
  656.  
  657. Promise.prototype.isCancellable = function() {
  658. return this.isPending() && !this.isCancelled();
  659. };
  660.  
  661. Promise.prototype._doInvokeOnCancel = function(onCancelCallback, internalOnly) {
  662. if (util.isArray(onCancelCallback)) {
  663. for (var i = 0; i < onCancelCallback.length; ++i) {
  664. this._doInvokeOnCancel(onCancelCallback[i], internalOnly);
  665. }
  666. } else if (onCancelCallback !== undefined) {
  667. if (typeof onCancelCallback === "function") {
  668. if (!internalOnly) {
  669. var e = tryCatch(onCancelCallback).call(this._boundValue());
  670. if (e === errorObj) {
  671. this._attachExtraTrace(e.e);
  672. async.throwLater(e.e);
  673. }
  674. }
  675. } else {
  676. onCancelCallback._resultCancelled(this);
  677. }
  678. }
  679. };
  680.  
  681. Promise.prototype._invokeOnCancel = function() {
  682. var onCancelCallback = this._onCancel();
  683. this._unsetOnCancel();
  684. async.invoke(this._doInvokeOnCancel, this, onCancelCallback);
  685. };
  686.  
  687. Promise.prototype._invokeInternalOnCancel = function() {
  688. if (this._isCancellable()) {
  689. this._doInvokeOnCancel(this._onCancel(), true);
  690. this._unsetOnCancel();
  691. }
  692. };
  693.  
  694. Promise.prototype._resultCancelled = function() {
  695. this.cancel();
  696. };
  697.  
  698. };
  699.  
  700. },{"./util":36}],7:[function(_dereq_,module,exports){
  701. "use strict";
  702. module.exports = function(NEXT_FILTER) {
  703. var util = _dereq_("./util");
  704. var getKeys = _dereq_("./es5").keys;
  705. var tryCatch = util.tryCatch;
  706. var errorObj = util.errorObj;
  707.  
  708. function catchFilter(instances, cb, promise) {
  709. return function(e) {
  710. var boundTo = promise._boundValue();
  711. predicateLoop: for (var i = 0; i < instances.length; ++i) {
  712. var item = instances[i];
  713.  
  714. if (item === Error ||
  715. (item != null && item.prototype instanceof Error)) {
  716. if (e instanceof item) {
  717. return tryCatch(cb).call(boundTo, e);
  718. }
  719. } else if (typeof item === "function") {
  720. var matchesPredicate = tryCatch(item).call(boundTo, e);
  721. if (matchesPredicate === errorObj) {
  722. return matchesPredicate;
  723. } else if (matchesPredicate) {
  724. return tryCatch(cb).call(boundTo, e);
  725. }
  726. } else if (util.isObject(e)) {
  727. var keys = getKeys(item);
  728. for (var j = 0; j < keys.length; ++j) {
  729. var key = keys[j];
  730. if (item[key] != e[key]) {
  731. continue predicateLoop;
  732. }
  733. }
  734. return tryCatch(cb).call(boundTo, e);
  735. }
  736. }
  737. return NEXT_FILTER;
  738. };
  739. }
  740.  
  741. return catchFilter;
  742. };
  743.  
  744. },{"./es5":13,"./util":36}],8:[function(_dereq_,module,exports){
  745. "use strict";
  746. module.exports = function(Promise) {
  747. var longStackTraces = false;
  748. var contextStack = [];
  749.  
  750. Promise.prototype._promiseCreated = function() {};
  751. Promise.prototype._pushContext = function() {};
  752. Promise.prototype._popContext = function() {return null;};
  753. Promise._peekContext = Promise.prototype._peekContext = function() {};
  754.  
  755. function Context() {
  756. this._trace = new Context.CapturedTrace(peekContext());
  757. }
  758. Context.prototype._pushContext = function () {
  759. if (this._trace !== undefined) {
  760. this._trace._promiseCreated = null;
  761. contextStack.push(this._trace);
  762. }
  763. };
  764.  
  765. Context.prototype._popContext = function () {
  766. if (this._trace !== undefined) {
  767. var trace = contextStack.pop();
  768. var ret = trace._promiseCreated;
  769. trace._promiseCreated = null;
  770. return ret;
  771. }
  772. return null;
  773. };
  774.  
  775. function createContext() {
  776. if (longStackTraces) return new Context();
  777. }
  778.  
  779. function peekContext() {
  780. var lastIndex = contextStack.length - 1;
  781. if (lastIndex >= 0) {
  782. return contextStack[lastIndex];
  783. }
  784. return undefined;
  785. }
  786. Context.CapturedTrace = null;
  787. Context.create = createContext;
  788. Context.deactivateLongStackTraces = function() {};
  789. Context.activateLongStackTraces = function() {
  790. var Promise_pushContext = Promise.prototype._pushContext;
  791. var Promise_popContext = Promise.prototype._popContext;
  792. var Promise_PeekContext = Promise._peekContext;
  793. var Promise_peekContext = Promise.prototype._peekContext;
  794. var Promise_promiseCreated = Promise.prototype._promiseCreated;
  795. Context.deactivateLongStackTraces = function() {
  796. Promise.prototype._pushContext = Promise_pushContext;
  797. Promise.prototype._popContext = Promise_popContext;
  798. Promise._peekContext = Promise_PeekContext;
  799. Promise.prototype._peekContext = Promise_peekContext;
  800. Promise.prototype._promiseCreated = Promise_promiseCreated;
  801. longStackTraces = false;
  802. };
  803. longStackTraces = true;
  804. Promise.prototype._pushContext = Context.prototype._pushContext;
  805. Promise.prototype._popContext = Context.prototype._popContext;
  806. Promise._peekContext = Promise.prototype._peekContext = peekContext;
  807. Promise.prototype._promiseCreated = function() {
  808. var ctx = this._peekContext();
  809. if (ctx && ctx._promiseCreated == null) ctx._promiseCreated = this;
  810. };
  811. };
  812. return Context;
  813. };
  814.  
  815. },{}],9:[function(_dereq_,module,exports){
  816. "use strict";
  817. module.exports = function(Promise, Context) {
  818. var getDomain = Promise._getDomain;
  819. var async = Promise._async;
  820. var Warning = _dereq_("./errors").Warning;
  821. var util = _dereq_("./util");
  822. var canAttachTrace = util.canAttachTrace;
  823. var unhandledRejectionHandled;
  824. var possiblyUnhandledRejection;
  825. var bluebirdFramePattern =
  826. /[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/;
  827. var nodeFramePattern = /\((?:timers\.js):\d+:\d+\)/;
  828. var parseLinePattern = /[\/<\(](.+?):(\d+):(\d+)\)?\s*$/;
  829. var stackFramePattern = null;
  830. var formatStack = null;
  831. var indentStackFrames = false;
  832. var printWarning;
  833. var debugging = !!(util.env("BLUEBIRD_DEBUG") != 0 &&
  834. (true ||
  835. util.env("BLUEBIRD_DEBUG") ||
  836. util.env("NODE_ENV") === "development"));
  837.  
  838. var warnings = !!(util.env("BLUEBIRD_WARNINGS") != 0 &&
  839. (debugging || util.env("BLUEBIRD_WARNINGS")));
  840.  
  841. var longStackTraces = !!(util.env("BLUEBIRD_LONG_STACK_TRACES") != 0 &&
  842. (debugging || util.env("BLUEBIRD_LONG_STACK_TRACES")));
  843.  
  844. var wForgottenReturn = util.env("BLUEBIRD_W_FORGOTTEN_RETURN") != 0 &&
  845. (warnings || !!util.env("BLUEBIRD_W_FORGOTTEN_RETURN"));
  846.  
  847. Promise.prototype.suppressUnhandledRejections = function() {
  848. var target = this._target();
  849. target._bitField = ((target._bitField & (~1048576)) |
  850. 524288);
  851. };
  852.  
  853. Promise.prototype._ensurePossibleRejectionHandled = function () {
  854. if ((this._bitField & 524288) !== 0) return;
  855. this._setRejectionIsUnhandled();
  856. async.invokeLater(this._notifyUnhandledRejection, this, undefined);
  857. };
  858.  
  859. Promise.prototype._notifyUnhandledRejectionIsHandled = function () {
  860. fireRejectionEvent("rejectionHandled",
  861. unhandledRejectionHandled, undefined, this);
  862. };
  863.  
  864. Promise.prototype._setReturnedNonUndefined = function() {
  865. this._bitField = this._bitField | 268435456;
  866. };
  867.  
  868. Promise.prototype._returnedNonUndefined = function() {
  869. return (this._bitField & 268435456) !== 0;
  870. };
  871.  
  872. Promise.prototype._notifyUnhandledRejection = function () {
  873. if (this._isRejectionUnhandled()) {
  874. var reason = this._settledValue();
  875. this._setUnhandledRejectionIsNotified();
  876. fireRejectionEvent("unhandledRejection",
  877. possiblyUnhandledRejection, reason, this);
  878. }
  879. };
  880.  
  881. Promise.prototype._setUnhandledRejectionIsNotified = function () {
  882. this._bitField = this._bitField | 262144;
  883. };
  884.  
  885. Promise.prototype._unsetUnhandledRejectionIsNotified = function () {
  886. this._bitField = this._bitField & (~262144);
  887. };
  888.  
  889. Promise.prototype._isUnhandledRejectionNotified = function () {
  890. return (this._bitField & 262144) > 0;
  891. };
  892.  
  893. Promise.prototype._setRejectionIsUnhandled = function () {
  894. this._bitField = this._bitField | 1048576;
  895. };
  896.  
  897. Promise.prototype._unsetRejectionIsUnhandled = function () {
  898. this._bitField = this._bitField & (~1048576);
  899. if (this._isUnhandledRejectionNotified()) {
  900. this._unsetUnhandledRejectionIsNotified();
  901. this._notifyUnhandledRejectionIsHandled();
  902. }
  903. };
  904.  
  905. Promise.prototype._isRejectionUnhandled = function () {
  906. return (this._bitField & 1048576) > 0;
  907. };
  908.  
  909. Promise.prototype._warn = function(message, shouldUseOwnTrace, promise) {
  910. return warn(message, shouldUseOwnTrace, promise || this);
  911. };
  912.  
  913. Promise.onPossiblyUnhandledRejection = function (fn) {
  914. var domain = getDomain();
  915. possiblyUnhandledRejection =
  916. typeof fn === "function" ? (domain === null ?
  917. fn : util.domainBind(domain, fn))
  918. : undefined;
  919. };
  920.  
  921. Promise.onUnhandledRejectionHandled = function (fn) {
  922. var domain = getDomain();
  923. unhandledRejectionHandled =
  924. typeof fn === "function" ? (domain === null ?
  925. fn : util.domainBind(domain, fn))
  926. : undefined;
  927. };
  928.  
  929. var disableLongStackTraces = function() {};
  930. Promise.longStackTraces = function () {
  931. if (async.haveItemsQueued() && !config.longStackTraces) {
  932. throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  933. }
  934. if (!config.longStackTraces && longStackTracesIsSupported()) {
  935. var Promise_captureStackTrace = Promise.prototype._captureStackTrace;
  936. var Promise_attachExtraTrace = Promise.prototype._attachExtraTrace;
  937. config.longStackTraces = true;
  938. disableLongStackTraces = function() {
  939. if (async.haveItemsQueued() && !config.longStackTraces) {
  940. throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  941. }
  942. Promise.prototype._captureStackTrace = Promise_captureStackTrace;
  943. Promise.prototype._attachExtraTrace = Promise_attachExtraTrace;
  944. Context.deactivateLongStackTraces();
  945. async.enableTrampoline();
  946. config.longStackTraces = false;
  947. };
  948. Promise.prototype._captureStackTrace = longStackTracesCaptureStackTrace;
  949. Promise.prototype._attachExtraTrace = longStackTracesAttachExtraTrace;
  950. Context.activateLongStackTraces();
  951. async.disableTrampolineIfNecessary();
  952. }
  953. };
  954.  
  955. Promise.hasLongStackTraces = function () {
  956. return config.longStackTraces && longStackTracesIsSupported();
  957. };
  958.  
  959. var fireDomEvent = (function() {
  960. try {
  961. if (typeof CustomEvent === "function") {
  962. var event = new CustomEvent("CustomEvent");
  963. util.global.dispatchEvent(event);
  964. return function(name, event) {
  965. var domEvent = new CustomEvent(name.toLowerCase(), {
  966. detail: event,
  967. cancelable: true
  968. });
  969. return !util.global.dispatchEvent(domEvent);
  970. };
  971. } else if (typeof Event === "function") {
  972. var event = new Event("CustomEvent");
  973. util.global.dispatchEvent(event);
  974. return function(name, event) {
  975. var domEvent = new Event(name.toLowerCase(), {
  976. cancelable: true
  977. });
  978. domEvent.detail = event;
  979. return !util.global.dispatchEvent(domEvent);
  980. };
  981. } else {
  982. var event = document.createEvent("CustomEvent");
  983. event.initCustomEvent("testingtheevent", false, true, {});
  984. util.global.dispatchEvent(event);
  985. return function(name, event) {
  986. var domEvent = document.createEvent("CustomEvent");
  987. domEvent.initCustomEvent(name.toLowerCase(), false, true,
  988. event);
  989. return !util.global.dispatchEvent(domEvent);
  990. };
  991. }
  992. } catch (e) {}
  993. return function() {
  994. return false;
  995. };
  996. })();
  997.  
  998. var fireGlobalEvent = (function() {
  999. if (util.isNode) {
  1000. return function() {
  1001. return process.emit.apply(process, arguments);
  1002. };
  1003. } else {
  1004. if (!util.global) {
  1005. return function() {
  1006. return false;
  1007. };
  1008. }
  1009. return function(name) {
  1010. var methodName = "on" + name.toLowerCase();
  1011. var method = util.global[methodName];
  1012. if (!method) return false;
  1013. method.apply(util.global, [].slice.call(arguments, 1));
  1014. return true;
  1015. };
  1016. }
  1017. })();
  1018.  
  1019. function generatePromiseLifecycleEventObject(name, promise) {
  1020. return {promise: promise};
  1021. }
  1022.  
  1023. var eventToObjectGenerator = {
  1024. promiseCreated: generatePromiseLifecycleEventObject,
  1025. promiseFulfilled: generatePromiseLifecycleEventObject,
  1026. promiseRejected: generatePromiseLifecycleEventObject,
  1027. promiseResolved: generatePromiseLifecycleEventObject,
  1028. promiseCancelled: generatePromiseLifecycleEventObject,
  1029. promiseChained: function(name, promise, child) {
  1030. return {promise: promise, child: child};
  1031. },
  1032. warning: function(name, warning) {
  1033. return {warning: warning};
  1034. },
  1035. unhandledRejection: function (name, reason, promise) {
  1036. return {reason: reason, promise: promise};
  1037. },
  1038. rejectionHandled: generatePromiseLifecycleEventObject
  1039. };
  1040.  
  1041. var activeFireEvent = function (name) {
  1042. var globalEventFired = false;
  1043. try {
  1044. globalEventFired = fireGlobalEvent.apply(null, arguments);
  1045. } catch (e) {
  1046. async.throwLater(e);
  1047. globalEventFired = true;
  1048. }
  1049.  
  1050. var domEventFired = false;
  1051. try {
  1052. domEventFired = fireDomEvent(name,
  1053. eventToObjectGenerator[name].apply(null, arguments));
  1054. } catch (e) {
  1055. async.throwLater(e);
  1056. domEventFired = true;
  1057. }
  1058.  
  1059. return domEventFired || globalEventFired;
  1060. };
  1061.  
  1062. Promise.config = function(opts) {
  1063. opts = Object(opts);
  1064. if ("longStackTraces" in opts) {
  1065. if (opts.longStackTraces) {
  1066. Promise.longStackTraces();
  1067. } else if (!opts.longStackTraces && Promise.hasLongStackTraces()) {
  1068. disableLongStackTraces();
  1069. }
  1070. }
  1071. if ("warnings" in opts) {
  1072. var warningsOption = opts.warnings;
  1073. config.warnings = !!warningsOption;
  1074. wForgottenReturn = config.warnings;
  1075.  
  1076. if (util.isObject(warningsOption)) {
  1077. if ("wForgottenReturn" in warningsOption) {
  1078. wForgottenReturn = !!warningsOption.wForgottenReturn;
  1079. }
  1080. }
  1081. }
  1082. if ("cancellation" in opts && opts.cancellation && !config.cancellation) {
  1083. if (async.haveItemsQueued()) {
  1084. throw new Error(
  1085. "cannot enable cancellation after promises are in use");
  1086. }
  1087. Promise.prototype._clearCancellationData =
  1088. cancellationClearCancellationData;
  1089. Promise.prototype._propagateFrom = cancellationPropagateFrom;
  1090. Promise.prototype._onCancel = cancellationOnCancel;
  1091. Promise.prototype._setOnCancel = cancellationSetOnCancel;
  1092. Promise.prototype._attachCancellationCallback =
  1093. cancellationAttachCancellationCallback;
  1094. Promise.prototype._execute = cancellationExecute;
  1095. propagateFromFunction = cancellationPropagateFrom;
  1096. config.cancellation = true;
  1097. }
  1098. if ("monitoring" in opts) {
  1099. if (opts.monitoring && !config.monitoring) {
  1100. config.monitoring = true;
  1101. Promise.prototype._fireEvent = activeFireEvent;
  1102. } else if (!opts.monitoring && config.monitoring) {
  1103. config.monitoring = false;
  1104. Promise.prototype._fireEvent = defaultFireEvent;
  1105. }
  1106. }
  1107. return Promise;
  1108. };
  1109.  
  1110. function defaultFireEvent() { return false; }
  1111.  
  1112. Promise.prototype._fireEvent = defaultFireEvent;
  1113. Promise.prototype._execute = function(executor, resolve, reject) {
  1114. try {
  1115. executor(resolve, reject);
  1116. } catch (e) {
  1117. return e;
  1118. }
  1119. };
  1120. Promise.prototype._onCancel = function () {};
  1121. Promise.prototype._setOnCancel = function (handler) { ; };
  1122. Promise.prototype._attachCancellationCallback = function(onCancel) {
  1123. ;
  1124. };
  1125. Promise.prototype._captureStackTrace = function () {};
  1126. Promise.prototype._attachExtraTrace = function () {};
  1127. Promise.prototype._clearCancellationData = function() {};
  1128. Promise.prototype._propagateFrom = function (parent, flags) {
  1129. ;
  1130. ;
  1131. };
  1132.  
  1133. function cancellationExecute(executor, resolve, reject) {
  1134. var promise = this;
  1135. try {
  1136. executor(resolve, reject, function(onCancel) {
  1137. if (typeof onCancel !== "function") {
  1138. throw new TypeError("onCancel must be a function, got: " +
  1139. util.toString(onCancel));
  1140. }
  1141. promise._attachCancellationCallback(onCancel);
  1142. });
  1143. } catch (e) {
  1144. return e;
  1145. }
  1146. }
  1147.  
  1148. function cancellationAttachCancellationCallback(onCancel) {
  1149. if (!this._isCancellable()) return this;
  1150.  
  1151. var previousOnCancel = this._onCancel();
  1152. if (previousOnCancel !== undefined) {
  1153. if (util.isArray(previousOnCancel)) {
  1154. previousOnCancel.push(onCancel);
  1155. } else {
  1156. this._setOnCancel([previousOnCancel, onCancel]);
  1157. }
  1158. } else {
  1159. this._setOnCancel(onCancel);
  1160. }
  1161. }
  1162.  
  1163. function cancellationOnCancel() {
  1164. return this._onCancelField;
  1165. }
  1166.  
  1167. function cancellationSetOnCancel(onCancel) {
  1168. this._onCancelField = onCancel;
  1169. }
  1170.  
  1171. function cancellationClearCancellationData() {
  1172. this._cancellationParent = undefined;
  1173. this._onCancelField = undefined;
  1174. }
  1175.  
  1176. function cancellationPropagateFrom(parent, flags) {
  1177. if ((flags & 1) !== 0) {
  1178. this._cancellationParent = parent;
  1179. var branchesRemainingToCancel = parent._branchesRemainingToCancel;
  1180. if (branchesRemainingToCancel === undefined) {
  1181. branchesRemainingToCancel = 0;
  1182. }
  1183. parent._branchesRemainingToCancel = branchesRemainingToCancel + 1;
  1184. }
  1185. if ((flags & 2) !== 0 && parent._isBound()) {
  1186. this._setBoundTo(parent._boundTo);
  1187. }
  1188. }
  1189.  
  1190. function bindingPropagateFrom(parent, flags) {
  1191. if ((flags & 2) !== 0 && parent._isBound()) {
  1192. this._setBoundTo(parent._boundTo);
  1193. }
  1194. }
  1195. var propagateFromFunction = bindingPropagateFrom;
  1196.  
  1197. function boundValueFunction() {
  1198. var ret = this._boundTo;
  1199. if (ret !== undefined) {
  1200. if (ret instanceof Promise) {
  1201. if (ret.isFulfilled()) {
  1202. return ret.value();
  1203. } else {
  1204. return undefined;
  1205. }
  1206. }
  1207. }
  1208. return ret;
  1209. }
  1210.  
  1211. function longStackTracesCaptureStackTrace() {
  1212. this._trace = new CapturedTrace(this._peekContext());
  1213. }
  1214.  
  1215. function longStackTracesAttachExtraTrace(error, ignoreSelf) {
  1216. if (canAttachTrace(error)) {
  1217. var trace = this._trace;
  1218. if (trace !== undefined) {
  1219. if (ignoreSelf) trace = trace._parent;
  1220. }
  1221. if (trace !== undefined) {
  1222. trace.attachExtraTrace(error);
  1223. } else if (!error.__stackCleaned__) {
  1224. var parsed = parseStackAndMessage(error);
  1225. util.notEnumerableProp(error, "stack",
  1226. parsed.message + "\n" + parsed.stack.join("\n"));
  1227. util.notEnumerableProp(error, "__stackCleaned__", true);
  1228. }
  1229. }
  1230. }
  1231.  
  1232. function checkForgottenReturns(returnValue, promiseCreated, name, promise,
  1233. parent) {
  1234. if (returnValue === undefined && promiseCreated !== null &&
  1235. wForgottenReturn) {
  1236. if (parent !== undefined && parent._returnedNonUndefined()) return;
  1237. if ((promise._bitField & 65535) === 0) return;
  1238.  
  1239. if (name) name = name + " ";
  1240. var handlerLine = "";
  1241. var creatorLine = "";
  1242. if (promiseCreated._trace) {
  1243. var traceLines = promiseCreated._trace.stack.split("\n");
  1244. var stack = cleanStack(traceLines);
  1245. for (var i = stack.length - 1; i >= 0; --i) {
  1246. var line = stack[i];
  1247. if (!nodeFramePattern.test(line)) {
  1248. var lineMatches = line.match(parseLinePattern);
  1249. if (lineMatches) {
  1250. handlerLine = "at " + lineMatches[1] +
  1251. ":" + lineMatches[2] + ":" + lineMatches[3] + " ";
  1252. }
  1253. break;
  1254. }
  1255. }
  1256.  
  1257. if (stack.length > 0) {
  1258. var firstUserLine = stack[0];
  1259. for (var i = 0; i < traceLines.length; ++i) {
  1260.  
  1261. if (traceLines[i] === firstUserLine) {
  1262. if (i > 0) {
  1263. creatorLine = "\n" + traceLines[i - 1];
  1264. }
  1265. break;
  1266. }
  1267. }
  1268.  
  1269. }
  1270. }
  1271. var msg = "a promise was created in a " + name +
  1272. "handler " + handlerLine + "but was not returned from it, " +
  1273. "see http://goo.gl/rRqMUw" +
  1274. creatorLine;
  1275. promise._warn(msg, true, promiseCreated);
  1276. }
  1277. }
  1278.  
  1279. function deprecated(name, replacement) {
  1280. var message = name +
  1281. " is deprecated and will be removed in a future version.";
  1282. if (replacement) message += " Use " + replacement + " instead.";
  1283. return warn(message);
  1284. }
  1285.  
  1286. function warn(message, shouldUseOwnTrace, promise) {
  1287. if (!config.warnings) return;
  1288. var warning = new Warning(message);
  1289. var ctx;
  1290. if (shouldUseOwnTrace) {
  1291. promise._attachExtraTrace(warning);
  1292. } else if (config.longStackTraces && (ctx = Promise._peekContext())) {
  1293. ctx.attachExtraTrace(warning);
  1294. } else {
  1295. var parsed = parseStackAndMessage(warning);
  1296. warning.stack = parsed.message + "\n" + parsed.stack.join("\n");
  1297. }
  1298.  
  1299. if (!activeFireEvent("warning", warning)) {
  1300. formatAndLogError(warning, "", true);
  1301. }
  1302. }
  1303.  
  1304. function reconstructStack(message, stacks) {
  1305. for (var i = 0; i < stacks.length - 1; ++i) {
  1306. stacks[i].push("From previous event:");
  1307. stacks[i] = stacks[i].join("\n");
  1308. }
  1309. if (i < stacks.length) {
  1310. stacks[i] = stacks[i].join("\n");
  1311. }
  1312. return message + "\n" + stacks.join("\n");
  1313. }
  1314.  
  1315. function removeDuplicateOrEmptyJumps(stacks) {
  1316. for (var i = 0; i < stacks.length; ++i) {
  1317. if (stacks[i].length === 0 ||
  1318. ((i + 1 < stacks.length) && stacks[i][0] === stacks[i+1][0])) {
  1319. stacks.splice(i, 1);
  1320. i--;
  1321. }
  1322. }
  1323. }
  1324.  
  1325. function removeCommonRoots(stacks) {
  1326. var current = stacks[0];
  1327. for (var i = 1; i < stacks.length; ++i) {
  1328. var prev = stacks[i];
  1329. var currentLastIndex = current.length - 1;
  1330. var currentLastLine = current[currentLastIndex];
  1331. var commonRootMeetPoint = -1;
  1332.  
  1333. for (var j = prev.length - 1; j >= 0; --j) {
  1334. if (prev[j] === currentLastLine) {
  1335. commonRootMeetPoint = j;
  1336. break;
  1337. }
  1338. }
  1339.  
  1340. for (var j = commonRootMeetPoint; j >= 0; --j) {
  1341. var line = prev[j];
  1342. if (current[currentLastIndex] === line) {
  1343. current.pop();
  1344. currentLastIndex--;
  1345. } else {
  1346. break;
  1347. }
  1348. }
  1349. current = prev;
  1350. }
  1351. }
  1352.  
  1353. function cleanStack(stack) {
  1354. var ret = [];
  1355. for (var i = 0; i < stack.length; ++i) {
  1356. var line = stack[i];
  1357. var isTraceLine = " (No stack trace)" === line ||
  1358. stackFramePattern.test(line);
  1359. var isInternalFrame = isTraceLine && shouldIgnore(line);
  1360. if (isTraceLine && !isInternalFrame) {
  1361. if (indentStackFrames && line.charAt(0) !== " ") {
  1362. line = " " + line;
  1363. }
  1364. ret.push(line);
  1365. }
  1366. }
  1367. return ret;
  1368. }
  1369.  
  1370. function stackFramesAsArray(error) {
  1371. var stack = error.stack.replace(/\s+$/g, "").split("\n");
  1372. for (var i = 0; i < stack.length; ++i) {
  1373. var line = stack[i];
  1374. if (" (No stack trace)" === line || stackFramePattern.test(line)) {
  1375. break;
  1376. }
  1377. }
  1378. if (i > 0 && error.name != "SyntaxError") {
  1379. stack = stack.slice(i);
  1380. }
  1381. return stack;
  1382. }
  1383.  
  1384. function parseStackAndMessage(error) {
  1385. var stack = error.stack;
  1386. var message = error.toString();
  1387. stack = typeof stack === "string" && stack.length > 0
  1388. ? stackFramesAsArray(error) : [" (No stack trace)"];
  1389. return {
  1390. message: message,
  1391. stack: error.name == "SyntaxError" ? stack : cleanStack(stack)
  1392. };
  1393. }
  1394.  
  1395. function formatAndLogError(error, title, isSoft) {
  1396. if (typeof console !== "undefined") {
  1397. var message;
  1398. if (util.isObject(error)) {
  1399. var stack = error.stack;
  1400. message = title + formatStack(stack, error);
  1401. } else {
  1402. message = title + String(error);
  1403. }
  1404. if (typeof printWarning === "function") {
  1405. printWarning(message, isSoft);
  1406. } else if (typeof console.log === "function" ||
  1407. typeof console.log === "object") {
  1408. console.log(message);
  1409. }
  1410. }
  1411. }
  1412.  
  1413. function fireRejectionEvent(name, localHandler, reason, promise) {
  1414. var localEventFired = false;
  1415. try {
  1416. if (typeof localHandler === "function") {
  1417. localEventFired = true;
  1418. if (name === "rejectionHandled") {
  1419. localHandler(promise);
  1420. } else {
  1421. localHandler(reason, promise);
  1422. }
  1423. }
  1424. } catch (e) {
  1425. async.throwLater(e);
  1426. }
  1427.  
  1428. if (name === "unhandledRejection") {
  1429. if (!activeFireEvent(name, reason, promise) && !localEventFired) {
  1430. formatAndLogError(reason, "Unhandled rejection ");
  1431. }
  1432. } else {
  1433. activeFireEvent(name, promise);
  1434. }
  1435. }
  1436.  
  1437. function formatNonError(obj) {
  1438. var str;
  1439. if (typeof obj === "function") {
  1440. str = "[function " +
  1441. (obj.name || "anonymous") +
  1442. "]";
  1443. } else {
  1444. str = obj && typeof obj.toString === "function"
  1445. ? obj.toString() : util.toString(obj);
  1446. var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/;
  1447. if (ruselessToString.test(str)) {
  1448. try {
  1449. var newStr = JSON.stringify(obj);
  1450. str = newStr;
  1451. }
  1452. catch(e) {
  1453.  
  1454. }
  1455. }
  1456. if (str.length === 0) {
  1457. str = "(empty array)";
  1458. }
  1459. }
  1460. return ("(<" + snip(str) + ">, no stack trace)");
  1461. }
  1462.  
  1463. function snip(str) {
  1464. var maxChars = 41;
  1465. if (str.length < maxChars) {
  1466. return str;
  1467. }
  1468. return str.substr(0, maxChars - 3) + "...";
  1469. }
  1470.  
  1471. function longStackTracesIsSupported() {
  1472. return typeof captureStackTrace === "function";
  1473. }
  1474.  
  1475. var shouldIgnore = function() { return false; };
  1476. var parseLineInfoRegex = /[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;
  1477. function parseLineInfo(line) {
  1478. var matches = line.match(parseLineInfoRegex);
  1479. if (matches) {
  1480. return {
  1481. fileName: matches[1],
  1482. line: parseInt(matches[2], 10)
  1483. };
  1484. }
  1485. }
  1486.  
  1487. function setBounds(firstLineError, lastLineError) {
  1488. if (!longStackTracesIsSupported()) return;
  1489. var firstStackLines = firstLineError.stack.split("\n");
  1490. var lastStackLines = lastLineError.stack.split("\n");
  1491. var firstIndex = -1;
  1492. var lastIndex = -1;
  1493. var firstFileName;
  1494. var lastFileName;
  1495. for (var i = 0; i < firstStackLines.length; ++i) {
  1496. var result = parseLineInfo(firstStackLines[i]);
  1497. if (result) {
  1498. firstFileName = result.fileName;
  1499. firstIndex = result.line;
  1500. break;
  1501. }
  1502. }
  1503. for (var i = 0; i < lastStackLines.length; ++i) {
  1504. var result = parseLineInfo(lastStackLines[i]);
  1505. if (result) {
  1506. lastFileName = result.fileName;
  1507. lastIndex = result.line;
  1508. break;
  1509. }
  1510. }
  1511. if (firstIndex < 0 || lastIndex < 0 || !firstFileName || !lastFileName ||
  1512. firstFileName !== lastFileName || firstIndex >= lastIndex) {
  1513. return;
  1514. }
  1515.  
  1516. shouldIgnore = function(line) {
  1517. if (bluebirdFramePattern.test(line)) return true;
  1518. var info = parseLineInfo(line);
  1519. if (info) {
  1520. if (info.fileName === firstFileName &&
  1521. (firstIndex <= info.line && info.line <= lastIndex)) {
  1522. return true;
  1523. }
  1524. }
  1525. return false;
  1526. };
  1527. }
  1528.  
  1529. function CapturedTrace(parent) {
  1530. this._parent = parent;
  1531. this._promisesCreated = 0;
  1532. var length = this._length = 1 + (parent === undefined ? 0 : parent._length);
  1533. captureStackTrace(this, CapturedTrace);
  1534. if (length > 32) this.uncycle();
  1535. }
  1536. util.inherits(CapturedTrace, Error);
  1537. Context.CapturedTrace = CapturedTrace;
  1538.  
  1539. CapturedTrace.prototype.uncycle = function() {
  1540. var length = this._length;
  1541. if (length < 2) return;
  1542. var nodes = [];
  1543. var stackToIndex = {};
  1544.  
  1545. for (var i = 0, node = this; node !== undefined; ++i) {
  1546. nodes.push(node);
  1547. node = node._parent;
  1548. }
  1549. length = this._length = i;
  1550. for (var i = length - 1; i >= 0; --i) {
  1551. var stack = nodes[i].stack;
  1552. if (stackToIndex[stack] === undefined) {
  1553. stackToIndex[stack] = i;
  1554. }
  1555. }
  1556. for (var i = 0; i < length; ++i) {
  1557. var currentStack = nodes[i].stack;
  1558. var index = stackToIndex[currentStack];
  1559. if (index !== undefined && index !== i) {
  1560. if (index > 0) {
  1561. nodes[index - 1]._parent = undefined;
  1562. nodes[index - 1]._length = 1;
  1563. }
  1564. nodes[i]._parent = undefined;
  1565. nodes[i]._length = 1;
  1566. var cycleEdgeNode = i > 0 ? nodes[i - 1] : this;
  1567.  
  1568. if (index < length - 1) {
  1569. cycleEdgeNode._parent = nodes[index + 1];
  1570. cycleEdgeNode._parent.uncycle();
  1571. cycleEdgeNode._length =
  1572. cycleEdgeNode._parent._length + 1;
  1573. } else {
  1574. cycleEdgeNode._parent = undefined;
  1575. cycleEdgeNode._length = 1;
  1576. }
  1577. var currentChildLength = cycleEdgeNode._length + 1;
  1578. for (var j = i - 2; j >= 0; --j) {
  1579. nodes[j]._length = currentChildLength;
  1580. currentChildLength++;
  1581. }
  1582. return;
  1583. }
  1584. }
  1585. };
  1586.  
  1587. CapturedTrace.prototype.attachExtraTrace = function(error) {
  1588. if (error.__stackCleaned__) return;
  1589. this.uncycle();
  1590. var parsed = parseStackAndMessage(error);
  1591. var message = parsed.message;
  1592. var stacks = [parsed.stack];
  1593.  
  1594. var trace = this;
  1595. while (trace !== undefined) {
  1596. stacks.push(cleanStack(trace.stack.split("\n")));
  1597. trace = trace._parent;
  1598. }
  1599. removeCommonRoots(stacks);
  1600. removeDuplicateOrEmptyJumps(stacks);
  1601. util.notEnumerableProp(error, "stack", reconstructStack(message, stacks));
  1602. util.notEnumerableProp(error, "__stackCleaned__", true);
  1603. };
  1604.  
  1605. var captureStackTrace = (function stackDetection() {
  1606. var v8stackFramePattern = /^\s*at\s*/;
  1607. var v8stackFormatter = function(stack, error) {
  1608. if (typeof stack === "string") return stack;
  1609.  
  1610. if (error.name !== undefined &&
  1611. error.message !== undefined) {
  1612. return error.toString();
  1613. }
  1614. return formatNonError(error);
  1615. };
  1616.  
  1617. if (typeof Error.stackTraceLimit === "number" &&
  1618. typeof Error.captureStackTrace === "function") {
  1619. Error.stackTraceLimit += 6;
  1620. stackFramePattern = v8stackFramePattern;
  1621. formatStack = v8stackFormatter;
  1622. var captureStackTrace = Error.captureStackTrace;
  1623.  
  1624. shouldIgnore = function(line) {
  1625. return bluebirdFramePattern.test(line);
  1626. };
  1627. return function(receiver, ignoreUntil) {
  1628. Error.stackTraceLimit += 6;
  1629. captureStackTrace(receiver, ignoreUntil);
  1630. Error.stackTraceLimit -= 6;
  1631. };
  1632. }
  1633. var err = new Error();
  1634.  
  1635. if (typeof err.stack === "string" &&
  1636. err.stack.split("\n")[0].indexOf("stackDetection@") >= 0) {
  1637. stackFramePattern = /@/;
  1638. formatStack = v8stackFormatter;
  1639. indentStackFrames = true;
  1640. return function captureStackTrace(o) {
  1641. o.stack = new Error().stack;
  1642. };
  1643. }
  1644.  
  1645. var hasStackAfterThrow;
  1646. try { throw new Error(); }
  1647. catch(e) {
  1648. hasStackAfterThrow = ("stack" in e);
  1649. }
  1650. if (!("stack" in err) && hasStackAfterThrow &&
  1651. typeof Error.stackTraceLimit === "number") {
  1652. stackFramePattern = v8stackFramePattern;
  1653. formatStack = v8stackFormatter;
  1654. return function captureStackTrace(o) {
  1655. Error.stackTraceLimit += 6;
  1656. try { throw new Error(); }
  1657. catch(e) { o.stack = e.stack; }
  1658. Error.stackTraceLimit -= 6;
  1659. };
  1660. }
  1661.  
  1662. formatStack = function(stack, error) {
  1663. if (typeof stack === "string") return stack;
  1664.  
  1665. if ((typeof error === "object" ||
  1666. typeof error === "function") &&
  1667. error.name !== undefined &&
  1668. error.message !== undefined) {
  1669. return error.toString();
  1670. }
  1671. return formatNonError(error);
  1672. };
  1673.  
  1674. return null;
  1675.  
  1676. })([]);
  1677.  
  1678. if (typeof console !== "undefined" && typeof console.warn !== "undefined") {
  1679. printWarning = function (message) {
  1680. console.warn(message);
  1681. };
  1682. if (util.isNode && process.stderr.isTTY) {
  1683. printWarning = function(message, isSoft) {
  1684. var color = isSoft ? "\u001b[33m" : "\u001b[31m";
  1685. console.warn(color + message + "\u001b[0m\n");
  1686. };
  1687. } else if (!util.isNode && typeof (new Error().stack) === "string") {
  1688. printWarning = function(message, isSoft) {
  1689. console.warn("%c" + message,
  1690. isSoft ? "color: darkorange" : "color: red");
  1691. };
  1692. }
  1693. }
  1694.  
  1695. var config = {
  1696. warnings: warnings,
  1697. longStackTraces: false,
  1698. cancellation: false,
  1699. monitoring: false
  1700. };
  1701.  
  1702. if (longStackTraces) Promise.longStackTraces();
  1703.  
  1704. return {
  1705. longStackTraces: function() {
  1706. return config.longStackTraces;
  1707. },
  1708. warnings: function() {
  1709. return config.warnings;
  1710. },
  1711. cancellation: function() {
  1712. return config.cancellation;
  1713. },
  1714. monitoring: function() {
  1715. return config.monitoring;
  1716. },
  1717. propagateFromFunction: function() {
  1718. return propagateFromFunction;
  1719. },
  1720. boundValueFunction: function() {
  1721. return boundValueFunction;
  1722. },
  1723. checkForgottenReturns: checkForgottenReturns,
  1724. setBounds: setBounds,
  1725. warn: warn,
  1726. deprecated: deprecated,
  1727. CapturedTrace: CapturedTrace,
  1728. fireDomEvent: fireDomEvent,
  1729. fireGlobalEvent: fireGlobalEvent
  1730. };
  1731. };
  1732.  
  1733. },{"./errors":12,"./util":36}],10:[function(_dereq_,module,exports){
  1734. "use strict";
  1735. module.exports = function(Promise) {
  1736. function returner() {
  1737. return this.value;
  1738. }
  1739. function thrower() {
  1740. throw this.reason;
  1741. }
  1742.  
  1743. Promise.prototype["return"] =
  1744. Promise.prototype.thenReturn = function (value) {
  1745. if (value instanceof Promise) value.suppressUnhandledRejections();
  1746. return this._then(
  1747. returner, undefined, undefined, {value: value}, undefined);
  1748. };
  1749.  
  1750. Promise.prototype["throw"] =
  1751. Promise.prototype.thenThrow = function (reason) {
  1752. return this._then(
  1753. thrower, undefined, undefined, {reason: reason}, undefined);
  1754. };
  1755.  
  1756. Promise.prototype.catchThrow = function (reason) {
  1757. if (arguments.length <= 1) {
  1758. return this._then(
  1759. undefined, thrower, undefined, {reason: reason}, undefined);
  1760. } else {
  1761. var _reason = arguments[1];
  1762. var handler = function() {throw _reason;};
  1763. return this.caught(reason, handler);
  1764. }
  1765. };
  1766.  
  1767. Promise.prototype.catchReturn = function (value) {
  1768. if (arguments.length <= 1) {
  1769. if (value instanceof Promise) value.suppressUnhandledRejections();
  1770. return this._then(
  1771. undefined, returner, undefined, {value: value}, undefined);
  1772. } else {
  1773. var _value = arguments[1];
  1774. if (_value instanceof Promise) _value.suppressUnhandledRejections();
  1775. var handler = function() {return _value;};
  1776. return this.caught(value, handler);
  1777. }
  1778. };
  1779. };
  1780.  
  1781. },{}],11:[function(_dereq_,module,exports){
  1782. "use strict";
  1783. module.exports = function(Promise, INTERNAL) {
  1784. var PromiseReduce = Promise.reduce;
  1785. var PromiseAll = Promise.all;
  1786.  
  1787. function promiseAllThis() {
  1788. return PromiseAll(this);
  1789. }
  1790.  
  1791. function PromiseMapSeries(promises, fn) {
  1792. return PromiseReduce(promises, fn, INTERNAL, INTERNAL);
  1793. }
  1794.  
  1795. Promise.prototype.each = function (fn) {
  1796. return PromiseReduce(this, fn, INTERNAL, 0)
  1797. ._then(promiseAllThis, undefined, undefined, this, undefined);
  1798. };
  1799.  
  1800. Promise.prototype.mapSeries = function (fn) {
  1801. return PromiseReduce(this, fn, INTERNAL, INTERNAL);
  1802. };
  1803.  
  1804. Promise.each = function (promises, fn) {
  1805. return PromiseReduce(promises, fn, INTERNAL, 0)
  1806. ._then(promiseAllThis, undefined, undefined, promises, undefined);
  1807. };
  1808.  
  1809. Promise.mapSeries = PromiseMapSeries;
  1810. };
  1811.  
  1812.  
  1813. },{}],12:[function(_dereq_,module,exports){
  1814. "use strict";
  1815. var es5 = _dereq_("./es5");
  1816. var Objectfreeze = es5.freeze;
  1817. var util = _dereq_("./util");
  1818. var inherits = util.inherits;
  1819. var notEnumerableProp = util.notEnumerableProp;
  1820.  
  1821. function subError(nameProperty, defaultMessage) {
  1822. function SubError(message) {
  1823. if (!(this instanceof SubError)) return new SubError(message);
  1824. notEnumerableProp(this, "message",
  1825. typeof message === "string" ? message : defaultMessage);
  1826. notEnumerableProp(this, "name", nameProperty);
  1827. if (Error.captureStackTrace) {
  1828. Error.captureStackTrace(this, this.constructor);
  1829. } else {
  1830. Error.call(this);
  1831. }
  1832. }
  1833. inherits(SubError, Error);
  1834. return SubError;
  1835. }
  1836.  
  1837. var _TypeError, _RangeError;
  1838. var Warning = subError("Warning", "warning");
  1839. var CancellationError = subError("CancellationError", "cancellation error");
  1840. var TimeoutError = subError("TimeoutError", "timeout error");
  1841. var AggregateError = subError("AggregateError", "aggregate error");
  1842. try {
  1843. _TypeError = TypeError;
  1844. _RangeError = RangeError;
  1845. } catch(e) {
  1846. _TypeError = subError("TypeError", "type error");
  1847. _RangeError = subError("RangeError", "range error");
  1848. }
  1849.  
  1850. var methods = ("join pop push shift unshift slice filter forEach some " +
  1851. "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" ");
  1852.  
  1853. for (var i = 0; i < methods.length; ++i) {
  1854. if (typeof Array.prototype[methods[i]] === "function") {
  1855. AggregateError.prototype[methods[i]] = Array.prototype[methods[i]];
  1856. }
  1857. }
  1858.  
  1859. es5.defineProperty(AggregateError.prototype, "length", {
  1860. value: 0,
  1861. configurable: false,
  1862. writable: true,
  1863. enumerable: true
  1864. });
  1865. AggregateError.prototype["isOperational"] = true;
  1866. var level = 0;
  1867. AggregateError.prototype.toString = function() {
  1868. var indent = Array(level * 4 + 1).join(" ");
  1869. var ret = "\n" + indent + "AggregateError of:" + "\n";
  1870. level++;
  1871. indent = Array(level * 4 + 1).join(" ");
  1872. for (var i = 0; i < this.length; ++i) {
  1873. var str = this[i] === this ? "[Circular AggregateError]" : this[i] + "";
  1874. var lines = str.split("\n");
  1875. for (var j = 0; j < lines.length; ++j) {
  1876. lines[j] = indent + lines[j];
  1877. }
  1878. str = lines.join("\n");
  1879. ret += str + "\n";
  1880. }
  1881. level--;
  1882. return ret;
  1883. };
  1884.  
  1885. function OperationalError(message) {
  1886. if (!(this instanceof OperationalError))
  1887. return new OperationalError(message);
  1888. notEnumerableProp(this, "name", "OperationalError");
  1889. notEnumerableProp(this, "message", message);
  1890. this.cause = message;
  1891. this["isOperational"] = true;
  1892.  
  1893. if (message instanceof Error) {
  1894. notEnumerableProp(this, "message", message.message);
  1895. notEnumerableProp(this, "stack", message.stack);
  1896. } else if (Error.captureStackTrace) {
  1897. Error.captureStackTrace(this, this.constructor);
  1898. }
  1899.  
  1900. }
  1901. inherits(OperationalError, Error);
  1902.  
  1903. var errorTypes = Error["__BluebirdErrorTypes__"];
  1904. if (!errorTypes) {
  1905. errorTypes = Objectfreeze({
  1906. CancellationError: CancellationError,
  1907. TimeoutError: TimeoutError,
  1908. OperationalError: OperationalError,
  1909. RejectionError: OperationalError,
  1910. AggregateError: AggregateError
  1911. });
  1912. es5.defineProperty(Error, "__BluebirdErrorTypes__", {
  1913. value: errorTypes,
  1914. writable: false,
  1915. enumerable: false,
  1916. configurable: false
  1917. });
  1918. }
  1919.  
  1920. module.exports = {
  1921. Error: Error,
  1922. TypeError: _TypeError,
  1923. RangeError: _RangeError,
  1924. CancellationError: errorTypes.CancellationError,
  1925. OperationalError: errorTypes.OperationalError,
  1926. TimeoutError: errorTypes.TimeoutError,
  1927. AggregateError: errorTypes.AggregateError,
  1928. Warning: Warning
  1929. };
  1930.  
  1931. },{"./es5":13,"./util":36}],13:[function(_dereq_,module,exports){
  1932. var isES5 = (function(){
  1933. "use strict";
  1934. return this === undefined;
  1935. })();
  1936.  
  1937. if (isES5) {
  1938. module.exports = {
  1939. freeze: Object.freeze,
  1940. defineProperty: Object.defineProperty,
  1941. getDescriptor: Object.getOwnPropertyDescriptor,
  1942. keys: Object.keys,
  1943. names: Object.getOwnPropertyNames,
  1944. getPrototypeOf: Object.getPrototypeOf,
  1945. isArray: Array.isArray,
  1946. isES5: isES5,
  1947. propertyIsWritable: function(obj, prop) {
  1948. var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
  1949. return !!(!descriptor || descriptor.writable || descriptor.set);
  1950. }
  1951. };
  1952. } else {
  1953. var has = {}.hasOwnProperty;
  1954. var str = {}.toString;
  1955. var proto = {}.constructor.prototype;
  1956.  
  1957. var ObjectKeys = function (o) {
  1958. var ret = [];
  1959. for (var key in o) {
  1960. if (has.call(o, key)) {
  1961. ret.push(key);
  1962. }
  1963. }
  1964. return ret;
  1965. };
  1966.  
  1967. var ObjectGetDescriptor = function(o, key) {
  1968. return {value: o[key]};
  1969. };
  1970.  
  1971. var ObjectDefineProperty = function (o, key, desc) {
  1972. o[key] = desc.value;
  1973. return o;
  1974. };
  1975.  
  1976. var ObjectFreeze = function (obj) {
  1977. return obj;
  1978. };
  1979.  
  1980. var ObjectGetPrototypeOf = function (obj) {
  1981. try {
  1982. return Object(obj).constructor.prototype;
  1983. }
  1984. catch (e) {
  1985. return proto;
  1986. }
  1987. };
  1988.  
  1989. var ArrayIsArray = function (obj) {
  1990. try {
  1991. return str.call(obj) === "[object Array]";
  1992. }
  1993. catch(e) {
  1994. return false;
  1995. }
  1996. };
  1997.  
  1998. module.exports = {
  1999. isArray: ArrayIsArray,
  2000. keys: ObjectKeys,
  2001. names: ObjectKeys,
  2002. defineProperty: ObjectDefineProperty,
  2003. getDescriptor: ObjectGetDescriptor,
  2004. freeze: ObjectFreeze,
  2005. getPrototypeOf: ObjectGetPrototypeOf,
  2006. isES5: isES5,
  2007. propertyIsWritable: function() {
  2008. return true;
  2009. }
  2010. };
  2011. }
  2012.  
  2013. },{}],14:[function(_dereq_,module,exports){
  2014. "use strict";
  2015. module.exports = function(Promise, INTERNAL) {
  2016. var PromiseMap = Promise.map;
  2017.  
  2018. Promise.prototype.filter = function (fn, options) {
  2019. return PromiseMap(this, fn, options, INTERNAL);
  2020. };
  2021.  
  2022. Promise.filter = function (promises, fn, options) {
  2023. return PromiseMap(promises, fn, options, INTERNAL);
  2024. };
  2025. };
  2026.  
  2027. },{}],15:[function(_dereq_,module,exports){
  2028. "use strict";
  2029. module.exports = function(Promise, tryConvertToPromise, NEXT_FILTER) {
  2030. var util = _dereq_("./util");
  2031. var CancellationError = Promise.CancellationError;
  2032. var errorObj = util.errorObj;
  2033. var catchFilter = _dereq_("./catch_filter")(NEXT_FILTER);
  2034.  
  2035. function PassThroughHandlerContext(promise, type, handler) {
  2036. this.promise = promise;
  2037. this.type = type;
  2038. this.handler = handler;
  2039. this.called = false;
  2040. this.cancelPromise = null;
  2041. }
  2042.  
  2043. PassThroughHandlerContext.prototype.isFinallyHandler = function() {
  2044. return this.type === 0;
  2045. };
  2046.  
  2047. function FinallyHandlerCancelReaction(finallyHandler) {
  2048. this.finallyHandler = finallyHandler;
  2049. }
  2050.  
  2051. FinallyHandlerCancelReaction.prototype._resultCancelled = function() {
  2052. checkCancel(this.finallyHandler);
  2053. };
  2054.  
  2055. function checkCancel(ctx, reason) {
  2056. if (ctx.cancelPromise != null) {
  2057. if (arguments.length > 1) {
  2058. ctx.cancelPromise._reject(reason);
  2059. } else {
  2060. ctx.cancelPromise._cancel();
  2061. }
  2062. ctx.cancelPromise = null;
  2063. return true;
  2064. }
  2065. return false;
  2066. }
  2067.  
  2068. function succeed() {
  2069. return finallyHandler.call(this, this.promise._target()._settledValue());
  2070. }
  2071. function fail(reason) {
  2072. if (checkCancel(this, reason)) return;
  2073. errorObj.e = reason;
  2074. return errorObj;
  2075. }
  2076. function finallyHandler(reasonOrValue) {
  2077. var promise = this.promise;
  2078. var handler = this.handler;
  2079.  
  2080. if (!this.called) {
  2081. this.called = true;
  2082. var ret = this.isFinallyHandler()
  2083. ? handler.call(promise._boundValue())
  2084. : handler.call(promise._boundValue(), reasonOrValue);
  2085. if (ret === NEXT_FILTER) {
  2086. return ret;
  2087. } else if (ret !== undefined) {
  2088. promise._setReturnedNonUndefined();
  2089. var maybePromise = tryConvertToPromise(ret, promise);
  2090. if (maybePromise instanceof Promise) {
  2091. if (this.cancelPromise != null) {
  2092. if (maybePromise._isCancelled()) {
  2093. var reason =
  2094. new CancellationError("late cancellation observer");
  2095. promise._attachExtraTrace(reason);
  2096. errorObj.e = reason;
  2097. return errorObj;
  2098. } else if (maybePromise.isPending()) {
  2099. maybePromise._attachCancellationCallback(
  2100. new FinallyHandlerCancelReaction(this));
  2101. }
  2102. }
  2103. return maybePromise._then(
  2104. succeed, fail, undefined, this, undefined);
  2105. }
  2106. }
  2107. }
  2108.  
  2109. if (promise.isRejected()) {
  2110. checkCancel(this);
  2111. errorObj.e = reasonOrValue;
  2112. return errorObj;
  2113. } else {
  2114. checkCancel(this);
  2115. return reasonOrValue;
  2116. }
  2117. }
  2118.  
  2119. Promise.prototype._passThrough = function(handler, type, success, fail) {
  2120. if (typeof handler !== "function") return this.then();
  2121. return this._then(success,
  2122. fail,
  2123. undefined,
  2124. new PassThroughHandlerContext(this, type, handler),
  2125. undefined);
  2126. };
  2127.  
  2128. Promise.prototype.lastly =
  2129. Promise.prototype["finally"] = function (handler) {
  2130. return this._passThrough(handler,
  2131. 0,
  2132. finallyHandler,
  2133. finallyHandler);
  2134. };
  2135.  
  2136.  
  2137. Promise.prototype.tap = function (handler) {
  2138. return this._passThrough(handler, 1, finallyHandler);
  2139. };
  2140.  
  2141. Promise.prototype.tapCatch = function (handlerOrPredicate) {
  2142. var len = arguments.length;
  2143. if(len === 1) {
  2144. return this._passThrough(handlerOrPredicate,
  2145. 1,
  2146. undefined,
  2147. finallyHandler);
  2148. } else {
  2149. var catchInstances = new Array(len - 1),
  2150. j = 0, i;
  2151. for (i = 0; i < len - 1; ++i) {
  2152. var item = arguments[i];
  2153. if (util.isObject(item)) {
  2154. catchInstances[j++] = item;
  2155. } else {
  2156. return Promise.reject(new TypeError(
  2157. "tapCatch statement predicate: "
  2158. + "expecting an object but got " + util.classString(item)
  2159. ));
  2160. }
  2161. }
  2162. catchInstances.length = j;
  2163. var handler = arguments[i];
  2164. return this._passThrough(catchFilter(catchInstances, handler, this),
  2165. 1,
  2166. undefined,
  2167. finallyHandler);
  2168. }
  2169.  
  2170. };
  2171.  
  2172. return PassThroughHandlerContext;
  2173. };
  2174.  
  2175. },{"./catch_filter":7,"./util":36}],16:[function(_dereq_,module,exports){
  2176. "use strict";
  2177. module.exports = function(Promise,
  2178. apiRejection,
  2179. INTERNAL,
  2180. tryConvertToPromise,
  2181. Proxyable,
  2182. debug) {
  2183. var errors = _dereq_("./errors");
  2184. var TypeError = errors.TypeError;
  2185. var util = _dereq_("./util");
  2186. var errorObj = util.errorObj;
  2187. var tryCatch = util.tryCatch;
  2188. var yieldHandlers = [];
  2189.  
  2190. function promiseFromYieldHandler(value, yieldHandlers, traceParent) {
  2191. for (var i = 0; i < yieldHandlers.length; ++i) {
  2192. traceParent._pushContext();
  2193. var result = tryCatch(yieldHandlers[i])(value);
  2194. traceParent._popContext();
  2195. if (result === errorObj) {
  2196. traceParent._pushContext();
  2197. var ret = Promise.reject(errorObj.e);
  2198. traceParent._popContext();
  2199. return ret;
  2200. }
  2201. var maybePromise = tryConvertToPromise(result, traceParent);
  2202. if (maybePromise instanceof Promise) return maybePromise;
  2203. }
  2204. return null;
  2205. }
  2206.  
  2207. function PromiseSpawn(generatorFunction, receiver, yieldHandler, stack) {
  2208. if (debug.cancellation()) {
  2209. var internal = new Promise(INTERNAL);
  2210. var _finallyPromise = this._finallyPromise = new Promise(INTERNAL);
  2211. this._promise = internal.lastly(function() {
  2212. return _finallyPromise;
  2213. });
  2214. internal._captureStackTrace();
  2215. internal._setOnCancel(this);
  2216. } else {
  2217. var promise = this._promise = new Promise(INTERNAL);
  2218. promise._captureStackTrace();
  2219. }
  2220. this._stack = stack;
  2221. this._generatorFunction = generatorFunction;
  2222. this._receiver = receiver;
  2223. this._generator = undefined;
  2224. this._yieldHandlers = typeof yieldHandler === "function"
  2225. ? [yieldHandler].concat(yieldHandlers)
  2226. : yieldHandlers;
  2227. this._yieldedPromise = null;
  2228. this._cancellationPhase = false;
  2229. }
  2230. util.inherits(PromiseSpawn, Proxyable);
  2231.  
  2232. PromiseSpawn.prototype._isResolved = function() {
  2233. return this._promise === null;
  2234. };
  2235.  
  2236. PromiseSpawn.prototype._cleanup = function() {
  2237. this._promise = this._generator = null;
  2238. if (debug.cancellation() && this._finallyPromise !== null) {
  2239. this._finallyPromise._fulfill();
  2240. this._finallyPromise = null;
  2241. }
  2242. };
  2243.  
  2244. PromiseSpawn.prototype._promiseCancelled = function() {
  2245. if (this._isResolved()) return;
  2246. var implementsReturn = typeof this._generator["return"] !== "undefined";
  2247.  
  2248. var result;
  2249. if (!implementsReturn) {
  2250. var reason = new Promise.CancellationError(
  2251. "generator .return() sentinel");
  2252. Promise.coroutine.returnSentinel = reason;
  2253. this._promise._attachExtraTrace(reason);
  2254. this._promise._pushContext();
  2255. result = tryCatch(this._generator["throw"]).call(this._generator,
  2256. reason);
  2257. this._promise._popContext();
  2258. } else {
  2259. this._promise._pushContext();
  2260. result = tryCatch(this._generator["return"]).call(this._generator,
  2261. undefined);
  2262. this._promise._popContext();
  2263. }
  2264. this._cancellationPhase = true;
  2265. this._yieldedPromise = null;
  2266. this._continue(result);
  2267. };
  2268.  
  2269. PromiseSpawn.prototype._promiseFulfilled = function(value) {
  2270. this._yieldedPromise = null;
  2271. this._promise._pushContext();
  2272. var result = tryCatch(this._generator.next).call(this._generator, value);
  2273. this._promise._popContext();
  2274. this._continue(result);
  2275. };
  2276.  
  2277. PromiseSpawn.prototype._promiseRejected = function(reason) {
  2278. this._yieldedPromise = null;
  2279. this._promise._attachExtraTrace(reason);
  2280. this._promise._pushContext();
  2281. var result = tryCatch(this._generator["throw"])
  2282. .call(this._generator, reason);
  2283. this._promise._popContext();
  2284. this._continue(result);
  2285. };
  2286.  
  2287. PromiseSpawn.prototype._resultCancelled = function() {
  2288. if (this._yieldedPromise instanceof Promise) {
  2289. var promise = this._yieldedPromise;
  2290. this._yieldedPromise = null;
  2291. promise.cancel();
  2292. }
  2293. };
  2294.  
  2295. PromiseSpawn.prototype.promise = function () {
  2296. return this._promise;
  2297. };
  2298.  
  2299. PromiseSpawn.prototype._run = function () {
  2300. this._generator = this._generatorFunction.call(this._receiver);
  2301. this._receiver =
  2302. this._generatorFunction = undefined;
  2303. this._promiseFulfilled(undefined);
  2304. };
  2305.  
  2306. PromiseSpawn.prototype._continue = function (result) {
  2307. var promise = this._promise;
  2308. if (result === errorObj) {
  2309. this._cleanup();
  2310. if (this._cancellationPhase) {
  2311. return promise.cancel();
  2312. } else {
  2313. return promise._rejectCallback(result.e, false);
  2314. }
  2315. }
  2316.  
  2317. var value = result.value;
  2318. if (result.done === true) {
  2319. this._cleanup();
  2320. if (this._cancellationPhase) {
  2321. return promise.cancel();
  2322. } else {
  2323. return promise._resolveCallback(value);
  2324. }
  2325. } else {
  2326. var maybePromise = tryConvertToPromise(value, this._promise);
  2327. if (!(maybePromise instanceof Promise)) {
  2328. maybePromise =
  2329. promiseFromYieldHandler(maybePromise,
  2330. this._yieldHandlers,
  2331. this._promise);
  2332. if (maybePromise === null) {
  2333. this._promiseRejected(
  2334. new TypeError(
  2335. "A value %s was yielded that could not be treated as a promise\u000a\u000a See http://goo.gl/MqrFmX\u000a\u000a".replace("%s", String(value)) +
  2336. "From coroutine:\u000a" +
  2337. this._stack.split("\n").slice(1, -7).join("\n")
  2338. )
  2339. );
  2340. return;
  2341. }
  2342. }
  2343. maybePromise = maybePromise._target();
  2344. var bitField = maybePromise._bitField;
  2345. ;
  2346. if (((bitField & 50397184) === 0)) {
  2347. this._yieldedPromise = maybePromise;
  2348. maybePromise._proxy(this, null);
  2349. } else if (((bitField & 33554432) !== 0)) {
  2350. Promise._async.invoke(
  2351. this._promiseFulfilled, this, maybePromise._value()
  2352. );
  2353. } else if (((bitField & 16777216) !== 0)) {
  2354. Promise._async.invoke(
  2355. this._promiseRejected, this, maybePromise._reason()
  2356. );
  2357. } else {
  2358. this._promiseCancelled();
  2359. }
  2360. }
  2361. };
  2362.  
  2363. Promise.coroutine = function (generatorFunction, options) {
  2364. if (typeof generatorFunction !== "function") {
  2365. throw new TypeError("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  2366. }
  2367. var yieldHandler = Object(options).yieldHandler;
  2368. var PromiseSpawn$ = PromiseSpawn;
  2369. var stack = new Error().stack;
  2370. return function () {
  2371. var generator = generatorFunction.apply(this, arguments);
  2372. var spawn = new PromiseSpawn$(undefined, undefined, yieldHandler,
  2373. stack);
  2374. var ret = spawn.promise();
  2375. spawn._generator = generator;
  2376. spawn._promiseFulfilled(undefined);
  2377. return ret;
  2378. };
  2379. };
  2380.  
  2381. Promise.coroutine.addYieldHandler = function(fn) {
  2382. if (typeof fn !== "function") {
  2383. throw new TypeError("expecting a function but got " + util.classString(fn));
  2384. }
  2385. yieldHandlers.push(fn);
  2386. };
  2387.  
  2388. Promise.spawn = function (generatorFunction) {
  2389. debug.deprecated("Promise.spawn()", "Promise.coroutine()");
  2390. if (typeof generatorFunction !== "function") {
  2391. return apiRejection("generatorFunction must be a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  2392. }
  2393. var spawn = new PromiseSpawn(generatorFunction, this);
  2394. var ret = spawn.promise();
  2395. spawn._run(Promise.spawn);
  2396. return ret;
  2397. };
  2398. };
  2399.  
  2400. },{"./errors":12,"./util":36}],17:[function(_dereq_,module,exports){
  2401. "use strict";
  2402. module.exports =
  2403. function(Promise, PromiseArray, tryConvertToPromise, INTERNAL, async,
  2404. getDomain) {
  2405. var util = _dereq_("./util");
  2406. var canEvaluate = util.canEvaluate;
  2407. var tryCatch = util.tryCatch;
  2408. var errorObj = util.errorObj;
  2409. var reject;
  2410.  
  2411. if (false) {
  2412. if (canEvaluate) {
  2413. var thenCallback = function(i) {
  2414. return new Function("value", "holder", " \n\
  2415. 'use strict'; \n\
  2416. holder.pIndex = value; \n\
  2417. holder.checkFulfillment(this); \n\
  2418. ".replace(/Index/g, i));
  2419. };
  2420.  
  2421. var promiseSetter = function(i) {
  2422. return new Function("promise", "holder", " \n\
  2423. 'use strict'; \n\
  2424. holder.pIndex = promise; \n\
  2425. ".replace(/Index/g, i));
  2426. };
  2427.  
  2428. var generateHolderClass = function(total) {
  2429. var props = new Array(total);
  2430. for (var i = 0; i < props.length; ++i) {
  2431. props[i] = "this.p" + (i+1);
  2432. }
  2433. var assignment = props.join(" = ") + " = null;";
  2434. var cancellationCode= "var promise;\n" + props.map(function(prop) {
  2435. return " \n\
  2436. promise = " + prop + "; \n\
  2437. if (promise instanceof Promise) { \n\
  2438. promise.cancel(); \n\
  2439. } \n\
  2440. ";
  2441. }).join("\n");
  2442. var passedArguments = props.join(", ");
  2443. var name = "Holder$" + total;
  2444.  
  2445.  
  2446. var code = "return function(tryCatch, errorObj, Promise, async) { \n\
  2447. 'use strict'; \n\
  2448. function [TheName](fn) { \n\
  2449. [TheProperties] \n\
  2450. this.fn = fn; \n\
  2451. this.asyncNeeded = true; \n\
  2452. this.now = 0; \n\
  2453. } \n\
  2454. \n\
  2455. [TheName].prototype._callFunction = function(promise) { \n\
  2456. promise._pushContext(); \n\
  2457. var ret = tryCatch(this.fn)([ThePassedArguments]); \n\
  2458. promise._popContext(); \n\
  2459. if (ret === errorObj) { \n\
  2460. promise._rejectCallback(ret.e, false); \n\
  2461. } else { \n\
  2462. promise._resolveCallback(ret); \n\
  2463. } \n\
  2464. }; \n\
  2465. \n\
  2466. [TheName].prototype.checkFulfillment = function(promise) { \n\
  2467. var now = ++this.now; \n\
  2468. if (now === [TheTotal]) { \n\
  2469. if (this.asyncNeeded) { \n\
  2470. async.invoke(this._callFunction, this, promise); \n\
  2471. } else { \n\
  2472. this._callFunction(promise); \n\
  2473. } \n\
  2474. \n\
  2475. } \n\
  2476. }; \n\
  2477. \n\
  2478. [TheName].prototype._resultCancelled = function() { \n\
  2479. [CancellationCode] \n\
  2480. }; \n\
  2481. \n\
  2482. return [TheName]; \n\
  2483. }(tryCatch, errorObj, Promise, async); \n\
  2484. ";
  2485.  
  2486. code = code.replace(/\[TheName\]/g, name)
  2487. .replace(/\[TheTotal\]/g, total)
  2488. .replace(/\[ThePassedArguments\]/g, passedArguments)
  2489. .replace(/\[TheProperties\]/g, assignment)
  2490. .replace(/\[CancellationCode\]/g, cancellationCode);
  2491.  
  2492. return new Function("tryCatch", "errorObj", "Promise", "async", code)
  2493. (tryCatch, errorObj, Promise, async);
  2494. };
  2495.  
  2496. var holderClasses = [];
  2497. var thenCallbacks = [];
  2498. var promiseSetters = [];
  2499.  
  2500. for (var i = 0; i < 8; ++i) {
  2501. holderClasses.push(generateHolderClass(i + 1));
  2502. thenCallbacks.push(thenCallback(i + 1));
  2503. promiseSetters.push(promiseSetter(i + 1));
  2504. }
  2505.  
  2506. reject = function (reason) {
  2507. this._reject(reason);
  2508. };
  2509. }}
  2510.  
  2511. Promise.join = function () {
  2512. var last = arguments.length - 1;
  2513. var fn;
  2514. if (last > 0 && typeof arguments[last] === "function") {
  2515. fn = arguments[last];
  2516. if (false) {
  2517. if (last <= 8 && canEvaluate) {
  2518. var ret = new Promise(INTERNAL);
  2519. ret._captureStackTrace();
  2520. var HolderClass = holderClasses[last - 1];
  2521. var holder = new HolderClass(fn);
  2522. var callbacks = thenCallbacks;
  2523.  
  2524. for (var i = 0; i < last; ++i) {
  2525. var maybePromise = tryConvertToPromise(arguments[i], ret);
  2526. if (maybePromise instanceof Promise) {
  2527. maybePromise = maybePromise._target();
  2528. var bitField = maybePromise._bitField;
  2529. ;
  2530. if (((bitField & 50397184) === 0)) {
  2531. maybePromise._then(callbacks[i], reject,
  2532. undefined, ret, holder);
  2533. promiseSetters[i](maybePromise, holder);
  2534. holder.asyncNeeded = false;
  2535. } else if (((bitField & 33554432) !== 0)) {
  2536. callbacks[i].call(ret,
  2537. maybePromise._value(), holder);
  2538. } else if (((bitField & 16777216) !== 0)) {
  2539. ret._reject(maybePromise._reason());
  2540. } else {
  2541. ret._cancel();
  2542. }
  2543. } else {
  2544. callbacks[i].call(ret, maybePromise, holder);
  2545. }
  2546. }
  2547.  
  2548. if (!ret._isFateSealed()) {
  2549. if (holder.asyncNeeded) {
  2550. var domain = getDomain();
  2551. if (domain !== null) {
  2552. holder.fn = util.domainBind(domain, holder.fn);
  2553. }
  2554. }
  2555. ret._setAsyncGuaranteed();
  2556. ret._setOnCancel(holder);
  2557. }
  2558. return ret;
  2559. }
  2560. }
  2561. }
  2562. var args = [].slice.call(arguments);;
  2563. if (fn) args.pop();
  2564. var ret = new PromiseArray(args).promise();
  2565. return fn !== undefined ? ret.spread(fn) : ret;
  2566. };
  2567.  
  2568. };
  2569.  
  2570. },{"./util":36}],18:[function(_dereq_,module,exports){
  2571. "use strict";
  2572. module.exports = function(Promise,
  2573. PromiseArray,
  2574. apiRejection,
  2575. tryConvertToPromise,
  2576. INTERNAL,
  2577. debug) {
  2578. var getDomain = Promise._getDomain;
  2579. var util = _dereq_("./util");
  2580. var tryCatch = util.tryCatch;
  2581. var errorObj = util.errorObj;
  2582. var async = Promise._async;
  2583.  
  2584. function MappingPromiseArray(promises, fn, limit, _filter) {
  2585. this.constructor$(promises);
  2586. this._promise._captureStackTrace();
  2587. var domain = getDomain();
  2588. this._callback = domain === null ? fn : util.domainBind(domain, fn);
  2589. this._preservedValues = _filter === INTERNAL
  2590. ? new Array(this.length())
  2591. : null;
  2592. this._limit = limit;
  2593. this._inFlight = 0;
  2594. this._queue = [];
  2595. async.invoke(this._asyncInit, this, undefined);
  2596. }
  2597. util.inherits(MappingPromiseArray, PromiseArray);
  2598.  
  2599. MappingPromiseArray.prototype._asyncInit = function() {
  2600. this._init$(undefined, -2);
  2601. };
  2602.  
  2603. MappingPromiseArray.prototype._init = function () {};
  2604.  
  2605. MappingPromiseArray.prototype._promiseFulfilled = function (value, index) {
  2606. var values = this._values;
  2607. var length = this.length();
  2608. var preservedValues = this._preservedValues;
  2609. var limit = this._limit;
  2610.  
  2611. if (index < 0) {
  2612. index = (index * -1) - 1;
  2613. values[index] = value;
  2614. if (limit >= 1) {
  2615. this._inFlight--;
  2616. this._drainQueue();
  2617. if (this._isResolved()) return true;
  2618. }
  2619. } else {
  2620. if (limit >= 1 && this._inFlight >= limit) {
  2621. values[index] = value;
  2622. this._queue.push(index);
  2623. return false;
  2624. }
  2625. if (preservedValues !== null) preservedValues[index] = value;
  2626.  
  2627. var promise = this._promise;
  2628. var callback = this._callback;
  2629. var receiver = promise._boundValue();
  2630. promise._pushContext();
  2631. var ret = tryCatch(callback).call(receiver, value, index, length);
  2632. var promiseCreated = promise._popContext();
  2633. debug.checkForgottenReturns(
  2634. ret,
  2635. promiseCreated,
  2636. preservedValues !== null ? "Promise.filter" : "Promise.map",
  2637. promise
  2638. );
  2639. if (ret === errorObj) {
  2640. this._reject(ret.e);
  2641. return true;
  2642. }
  2643.  
  2644. var maybePromise = tryConvertToPromise(ret, this._promise);
  2645. if (maybePromise instanceof Promise) {
  2646. maybePromise = maybePromise._target();
  2647. var bitField = maybePromise._bitField;
  2648. ;
  2649. if (((bitField & 50397184) === 0)) {
  2650. if (limit >= 1) this._inFlight++;
  2651. values[index] = maybePromise;
  2652. maybePromise._proxy(this, (index + 1) * -1);
  2653. return false;
  2654. } else if (((bitField & 33554432) !== 0)) {
  2655. ret = maybePromise._value();
  2656. } else if (((bitField & 16777216) !== 0)) {
  2657. this._reject(maybePromise._reason());
  2658. return true;
  2659. } else {
  2660. this._cancel();
  2661. return true;
  2662. }
  2663. }
  2664. values[index] = ret;
  2665. }
  2666. var totalResolved = ++this._totalResolved;
  2667. if (totalResolved >= length) {
  2668. if (preservedValues !== null) {
  2669. this._filter(values, preservedValues);
  2670. } else {
  2671. this._resolve(values);
  2672. }
  2673. return true;
  2674. }
  2675. return false;
  2676. };
  2677.  
  2678. MappingPromiseArray.prototype._drainQueue = function () {
  2679. var queue = this._queue;
  2680. var limit = this._limit;
  2681. var values = this._values;
  2682. while (queue.length > 0 && this._inFlight < limit) {
  2683. if (this._isResolved()) return;
  2684. var index = queue.pop();
  2685. this._promiseFulfilled(values[index], index);
  2686. }
  2687. };
  2688.  
  2689. MappingPromiseArray.prototype._filter = function (booleans, values) {
  2690. var len = values.length;
  2691. var ret = new Array(len);
  2692. var j = 0;
  2693. for (var i = 0; i < len; ++i) {
  2694. if (booleans[i]) ret[j++] = values[i];
  2695. }
  2696. ret.length = j;
  2697. this._resolve(ret);
  2698. };
  2699.  
  2700. MappingPromiseArray.prototype.preservedValues = function () {
  2701. return this._preservedValues;
  2702. };
  2703.  
  2704. function map(promises, fn, options, _filter) {
  2705. if (typeof fn !== "function") {
  2706. return apiRejection("expecting a function but got " + util.classString(fn));
  2707. }
  2708.  
  2709. var limit = 0;
  2710. if (options !== undefined) {
  2711. if (typeof options === "object" && options !== null) {
  2712. if (typeof options.concurrency !== "number") {
  2713. return Promise.reject(
  2714. new TypeError("'concurrency' must be a number but it is " +
  2715. util.classString(options.concurrency)));
  2716. }
  2717. limit = options.concurrency;
  2718. } else {
  2719. return Promise.reject(new TypeError(
  2720. "options argument must be an object but it is " +
  2721. util.classString(options)));
  2722. }
  2723. }
  2724. limit = typeof limit === "number" &&
  2725. isFinite(limit) && limit >= 1 ? limit : 0;
  2726. return new MappingPromiseArray(promises, fn, limit, _filter).promise();
  2727. }
  2728.  
  2729. Promise.prototype.map = function (fn, options) {
  2730. return map(this, fn, options, null);
  2731. };
  2732.  
  2733. Promise.map = function (promises, fn, options, _filter) {
  2734. return map(promises, fn, options, _filter);
  2735. };
  2736.  
  2737.  
  2738. };
  2739.  
  2740. },{"./util":36}],19:[function(_dereq_,module,exports){
  2741. "use strict";
  2742. module.exports =
  2743. function(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug) {
  2744. var util = _dereq_("./util");
  2745. var tryCatch = util.tryCatch;
  2746.  
  2747. Promise.method = function (fn) {
  2748. if (typeof fn !== "function") {
  2749. throw new Promise.TypeError("expecting a function but got " + util.classString(fn));
  2750. }
  2751. return function () {
  2752. var ret = new Promise(INTERNAL);
  2753. ret._captureStackTrace();
  2754. ret._pushContext();
  2755. var value = tryCatch(fn).apply(this, arguments);
  2756. var promiseCreated = ret._popContext();
  2757. debug.checkForgottenReturns(
  2758. value, promiseCreated, "Promise.method", ret);
  2759. ret._resolveFromSyncValue(value);
  2760. return ret;
  2761. };
  2762. };
  2763.  
  2764. Promise.attempt = Promise["try"] = function (fn) {
  2765. if (typeof fn !== "function") {
  2766. return apiRejection("expecting a function but got " + util.classString(fn));
  2767. }
  2768. var ret = new Promise(INTERNAL);
  2769. ret._captureStackTrace();
  2770. ret._pushContext();
  2771. var value;
  2772. if (arguments.length > 1) {
  2773. debug.deprecated("calling Promise.try with more than 1 argument");
  2774. var arg = arguments[1];
  2775. var ctx = arguments[2];
  2776. value = util.isArray(arg) ? tryCatch(fn).apply(ctx, arg)
  2777. : tryCatch(fn).call(ctx, arg);
  2778. } else {
  2779. value = tryCatch(fn)();
  2780. }
  2781. var promiseCreated = ret._popContext();
  2782. debug.checkForgottenReturns(
  2783. value, promiseCreated, "Promise.try", ret);
  2784. ret._resolveFromSyncValue(value);
  2785. return ret;
  2786. };
  2787.  
  2788. Promise.prototype._resolveFromSyncValue = function (value) {
  2789. if (value === util.errorObj) {
  2790. this._rejectCallback(value.e, false);
  2791. } else {
  2792. this._resolveCallback(value, true);
  2793. }
  2794. };
  2795. };
  2796.  
  2797. },{"./util":36}],20:[function(_dereq_,module,exports){
  2798. "use strict";
  2799. var util = _dereq_("./util");
  2800. var maybeWrapAsError = util.maybeWrapAsError;
  2801. var errors = _dereq_("./errors");
  2802. var OperationalError = errors.OperationalError;
  2803. var es5 = _dereq_("./es5");
  2804.  
  2805. function isUntypedError(obj) {
  2806. return obj instanceof Error &&
  2807. es5.getPrototypeOf(obj) === Error.prototype;
  2808. }
  2809.  
  2810. var rErrorKey = /^(?:name|message|stack|cause)$/;
  2811. function wrapAsOperationalError(obj) {
  2812. var ret;
  2813. if (isUntypedError(obj)) {
  2814. ret = new OperationalError(obj);
  2815. ret.name = obj.name;
  2816. ret.message = obj.message;
  2817. ret.stack = obj.stack;
  2818. var keys = es5.keys(obj);
  2819. for (var i = 0; i < keys.length; ++i) {
  2820. var key = keys[i];
  2821. if (!rErrorKey.test(key)) {
  2822. ret[key] = obj[key];
  2823. }
  2824. }
  2825. return ret;
  2826. }
  2827. util.markAsOriginatingFromRejection(obj);
  2828. return obj;
  2829. }
  2830.  
  2831. function nodebackForPromise(promise, multiArgs) {
  2832. return function(err, value) {
  2833. if (promise === null) return;
  2834. if (err) {
  2835. var wrapped = wrapAsOperationalError(maybeWrapAsError(err));
  2836. promise._attachExtraTrace(wrapped);
  2837. promise._reject(wrapped);
  2838. } else if (!multiArgs) {
  2839. promise._fulfill(value);
  2840. } else {
  2841. var args = [].slice.call(arguments, 1);;
  2842. promise._fulfill(args);
  2843. }
  2844. promise = null;
  2845. };
  2846. }
  2847.  
  2848. module.exports = nodebackForPromise;
  2849.  
  2850. },{"./errors":12,"./es5":13,"./util":36}],21:[function(_dereq_,module,exports){
  2851. "use strict";
  2852. module.exports = function(Promise) {
  2853. var util = _dereq_("./util");
  2854. var async = Promise._async;
  2855. var tryCatch = util.tryCatch;
  2856. var errorObj = util.errorObj;
  2857.  
  2858. function spreadAdapter(val, nodeback) {
  2859. var promise = this;
  2860. if (!util.isArray(val)) return successAdapter.call(promise, val, nodeback);
  2861. var ret =
  2862. tryCatch(nodeback).apply(promise._boundValue(), [null].concat(val));
  2863. if (ret === errorObj) {
  2864. async.throwLater(ret.e);
  2865. }
  2866. }
  2867.  
  2868. function successAdapter(val, nodeback) {
  2869. var promise = this;
  2870. var receiver = promise._boundValue();
  2871. var ret = val === undefined
  2872. ? tryCatch(nodeback).call(receiver, null)
  2873. : tryCatch(nodeback).call(receiver, null, val);
  2874. if (ret === errorObj) {
  2875. async.throwLater(ret.e);
  2876. }
  2877. }
  2878. function errorAdapter(reason, nodeback) {
  2879. var promise = this;
  2880. if (!reason) {
  2881. var newReason = new Error(reason + "");
  2882. newReason.cause = reason;
  2883. reason = newReason;
  2884. }
  2885. var ret = tryCatch(nodeback).call(promise._boundValue(), reason);
  2886. if (ret === errorObj) {
  2887. async.throwLater(ret.e);
  2888. }
  2889. }
  2890.  
  2891. Promise.prototype.asCallback = Promise.prototype.nodeify = function (nodeback,
  2892. options) {
  2893. if (typeof nodeback == "function") {
  2894. var adapter = successAdapter;
  2895. if (options !== undefined && Object(options).spread) {
  2896. adapter = spreadAdapter;
  2897. }
  2898. this._then(
  2899. adapter,
  2900. errorAdapter,
  2901. undefined,
  2902. this,
  2903. nodeback
  2904. );
  2905. }
  2906. return this;
  2907. };
  2908. };
  2909.  
  2910. },{"./util":36}],22:[function(_dereq_,module,exports){
  2911. "use strict";
  2912. module.exports = function() {
  2913. var makeSelfResolutionError = function () {
  2914. return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  2915. };
  2916. var reflectHandler = function() {
  2917. return new Promise.PromiseInspection(this._target());
  2918. };
  2919. var apiRejection = function(msg) {
  2920. return Promise.reject(new TypeError(msg));
  2921. };
  2922. function Proxyable() {}
  2923. var UNDEFINED_BINDING = {};
  2924. var util = _dereq_("./util");
  2925.  
  2926. var getDomain;
  2927. if (util.isNode) {
  2928. getDomain = function() {
  2929. var ret = process.domain;
  2930. if (ret === undefined) ret = null;
  2931. return ret;
  2932. };
  2933. } else {
  2934. getDomain = function() {
  2935. return null;
  2936. };
  2937. }
  2938. util.notEnumerableProp(Promise, "_getDomain", getDomain);
  2939.  
  2940. var es5 = _dereq_("./es5");
  2941. var Async = _dereq_("./async");
  2942. var async = new Async();
  2943. es5.defineProperty(Promise, "_async", {value: async});
  2944. var errors = _dereq_("./errors");
  2945. var TypeError = Promise.TypeError = errors.TypeError;
  2946. Promise.RangeError = errors.RangeError;
  2947. var CancellationError = Promise.CancellationError = errors.CancellationError;
  2948. Promise.TimeoutError = errors.TimeoutError;
  2949. Promise.OperationalError = errors.OperationalError;
  2950. Promise.RejectionError = errors.OperationalError;
  2951. Promise.AggregateError = errors.AggregateError;
  2952. var INTERNAL = function(){};
  2953. var APPLY = {};
  2954. var NEXT_FILTER = {};
  2955. var tryConvertToPromise = _dereq_("./thenables")(Promise, INTERNAL);
  2956. var PromiseArray =
  2957. _dereq_("./promise_array")(Promise, INTERNAL,
  2958. tryConvertToPromise, apiRejection, Proxyable);
  2959. var Context = _dereq_("./context")(Promise);
  2960. /*jshint unused:false*/
  2961. var createContext = Context.create;
  2962. var debug = _dereq_("./debuggability")(Promise, Context);
  2963. var CapturedTrace = debug.CapturedTrace;
  2964. var PassThroughHandlerContext =
  2965. _dereq_("./finally")(Promise, tryConvertToPromise, NEXT_FILTER);
  2966. var catchFilter = _dereq_("./catch_filter")(NEXT_FILTER);
  2967. var nodebackForPromise = _dereq_("./nodeback");
  2968. var errorObj = util.errorObj;
  2969. var tryCatch = util.tryCatch;
  2970. function check(self, executor) {
  2971. if (self == null || self.constructor !== Promise) {
  2972. throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  2973. }
  2974. if (typeof executor !== "function") {
  2975. throw new TypeError("expecting a function but got " + util.classString(executor));
  2976. }
  2977.  
  2978. }
  2979.  
  2980. function Promise(executor) {
  2981. if (executor !== INTERNAL) {
  2982. check(this, executor);
  2983. }
  2984. this._bitField = 0;
  2985. this._fulfillmentHandler0 = undefined;
  2986. this._rejectionHandler0 = undefined;
  2987. this._promise0 = undefined;
  2988. this._receiver0 = undefined;
  2989. this._resolveFromExecutor(executor);
  2990. this._promiseCreated();
  2991. this._fireEvent("promiseCreated", this);
  2992. }
  2993.  
  2994. Promise.prototype.toString = function () {
  2995. return "[object Promise]";
  2996. };
  2997.  
  2998. Promise.prototype.caught = Promise.prototype["catch"] = function (fn) {
  2999. var len = arguments.length;
  3000. if (len > 1) {
  3001. var catchInstances = new Array(len - 1),
  3002. j = 0, i;
  3003. for (i = 0; i < len - 1; ++i) {
  3004. var item = arguments[i];
  3005. if (util.isObject(item)) {
  3006. catchInstances[j++] = item;
  3007. } else {
  3008. return apiRejection("Catch statement predicate: " +
  3009. "expecting an object but got " + util.classString(item));
  3010. }
  3011. }
  3012. catchInstances.length = j;
  3013. fn = arguments[i];
  3014. return this.then(undefined, catchFilter(catchInstances, fn, this));
  3015. }
  3016. return this.then(undefined, fn);
  3017. };
  3018.  
  3019. Promise.prototype.reflect = function () {
  3020. return this._then(reflectHandler,
  3021. reflectHandler, undefined, this, undefined);
  3022. };
  3023.  
  3024. Promise.prototype.then = function (didFulfill, didReject) {
  3025. if (debug.warnings() && arguments.length > 0 &&
  3026. typeof didFulfill !== "function" &&
  3027. typeof didReject !== "function") {
  3028. var msg = ".then() only accepts functions but was passed: " +
  3029. util.classString(didFulfill);
  3030. if (arguments.length > 1) {
  3031. msg += ", " + util.classString(didReject);
  3032. }
  3033. this._warn(msg);
  3034. }
  3035. return this._then(didFulfill, didReject, undefined, undefined, undefined);
  3036. };
  3037.  
  3038. Promise.prototype.done = function (didFulfill, didReject) {
  3039. var promise =
  3040. this._then(didFulfill, didReject, undefined, undefined, undefined);
  3041. promise._setIsFinal();
  3042. };
  3043.  
  3044. Promise.prototype.spread = function (fn) {
  3045. if (typeof fn !== "function") {
  3046. return apiRejection("expecting a function but got " + util.classString(fn));
  3047. }
  3048. return this.all()._then(fn, undefined, undefined, APPLY, undefined);
  3049. };
  3050.  
  3051. Promise.prototype.toJSON = function () {
  3052. var ret = {
  3053. isFulfilled: false,
  3054. isRejected: false,
  3055. fulfillmentValue: undefined,
  3056. rejectionReason: undefined
  3057. };
  3058. if (this.isFulfilled()) {
  3059. ret.fulfillmentValue = this.value();
  3060. ret.isFulfilled = true;
  3061. } else if (this.isRejected()) {
  3062. ret.rejectionReason = this.reason();
  3063. ret.isRejected = true;
  3064. }
  3065. return ret;
  3066. };
  3067.  
  3068. Promise.prototype.all = function () {
  3069. if (arguments.length > 0) {
  3070. this._warn(".all() was passed arguments but it does not take any");
  3071. }
  3072. return new PromiseArray(this).promise();
  3073. };
  3074.  
  3075. Promise.prototype.error = function (fn) {
  3076. return this.caught(util.originatesFromRejection, fn);
  3077. };
  3078.  
  3079. Promise.getNewLibraryCopy = module.exports;
  3080.  
  3081. Promise.is = function (val) {
  3082. return val instanceof Promise;
  3083. };
  3084.  
  3085. Promise.fromNode = Promise.fromCallback = function(fn) {
  3086. var ret = new Promise(INTERNAL);
  3087. ret._captureStackTrace();
  3088. var multiArgs = arguments.length > 1 ? !!Object(arguments[1]).multiArgs
  3089. : false;
  3090. var result = tryCatch(fn)(nodebackForPromise(ret, multiArgs));
  3091. if (result === errorObj) {
  3092. ret._rejectCallback(result.e, true);
  3093. }
  3094. if (!ret._isFateSealed()) ret._setAsyncGuaranteed();
  3095. return ret;
  3096. };
  3097.  
  3098. Promise.all = function (promises) {
  3099. return new PromiseArray(promises).promise();
  3100. };
  3101.  
  3102. Promise.cast = function (obj) {
  3103. var ret = tryConvertToPromise(obj);
  3104. if (!(ret instanceof Promise)) {
  3105. ret = new Promise(INTERNAL);
  3106. ret._captureStackTrace();
  3107. ret._setFulfilled();
  3108. ret._rejectionHandler0 = obj;
  3109. }
  3110. return ret;
  3111. };
  3112.  
  3113. Promise.resolve = Promise.fulfilled = Promise.cast;
  3114.  
  3115. Promise.reject = Promise.rejected = function (reason) {
  3116. var ret = new Promise(INTERNAL);
  3117. ret._captureStackTrace();
  3118. ret._rejectCallback(reason, true);
  3119. return ret;
  3120. };
  3121.  
  3122. Promise.setScheduler = function(fn) {
  3123. if (typeof fn !== "function") {
  3124. throw new TypeError("expecting a function but got " + util.classString(fn));
  3125. }
  3126. return async.setScheduler(fn);
  3127. };
  3128.  
  3129. Promise.prototype._then = function (
  3130. didFulfill,
  3131. didReject,
  3132. _, receiver,
  3133. internalData
  3134. ) {
  3135. var haveInternalData = internalData !== undefined;
  3136. var promise = haveInternalData ? internalData : new Promise(INTERNAL);
  3137. var target = this._target();
  3138. var bitField = target._bitField;
  3139.  
  3140. if (!haveInternalData) {
  3141. promise._propagateFrom(this, 3);
  3142. promise._captureStackTrace();
  3143. if (receiver === undefined &&
  3144. ((this._bitField & 2097152) !== 0)) {
  3145. if (!((bitField & 50397184) === 0)) {
  3146. receiver = this._boundValue();
  3147. } else {
  3148. receiver = target === this ? undefined : this._boundTo;
  3149. }
  3150. }
  3151. this._fireEvent("promiseChained", this, promise);
  3152. }
  3153.  
  3154. var domain = getDomain();
  3155. if (!((bitField & 50397184) === 0)) {
  3156. var handler, value, settler = target._settlePromiseCtx;
  3157. if (((bitField & 33554432) !== 0)) {
  3158. value = target._rejectionHandler0;
  3159. handler = didFulfill;
  3160. } else if (((bitField & 16777216) !== 0)) {
  3161. value = target._fulfillmentHandler0;
  3162. handler = didReject;
  3163. target._unsetRejectionIsUnhandled();
  3164. } else {
  3165. settler = target._settlePromiseLateCancellationObserver;
  3166. value = new CancellationError("late cancellation observer");
  3167. target._attachExtraTrace(value);
  3168. handler = didReject;
  3169. }
  3170.  
  3171. async.invoke(settler, target, {
  3172. handler: domain === null ? handler
  3173. : (typeof handler === "function" &&
  3174. util.domainBind(domain, handler)),
  3175. promise: promise,
  3176. receiver: receiver,
  3177. value: value
  3178. });
  3179. } else {
  3180. target._addCallbacks(didFulfill, didReject, promise, receiver, domain);
  3181. }
  3182.  
  3183. return promise;
  3184. };
  3185.  
  3186. Promise.prototype._length = function () {
  3187. return this._bitField & 65535;
  3188. };
  3189.  
  3190. Promise.prototype._isFateSealed = function () {
  3191. return (this._bitField & 117506048) !== 0;
  3192. };
  3193.  
  3194. Promise.prototype._isFollowing = function () {
  3195. return (this._bitField & 67108864) === 67108864;
  3196. };
  3197.  
  3198. Promise.prototype._setLength = function (len) {
  3199. this._bitField = (this._bitField & -65536) |
  3200. (len & 65535);
  3201. };
  3202.  
  3203. Promise.prototype._setFulfilled = function () {
  3204. this._bitField = this._bitField | 33554432;
  3205. this._fireEvent("promiseFulfilled", this);
  3206. };
  3207.  
  3208. Promise.prototype._setRejected = function () {
  3209. this._bitField = this._bitField | 16777216;
  3210. this._fireEvent("promiseRejected", this);
  3211. };
  3212.  
  3213. Promise.prototype._setFollowing = function () {
  3214. this._bitField = this._bitField | 67108864;
  3215. this._fireEvent("promiseResolved", this);
  3216. };
  3217.  
  3218. Promise.prototype._setIsFinal = function () {
  3219. this._bitField = this._bitField | 4194304;
  3220. };
  3221.  
  3222. Promise.prototype._isFinal = function () {
  3223. return (this._bitField & 4194304) > 0;
  3224. };
  3225.  
  3226. Promise.prototype._unsetCancelled = function() {
  3227. this._bitField = this._bitField & (~65536);
  3228. };
  3229.  
  3230. Promise.prototype._setCancelled = function() {
  3231. this._bitField = this._bitField | 65536;
  3232. this._fireEvent("promiseCancelled", this);
  3233. };
  3234.  
  3235. Promise.prototype._setWillBeCancelled = function() {
  3236. this._bitField = this._bitField | 8388608;
  3237. };
  3238.  
  3239. Promise.prototype._setAsyncGuaranteed = function() {
  3240. if (async.hasCustomScheduler()) return;
  3241. this._bitField = this._bitField | 134217728;
  3242. };
  3243.  
  3244. Promise.prototype._receiverAt = function (index) {
  3245. var ret = index === 0 ? this._receiver0 : this[
  3246. index * 4 - 4 + 3];
  3247. if (ret === UNDEFINED_BINDING) {
  3248. return undefined;
  3249. } else if (ret === undefined && this._isBound()) {
  3250. return this._boundValue();
  3251. }
  3252. return ret;
  3253. };
  3254.  
  3255. Promise.prototype._promiseAt = function (index) {
  3256. return this[
  3257. index * 4 - 4 + 2];
  3258. };
  3259.  
  3260. Promise.prototype._fulfillmentHandlerAt = function (index) {
  3261. return this[
  3262. index * 4 - 4 + 0];
  3263. };
  3264.  
  3265. Promise.prototype._rejectionHandlerAt = function (index) {
  3266. return this[
  3267. index * 4 - 4 + 1];
  3268. };
  3269.  
  3270. Promise.prototype._boundValue = function() {};
  3271.  
  3272. Promise.prototype._migrateCallback0 = function (follower) {
  3273. var bitField = follower._bitField;
  3274. var fulfill = follower._fulfillmentHandler0;
  3275. var reject = follower._rejectionHandler0;
  3276. var promise = follower._promise0;
  3277. var receiver = follower._receiverAt(0);
  3278. if (receiver === undefined) receiver = UNDEFINED_BINDING;
  3279. this._addCallbacks(fulfill, reject, promise, receiver, null);
  3280. };
  3281.  
  3282. Promise.prototype._migrateCallbackAt = function (follower, index) {
  3283. var fulfill = follower._fulfillmentHandlerAt(index);
  3284. var reject = follower._rejectionHandlerAt(index);
  3285. var promise = follower._promiseAt(index);
  3286. var receiver = follower._receiverAt(index);
  3287. if (receiver === undefined) receiver = UNDEFINED_BINDING;
  3288. this._addCallbacks(fulfill, reject, promise, receiver, null);
  3289. };
  3290.  
  3291. Promise.prototype._addCallbacks = function (
  3292. fulfill,
  3293. reject,
  3294. promise,
  3295. receiver,
  3296. domain
  3297. ) {
  3298. var index = this._length();
  3299.  
  3300. if (index >= 65535 - 4) {
  3301. index = 0;
  3302. this._setLength(0);
  3303. }
  3304.  
  3305. if (index === 0) {
  3306. this._promise0 = promise;
  3307. this._receiver0 = receiver;
  3308. if (typeof fulfill === "function") {
  3309. this._fulfillmentHandler0 =
  3310. domain === null ? fulfill : util.domainBind(domain, fulfill);
  3311. }
  3312. if (typeof reject === "function") {
  3313. this._rejectionHandler0 =
  3314. domain === null ? reject : util.domainBind(domain, reject);
  3315. }
  3316. } else {
  3317. var base = index * 4 - 4;
  3318. this[base + 2] = promise;
  3319. this[base + 3] = receiver;
  3320. if (typeof fulfill === "function") {
  3321. this[base + 0] =
  3322. domain === null ? fulfill : util.domainBind(domain, fulfill);
  3323. }
  3324. if (typeof reject === "function") {
  3325. this[base + 1] =
  3326. domain === null ? reject : util.domainBind(domain, reject);
  3327. }
  3328. }
  3329. this._setLength(index + 1);
  3330. return index;
  3331. };
  3332.  
  3333. Promise.prototype._proxy = function (proxyable, arg) {
  3334. this._addCallbacks(undefined, undefined, arg, proxyable, null);
  3335. };
  3336.  
  3337. Promise.prototype._resolveCallback = function(value, shouldBind) {
  3338. if (((this._bitField & 117506048) !== 0)) return;
  3339. if (value === this)
  3340. return this._rejectCallback(makeSelfResolutionError(), false);
  3341. var maybePromise = tryConvertToPromise(value, this);
  3342. if (!(maybePromise instanceof Promise)) return this._fulfill(value);
  3343.  
  3344. if (shouldBind) this._propagateFrom(maybePromise, 2);
  3345.  
  3346. var promise = maybePromise._target();
  3347.  
  3348. if (promise === this) {
  3349. this._reject(makeSelfResolutionError());
  3350. return;
  3351. }
  3352.  
  3353. var bitField = promise._bitField;
  3354. if (((bitField & 50397184) === 0)) {
  3355. var len = this._length();
  3356. if (len > 0) promise._migrateCallback0(this);
  3357. for (var i = 1; i < len; ++i) {
  3358. promise._migrateCallbackAt(this, i);
  3359. }
  3360. this._setFollowing();
  3361. this._setLength(0);
  3362. this._setFollowee(promise);
  3363. } else if (((bitField & 33554432) !== 0)) {
  3364. this._fulfill(promise._value());
  3365. } else if (((bitField & 16777216) !== 0)) {
  3366. this._reject(promise._reason());
  3367. } else {
  3368. var reason = new CancellationError("late cancellation observer");
  3369. promise._attachExtraTrace(reason);
  3370. this._reject(reason);
  3371. }
  3372. };
  3373.  
  3374. Promise.prototype._rejectCallback =
  3375. function(reason, synchronous, ignoreNonErrorWarnings) {
  3376. var trace = util.ensureErrorObject(reason);
  3377. var hasStack = trace === reason;
  3378. if (!hasStack && !ignoreNonErrorWarnings && debug.warnings()) {
  3379. var message = "a promise was rejected with a non-error: " +
  3380. util.classString(reason);
  3381. this._warn(message, true);
  3382. }
  3383. this._attachExtraTrace(trace, synchronous ? hasStack : false);
  3384. this._reject(reason);
  3385. };
  3386.  
  3387. Promise.prototype._resolveFromExecutor = function (executor) {
  3388. if (executor === INTERNAL) return;
  3389. var promise = this;
  3390. this._captureStackTrace();
  3391. this._pushContext();
  3392. var synchronous = true;
  3393. var r = this._execute(executor, function(value) {
  3394. promise._resolveCallback(value);
  3395. }, function (reason) {
  3396. promise._rejectCallback(reason, synchronous);
  3397. });
  3398. synchronous = false;
  3399. this._popContext();
  3400.  
  3401. if (r !== undefined) {
  3402. promise._rejectCallback(r, true);
  3403. }
  3404. };
  3405.  
  3406. Promise.prototype._settlePromiseFromHandler = function (
  3407. handler, receiver, value, promise
  3408. ) {
  3409. var bitField = promise._bitField;
  3410. if (((bitField & 65536) !== 0)) return;
  3411. promise._pushContext();
  3412. var x;
  3413. if (receiver === APPLY) {
  3414. if (!value || typeof value.length !== "number") {
  3415. x = errorObj;
  3416. x.e = new TypeError("cannot .spread() a non-array: " +
  3417. util.classString(value));
  3418. } else {
  3419. x = tryCatch(handler).apply(this._boundValue(), value);
  3420. }
  3421. } else {
  3422. x = tryCatch(handler).call(receiver, value);
  3423. }
  3424. var promiseCreated = promise._popContext();
  3425. bitField = promise._bitField;
  3426. if (((bitField & 65536) !== 0)) return;
  3427.  
  3428. if (x === NEXT_FILTER) {
  3429. promise._reject(value);
  3430. } else if (x === errorObj) {
  3431. promise._rejectCallback(x.e, false);
  3432. } else {
  3433. debug.checkForgottenReturns(x, promiseCreated, "", promise, this);
  3434. promise._resolveCallback(x);
  3435. }
  3436. };
  3437.  
  3438. Promise.prototype._target = function() {
  3439. var ret = this;
  3440. while (ret._isFollowing()) ret = ret._followee();
  3441. return ret;
  3442. };
  3443.  
  3444. Promise.prototype._followee = function() {
  3445. return this._rejectionHandler0;
  3446. };
  3447.  
  3448. Promise.prototype._setFollowee = function(promise) {
  3449. this._rejectionHandler0 = promise;
  3450. };
  3451.  
  3452. Promise.prototype._settlePromise = function(promise, handler, receiver, value) {
  3453. var isPromise = promise instanceof Promise;
  3454. var bitField = this._bitField;
  3455. var asyncGuaranteed = ((bitField & 134217728) !== 0);
  3456. if (((bitField & 65536) !== 0)) {
  3457. if (isPromise) promise._invokeInternalOnCancel();
  3458.  
  3459. if (receiver instanceof PassThroughHandlerContext &&
  3460. receiver.isFinallyHandler()) {
  3461. receiver.cancelPromise = promise;
  3462. if (tryCatch(handler).call(receiver, value) === errorObj) {
  3463. promise._reject(errorObj.e);
  3464. }
  3465. } else if (handler === reflectHandler) {
  3466. promise._fulfill(reflectHandler.call(receiver));
  3467. } else if (receiver instanceof Proxyable) {
  3468. receiver._promiseCancelled(promise);
  3469. } else if (isPromise || promise instanceof PromiseArray) {
  3470. promise._cancel();
  3471. } else {
  3472. receiver.cancel();
  3473. }
  3474. } else if (typeof handler === "function") {
  3475. if (!isPromise) {
  3476. handler.call(receiver, value, promise);
  3477. } else {
  3478. if (asyncGuaranteed) promise._setAsyncGuaranteed();
  3479. this._settlePromiseFromHandler(handler, receiver, value, promise);
  3480. }
  3481. } else if (receiver instanceof Proxyable) {
  3482. if (!receiver._isResolved()) {
  3483. if (((bitField & 33554432) !== 0)) {
  3484. receiver._promiseFulfilled(value, promise);
  3485. } else {
  3486. receiver._promiseRejected(value, promise);
  3487. }
  3488. }
  3489. } else if (isPromise) {
  3490. if (asyncGuaranteed) promise._setAsyncGuaranteed();
  3491. if (((bitField & 33554432) !== 0)) {
  3492. promise._fulfill(value);
  3493. } else {
  3494. promise._reject(value);
  3495. }
  3496. }
  3497. };
  3498.  
  3499. Promise.prototype._settlePromiseLateCancellationObserver = function(ctx) {
  3500. var handler = ctx.handler;
  3501. var promise = ctx.promise;
  3502. var receiver = ctx.receiver;
  3503. var value = ctx.value;
  3504. if (typeof handler === "function") {
  3505. if (!(promise instanceof Promise)) {
  3506. handler.call(receiver, value, promise);
  3507. } else {
  3508. this._settlePromiseFromHandler(handler, receiver, value, promise);
  3509. }
  3510. } else if (promise instanceof Promise) {
  3511. promise._reject(value);
  3512. }
  3513. };
  3514.  
  3515. Promise.prototype._settlePromiseCtx = function(ctx) {
  3516. this._settlePromise(ctx.promise, ctx.handler, ctx.receiver, ctx.value);
  3517. };
  3518.  
  3519. Promise.prototype._settlePromise0 = function(handler, value, bitField) {
  3520. var promise = this._promise0;
  3521. var receiver = this._receiverAt(0);
  3522. this._promise0 = undefined;
  3523. this._receiver0 = undefined;
  3524. this._settlePromise(promise, handler, receiver, value);
  3525. };
  3526.  
  3527. Promise.prototype._clearCallbackDataAtIndex = function(index) {
  3528. var base = index * 4 - 4;
  3529. this[base + 2] =
  3530. this[base + 3] =
  3531. this[base + 0] =
  3532. this[base + 1] = undefined;
  3533. };
  3534.  
  3535. Promise.prototype._fulfill = function (value) {
  3536. var bitField = this._bitField;
  3537. if (((bitField & 117506048) >>> 16)) return;
  3538. if (value === this) {
  3539. var err = makeSelfResolutionError();
  3540. this._attachExtraTrace(err);
  3541. return this._reject(err);
  3542. }
  3543. this._setFulfilled();
  3544. this._rejectionHandler0 = value;
  3545.  
  3546. if ((bitField & 65535) > 0) {
  3547. if (((bitField & 134217728) !== 0)) {
  3548. this._settlePromises();
  3549. } else {
  3550. async.settlePromises(this);
  3551. }
  3552. }
  3553. };
  3554.  
  3555. Promise.prototype._reject = function (reason) {
  3556. var bitField = this._bitField;
  3557. if (((bitField & 117506048) >>> 16)) return;
  3558. this._setRejected();
  3559. this._fulfillmentHandler0 = reason;
  3560.  
  3561. if (this._isFinal()) {
  3562. return async.fatalError(reason, util.isNode);
  3563. }
  3564.  
  3565. if ((bitField & 65535) > 0) {
  3566. async.settlePromises(this);
  3567. } else {
  3568. this._ensurePossibleRejectionHandled();
  3569. }
  3570. };
  3571.  
  3572. Promise.prototype._fulfillPromises = function (len, value) {
  3573. for (var i = 1; i < len; i++) {
  3574. var handler = this._fulfillmentHandlerAt(i);
  3575. var promise = this._promiseAt(i);
  3576. var receiver = this._receiverAt(i);
  3577. this._clearCallbackDataAtIndex(i);
  3578. this._settlePromise(promise, handler, receiver, value);
  3579. }
  3580. };
  3581.  
  3582. Promise.prototype._rejectPromises = function (len, reason) {
  3583. for (var i = 1; i < len; i++) {
  3584. var handler = this._rejectionHandlerAt(i);
  3585. var promise = this._promiseAt(i);
  3586. var receiver = this._receiverAt(i);
  3587. this._clearCallbackDataAtIndex(i);
  3588. this._settlePromise(promise, handler, receiver, reason);
  3589. }
  3590. };
  3591.  
  3592. Promise.prototype._settlePromises = function () {
  3593. var bitField = this._bitField;
  3594. var len = (bitField & 65535);
  3595.  
  3596. if (len > 0) {
  3597. if (((bitField & 16842752) !== 0)) {
  3598. var reason = this._fulfillmentHandler0;
  3599. this._settlePromise0(this._rejectionHandler0, reason, bitField);
  3600. this._rejectPromises(len, reason);
  3601. } else {
  3602. var value = this._rejectionHandler0;
  3603. this._settlePromise0(this._fulfillmentHandler0, value, bitField);
  3604. this._fulfillPromises(len, value);
  3605. }
  3606. this._setLength(0);
  3607. }
  3608. this._clearCancellationData();
  3609. };
  3610.  
  3611. Promise.prototype._settledValue = function() {
  3612. var bitField = this._bitField;
  3613. if (((bitField & 33554432) !== 0)) {
  3614. return this._rejectionHandler0;
  3615. } else if (((bitField & 16777216) !== 0)) {
  3616. return this._fulfillmentHandler0;
  3617. }
  3618. };
  3619.  
  3620. function deferResolve(v) {this.promise._resolveCallback(v);}
  3621. function deferReject(v) {this.promise._rejectCallback(v, false);}
  3622.  
  3623. Promise.defer = Promise.pending = function() {
  3624. debug.deprecated("Promise.defer", "new Promise");
  3625. var promise = new Promise(INTERNAL);
  3626. return {
  3627. promise: promise,
  3628. resolve: deferResolve,
  3629. reject: deferReject
  3630. };
  3631. };
  3632.  
  3633. util.notEnumerableProp(Promise,
  3634. "_makeSelfResolutionError",
  3635. makeSelfResolutionError);
  3636.  
  3637. _dereq_("./method")(Promise, INTERNAL, tryConvertToPromise, apiRejection,
  3638. debug);
  3639. _dereq_("./bind")(Promise, INTERNAL, tryConvertToPromise, debug);
  3640. _dereq_("./cancel")(Promise, PromiseArray, apiRejection, debug);
  3641. _dereq_("./direct_resolve")(Promise);
  3642. _dereq_("./synchronous_inspection")(Promise);
  3643. _dereq_("./join")(
  3644. Promise, PromiseArray, tryConvertToPromise, INTERNAL, async, getDomain);
  3645. Promise.Promise = Promise;
  3646. Promise.version = "3.5.0";
  3647. _dereq_('./map.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
  3648. _dereq_('./call_get.js')(Promise);
  3649. _dereq_('./using.js')(Promise, apiRejection, tryConvertToPromise, createContext, INTERNAL, debug);
  3650. _dereq_('./timers.js')(Promise, INTERNAL, debug);
  3651. _dereq_('./generators.js')(Promise, apiRejection, INTERNAL, tryConvertToPromise, Proxyable, debug);
  3652. _dereq_('./nodeify.js')(Promise);
  3653. _dereq_('./promisify.js')(Promise, INTERNAL);
  3654. _dereq_('./props.js')(Promise, PromiseArray, tryConvertToPromise, apiRejection);
  3655. _dereq_('./race.js')(Promise, INTERNAL, tryConvertToPromise, apiRejection);
  3656. _dereq_('./reduce.js')(Promise, PromiseArray, apiRejection, tryConvertToPromise, INTERNAL, debug);
  3657. _dereq_('./settle.js')(Promise, PromiseArray, debug);
  3658. _dereq_('./some.js')(Promise, PromiseArray, apiRejection);
  3659. _dereq_('./filter.js')(Promise, INTERNAL);
  3660. _dereq_('./each.js')(Promise, INTERNAL);
  3661. _dereq_('./any.js')(Promise);
  3662. util.toFastProperties(Promise);
  3663. util.toFastProperties(Promise.prototype);
  3664. function fillTypes(value) {
  3665. var p = new Promise(INTERNAL);
  3666. p._fulfillmentHandler0 = value;
  3667. p._rejectionHandler0 = value;
  3668. p._promise0 = value;
  3669. p._receiver0 = value;
  3670. }
  3671. // Complete slack tracking, opt out of field-type tracking and
  3672. // stabilize map
  3673. fillTypes({a: 1});
  3674. fillTypes({b: 2});
  3675. fillTypes({c: 3});
  3676. fillTypes(1);
  3677. fillTypes(function(){});
  3678. fillTypes(undefined);
  3679. fillTypes(false);
  3680. fillTypes(new Promise(INTERNAL));
  3681. debug.setBounds(Async.firstLineError, util.lastLineError);
  3682. return Promise;
  3683.  
  3684. };
  3685.  
  3686. },{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36}],23:[function(_dereq_,module,exports){
  3687. "use strict";
  3688. module.exports = function(Promise, INTERNAL, tryConvertToPromise,
  3689. apiRejection, Proxyable) {
  3690. var util = _dereq_("./util");
  3691. var isArray = util.isArray;
  3692.  
  3693. function toResolutionValue(val) {
  3694. switch(val) {
  3695. case -2: return [];
  3696. case -3: return {};
  3697. case -6: return new Map();
  3698. }
  3699. }
  3700.  
  3701. function PromiseArray(values) {
  3702. var promise = this._promise = new Promise(INTERNAL);
  3703. if (values instanceof Promise) {
  3704. promise._propagateFrom(values, 3);
  3705. }
  3706. promise._setOnCancel(this);
  3707. this._values = values;
  3708. this._length = 0;
  3709. this._totalResolved = 0;
  3710. this._init(undefined, -2);
  3711. }
  3712. util.inherits(PromiseArray, Proxyable);
  3713.  
  3714. PromiseArray.prototype.length = function () {
  3715. return this._length;
  3716. };
  3717.  
  3718. PromiseArray.prototype.promise = function () {
  3719. return this._promise;
  3720. };
  3721.  
  3722. PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) {
  3723. var values = tryConvertToPromise(this._values, this._promise);
  3724. if (values instanceof Promise) {
  3725. values = values._target();
  3726. var bitField = values._bitField;
  3727. ;
  3728. this._values = values;
  3729.  
  3730. if (((bitField & 50397184) === 0)) {
  3731. this._promise._setAsyncGuaranteed();
  3732. return values._then(
  3733. init,
  3734. this._reject,
  3735. undefined,
  3736. this,
  3737. resolveValueIfEmpty
  3738. );
  3739. } else if (((bitField & 33554432) !== 0)) {
  3740. values = values._value();
  3741. } else if (((bitField & 16777216) !== 0)) {
  3742. return this._reject(values._reason());
  3743. } else {
  3744. return this._cancel();
  3745. }
  3746. }
  3747. values = util.asArray(values);
  3748. if (values === null) {
  3749. var err = apiRejection(
  3750. "expecting an array or an iterable object but got " + util.classString(values)).reason();
  3751. this._promise._rejectCallback(err, false);
  3752. return;
  3753. }
  3754.  
  3755. if (values.length === 0) {
  3756. if (resolveValueIfEmpty === -5) {
  3757. this._resolveEmptyArray();
  3758. }
  3759. else {
  3760. this._resolve(toResolutionValue(resolveValueIfEmpty));
  3761. }
  3762. return;
  3763. }
  3764. this._iterate(values);
  3765. };
  3766.  
  3767. PromiseArray.prototype._iterate = function(values) {
  3768. var len = this.getActualLength(values.length);
  3769. this._length = len;
  3770. this._values = this.shouldCopyValues() ? new Array(len) : this._values;
  3771. var result = this._promise;
  3772. var isResolved = false;
  3773. var bitField = null;
  3774. for (var i = 0; i < len; ++i) {
  3775. var maybePromise = tryConvertToPromise(values[i], result);
  3776.  
  3777. if (maybePromise instanceof Promise) {
  3778. maybePromise = maybePromise._target();
  3779. bitField = maybePromise._bitField;
  3780. } else {
  3781. bitField = null;
  3782. }
  3783.  
  3784. if (isResolved) {
  3785. if (bitField !== null) {
  3786. maybePromise.suppressUnhandledRejections();
  3787. }
  3788. } else if (bitField !== null) {
  3789. if (((bitField & 50397184) === 0)) {
  3790. maybePromise._proxy(this, i);
  3791. this._values[i] = maybePromise;
  3792. } else if (((bitField & 33554432) !== 0)) {
  3793. isResolved = this._promiseFulfilled(maybePromise._value(), i);
  3794. } else if (((bitField & 16777216) !== 0)) {
  3795. isResolved = this._promiseRejected(maybePromise._reason(), i);
  3796. } else {
  3797. isResolved = this._promiseCancelled(i);
  3798. }
  3799. } else {
  3800. isResolved = this._promiseFulfilled(maybePromise, i);
  3801. }
  3802. }
  3803. if (!isResolved) result._setAsyncGuaranteed();
  3804. };
  3805.  
  3806. PromiseArray.prototype._isResolved = function () {
  3807. return this._values === null;
  3808. };
  3809.  
  3810. PromiseArray.prototype._resolve = function (value) {
  3811. this._values = null;
  3812. this._promise._fulfill(value);
  3813. };
  3814.  
  3815. PromiseArray.prototype._cancel = function() {
  3816. if (this._isResolved() || !this._promise._isCancellable()) return;
  3817. this._values = null;
  3818. this._promise._cancel();
  3819. };
  3820.  
  3821. PromiseArray.prototype._reject = function (reason) {
  3822. this._values = null;
  3823. this._promise._rejectCallback(reason, false);
  3824. };
  3825.  
  3826. PromiseArray.prototype._promiseFulfilled = function (value, index) {
  3827. this._values[index] = value;
  3828. var totalResolved = ++this._totalResolved;
  3829. if (totalResolved >= this._length) {
  3830. this._resolve(this._values);
  3831. return true;
  3832. }
  3833. return false;
  3834. };
  3835.  
  3836. PromiseArray.prototype._promiseCancelled = function() {
  3837. this._cancel();
  3838. return true;
  3839. };
  3840.  
  3841. PromiseArray.prototype._promiseRejected = function (reason) {
  3842. this._totalResolved++;
  3843. this._reject(reason);
  3844. return true;
  3845. };
  3846.  
  3847. PromiseArray.prototype._resultCancelled = function() {
  3848. if (this._isResolved()) return;
  3849. var values = this._values;
  3850. this._cancel();
  3851. if (values instanceof Promise) {
  3852. values.cancel();
  3853. } else {
  3854. for (var i = 0; i < values.length; ++i) {
  3855. if (values[i] instanceof Promise) {
  3856. values[i].cancel();
  3857. }
  3858. }
  3859. }
  3860. };
  3861.  
  3862. PromiseArray.prototype.shouldCopyValues = function () {
  3863. return true;
  3864. };
  3865.  
  3866. PromiseArray.prototype.getActualLength = function (len) {
  3867. return len;
  3868. };
  3869.  
  3870. return PromiseArray;
  3871. };
  3872.  
  3873. },{"./util":36}],24:[function(_dereq_,module,exports){
  3874. "use strict";
  3875. module.exports = function(Promise, INTERNAL) {
  3876. var THIS = {};
  3877. var util = _dereq_("./util");
  3878. var nodebackForPromise = _dereq_("./nodeback");
  3879. var withAppended = util.withAppended;
  3880. var maybeWrapAsError = util.maybeWrapAsError;
  3881. var canEvaluate = util.canEvaluate;
  3882. var TypeError = _dereq_("./errors").TypeError;
  3883. var defaultSuffix = "Async";
  3884. var defaultPromisified = {__isPromisified__: true};
  3885. var noCopyProps = [
  3886. "arity", "length",
  3887. "name",
  3888. "arguments",
  3889. "caller",
  3890. "callee",
  3891. "prototype",
  3892. "__isPromisified__"
  3893. ];
  3894. var noCopyPropsPattern = new RegExp("^(?:" + noCopyProps.join("|") + ")$");
  3895.  
  3896. var defaultFilter = function(name) {
  3897. return util.isIdentifier(name) &&
  3898. name.charAt(0) !== "_" &&
  3899. name !== "constructor";
  3900. };
  3901.  
  3902. function propsFilter(key) {
  3903. return !noCopyPropsPattern.test(key);
  3904. }
  3905.  
  3906. function isPromisified(fn) {
  3907. try {
  3908. return fn.__isPromisified__ === true;
  3909. }
  3910. catch (e) {
  3911. return false;
  3912. }
  3913. }
  3914.  
  3915. function hasPromisified(obj, key, suffix) {
  3916. var val = util.getDataPropertyOrDefault(obj, key + suffix,
  3917. defaultPromisified);
  3918. return val ? isPromisified(val) : false;
  3919. }
  3920. function checkValid(ret, suffix, suffixRegexp) {
  3921. for (var i = 0; i < ret.length; i += 2) {
  3922. var key = ret[i];
  3923. if (suffixRegexp.test(key)) {
  3924. var keyWithoutAsyncSuffix = key.replace(suffixRegexp, "");
  3925. for (var j = 0; j < ret.length; j += 2) {
  3926. if (ret[j] === keyWithoutAsyncSuffix) {
  3927. throw new TypeError("Cannot promisify an API that has normal methods with '%s'-suffix\u000a\u000a See http://goo.gl/MqrFmX\u000a"
  3928. .replace("%s", suffix));
  3929. }
  3930. }
  3931. }
  3932. }
  3933. }
  3934.  
  3935. function promisifiableMethods(obj, suffix, suffixRegexp, filter) {
  3936. var keys = util.inheritedDataKeys(obj);
  3937. var ret = [];
  3938. for (var i = 0; i < keys.length; ++i) {
  3939. var key = keys[i];
  3940. var value = obj[key];
  3941. var passesDefaultFilter = filter === defaultFilter
  3942. ? true : defaultFilter(key, value, obj);
  3943. if (typeof value === "function" &&
  3944. !isPromisified(value) &&
  3945. !hasPromisified(obj, key, suffix) &&
  3946. filter(key, value, obj, passesDefaultFilter)) {
  3947. ret.push(key, value);
  3948. }
  3949. }
  3950. checkValid(ret, suffix, suffixRegexp);
  3951. return ret;
  3952. }
  3953.  
  3954. var escapeIdentRegex = function(str) {
  3955. return str.replace(/([$])/, "\\$");
  3956. };
  3957.  
  3958. var makeNodePromisifiedEval;
  3959. if (false) {
  3960. var switchCaseArgumentOrder = function(likelyArgumentCount) {
  3961. var ret = [likelyArgumentCount];
  3962. var min = Math.max(0, likelyArgumentCount - 1 - 3);
  3963. for(var i = likelyArgumentCount - 1; i >= min; --i) {
  3964. ret.push(i);
  3965. }
  3966. for(var i = likelyArgumentCount + 1; i <= 3; ++i) {
  3967. ret.push(i);
  3968. }
  3969. return ret;
  3970. };
  3971.  
  3972. var argumentSequence = function(argumentCount) {
  3973. return util.filledRange(argumentCount, "_arg", "");
  3974. };
  3975.  
  3976. var parameterDeclaration = function(parameterCount) {
  3977. return util.filledRange(
  3978. Math.max(parameterCount, 3), "_arg", "");
  3979. };
  3980.  
  3981. var parameterCount = function(fn) {
  3982. if (typeof fn.length === "number") {
  3983. return Math.max(Math.min(fn.length, 1023 + 1), 0);
  3984. }
  3985. return 0;
  3986. };
  3987.  
  3988. makeNodePromisifiedEval =
  3989. function(callback, receiver, originalName, fn, _, multiArgs) {
  3990. var newParameterCount = Math.max(0, parameterCount(fn) - 1);
  3991. var argumentOrder = switchCaseArgumentOrder(newParameterCount);
  3992. var shouldProxyThis = typeof callback === "string" || receiver === THIS;
  3993.  
  3994. function generateCallForArgumentCount(count) {
  3995. var args = argumentSequence(count).join(", ");
  3996. var comma = count > 0 ? ", " : "";
  3997. var ret;
  3998. if (shouldProxyThis) {
  3999. ret = "ret = callback.call(this, {{args}}, nodeback); break;\n";
  4000. } else {
  4001. ret = receiver === undefined
  4002. ? "ret = callback({{args}}, nodeback); break;\n"
  4003. : "ret = callback.call(receiver, {{args}}, nodeback); break;\n";
  4004. }
  4005. return ret.replace("{{args}}", args).replace(", ", comma);
  4006. }
  4007.  
  4008. function generateArgumentSwitchCase() {
  4009. var ret = "";
  4010. for (var i = 0; i < argumentOrder.length; ++i) {
  4011. ret += "case " + argumentOrder[i] +":" +
  4012. generateCallForArgumentCount(argumentOrder[i]);
  4013. }
  4014.  
  4015. ret += " \n\
  4016. default: \n\
  4017. var args = new Array(len + 1); \n\
  4018. var i = 0; \n\
  4019. for (var i = 0; i < len; ++i) { \n\
  4020. args[i] = arguments[i]; \n\
  4021. } \n\
  4022. args[i] = nodeback; \n\
  4023. [CodeForCall] \n\
  4024. break; \n\
  4025. ".replace("[CodeForCall]", (shouldProxyThis
  4026. ? "ret = callback.apply(this, args);\n"
  4027. : "ret = callback.apply(receiver, args);\n"));
  4028. return ret;
  4029. }
  4030.  
  4031. var getFunctionCode = typeof callback === "string"
  4032. ? ("this != null ? this['"+callback+"'] : fn")
  4033. : "fn";
  4034. var body = "'use strict'; \n\
  4035. var ret = function (Parameters) { \n\
  4036. 'use strict'; \n\
  4037. var len = arguments.length; \n\
  4038. var promise = new Promise(INTERNAL); \n\
  4039. promise._captureStackTrace(); \n\
  4040. var nodeback = nodebackForPromise(promise, " + multiArgs + "); \n\
  4041. var ret; \n\
  4042. var callback = tryCatch([GetFunctionCode]); \n\
  4043. switch(len) { \n\
  4044. [CodeForSwitchCase] \n\
  4045. } \n\
  4046. if (ret === errorObj) { \n\
  4047. promise._rejectCallback(maybeWrapAsError(ret.e), true, true);\n\
  4048. } \n\
  4049. if (!promise._isFateSealed()) promise._setAsyncGuaranteed(); \n\
  4050. return promise; \n\
  4051. }; \n\
  4052. notEnumerableProp(ret, '__isPromisified__', true); \n\
  4053. return ret; \n\
  4054. ".replace("[CodeForSwitchCase]", generateArgumentSwitchCase())
  4055. .replace("[GetFunctionCode]", getFunctionCode);
  4056. body = body.replace("Parameters", parameterDeclaration(newParameterCount));
  4057. return new Function("Promise",
  4058. "fn",
  4059. "receiver",
  4060. "withAppended",
  4061. "maybeWrapAsError",
  4062. "nodebackForPromise",
  4063. "tryCatch",
  4064. "errorObj",
  4065. "notEnumerableProp",
  4066. "INTERNAL",
  4067. body)(
  4068. Promise,
  4069. fn,
  4070. receiver,
  4071. withAppended,
  4072. maybeWrapAsError,
  4073. nodebackForPromise,
  4074. util.tryCatch,
  4075. util.errorObj,
  4076. util.notEnumerableProp,
  4077. INTERNAL);
  4078. };
  4079. }
  4080.  
  4081. function makeNodePromisifiedClosure(callback, receiver, _, fn, __, multiArgs) {
  4082. var defaultThis = (function() {return this;})();
  4083. var method = callback;
  4084. if (typeof method === "string") {
  4085. callback = fn;
  4086. }
  4087. function promisified() {
  4088. var _receiver = receiver;
  4089. if (receiver === THIS) _receiver = this;
  4090. var promise = new Promise(INTERNAL);
  4091. promise._captureStackTrace();
  4092. var cb = typeof method === "string" && this !== defaultThis
  4093. ? this[method] : callback;
  4094. var fn = nodebackForPromise(promise, multiArgs);
  4095. try {
  4096. cb.apply(_receiver, withAppended(arguments, fn));
  4097. } catch(e) {
  4098. promise._rejectCallback(maybeWrapAsError(e), true, true);
  4099. }
  4100. if (!promise._isFateSealed()) promise._setAsyncGuaranteed();
  4101. return promise;
  4102. }
  4103. util.notEnumerableProp(promisified, "__isPromisified__", true);
  4104. return promisified;
  4105. }
  4106.  
  4107. var makeNodePromisified = canEvaluate
  4108. ? makeNodePromisifiedEval
  4109. : makeNodePromisifiedClosure;
  4110.  
  4111. function promisifyAll(obj, suffix, filter, promisifier, multiArgs) {
  4112. var suffixRegexp = new RegExp(escapeIdentRegex(suffix) + "$");
  4113. var methods =
  4114. promisifiableMethods(obj, suffix, suffixRegexp, filter);
  4115.  
  4116. for (var i = 0, len = methods.length; i < len; i+= 2) {
  4117. var key = methods[i];
  4118. var fn = methods[i+1];
  4119. var promisifiedKey = key + suffix;
  4120. if (promisifier === makeNodePromisified) {
  4121. obj[promisifiedKey] =
  4122. makeNodePromisified(key, THIS, key, fn, suffix, multiArgs);
  4123. } else {
  4124. var promisified = promisifier(fn, function() {
  4125. return makeNodePromisified(key, THIS, key,
  4126. fn, suffix, multiArgs);
  4127. });
  4128. util.notEnumerableProp(promisified, "__isPromisified__", true);
  4129. obj[promisifiedKey] = promisified;
  4130. }
  4131. }
  4132. util.toFastProperties(obj);
  4133. return obj;
  4134. }
  4135.  
  4136. function promisify(callback, receiver, multiArgs) {
  4137. return makeNodePromisified(callback, receiver, undefined,
  4138. callback, null, multiArgs);
  4139. }
  4140.  
  4141. Promise.promisify = function (fn, options) {
  4142. if (typeof fn !== "function") {
  4143. throw new TypeError("expecting a function but got " + util.classString(fn));
  4144. }
  4145. if (isPromisified(fn)) {
  4146. return fn;
  4147. }
  4148. options = Object(options);
  4149. var receiver = options.context === undefined ? THIS : options.context;
  4150. var multiArgs = !!options.multiArgs;
  4151. var ret = promisify(fn, receiver, multiArgs);
  4152. util.copyDescriptors(fn, ret, propsFilter);
  4153. return ret;
  4154. };
  4155.  
  4156. Promise.promisifyAll = function (target, options) {
  4157. if (typeof target !== "function" && typeof target !== "object") {
  4158. throw new TypeError("the target of promisifyAll must be an object or a function\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  4159. }
  4160. options = Object(options);
  4161. var multiArgs = !!options.multiArgs;
  4162. var suffix = options.suffix;
  4163. if (typeof suffix !== "string") suffix = defaultSuffix;
  4164. var filter = options.filter;
  4165. if (typeof filter !== "function") filter = defaultFilter;
  4166. var promisifier = options.promisifier;
  4167. if (typeof promisifier !== "function") promisifier = makeNodePromisified;
  4168.  
  4169. if (!util.isIdentifier(suffix)) {
  4170. throw new RangeError("suffix must be a valid identifier\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  4171. }
  4172.  
  4173. var keys = util.inheritedDataKeys(target);
  4174. for (var i = 0; i < keys.length; ++i) {
  4175. var value = target[keys[i]];
  4176. if (keys[i] !== "constructor" &&
  4177. util.isClass(value)) {
  4178. promisifyAll(value.prototype, suffix, filter, promisifier,
  4179. multiArgs);
  4180. promisifyAll(value, suffix, filter, promisifier, multiArgs);
  4181. }
  4182. }
  4183.  
  4184. return promisifyAll(target, suffix, filter, promisifier, multiArgs);
  4185. };
  4186. };
  4187.  
  4188.  
  4189. },{"./errors":12,"./nodeback":20,"./util":36}],25:[function(_dereq_,module,exports){
  4190. "use strict";
  4191. module.exports = function(
  4192. Promise, PromiseArray, tryConvertToPromise, apiRejection) {
  4193. var util = _dereq_("./util");
  4194. var isObject = util.isObject;
  4195. var es5 = _dereq_("./es5");
  4196. var Es6Map;
  4197. if (typeof Map === "function") Es6Map = Map;
  4198.  
  4199. var mapToEntries = (function() {
  4200. var index = 0;
  4201. var size = 0;
  4202.  
  4203. function extractEntry(value, key) {
  4204. this[index] = value;
  4205. this[index + size] = key;
  4206. index++;
  4207. }
  4208.  
  4209. return function mapToEntries(map) {
  4210. size = map.size;
  4211. index = 0;
  4212. var ret = new Array(map.size * 2);
  4213. map.forEach(extractEntry, ret);
  4214. return ret;
  4215. };
  4216. })();
  4217.  
  4218. var entriesToMap = function(entries) {
  4219. var ret = new Es6Map();
  4220. var length = entries.length / 2 | 0;
  4221. for (var i = 0; i < length; ++i) {
  4222. var key = entries[length + i];
  4223. var value = entries[i];
  4224. ret.set(key, value);
  4225. }
  4226. return ret;
  4227. };
  4228.  
  4229. function PropertiesPromiseArray(obj) {
  4230. var isMap = false;
  4231. var entries;
  4232. if (Es6Map !== undefined && obj instanceof Es6Map) {
  4233. entries = mapToEntries(obj);
  4234. isMap = true;
  4235. } else {
  4236. var keys = es5.keys(obj);
  4237. var len = keys.length;
  4238. entries = new Array(len * 2);
  4239. for (var i = 0; i < len; ++i) {
  4240. var key = keys[i];
  4241. entries[i] = obj[key];
  4242. entries[i + len] = key;
  4243. }
  4244. }
  4245. this.constructor$(entries);
  4246. this._isMap = isMap;
  4247. this._init$(undefined, isMap ? -6 : -3);
  4248. }
  4249. util.inherits(PropertiesPromiseArray, PromiseArray);
  4250.  
  4251. PropertiesPromiseArray.prototype._init = function () {};
  4252.  
  4253. PropertiesPromiseArray.prototype._promiseFulfilled = function (value, index) {
  4254. this._values[index] = value;
  4255. var totalResolved = ++this._totalResolved;
  4256. if (totalResolved >= this._length) {
  4257. var val;
  4258. if (this._isMap) {
  4259. val = entriesToMap(this._values);
  4260. } else {
  4261. val = {};
  4262. var keyOffset = this.length();
  4263. for (var i = 0, len = this.length(); i < len; ++i) {
  4264. val[this._values[i + keyOffset]] = this._values[i];
  4265. }
  4266. }
  4267. this._resolve(val);
  4268. return true;
  4269. }
  4270. return false;
  4271. };
  4272.  
  4273. PropertiesPromiseArray.prototype.shouldCopyValues = function () {
  4274. return false;
  4275. };
  4276.  
  4277. PropertiesPromiseArray.prototype.getActualLength = function (len) {
  4278. return len >> 1;
  4279. };
  4280.  
  4281. function props(promises) {
  4282. var ret;
  4283. var castValue = tryConvertToPromise(promises);
  4284.  
  4285. if (!isObject(castValue)) {
  4286. return apiRejection("cannot await properties of a non-object\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  4287. } else if (castValue instanceof Promise) {
  4288. ret = castValue._then(
  4289. Promise.props, undefined, undefined, undefined, undefined);
  4290. } else {
  4291. ret = new PropertiesPromiseArray(castValue).promise();
  4292. }
  4293.  
  4294. if (castValue instanceof Promise) {
  4295. ret._propagateFrom(castValue, 2);
  4296. }
  4297. return ret;
  4298. }
  4299.  
  4300. Promise.prototype.props = function () {
  4301. return props(this);
  4302. };
  4303.  
  4304. Promise.props = function (promises) {
  4305. return props(promises);
  4306. };
  4307. };
  4308.  
  4309. },{"./es5":13,"./util":36}],26:[function(_dereq_,module,exports){
  4310. "use strict";
  4311. function arrayMove(src, srcIndex, dst, dstIndex, len) {
  4312. for (var j = 0; j < len; ++j) {
  4313. dst[j + dstIndex] = src[j + srcIndex];
  4314. src[j + srcIndex] = void 0;
  4315. }
  4316. }
  4317.  
  4318. function Queue(capacity) {
  4319. this._capacity = capacity;
  4320. this._length = 0;
  4321. this._front = 0;
  4322. }
  4323.  
  4324. Queue.prototype._willBeOverCapacity = function (size) {
  4325. return this._capacity < size;
  4326. };
  4327.  
  4328. Queue.prototype._pushOne = function (arg) {
  4329. var length = this.length();
  4330. this._checkCapacity(length + 1);
  4331. var i = (this._front + length) & (this._capacity - 1);
  4332. this[i] = arg;
  4333. this._length = length + 1;
  4334. };
  4335.  
  4336. Queue.prototype.push = function (fn, receiver, arg) {
  4337. var length = this.length() + 3;
  4338. if (this._willBeOverCapacity(length)) {
  4339. this._pushOne(fn);
  4340. this._pushOne(receiver);
  4341. this._pushOne(arg);
  4342. return;
  4343. }
  4344. var j = this._front + length - 3;
  4345. this._checkCapacity(length);
  4346. var wrapMask = this._capacity - 1;
  4347. this[(j + 0) & wrapMask] = fn;
  4348. this[(j + 1) & wrapMask] = receiver;
  4349. this[(j + 2) & wrapMask] = arg;
  4350. this._length = length;
  4351. };
  4352.  
  4353. Queue.prototype.shift = function () {
  4354. var front = this._front,
  4355. ret = this[front];
  4356.  
  4357. this[front] = undefined;
  4358. this._front = (front + 1) & (this._capacity - 1);
  4359. this._length--;
  4360. return ret;
  4361. };
  4362.  
  4363. Queue.prototype.length = function () {
  4364. return this._length;
  4365. };
  4366.  
  4367. Queue.prototype._checkCapacity = function (size) {
  4368. if (this._capacity < size) {
  4369. this._resizeTo(this._capacity << 1);
  4370. }
  4371. };
  4372.  
  4373. Queue.prototype._resizeTo = function (capacity) {
  4374. var oldCapacity = this._capacity;
  4375. this._capacity = capacity;
  4376. var front = this._front;
  4377. var length = this._length;
  4378. var moveItemsCount = (front + length) & (oldCapacity - 1);
  4379. arrayMove(this, 0, this, oldCapacity, moveItemsCount);
  4380. };
  4381.  
  4382. module.exports = Queue;
  4383.  
  4384. },{}],27:[function(_dereq_,module,exports){
  4385. "use strict";
  4386. module.exports = function(
  4387. Promise, INTERNAL, tryConvertToPromise, apiRejection) {
  4388. var util = _dereq_("./util");
  4389.  
  4390. var raceLater = function (promise) {
  4391. return promise.then(function(array) {
  4392. return race(array, promise);
  4393. });
  4394. };
  4395.  
  4396. function race(promises, parent) {
  4397. var maybePromise = tryConvertToPromise(promises);
  4398.  
  4399. if (maybePromise instanceof Promise) {
  4400. return raceLater(maybePromise);
  4401. } else {
  4402. promises = util.asArray(promises);
  4403. if (promises === null)
  4404. return apiRejection("expecting an array or an iterable object but got " + util.classString(promises));
  4405. }
  4406.  
  4407. var ret = new Promise(INTERNAL);
  4408. if (parent !== undefined) {
  4409. ret._propagateFrom(parent, 3);
  4410. }
  4411. var fulfill = ret._fulfill;
  4412. var reject = ret._reject;
  4413. for (var i = 0, len = promises.length; i < len; ++i) {
  4414. var val = promises[i];
  4415.  
  4416. if (val === undefined && !(i in promises)) {
  4417. continue;
  4418. }
  4419.  
  4420. Promise.cast(val)._then(fulfill, reject, undefined, ret, null);
  4421. }
  4422. return ret;
  4423. }
  4424.  
  4425. Promise.race = function (promises) {
  4426. return race(promises, undefined);
  4427. };
  4428.  
  4429. Promise.prototype.race = function () {
  4430. return race(this, undefined);
  4431. };
  4432.  
  4433. };
  4434.  
  4435. },{"./util":36}],28:[function(_dereq_,module,exports){
  4436. "use strict";
  4437. module.exports = function(Promise,
  4438. PromiseArray,
  4439. apiRejection,
  4440. tryConvertToPromise,
  4441. INTERNAL,
  4442. debug) {
  4443. var getDomain = Promise._getDomain;
  4444. var util = _dereq_("./util");
  4445. var tryCatch = util.tryCatch;
  4446.  
  4447. function ReductionPromiseArray(promises, fn, initialValue, _each) {
  4448. this.constructor$(promises);
  4449. var domain = getDomain();
  4450. this._fn = domain === null ? fn : util.domainBind(domain, fn);
  4451. if (initialValue !== undefined) {
  4452. initialValue = Promise.resolve(initialValue);
  4453. initialValue._attachCancellationCallback(this);
  4454. }
  4455. this._initialValue = initialValue;
  4456. this._currentCancellable = null;
  4457. if(_each === INTERNAL) {
  4458. this._eachValues = Array(this._length);
  4459. } else if (_each === 0) {
  4460. this._eachValues = null;
  4461. } else {
  4462. this._eachValues = undefined;
  4463. }
  4464. this._promise._captureStackTrace();
  4465. this._init$(undefined, -5);
  4466. }
  4467. util.inherits(ReductionPromiseArray, PromiseArray);
  4468.  
  4469. ReductionPromiseArray.prototype._gotAccum = function(accum) {
  4470. if (this._eachValues !== undefined &&
  4471. this._eachValues !== null &&
  4472. accum !== INTERNAL) {
  4473. this._eachValues.push(accum);
  4474. }
  4475. };
  4476.  
  4477. ReductionPromiseArray.prototype._eachComplete = function(value) {
  4478. if (this._eachValues !== null) {
  4479. this._eachValues.push(value);
  4480. }
  4481. return this._eachValues;
  4482. };
  4483.  
  4484. ReductionPromiseArray.prototype._init = function() {};
  4485.  
  4486. ReductionPromiseArray.prototype._resolveEmptyArray = function() {
  4487. this._resolve(this._eachValues !== undefined ? this._eachValues
  4488. : this._initialValue);
  4489. };
  4490.  
  4491. ReductionPromiseArray.prototype.shouldCopyValues = function () {
  4492. return false;
  4493. };
  4494.  
  4495. ReductionPromiseArray.prototype._resolve = function(value) {
  4496. this._promise._resolveCallback(value);
  4497. this._values = null;
  4498. };
  4499.  
  4500. ReductionPromiseArray.prototype._resultCancelled = function(sender) {
  4501. if (sender === this._initialValue) return this._cancel();
  4502. if (this._isResolved()) return;
  4503. this._resultCancelled$();
  4504. if (this._currentCancellable instanceof Promise) {
  4505. this._currentCancellable.cancel();
  4506. }
  4507. if (this._initialValue instanceof Promise) {
  4508. this._initialValue.cancel();
  4509. }
  4510. };
  4511.  
  4512. ReductionPromiseArray.prototype._iterate = function (values) {
  4513. this._values = values;
  4514. var value;
  4515. var i;
  4516. var length = values.length;
  4517. if (this._initialValue !== undefined) {
  4518. value = this._initialValue;
  4519. i = 0;
  4520. } else {
  4521. value = Promise.resolve(values[0]);
  4522. i = 1;
  4523. }
  4524.  
  4525. this._currentCancellable = value;
  4526.  
  4527. if (!value.isRejected()) {
  4528. for (; i < length; ++i) {
  4529. var ctx = {
  4530. accum: null,
  4531. value: values[i],
  4532. index: i,
  4533. length: length,
  4534. array: this
  4535. };
  4536. value = value._then(gotAccum, undefined, undefined, ctx, undefined);
  4537. }
  4538. }
  4539.  
  4540. if (this._eachValues !== undefined) {
  4541. value = value
  4542. ._then(this._eachComplete, undefined, undefined, this, undefined);
  4543. }
  4544. value._then(completed, completed, undefined, value, this);
  4545. };
  4546.  
  4547. Promise.prototype.reduce = function (fn, initialValue) {
  4548. return reduce(this, fn, initialValue, null);
  4549. };
  4550.  
  4551. Promise.reduce = function (promises, fn, initialValue, _each) {
  4552. return reduce(promises, fn, initialValue, _each);
  4553. };
  4554.  
  4555. function completed(valueOrReason, array) {
  4556. if (this.isFulfilled()) {
  4557. array._resolve(valueOrReason);
  4558. } else {
  4559. array._reject(valueOrReason);
  4560. }
  4561. }
  4562.  
  4563. function reduce(promises, fn, initialValue, _each) {
  4564. if (typeof fn !== "function") {
  4565. return apiRejection("expecting a function but got " + util.classString(fn));
  4566. }
  4567. var array = new ReductionPromiseArray(promises, fn, initialValue, _each);
  4568. return array.promise();
  4569. }
  4570.  
  4571. function gotAccum(accum) {
  4572. this.accum = accum;
  4573. this.array._gotAccum(accum);
  4574. var value = tryConvertToPromise(this.value, this.array._promise);
  4575. if (value instanceof Promise) {
  4576. this.array._currentCancellable = value;
  4577. return value._then(gotValue, undefined, undefined, this, undefined);
  4578. } else {
  4579. return gotValue.call(this, value);
  4580. }
  4581. }
  4582.  
  4583. function gotValue(value) {
  4584. var array = this.array;
  4585. var promise = array._promise;
  4586. var fn = tryCatch(array._fn);
  4587. promise._pushContext();
  4588. var ret;
  4589. if (array._eachValues !== undefined) {
  4590. ret = fn.call(promise._boundValue(), value, this.index, this.length);
  4591. } else {
  4592. ret = fn.call(promise._boundValue(),
  4593. this.accum, value, this.index, this.length);
  4594. }
  4595. if (ret instanceof Promise) {
  4596. array._currentCancellable = ret;
  4597. }
  4598. var promiseCreated = promise._popContext();
  4599. debug.checkForgottenReturns(
  4600. ret,
  4601. promiseCreated,
  4602. array._eachValues !== undefined ? "Promise.each" : "Promise.reduce",
  4603. promise
  4604. );
  4605. return ret;
  4606. }
  4607. };
  4608.  
  4609. },{"./util":36}],29:[function(_dereq_,module,exports){
  4610. "use strict";
  4611. var util = _dereq_("./util");
  4612. var schedule;
  4613. var noAsyncScheduler = function() {
  4614. throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  4615. };
  4616. var NativePromise = util.getNativePromise();
  4617. if (util.isNode && typeof MutationObserver === "undefined") {
  4618. var GlobalSetImmediate = global.setImmediate;
  4619. var ProcessNextTick = process.nextTick;
  4620. schedule = util.isRecentNode
  4621. ? function(fn) { GlobalSetImmediate.call(global, fn); }
  4622. : function(fn) { ProcessNextTick.call(process, fn); };
  4623. } else if (typeof NativePromise === "function" &&
  4624. typeof NativePromise.resolve === "function") {
  4625. var nativePromise = NativePromise.resolve();
  4626. schedule = function(fn) {
  4627. nativePromise.then(fn);
  4628. };
  4629. } else if ((typeof MutationObserver !== "undefined") &&
  4630. !(typeof window !== "undefined" &&
  4631. window.navigator &&
  4632. (window.navigator.standalone || window.cordova))) {
  4633. schedule = (function() {
  4634. var div = document.createElement("div");
  4635. var opts = {attributes: true};
  4636. var toggleScheduled = false;
  4637. var div2 = document.createElement("div");
  4638. var o2 = new MutationObserver(function() {
  4639. div.classList.toggle("foo");
  4640. toggleScheduled = false;
  4641. });
  4642. o2.observe(div2, opts);
  4643.  
  4644. var scheduleToggle = function() {
  4645. if (toggleScheduled) return;
  4646. toggleScheduled = true;
  4647. div2.classList.toggle("foo");
  4648. };
  4649.  
  4650. return function schedule(fn) {
  4651. var o = new MutationObserver(function() {
  4652. o.disconnect();
  4653. fn();
  4654. });
  4655. o.observe(div, opts);
  4656. scheduleToggle();
  4657. };
  4658. })();
  4659. } else if (typeof setImmediate !== "undefined") {
  4660. schedule = function (fn) {
  4661. setImmediate(fn);
  4662. };
  4663. } else if (typeof setTimeout !== "undefined") {
  4664. schedule = function (fn) {
  4665. setTimeout(fn, 0);
  4666. };
  4667. } else {
  4668. schedule = noAsyncScheduler;
  4669. }
  4670. module.exports = schedule;
  4671.  
  4672. },{"./util":36}],30:[function(_dereq_,module,exports){
  4673. "use strict";
  4674. module.exports =
  4675. function(Promise, PromiseArray, debug) {
  4676. var PromiseInspection = Promise.PromiseInspection;
  4677. var util = _dereq_("./util");
  4678.  
  4679. function SettledPromiseArray(values) {
  4680. this.constructor$(values);
  4681. }
  4682. util.inherits(SettledPromiseArray, PromiseArray);
  4683.  
  4684. SettledPromiseArray.prototype._promiseResolved = function (index, inspection) {
  4685. this._values[index] = inspection;
  4686. var totalResolved = ++this._totalResolved;
  4687. if (totalResolved >= this._length) {
  4688. this._resolve(this._values);
  4689. return true;
  4690. }
  4691. return false;
  4692. };
  4693.  
  4694. SettledPromiseArray.prototype._promiseFulfilled = function (value, index) {
  4695. var ret = new PromiseInspection();
  4696. ret._bitField = 33554432;
  4697. ret._settledValueField = value;
  4698. return this._promiseResolved(index, ret);
  4699. };
  4700. SettledPromiseArray.prototype._promiseRejected = function (reason, index) {
  4701. var ret = new PromiseInspection();
  4702. ret._bitField = 16777216;
  4703. ret._settledValueField = reason;
  4704. return this._promiseResolved(index, ret);
  4705. };
  4706.  
  4707. Promise.settle = function (promises) {
  4708. debug.deprecated(".settle()", ".reflect()");
  4709. return new SettledPromiseArray(promises).promise();
  4710. };
  4711.  
  4712. Promise.prototype.settle = function () {
  4713. return Promise.settle(this);
  4714. };
  4715. };
  4716.  
  4717. },{"./util":36}],31:[function(_dereq_,module,exports){
  4718. "use strict";
  4719. module.exports =
  4720. function(Promise, PromiseArray, apiRejection) {
  4721. var util = _dereq_("./util");
  4722. var RangeError = _dereq_("./errors").RangeError;
  4723. var AggregateError = _dereq_("./errors").AggregateError;
  4724. var isArray = util.isArray;
  4725. var CANCELLATION = {};
  4726.  
  4727.  
  4728. function SomePromiseArray(values) {
  4729. this.constructor$(values);
  4730. this._howMany = 0;
  4731. this._unwrap = false;
  4732. this._initialized = false;
  4733. }
  4734. util.inherits(SomePromiseArray, PromiseArray);
  4735.  
  4736. SomePromiseArray.prototype._init = function () {
  4737. if (!this._initialized) {
  4738. return;
  4739. }
  4740. if (this._howMany === 0) {
  4741. this._resolve([]);
  4742. return;
  4743. }
  4744. this._init$(undefined, -5);
  4745. var isArrayResolved = isArray(this._values);
  4746. if (!this._isResolved() &&
  4747. isArrayResolved &&
  4748. this._howMany > this._canPossiblyFulfill()) {
  4749. this._reject(this._getRangeError(this.length()));
  4750. }
  4751. };
  4752.  
  4753. SomePromiseArray.prototype.init = function () {
  4754. this._initialized = true;
  4755. this._init();
  4756. };
  4757.  
  4758. SomePromiseArray.prototype.setUnwrap = function () {
  4759. this._unwrap = true;
  4760. };
  4761.  
  4762. SomePromiseArray.prototype.howMany = function () {
  4763. return this._howMany;
  4764. };
  4765.  
  4766. SomePromiseArray.prototype.setHowMany = function (count) {
  4767. this._howMany = count;
  4768. };
  4769.  
  4770. SomePromiseArray.prototype._promiseFulfilled = function (value) {
  4771. this._addFulfilled(value);
  4772. if (this._fulfilled() === this.howMany()) {
  4773. this._values.length = this.howMany();
  4774. if (this.howMany() === 1 && this._unwrap) {
  4775. this._resolve(this._values[0]);
  4776. } else {
  4777. this._resolve(this._values);
  4778. }
  4779. return true;
  4780. }
  4781. return false;
  4782.  
  4783. };
  4784. SomePromiseArray.prototype._promiseRejected = function (reason) {
  4785. this._addRejected(reason);
  4786. return this._checkOutcome();
  4787. };
  4788.  
  4789. SomePromiseArray.prototype._promiseCancelled = function () {
  4790. if (this._values instanceof Promise || this._values == null) {
  4791. return this._cancel();
  4792. }
  4793. this._addRejected(CANCELLATION);
  4794. return this._checkOutcome();
  4795. };
  4796.  
  4797. SomePromiseArray.prototype._checkOutcome = function() {
  4798. if (this.howMany() > this._canPossiblyFulfill()) {
  4799. var e = new AggregateError();
  4800. for (var i = this.length(); i < this._values.length; ++i) {
  4801. if (this._values[i] !== CANCELLATION) {
  4802. e.push(this._values[i]);
  4803. }
  4804. }
  4805. if (e.length > 0) {
  4806. this._reject(e);
  4807. } else {
  4808. this._cancel();
  4809. }
  4810. return true;
  4811. }
  4812. return false;
  4813. };
  4814.  
  4815. SomePromiseArray.prototype._fulfilled = function () {
  4816. return this._totalResolved;
  4817. };
  4818.  
  4819. SomePromiseArray.prototype._rejected = function () {
  4820. return this._values.length - this.length();
  4821. };
  4822.  
  4823. SomePromiseArray.prototype._addRejected = function (reason) {
  4824. this._values.push(reason);
  4825. };
  4826.  
  4827. SomePromiseArray.prototype._addFulfilled = function (value) {
  4828. this._values[this._totalResolved++] = value;
  4829. };
  4830.  
  4831. SomePromiseArray.prototype._canPossiblyFulfill = function () {
  4832. return this.length() - this._rejected();
  4833. };
  4834.  
  4835. SomePromiseArray.prototype._getRangeError = function (count) {
  4836. var message = "Input array must contain at least " +
  4837. this._howMany + " items but contains only " + count + " items";
  4838. return new RangeError(message);
  4839. };
  4840.  
  4841. SomePromiseArray.prototype._resolveEmptyArray = function () {
  4842. this._reject(this._getRangeError(0));
  4843. };
  4844.  
  4845. function some(promises, howMany) {
  4846. if ((howMany | 0) !== howMany || howMany < 0) {
  4847. return apiRejection("expecting a positive integer\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  4848. }
  4849. var ret = new SomePromiseArray(promises);
  4850. var promise = ret.promise();
  4851. ret.setHowMany(howMany);
  4852. ret.init();
  4853. return promise;
  4854. }
  4855.  
  4856. Promise.some = function (promises, howMany) {
  4857. return some(promises, howMany);
  4858. };
  4859.  
  4860. Promise.prototype.some = function (howMany) {
  4861. return some(this, howMany);
  4862. };
  4863.  
  4864. Promise._SomePromiseArray = SomePromiseArray;
  4865. };
  4866.  
  4867. },{"./errors":12,"./util":36}],32:[function(_dereq_,module,exports){
  4868. "use strict";
  4869. module.exports = function(Promise) {
  4870. function PromiseInspection(promise) {
  4871. if (promise !== undefined) {
  4872. promise = promise._target();
  4873. this._bitField = promise._bitField;
  4874. this._settledValueField = promise._isFateSealed()
  4875. ? promise._settledValue() : undefined;
  4876. }
  4877. else {
  4878. this._bitField = 0;
  4879. this._settledValueField = undefined;
  4880. }
  4881. }
  4882.  
  4883. PromiseInspection.prototype._settledValue = function() {
  4884. return this._settledValueField;
  4885. };
  4886.  
  4887. var value = PromiseInspection.prototype.value = function () {
  4888. if (!this.isFulfilled()) {
  4889. throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  4890. }
  4891. return this._settledValue();
  4892. };
  4893.  
  4894. var reason = PromiseInspection.prototype.error =
  4895. PromiseInspection.prototype.reason = function () {
  4896. if (!this.isRejected()) {
  4897. throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/MqrFmX\u000a");
  4898. }
  4899. return this._settledValue();
  4900. };
  4901.  
  4902. var isFulfilled = PromiseInspection.prototype.isFulfilled = function() {
  4903. return (this._bitField & 33554432) !== 0;
  4904. };
  4905.  
  4906. var isRejected = PromiseInspection.prototype.isRejected = function () {
  4907. return (this._bitField & 16777216) !== 0;
  4908. };
  4909.  
  4910. var isPending = PromiseInspection.prototype.isPending = function () {
  4911. return (this._bitField & 50397184) === 0;
  4912. };
  4913.  
  4914. var isResolved = PromiseInspection.prototype.isResolved = function () {
  4915. return (this._bitField & 50331648) !== 0;
  4916. };
  4917.  
  4918. PromiseInspection.prototype.isCancelled = function() {
  4919. return (this._bitField & 8454144) !== 0;
  4920. };
  4921.  
  4922. Promise.prototype.__isCancelled = function() {
  4923. return (this._bitField & 65536) === 65536;
  4924. };
  4925.  
  4926. Promise.prototype._isCancelled = function() {
  4927. return this._target().__isCancelled();
  4928. };
  4929.  
  4930. Promise.prototype.isCancelled = function() {
  4931. return (this._target()._bitField & 8454144) !== 0;
  4932. };
  4933.  
  4934. Promise.prototype.isPending = function() {
  4935. return isPending.call(this._target());
  4936. };
  4937.  
  4938. Promise.prototype.isRejected = function() {
  4939. return isRejected.call(this._target());
  4940. };
  4941.  
  4942. Promise.prototype.isFulfilled = function() {
  4943. return isFulfilled.call(this._target());
  4944. };
  4945.  
  4946. Promise.prototype.isResolved = function() {
  4947. return isResolved.call(this._target());
  4948. };
  4949.  
  4950. Promise.prototype.value = function() {
  4951. return value.call(this._target());
  4952. };
  4953.  
  4954. Promise.prototype.reason = function() {
  4955. var target = this._target();
  4956. target._unsetRejectionIsUnhandled();
  4957. return reason.call(target);
  4958. };
  4959.  
  4960. Promise.prototype._value = function() {
  4961. return this._settledValue();
  4962. };
  4963.  
  4964. Promise.prototype._reason = function() {
  4965. this._unsetRejectionIsUnhandled();
  4966. return this._settledValue();
  4967. };
  4968.  
  4969. Promise.PromiseInspection = PromiseInspection;
  4970. };
  4971.  
  4972. },{}],33:[function(_dereq_,module,exports){
  4973. "use strict";
  4974. module.exports = function(Promise, INTERNAL) {
  4975. var util = _dereq_("./util");
  4976. var errorObj = util.errorObj;
  4977. var isObject = util.isObject;
  4978.  
  4979. function tryConvertToPromise(obj, context) {
  4980. if (isObject(obj)) {
  4981. if (obj instanceof Promise) return obj;
  4982. var then = getThen(obj);
  4983. if (then === errorObj) {
  4984. if (context) context._pushContext();
  4985. var ret = Promise.reject(then.e);
  4986. if (context) context._popContext();
  4987. return ret;
  4988. } else if (typeof then === "function") {
  4989. if (isAnyBluebirdPromise(obj)) {
  4990. var ret = new Promise(INTERNAL);
  4991. obj._then(
  4992. ret._fulfill,
  4993. ret._reject,
  4994. undefined,
  4995. ret,
  4996. null
  4997. );
  4998. return ret;
  4999. }
  5000. return doThenable(obj, then, context);
  5001. }
  5002. }
  5003. return obj;
  5004. }
  5005.  
  5006. function doGetThen(obj) {
  5007. return obj.then;
  5008. }
  5009.  
  5010. function getThen(obj) {
  5011. try {
  5012. return doGetThen(obj);
  5013. } catch (e) {
  5014. errorObj.e = e;
  5015. return errorObj;
  5016. }
  5017. }
  5018.  
  5019. var hasProp = {}.hasOwnProperty;
  5020. function isAnyBluebirdPromise(obj) {
  5021. try {
  5022. return hasProp.call(obj, "_promise0");
  5023. } catch (e) {
  5024. return false;
  5025. }
  5026. }
  5027.  
  5028. function doThenable(x, then, context) {
  5029. var promise = new Promise(INTERNAL);
  5030. var ret = promise;
  5031. if (context) context._pushContext();
  5032. promise._captureStackTrace();
  5033. if (context) context._popContext();
  5034. var synchronous = true;
  5035. var result = util.tryCatch(then).call(x, resolve, reject);
  5036. synchronous = false;
  5037.  
  5038. if (promise && result === errorObj) {
  5039. promise._rejectCallback(result.e, true, true);
  5040. promise = null;
  5041. }
  5042.  
  5043. function resolve(value) {
  5044. if (!promise) return;
  5045. promise._resolveCallback(value);
  5046. promise = null;
  5047. }
  5048.  
  5049. function reject(reason) {
  5050. if (!promise) return;
  5051. promise._rejectCallback(reason, synchronous, true);
  5052. promise = null;
  5053. }
  5054. return ret;
  5055. }
  5056.  
  5057. return tryConvertToPromise;
  5058. };
  5059.  
  5060. },{"./util":36}],34:[function(_dereq_,module,exports){
  5061. "use strict";
  5062. module.exports = function(Promise, INTERNAL, debug) {
  5063. var util = _dereq_("./util");
  5064. var TimeoutError = Promise.TimeoutError;
  5065.  
  5066. function HandleWrapper(handle) {
  5067. this.handle = handle;
  5068. }
  5069.  
  5070. HandleWrapper.prototype._resultCancelled = function() {
  5071. clearTimeout(this.handle);
  5072. };
  5073.  
  5074. var afterValue = function(value) { return delay(+this).thenReturn(value); };
  5075. var delay = Promise.delay = function (ms, value) {
  5076. var ret;
  5077. var handle;
  5078. if (value !== undefined) {
  5079. ret = Promise.resolve(value)
  5080. ._then(afterValue, null, null, ms, undefined);
  5081. if (debug.cancellation() && value instanceof Promise) {
  5082. ret._setOnCancel(value);
  5083. }
  5084. } else {
  5085. ret = new Promise(INTERNAL);
  5086. handle = setTimeout(function() { ret._fulfill(); }, +ms);
  5087. if (debug.cancellation()) {
  5088. ret._setOnCancel(new HandleWrapper(handle));
  5089. }
  5090. ret._captureStackTrace();
  5091. }
  5092. ret._setAsyncGuaranteed();
  5093. return ret;
  5094. };
  5095.  
  5096. Promise.prototype.delay = function (ms) {
  5097. return delay(ms, this);
  5098. };
  5099.  
  5100. var afterTimeout = function (promise, message, parent) {
  5101. var err;
  5102. if (typeof message !== "string") {
  5103. if (message instanceof Error) {
  5104. err = message;
  5105. } else {
  5106. err = new TimeoutError("operation timed out");
  5107. }
  5108. } else {
  5109. err = new TimeoutError(message);
  5110. }
  5111. util.markAsOriginatingFromRejection(err);
  5112. promise._attachExtraTrace(err);
  5113. promise._reject(err);
  5114.  
  5115. if (parent != null) {
  5116. parent.cancel();
  5117. }
  5118. };
  5119.  
  5120. function successClear(value) {
  5121. clearTimeout(this.handle);
  5122. return value;
  5123. }
  5124.  
  5125. function failureClear(reason) {
  5126. clearTimeout(this.handle);
  5127. throw reason;
  5128. }
  5129.  
  5130. Promise.prototype.timeout = function (ms, message) {
  5131. ms = +ms;
  5132. var ret, parent;
  5133.  
  5134. var handleWrapper = new HandleWrapper(setTimeout(function timeoutTimeout() {
  5135. if (ret.isPending()) {
  5136. afterTimeout(ret, message, parent);
  5137. }
  5138. }, ms));
  5139.  
  5140. if (debug.cancellation()) {
  5141. parent = this.then();
  5142. ret = parent._then(successClear, failureClear,
  5143. undefined, handleWrapper, undefined);
  5144. ret._setOnCancel(handleWrapper);
  5145. } else {
  5146. ret = this._then(successClear, failureClear,
  5147. undefined, handleWrapper, undefined);
  5148. }
  5149.  
  5150. return ret;
  5151. };
  5152.  
  5153. };
  5154.  
  5155. },{"./util":36}],35:[function(_dereq_,module,exports){
  5156. "use strict";
  5157. module.exports = function (Promise, apiRejection, tryConvertToPromise,
  5158. createContext, INTERNAL, debug) {
  5159. var util = _dereq_("./util");
  5160. var TypeError = _dereq_("./errors").TypeError;
  5161. var inherits = _dereq_("./util").inherits;
  5162. var errorObj = util.errorObj;
  5163. var tryCatch = util.tryCatch;
  5164. var NULL = {};
  5165.  
  5166. function thrower(e) {
  5167. setTimeout(function(){throw e;}, 0);
  5168. }
  5169.  
  5170. function castPreservingDisposable(thenable) {
  5171. var maybePromise = tryConvertToPromise(thenable);
  5172. if (maybePromise !== thenable &&
  5173. typeof thenable._isDisposable === "function" &&
  5174. typeof thenable._getDisposer === "function" &&
  5175. thenable._isDisposable()) {
  5176. maybePromise._setDisposable(thenable._getDisposer());
  5177. }
  5178. return maybePromise;
  5179. }
  5180. function dispose(resources, inspection) {
  5181. var i = 0;
  5182. var len = resources.length;
  5183. var ret = new Promise(INTERNAL);
  5184. function iterator() {
  5185. if (i >= len) return ret._fulfill();
  5186. var maybePromise = castPreservingDisposable(resources[i++]);
  5187. if (maybePromise instanceof Promise &&
  5188. maybePromise._isDisposable()) {
  5189. try {
  5190. maybePromise = tryConvertToPromise(
  5191. maybePromise._getDisposer().tryDispose(inspection),
  5192. resources.promise);
  5193. } catch (e) {
  5194. return thrower(e);
  5195. }
  5196. if (maybePromise instanceof Promise) {
  5197. return maybePromise._then(iterator, thrower,
  5198. null, null, null);
  5199. }
  5200. }
  5201. iterator();
  5202. }
  5203. iterator();
  5204. return ret;
  5205. }
  5206.  
  5207. function Disposer(data, promise, context) {
  5208. this._data = data;
  5209. this._promise = promise;
  5210. this._context = context;
  5211. }
  5212.  
  5213. Disposer.prototype.data = function () {
  5214. return this._data;
  5215. };
  5216.  
  5217. Disposer.prototype.promise = function () {
  5218. return this._promise;
  5219. };
  5220.  
  5221. Disposer.prototype.resource = function () {
  5222. if (this.promise().isFulfilled()) {
  5223. return this.promise().value();
  5224. }
  5225. return NULL;
  5226. };
  5227.  
  5228. Disposer.prototype.tryDispose = function(inspection) {
  5229. var resource = this.resource();
  5230. var context = this._context;
  5231. if (context !== undefined) context._pushContext();
  5232. var ret = resource !== NULL
  5233. ? this.doDispose(resource, inspection) : null;
  5234. if (context !== undefined) context._popContext();
  5235. this._promise._unsetDisposable();
  5236. this._data = null;
  5237. return ret;
  5238. };
  5239.  
  5240. Disposer.isDisposer = function (d) {
  5241. return (d != null &&
  5242. typeof d.resource === "function" &&
  5243. typeof d.tryDispose === "function");
  5244. };
  5245.  
  5246. function FunctionDisposer(fn, promise, context) {
  5247. this.constructor$(fn, promise, context);
  5248. }
  5249. inherits(FunctionDisposer, Disposer);
  5250.  
  5251. FunctionDisposer.prototype.doDispose = function (resource, inspection) {
  5252. var fn = this.data();
  5253. return fn.call(resource, resource, inspection);
  5254. };
  5255.  
  5256. function maybeUnwrapDisposer(value) {
  5257. if (Disposer.isDisposer(value)) {
  5258. this.resources[this.index]._setDisposable(value);
  5259. return value.promise();
  5260. }
  5261. return value;
  5262. }
  5263.  
  5264. function ResourceList(length) {
  5265. this.length = length;
  5266. this.promise = null;
  5267. this[length-1] = null;
  5268. }
  5269.  
  5270. ResourceList.prototype._resultCancelled = function() {
  5271. var len = this.length;
  5272. for (var i = 0; i < len; ++i) {
  5273. var item = this[i];
  5274. if (item instanceof Promise) {
  5275. item.cancel();
  5276. }
  5277. }
  5278. };
  5279.  
  5280. Promise.using = function () {
  5281. var len = arguments.length;
  5282. if (len < 2) return apiRejection(
  5283. "you must pass at least 2 arguments to Promise.using");
  5284. var fn = arguments[len - 1];
  5285. if (typeof fn !== "function") {
  5286. return apiRejection("expecting a function but got " + util.classString(fn));
  5287. }
  5288. var input;
  5289. var spreadArgs = true;
  5290. if (len === 2 && Array.isArray(arguments[0])) {
  5291. input = arguments[0];
  5292. len = input.length;
  5293. spreadArgs = false;
  5294. } else {
  5295. input = arguments;
  5296. len--;
  5297. }
  5298. var resources = new ResourceList(len);
  5299. for (var i = 0; i < len; ++i) {
  5300. var resource = input[i];
  5301. if (Disposer.isDisposer(resource)) {
  5302. var disposer = resource;
  5303. resource = resource.promise();
  5304. resource._setDisposable(disposer);
  5305. } else {
  5306. var maybePromise = tryConvertToPromise(resource);
  5307. if (maybePromise instanceof Promise) {
  5308. resource =
  5309. maybePromise._then(maybeUnwrapDisposer, null, null, {
  5310. resources: resources,
  5311. index: i
  5312. }, undefined);
  5313. }
  5314. }
  5315. resources[i] = resource;
  5316. }
  5317.  
  5318. var reflectedResources = new Array(resources.length);
  5319. for (var i = 0; i < reflectedResources.length; ++i) {
  5320. reflectedResources[i] = Promise.resolve(resources[i]).reflect();
  5321. }
  5322.  
  5323. var resultPromise = Promise.all(reflectedResources)
  5324. .then(function(inspections) {
  5325. for (var i = 0; i < inspections.length; ++i) {
  5326. var inspection = inspections[i];
  5327. if (inspection.isRejected()) {
  5328. errorObj.e = inspection.error();
  5329. return errorObj;
  5330. } else if (!inspection.isFulfilled()) {
  5331. resultPromise.cancel();
  5332. return;
  5333. }
  5334. inspections[i] = inspection.value();
  5335. }
  5336. promise._pushContext();
  5337.  
  5338. fn = tryCatch(fn);
  5339. var ret = spreadArgs
  5340. ? fn.apply(undefined, inspections) : fn(inspections);
  5341. var promiseCreated = promise._popContext();
  5342. debug.checkForgottenReturns(
  5343. ret, promiseCreated, "Promise.using", promise);
  5344. return ret;
  5345. });
  5346.  
  5347. var promise = resultPromise.lastly(function() {
  5348. var inspection = new Promise.PromiseInspection(resultPromise);
  5349. return dispose(resources, inspection);
  5350. });
  5351. resources.promise = promise;
  5352. promise._setOnCancel(resources);
  5353. return promise;
  5354. };
  5355.  
  5356. Promise.prototype._setDisposable = function (disposer) {
  5357. this._bitField = this._bitField | 131072;
  5358. this._disposer = disposer;
  5359. };
  5360.  
  5361. Promise.prototype._isDisposable = function () {
  5362. return (this._bitField & 131072) > 0;
  5363. };
  5364.  
  5365. Promise.prototype._getDisposer = function () {
  5366. return this._disposer;
  5367. };
  5368.  
  5369. Promise.prototype._unsetDisposable = function () {
  5370. this._bitField = this._bitField & (~131072);
  5371. this._disposer = undefined;
  5372. };
  5373.  
  5374. Promise.prototype.disposer = function (fn) {
  5375. if (typeof fn === "function") {
  5376. return new FunctionDisposer(fn, this, createContext());
  5377. }
  5378. throw new TypeError();
  5379. };
  5380.  
  5381. };
  5382.  
  5383. },{"./errors":12,"./util":36}],36:[function(_dereq_,module,exports){
  5384. "use strict";
  5385. var es5 = _dereq_("./es5");
  5386. var canEvaluate = typeof navigator == "undefined";
  5387.  
  5388. var errorObj = {e: {}};
  5389. var tryCatchTarget;
  5390. var globalObject = typeof self !== "undefined" ? self :
  5391. typeof window !== "undefined" ? window :
  5392. typeof global !== "undefined" ? global :
  5393. this !== undefined ? this : null;
  5394.  
  5395. function tryCatcher() {
  5396. try {
  5397. var target = tryCatchTarget;
  5398. tryCatchTarget = null;
  5399. return target.apply(this, arguments);
  5400. } catch (e) {
  5401. errorObj.e = e;
  5402. return errorObj;
  5403. }
  5404. }
  5405. function tryCatch(fn) {
  5406. tryCatchTarget = fn;
  5407. return tryCatcher;
  5408. }
  5409.  
  5410. var inherits = function(Child, Parent) {
  5411. var hasProp = {}.hasOwnProperty;
  5412.  
  5413. function T() {
  5414. this.constructor = Child;
  5415. this.constructor$ = Parent;
  5416. for (var propertyName in Parent.prototype) {
  5417. if (hasProp.call(Parent.prototype, propertyName) &&
  5418. propertyName.charAt(propertyName.length-1) !== "$"
  5419. ) {
  5420. this[propertyName + "$"] = Parent.prototype[propertyName];
  5421. }
  5422. }
  5423. }
  5424. T.prototype = Parent.prototype;
  5425. Child.prototype = new T();
  5426. return Child.prototype;
  5427. };
  5428.  
  5429.  
  5430. function isPrimitive(val) {
  5431. return val == null || val === true || val === false ||
  5432. typeof val === "string" || typeof val === "number";
  5433.  
  5434. }
  5435.  
  5436. function isObject(value) {
  5437. return typeof value === "function" ||
  5438. typeof value === "object" && value !== null;
  5439. }
  5440.  
  5441. function maybeWrapAsError(maybeError) {
  5442. if (!isPrimitive(maybeError)) return maybeError;
  5443.  
  5444. return new Error(safeToString(maybeError));
  5445. }
  5446.  
  5447. function withAppended(target, appendee) {
  5448. var len = target.length;
  5449. var ret = new Array(len + 1);
  5450. var i;
  5451. for (i = 0; i < len; ++i) {
  5452. ret[i] = target[i];
  5453. }
  5454. ret[i] = appendee;
  5455. return ret;
  5456. }
  5457.  
  5458. function getDataPropertyOrDefault(obj, key, defaultValue) {
  5459. if (es5.isES5) {
  5460. var desc = Object.getOwnPropertyDescriptor(obj, key);
  5461.  
  5462. if (desc != null) {
  5463. return desc.get == null && desc.set == null
  5464. ? desc.value
  5465. : defaultValue;
  5466. }
  5467. } else {
  5468. return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined;
  5469. }
  5470. }
  5471.  
  5472. function notEnumerableProp(obj, name, value) {
  5473. if (isPrimitive(obj)) return obj;
  5474. var descriptor = {
  5475. value: value,
  5476. configurable: true,
  5477. enumerable: false,
  5478. writable: true
  5479. };
  5480. es5.defineProperty(obj, name, descriptor);
  5481. return obj;
  5482. }
  5483.  
  5484. function thrower(r) {
  5485. throw r;
  5486. }
  5487.  
  5488. var inheritedDataKeys = (function() {
  5489. var excludedPrototypes = [
  5490. Array.prototype,
  5491. Object.prototype,
  5492. Function.prototype
  5493. ];
  5494.  
  5495. var isExcludedProto = function(val) {
  5496. for (var i = 0; i < excludedPrototypes.length; ++i) {
  5497. if (excludedPrototypes[i] === val) {
  5498. return true;
  5499. }
  5500. }
  5501. return false;
  5502. };
  5503.  
  5504. if (es5.isES5) {
  5505. var getKeys = Object.getOwnPropertyNames;
  5506. return function(obj) {
  5507. var ret = [];
  5508. var visitedKeys = Object.create(null);
  5509. while (obj != null && !isExcludedProto(obj)) {
  5510. var keys;
  5511. try {
  5512. keys = getKeys(obj);
  5513. } catch (e) {
  5514. return ret;
  5515. }
  5516. for (var i = 0; i < keys.length; ++i) {
  5517. var key = keys[i];
  5518. if (visitedKeys[key]) continue;
  5519. visitedKeys[key] = true;
  5520. var desc = Object.getOwnPropertyDescriptor(obj, key);
  5521. if (desc != null && desc.get == null && desc.set == null) {
  5522. ret.push(key);
  5523. }
  5524. }
  5525. obj = es5.getPrototypeOf(obj);
  5526. }
  5527. return ret;
  5528. };
  5529. } else {
  5530. var hasProp = {}.hasOwnProperty;
  5531. return function(obj) {
  5532. if (isExcludedProto(obj)) return [];
  5533. var ret = [];
  5534.  
  5535. /*jshint forin:false */
  5536. enumeration: for (var key in obj) {
  5537. if (hasProp.call(obj, key)) {
  5538. ret.push(key);
  5539. } else {
  5540. for (var i = 0; i < excludedPrototypes.length; ++i) {
  5541. if (hasProp.call(excludedPrototypes[i], key)) {
  5542. continue enumeration;
  5543. }
  5544. }
  5545. ret.push(key);
  5546. }
  5547. }
  5548. return ret;
  5549. };
  5550. }
  5551.  
  5552. })();
  5553.  
  5554. var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/;
  5555. function isClass(fn) {
  5556. try {
  5557. if (typeof fn === "function") {
  5558. var keys = es5.names(fn.prototype);
  5559.  
  5560. var hasMethods = es5.isES5 && keys.length > 1;
  5561. var hasMethodsOtherThanConstructor = keys.length > 0 &&
  5562. !(keys.length === 1 && keys[0] === "constructor");
  5563. var hasThisAssignmentAndStaticMethods =
  5564. thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0;
  5565.  
  5566. if (hasMethods || hasMethodsOtherThanConstructor ||
  5567. hasThisAssignmentAndStaticMethods) {
  5568. return true;
  5569. }
  5570. }
  5571. return false;
  5572. } catch (e) {
  5573. return false;
  5574. }
  5575. }
  5576.  
  5577. function toFastProperties(obj) {
  5578. /*jshint -W027,-W055,-W031*/
  5579. function FakeConstructor() {}
  5580. FakeConstructor.prototype = obj;
  5581. var l = 8;
  5582. while (l--) new FakeConstructor();
  5583. return obj;
  5584. eval(obj);
  5585. }
  5586.  
  5587. var rident = /^[a-z$_][a-z$_0-9]*$/i;
  5588. function isIdentifier(str) {
  5589. return rident.test(str);
  5590. }
  5591.  
  5592. function filledRange(count, prefix, suffix) {
  5593. var ret = new Array(count);
  5594. for(var i = 0; i < count; ++i) {
  5595. ret[i] = prefix + i + suffix;
  5596. }
  5597. return ret;
  5598. }
  5599.  
  5600. function safeToString(obj) {
  5601. try {
  5602. return obj + "";
  5603. } catch (e) {
  5604. return "[no string representation]";
  5605. }
  5606. }
  5607.  
  5608. function isError(obj) {
  5609. return obj !== null &&
  5610. typeof obj === "object" &&
  5611. typeof obj.message === "string" &&
  5612. typeof obj.name === "string";
  5613. }
  5614.  
  5615. function markAsOriginatingFromRejection(e) {
  5616. try {
  5617. notEnumerableProp(e, "isOperational", true);
  5618. }
  5619. catch(ignore) {}
  5620. }
  5621.  
  5622. function originatesFromRejection(e) {
  5623. if (e == null) return false;
  5624. return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) ||
  5625. e["isOperational"] === true);
  5626. }
  5627.  
  5628. function canAttachTrace(obj) {
  5629. return isError(obj) && es5.propertyIsWritable(obj, "stack");
  5630. }
  5631.  
  5632. var ensureErrorObject = (function() {
  5633. if (!("stack" in new Error())) {
  5634. return function(value) {
  5635. if (canAttachTrace(value)) return value;
  5636. try {throw new Error(safeToString(value));}
  5637. catch(err) {return err;}
  5638. };
  5639. } else {
  5640. return function(value) {
  5641. if (canAttachTrace(value)) return value;
  5642. return new Error(safeToString(value));
  5643. };
  5644. }
  5645. })();
  5646.  
  5647. function classString(obj) {
  5648. return {}.toString.call(obj);
  5649. }
  5650.  
  5651. function copyDescriptors(from, to, filter) {
  5652. var keys = es5.names(from);
  5653. for (var i = 0; i < keys.length; ++i) {
  5654. var key = keys[i];
  5655. if (filter(key)) {
  5656. try {
  5657. es5.defineProperty(to, key, es5.getDescriptor(from, key));
  5658. } catch (ignore) {}
  5659. }
  5660. }
  5661. }
  5662.  
  5663. var asArray = function(v) {
  5664. if (es5.isArray(v)) {
  5665. return v;
  5666. }
  5667. return null;
  5668. };
  5669.  
  5670. if (typeof Symbol !== "undefined" && Symbol.iterator) {
  5671. var ArrayFrom = typeof Array.from === "function" ? function(v) {
  5672. return Array.from(v);
  5673. } : function(v) {
  5674. var ret = [];
  5675. var it = v[Symbol.iterator]();
  5676. var itResult;
  5677. while (!((itResult = it.next()).done)) {
  5678. ret.push(itResult.value);
  5679. }
  5680. return ret;
  5681. };
  5682.  
  5683. asArray = function(v) {
  5684. if (es5.isArray(v)) {
  5685. return v;
  5686. } else if (v != null && typeof v[Symbol.iterator] === "function") {
  5687. return ArrayFrom(v);
  5688. }
  5689. return null;
  5690. };
  5691. }
  5692.  
  5693. var isNode = typeof process !== "undefined" &&
  5694. classString(process).toLowerCase() === "[object process]";
  5695.  
  5696. var hasEnvVariables = typeof process !== "undefined" &&
  5697. typeof process.env !== "undefined";
  5698.  
  5699. function env(key) {
  5700. return hasEnvVariables ? process.env[key] : undefined;
  5701. }
  5702.  
  5703. function getNativePromise() {
  5704. if (typeof Promise === "function") {
  5705. try {
  5706. var promise = new Promise(function(){});
  5707. if ({}.toString.call(promise) === "[object Promise]") {
  5708. return Promise;
  5709. }
  5710. } catch (e) {}
  5711. }
  5712. }
  5713.  
  5714. function domainBind(self, cb) {
  5715. return self.bind(cb);
  5716. }
  5717.  
  5718. var ret = {
  5719. isClass: isClass,
  5720. isIdentifier: isIdentifier,
  5721. inheritedDataKeys: inheritedDataKeys,
  5722. getDataPropertyOrDefault: getDataPropertyOrDefault,
  5723. thrower: thrower,
  5724. isArray: es5.isArray,
  5725. asArray: asArray,
  5726. notEnumerableProp: notEnumerableProp,
  5727. isPrimitive: isPrimitive,
  5728. isObject: isObject,
  5729. isError: isError,
  5730. canEvaluate: canEvaluate,
  5731. errorObj: errorObj,
  5732. tryCatch: tryCatch,
  5733. inherits: inherits,
  5734. withAppended: withAppended,
  5735. maybeWrapAsError: maybeWrapAsError,
  5736. toFastProperties: toFastProperties,
  5737. filledRange: filledRange,
  5738. toString: safeToString,
  5739. canAttachTrace: canAttachTrace,
  5740. ensureErrorObject: ensureErrorObject,
  5741. originatesFromRejection: originatesFromRejection,
  5742. markAsOriginatingFromRejection: markAsOriginatingFromRejection,
  5743. classString: classString,
  5744. copyDescriptors: copyDescriptors,
  5745. hasDevTools: typeof chrome !== "undefined" && chrome &&
  5746. typeof chrome.loadTimes === "function",
  5747. isNode: isNode,
  5748. hasEnvVariables: hasEnvVariables,
  5749. env: env,
  5750. global: globalObject,
  5751. getNativePromise: getNativePromise,
  5752. domainBind: domainBind
  5753. };
  5754. ret.isRecentNode = ret.isNode && (function() {
  5755. var version = process.versions.node.split(".").map(Number);
  5756. return (version[0] === 0 && version[1] > 10) || (version[0] > 0);
  5757. })();
  5758.  
  5759. if (ret.isNode) ret.toFastProperties(process);
  5760.  
  5761. try {throw new Error(); } catch (e) {ret.lastLineError = e;}
  5762. module.exports = ret;
  5763.  
  5764. },{"./es5":13}]},{},[4])(4)
  5765. }); ;if (typeof window !== 'undefined' && window !== null) { window.P = window.Promise; } else if (typeof self !== 'undefined' && self !== null) { self.P = self.Promise; }
  5766. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(31), __webpack_require__(8), __webpack_require__(112).setImmediate))
  5767.  
  5768. /***/ }),
  5769. /* 4 */
  5770. /***/ (function(module, exports, __webpack_require__) {
  5771.  
  5772. var isObject = __webpack_require__(19);
  5773. module.exports = function(it){
  5774. if(!isObject(it))throw TypeError(it + ' is not an object!');
  5775. return it;
  5776. };
  5777.  
  5778. /***/ }),
  5779. /* 5 */
  5780. /***/ (function(module, exports, __webpack_require__) {
  5781.  
  5782. // Thank's IE8 for his funny defineProperty
  5783. module.exports = !__webpack_require__(36)(function(){
  5784. return Object.defineProperty({}, 'a', {get: function(){ return 7; }}).a != 7;
  5785. });
  5786.  
  5787. /***/ }),
  5788. /* 6 */
  5789. /***/ (function(module, exports, __webpack_require__) {
  5790.  
  5791. var dP = __webpack_require__(7)
  5792. , createDesc = __webpack_require__(24);
  5793. module.exports = __webpack_require__(5) ? function(object, key, value){
  5794. return dP.f(object, key, createDesc(1, value));
  5795. } : function(object, key, value){
  5796. object[key] = value;
  5797. return object;
  5798. };
  5799.  
  5800. /***/ }),
  5801. /* 7 */
  5802. /***/ (function(module, exports, __webpack_require__) {
  5803.  
  5804. var anObject = __webpack_require__(4)
  5805. , IE8_DOM_DEFINE = __webpack_require__(72)
  5806. , toPrimitive = __webpack_require__(89)
  5807. , dP = Object.defineProperty;
  5808.  
  5809. exports.f = __webpack_require__(5) ? Object.defineProperty : function defineProperty(O, P, Attributes){
  5810. anObject(O);
  5811. P = toPrimitive(P, true);
  5812. anObject(Attributes);
  5813. if(IE8_DOM_DEFINE)try {
  5814. return dP(O, P, Attributes);
  5815. } catch(e){ /* empty */ }
  5816. if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!');
  5817. if('value' in Attributes)O[P] = Attributes.value;
  5818. return O;
  5819. };
  5820.  
  5821. /***/ }),
  5822. /* 8 */
  5823. /***/ (function(module, exports) {
  5824.  
  5825. var g;
  5826.  
  5827. // This works in non-strict mode
  5828. g = (function() {
  5829. return this;
  5830. })();
  5831.  
  5832. try {
  5833. // This works if eval is allowed (see CSP)
  5834. g = g || Function("return this")() || (1,eval)("this");
  5835. } catch(e) {
  5836. // This works if the window reference is available
  5837. if(typeof window === "object")
  5838. g = window;
  5839. }
  5840.  
  5841. // g can still be undefined, but nothing to do about it...
  5842. // We return undefined, instead of nothing here, so it's
  5843. // easier to handle this case. if(!global) { ...}
  5844.  
  5845. module.exports = g;
  5846.  
  5847.  
  5848. /***/ }),
  5849. /* 9 */
  5850. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5851.  
  5852. "use strict";
  5853. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_bluebird__ = __webpack_require__(3);
  5854. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_bluebird___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_bluebird__);
  5855. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_debounce__ = __webpack_require__(99);
  5856. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_debounce___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_debounce__);
  5857. /* harmony export (immutable) */ __webpack_exports__["c"] = jsonify;
  5858. /* harmony export (immutable) */ __webpack_exports__["b"] = numFormat;
  5859. /* unused harmony export sleep */
  5860. /* harmony export (immutable) */ __webpack_exports__["d"] = debounce;
  5861. /* unused harmony export print */
  5862. /* harmony export (immutable) */ __webpack_exports__["a"] = printError;
  5863. /* harmony export (immutable) */ __webpack_exports__["e"] = diffDays;
  5864.  
  5865.  
  5866.  
  5867.  
  5868.  
  5869. function jsonify(func) {
  5870. return function () {
  5871. return func.apply(this, arguments).then(function (data) {
  5872. var text = data.responseText;
  5873. try {
  5874. var json = JSON.parse(text);
  5875. return __WEBPACK_IMPORTED_MODULE_0_bluebird___default.a.resolve(json);
  5876. } catch (err) {
  5877. return __WEBPACK_IMPORTED_MODULE_0_bluebird___default.a.reject(err);
  5878. }
  5879. }).catch(function (err) {
  5880. return __WEBPACK_IMPORTED_MODULE_0_bluebird___default.a.reject(err);
  5881. });
  5882. };
  5883. }
  5884.  
  5885. function numFormat(num) {
  5886. return num.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,').replace(/\.\d+/, '');
  5887. }
  5888.  
  5889. function sleep(ms) {
  5890. return new __WEBPACK_IMPORTED_MODULE_0_bluebird___default.a(function (resolve, reject) {
  5891. setTimeout(function () {
  5892. resolve();
  5893. }, ms);
  5894. });
  5895. }
  5896.  
  5897. function debounce() {
  5898. return __WEBPACK_IMPORTED_MODULE_1_debounce___default.a.apply(this, arguments);
  5899. }
  5900.  
  5901. function print(msg) {
  5902. console.log(msg);
  5903. }
  5904.  
  5905. function printError(err) {
  5906. console.error(err);
  5907. }
  5908.  
  5909. function diffDays(from, to) {
  5910. var fromDate = new Date(from);
  5911. var toDate = new Date(to);
  5912. return Math.ceil(Math.abs(fromDate - toDate) / 1000 / 3600 / 24);
  5913. }
  5914.  
  5915. /***/ }),
  5916. /* 10 */
  5917. /***/ (function(module, exports, __webpack_require__) {
  5918.  
  5919. "use strict";
  5920.  
  5921.  
  5922. exports.__esModule = true;
  5923.  
  5924. var _promise = __webpack_require__(57);
  5925.  
  5926. var _promise2 = _interopRequireDefault(_promise);
  5927.  
  5928. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  5929.  
  5930. exports.default = function (fn) {
  5931. return function () {
  5932. var gen = fn.apply(this, arguments);
  5933. return new _promise2.default(function (resolve, reject) {
  5934. function step(key, arg) {
  5935. try {
  5936. var info = gen[key](arg);
  5937. var value = info.value;
  5938. } catch (error) {
  5939. reject(error);
  5940. return;
  5941. }
  5942.  
  5943. if (info.done) {
  5944. resolve(value);
  5945. } else {
  5946. return _promise2.default.resolve(value).then(function (value) {
  5947. step("next", value);
  5948. }, function (err) {
  5949. step("throw", err);
  5950. });
  5951. }
  5952. }
  5953.  
  5954. return step("next");
  5955. });
  5956. };
  5957. };
  5958.  
  5959. /***/ }),
  5960. /* 11 */
  5961. /***/ (function(module, exports, __webpack_require__) {
  5962.  
  5963. module.exports = __webpack_require__(106);
  5964.  
  5965.  
  5966. /***/ }),
  5967. /* 12 */
  5968. /***/ (function(module, exports, __webpack_require__) {
  5969.  
  5970. // optional / simple context binding
  5971. var aFunction = __webpack_require__(21);
  5972. module.exports = function(fn, that, length){
  5973. aFunction(fn);
  5974. if(that === undefined)return fn;
  5975. switch(length){
  5976. case 1: return function(a){
  5977. return fn.call(that, a);
  5978. };
  5979. case 2: return function(a, b){
  5980. return fn.call(that, a, b);
  5981. };
  5982. case 3: return function(a, b, c){
  5983. return fn.call(that, a, b, c);
  5984. };
  5985. }
  5986. return function(/* ...args */){
  5987. return fn.apply(that, arguments);
  5988. };
  5989. };
  5990.  
  5991. /***/ }),
  5992. /* 13 */
  5993. /***/ (function(module, exports) {
  5994.  
  5995. module.exports = {};
  5996.  
  5997. /***/ }),
  5998. /* 14 */
  5999. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6000.  
  6001. "use strict";
  6002.  
  6003.  
  6004. /* harmony default export */ __webpack_exports__["a"] = {
  6005. dev: "production" === "development",
  6006. prod: "production" === "production"
  6007. };
  6008.  
  6009. /***/ }),
  6010. /* 15 */
  6011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6012.  
  6013. "use strict";
  6014. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_bluebird__ = __webpack_require__(3);
  6015. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_bluebird___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_bluebird__);
  6016. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__http__ = __webpack_require__(32);
  6017. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils__ = __webpack_require__(9);
  6018. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__svg__ = __webpack_require__(54);
  6019.  
  6020.  
  6021.  
  6022.  
  6023.  
  6024.  
  6025.  
  6026. var GITHUB_API = 'https://api.github.com';
  6027. var CLIENT_ID = 'b8257841dd7ca5eef2aa';
  6028. var CLIENT_SECRET = '4da33dd6fcb0a01d395945ad18613ecf9c12079e';
  6029.  
  6030. function fetchRepoInfo(githubRepoPath) {
  6031. return __WEBPACK_IMPORTED_MODULE_1__http__["a" /* http */].get(GITHUB_API + '/repos/' + githubRepoPath.trim().replace(/^\/+/g, '') + '?client_id=' + CLIENT_ID + '&client_secret=' + CLIENT_SECRET);
  6032. }
  6033.  
  6034. function fetchUserInfo(username) {
  6035. return __WEBPACK_IMPORTED_MODULE_1__http__["a" /* http */].get(GITHUB_API + '/users/' + username + '?client_id=' + CLIENT_ID + '&client_secret=' + CLIENT_SECRET);
  6036. }
  6037.  
  6038. function fetchRepoBranchInfo(githubRepoPath, branch) {
  6039. return __WEBPACK_IMPORTED_MODULE_1__http__["a" /* http */].get(GITHUB_API + '/repos/' + githubRepoPath.trim().replace(/^\/+/g, '') + '/branches/' + branch + '?client_id=' + CLIENT_ID + '&client_secret=' + CLIENT_SECRET);
  6040. }
  6041.  
  6042. function createWidget(containerTagName) {
  6043. var container = document.createElement(containerTagName);
  6044. var span = document.createElement('span');
  6045. container.style.verticalAlign = 'text-bottom';
  6046. container.classList.add('github-info');
  6047. span.style.display = 'inline-block';
  6048. return function (_ref) {
  6049. var watch = _ref.watch,
  6050. star = _ref.star,
  6051. fork = _ref.fork;
  6052.  
  6053.  
  6054. var watchEle = span.cloneNode(false);
  6055. var starEle = span.cloneNode(false);
  6056. var forkEle = span.cloneNode(false);
  6057.  
  6058. watchEle.appendChild(__WEBPACK_IMPORTED_MODULE_3__svg__["a" /* default */].watch);
  6059. starEle.appendChild(__WEBPACK_IMPORTED_MODULE_3__svg__["a" /* default */].star);
  6060. forkEle.appendChild(__WEBPACK_IMPORTED_MODULE_3__svg__["a" /* default */].fork);
  6061.  
  6062. watchEle.innerHTML += '&nbsp;' + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__utils__["b" /* numFormat */])(watch) + '&nbsp;';
  6063. starEle.innerHTML += '&nbsp;' + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__utils__["b" /* numFormat */])(star) + '&nbsp;';
  6064. forkEle.innerHTML += '&nbsp;' + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__utils__["b" /* numFormat */])(fork);
  6065.  
  6066. container.appendChild(watchEle);
  6067. container.appendChild(starEle);
  6068. container.appendChild(forkEle);
  6069.  
  6070. return { container: container, watch: watchEle, star: starEle, fork: forkEle };
  6071. };
  6072. }
  6073.  
  6074. /* harmony default export */ __webpack_exports__["a"] = {
  6075. fetchUserInfo: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__utils__["c" /* jsonify */])(fetchUserInfo),
  6076. fetchRepoInfo: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__utils__["c" /* jsonify */])(fetchRepoInfo),
  6077. fetchRepoBranchInfo: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_2__utils__["c" /* jsonify */])(fetchRepoBranchInfo),
  6078. createWidget: createWidget
  6079. };
  6080.  
  6081. /***/ }),
  6082. /* 16 */
  6083. /***/ (function(module, exports) {
  6084.  
  6085. var toString = {}.toString;
  6086.  
  6087. module.exports = function(it){
  6088. return toString.call(it).slice(8, -1);
  6089. };
  6090.  
  6091. /***/ }),
  6092. /* 17 */
  6093. /***/ (function(module, exports, __webpack_require__) {
  6094.  
  6095. var global = __webpack_require__(1)
  6096. , core = __webpack_require__(2)
  6097. , ctx = __webpack_require__(12)
  6098. , hide = __webpack_require__(6)
  6099. , PROTOTYPE = 'prototype';
  6100.  
  6101. var $export = function(type, name, source){
  6102. var IS_FORCED = type & $export.F
  6103. , IS_GLOBAL = type & $export.G
  6104. , IS_STATIC = type & $export.S
  6105. , IS_PROTO = type & $export.P
  6106. , IS_BIND = type & $export.B
  6107. , IS_WRAP = type & $export.W
  6108. , exports = IS_GLOBAL ? core : core[name] || (core[name] = {})
  6109. , expProto = exports[PROTOTYPE]
  6110. , target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]
  6111. , key, own, out;
  6112. if(IS_GLOBAL)source = name;
  6113. for(key in source){
  6114. // contains in native
  6115. own = !IS_FORCED && target && target[key] !== undefined;
  6116. if(own && key in exports)continue;
  6117. // export native or passed
  6118. out = own ? target[key] : source[key];
  6119. // prevent global pollution for namespaces
  6120. exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key]
  6121. // bind timers to global for call from export context
  6122. : IS_BIND && own ? ctx(out, global)
  6123. // wrap global constructors for prevent change them in library
  6124. : IS_WRAP && target[key] == out ? (function(C){
  6125. var F = function(a, b, c){
  6126. if(this instanceof C){
  6127. switch(arguments.length){
  6128. case 0: return new C;
  6129. case 1: return new C(a);
  6130. case 2: return new C(a, b);
  6131. } return new C(a, b, c);
  6132. } return C.apply(this, arguments);
  6133. };
  6134. F[PROTOTYPE] = C[PROTOTYPE];
  6135. return F;
  6136. // make static versions for prototype methods
  6137. })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out;
  6138. // export proto methods to core.%CONSTRUCTOR%.methods.%NAME%
  6139. if(IS_PROTO){
  6140. (exports.virtual || (exports.virtual = {}))[key] = out;
  6141. // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME%
  6142. if(type & $export.R && expProto && !expProto[key])hide(expProto, key, out);
  6143. }
  6144. }
  6145. };
  6146. // type bitmap
  6147. $export.F = 1; // forced
  6148. $export.G = 2; // global
  6149. $export.S = 4; // static
  6150. $export.P = 8; // proto
  6151. $export.B = 16; // bind
  6152. $export.W = 32; // wrap
  6153. $export.U = 64; // safe
  6154. $export.R = 128; // real proto method for `library`
  6155. module.exports = $export;
  6156.  
  6157. /***/ }),
  6158. /* 18 */
  6159. /***/ (function(module, exports) {
  6160.  
  6161. var hasOwnProperty = {}.hasOwnProperty;
  6162. module.exports = function(it, key){
  6163. return hasOwnProperty.call(it, key);
  6164. };
  6165.  
  6166. /***/ }),
  6167. /* 19 */
  6168. /***/ (function(module, exports) {
  6169.  
  6170. module.exports = function(it){
  6171. return typeof it === 'object' ? it !== null : typeof it === 'function';
  6172. };
  6173.  
  6174. /***/ }),
  6175. /* 20 */
  6176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6177.  
  6178. "use strict";
  6179. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__http__ = __webpack_require__(32);
  6180. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils__ = __webpack_require__(9);
  6181.  
  6182.  
  6183.  
  6184.  
  6185.  
  6186. var registry = 'https://registry.npm.taobao.org';
  6187.  
  6188. function fetchPackageInfo(name) {
  6189. return __WEBPACK_IMPORTED_MODULE_0__http__["a" /* http */].get(registry + '/' + name.trim() + '/latest');
  6190. }
  6191.  
  6192. /* harmony default export */ __webpack_exports__["a"] = {
  6193. fetchPackageInfo: __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__utils__["c" /* jsonify */])(fetchPackageInfo)
  6194. };
  6195.  
  6196. /***/ }),
  6197. /* 21 */
  6198. /***/ (function(module, exports) {
  6199.  
  6200. module.exports = function(it){
  6201. if(typeof it != 'function')throw TypeError(it + ' is not a function!');
  6202. return it;
  6203. };
  6204.  
  6205. /***/ }),
  6206. /* 22 */
  6207. /***/ (function(module, exports) {
  6208.  
  6209. // 7.2.1 RequireObjectCoercible(argument)
  6210. module.exports = function(it){
  6211. if(it == undefined)throw TypeError("Can't call method on " + it);
  6212. return it;
  6213. };
  6214.  
  6215. /***/ }),
  6216. /* 23 */
  6217. /***/ (function(module, exports, __webpack_require__) {
  6218.  
  6219. var isObject = __webpack_require__(19)
  6220. , document = __webpack_require__(1).document
  6221. // in old IE typeof document.createElement is 'object'
  6222. , is = isObject(document) && isObject(document.createElement);
  6223. module.exports = function(it){
  6224. return is ? document.createElement(it) : {};
  6225. };
  6226.  
  6227. /***/ }),
  6228. /* 24 */
  6229. /***/ (function(module, exports) {
  6230.  
  6231. module.exports = function(bitmap, value){
  6232. return {
  6233. enumerable : !(bitmap & 1),
  6234. configurable: !(bitmap & 2),
  6235. writable : !(bitmap & 4),
  6236. value : value
  6237. };
  6238. };
  6239.  
  6240. /***/ }),
  6241. /* 25 */
  6242. /***/ (function(module, exports, __webpack_require__) {
  6243.  
  6244. var def = __webpack_require__(7).f
  6245. , has = __webpack_require__(18)
  6246. , TAG = __webpack_require__(0)('toStringTag');
  6247.  
  6248. module.exports = function(it, tag, stat){
  6249. if(it && !has(it = stat ? it : it.prototype, TAG))def(it, TAG, {configurable: true, value: tag});
  6250. };
  6251.  
  6252. /***/ }),
  6253. /* 26 */
  6254. /***/ (function(module, exports, __webpack_require__) {
  6255.  
  6256. var shared = __webpack_require__(43)('keys')
  6257. , uid = __webpack_require__(46);
  6258. module.exports = function(key){
  6259. return shared[key] || (shared[key] = uid(key));
  6260. };
  6261.  
  6262. /***/ }),
  6263. /* 27 */
  6264. /***/ (function(module, exports) {
  6265.  
  6266. // 7.1.4 ToInteger
  6267. var ceil = Math.ceil
  6268. , floor = Math.floor;
  6269. module.exports = function(it){
  6270. return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
  6271. };
  6272.  
  6273. /***/ }),
  6274. /* 28 */
  6275. /***/ (function(module, exports, __webpack_require__) {
  6276.  
  6277. // to indexed object, toObject with fallback for non-array-like ES3 strings
  6278. var IObject = __webpack_require__(74)
  6279. , defined = __webpack_require__(22);
  6280. module.exports = function(it){
  6281. return IObject(defined(it));
  6282. };
  6283.  
  6284. /***/ }),
  6285. /* 29 */
  6286. /***/ (function(module, exports, __webpack_require__) {
  6287.  
  6288. // 7.1.15 ToLength
  6289. var toInteger = __webpack_require__(27)
  6290. , min = Math.min;
  6291. module.exports = function(it){
  6292. return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991
  6293. };
  6294.  
  6295. /***/ }),
  6296. /* 30 */
  6297. /***/ (function(module, exports, __webpack_require__) {
  6298.  
  6299. "use strict";
  6300. /*!
  6301. * parse-github-url <https://github.com/jonschlinkert/parse-github-url>
  6302. *
  6303. * Copyright (c) 2015, Jon Schlinkert.
  6304. * Licensed under the MIT License.
  6305. */
  6306.  
  6307.  
  6308.  
  6309. var url = __webpack_require__(114);
  6310. var cache = {};
  6311.  
  6312. module.exports = function parseGithubUrl(str) {
  6313. return cache[str] || (cache[str] = parse(str));
  6314. };
  6315.  
  6316. function parse(str) {
  6317. if (typeof str !== 'string' || !str.length) {
  6318. return null;
  6319. }
  6320.  
  6321. if (str.indexOf('git@gist') !== -1 || str.indexOf('//gist') !== -1) {
  6322. return null;
  6323. }
  6324.  
  6325. // parse the URL
  6326. var obj = url.parse(str);
  6327. if (typeof obj.path !== 'string' || !obj.path.length || typeof obj.pathname !== 'string' || !obj.pathname.length) {
  6328. return null;
  6329. }
  6330.  
  6331. obj.path = trimSlash(obj.path);
  6332. obj.pathname = trimSlash(obj.pathname);
  6333. obj.filepath = null;
  6334.  
  6335. if (obj.path.indexOf('repos') === 0) {
  6336. obj.path = obj.path.slice(6);
  6337. }
  6338.  
  6339. var seg = obj.path.split('/').filter(Boolean);
  6340. var hasBlob = seg[2] === 'blob';
  6341. if (hasBlob && !isChecksum(seg[3])) {
  6342. obj.branch = seg[3];
  6343. if (seg.length > 4) {
  6344. obj.filepath = seg.slice(4).join('/');
  6345. }
  6346. }
  6347.  
  6348. var blob = str.indexOf('blob');
  6349. if (blob !== -1) {
  6350. obj.blob = str.slice(blob + 5);
  6351. }
  6352.  
  6353. var tree = str.indexOf('tree');
  6354. if (tree !== -1) {
  6355. var idx = tree + 5;
  6356. var branch = str.slice(idx);
  6357. var slash = branch.indexOf('/');
  6358. if (slash !== -1) {
  6359. branch = branch.slice(0, slash);
  6360. }
  6361. obj.branch = branch;
  6362. }
  6363.  
  6364. obj.owner = owner(seg[0]);
  6365. obj.name = name(seg[1]);
  6366.  
  6367. if (seg.length > 1 && obj.owner && obj.name) {
  6368. obj.repo = obj.owner + '/' + obj.name;
  6369. } else {
  6370. var href = obj.href.split(':');
  6371. if (href.length === 2 && obj.href.indexOf('//') === -1) {
  6372. obj.repo = obj.repo || href[href.length - 1];
  6373. var repoSegments = obj.repo.split('/');
  6374. obj.owner = repoSegments[0];
  6375. obj.name = repoSegments[1];
  6376.  
  6377. } else {
  6378. var match = obj.href.match(/\/([^\/]*)$/);
  6379. obj.owner = match ? match[1] : null;
  6380. obj.repo = null;
  6381. }
  6382.  
  6383. if (obj.repo && (!obj.owner || !obj.name)) {
  6384. var segs = obj.repo.split('/');
  6385. if (segs.length === 2) {
  6386. obj.owner = segs[0];
  6387. obj.name = segs[1];
  6388. }
  6389. }
  6390. }
  6391.  
  6392. if (!obj.branch) {
  6393. obj.branch = seg[2] || getBranch(obj.path, obj);
  6394. if (seg.length > 3) {
  6395. obj.filepath = seg.slice(3).join('/');
  6396. }
  6397. }
  6398.  
  6399. obj.host = obj.host || 'github.com';
  6400. obj.owner = obj.owner || null;
  6401. obj.name = obj.name || null;
  6402. obj.repository = obj.repo;
  6403. return obj;
  6404. }
  6405.  
  6406. function isChecksum(str) {
  6407. return /^[a-f0-9]{40}$/i.test(str);
  6408. }
  6409.  
  6410. function getBranch(str, obj) {
  6411. var segs = str.split('#');
  6412. var branch;
  6413. if (segs.length > 1) {
  6414. branch = segs[segs.length - 1];
  6415. }
  6416. if (!branch && obj.hash && obj.hash.charAt(0) === '#') {
  6417. branch = obj.hash.slice(1);
  6418. }
  6419. return branch || 'master';
  6420. }
  6421.  
  6422. function trimSlash(path) {
  6423. return path.charAt(0) === '/' ? path.slice(1) : path;
  6424. }
  6425.  
  6426. function name(str) {
  6427. return str ? str.replace(/^\W+|\.git$/g, '') : null;
  6428. }
  6429.  
  6430. function owner(str) {
  6431. if (!str) return null;
  6432. var idx = str.indexOf(':');
  6433. if (idx > -1) {
  6434. return str.slice(idx + 1);
  6435. }
  6436. return str;
  6437. }
  6438.  
  6439.  
  6440. /***/ }),
  6441. /* 31 */
  6442. /***/ (function(module, exports) {
  6443.  
  6444. // shim for using process in browser
  6445. var process = module.exports = {};
  6446.  
  6447. // cached from whatever global is present so that test runners that stub it
  6448. // don't break things. But we need to wrap it in a try catch in case it is
  6449. // wrapped in strict mode code which doesn't define any globals. It's inside a
  6450. // function because try/catches deoptimize in certain engines.
  6451.  
  6452. var cachedSetTimeout;
  6453. var cachedClearTimeout;
  6454.  
  6455. function defaultSetTimout() {
  6456. throw new Error('setTimeout has not been defined');
  6457. }
  6458. function defaultClearTimeout () {
  6459. throw new Error('clearTimeout has not been defined');
  6460. }
  6461. (function () {
  6462. try {
  6463. if (typeof setTimeout === 'function') {
  6464. cachedSetTimeout = setTimeout;
  6465. } else {
  6466. cachedSetTimeout = defaultSetTimout;
  6467. }
  6468. } catch (e) {
  6469. cachedSetTimeout = defaultSetTimout;
  6470. }
  6471. try {
  6472. if (typeof clearTimeout === 'function') {
  6473. cachedClearTimeout = clearTimeout;
  6474. } else {
  6475. cachedClearTimeout = defaultClearTimeout;
  6476. }
  6477. } catch (e) {
  6478. cachedClearTimeout = defaultClearTimeout;
  6479. }
  6480. } ())
  6481. function runTimeout(fun) {
  6482. if (cachedSetTimeout === setTimeout) {
  6483. //normal enviroments in sane situations
  6484. return setTimeout(fun, 0);
  6485. }
  6486. // if setTimeout wasn't available but was latter defined
  6487. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  6488. cachedSetTimeout = setTimeout;
  6489. return setTimeout(fun, 0);
  6490. }
  6491. try {
  6492. // when when somebody has screwed with setTimeout but no I.E. maddness
  6493. return cachedSetTimeout(fun, 0);
  6494. } catch(e){
  6495. try {
  6496. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  6497. return cachedSetTimeout.call(null, fun, 0);
  6498. } catch(e){
  6499. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  6500. return cachedSetTimeout.call(this, fun, 0);
  6501. }
  6502. }
  6503.  
  6504.  
  6505. }
  6506. function runClearTimeout(marker) {
  6507. if (cachedClearTimeout === clearTimeout) {
  6508. //normal enviroments in sane situations
  6509. return clearTimeout(marker);
  6510. }
  6511. // if clearTimeout wasn't available but was latter defined
  6512. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  6513. cachedClearTimeout = clearTimeout;
  6514. return clearTimeout(marker);
  6515. }
  6516. try {
  6517. // when when somebody has screwed with setTimeout but no I.E. maddness
  6518. return cachedClearTimeout(marker);
  6519. } catch (e){
  6520. try {
  6521. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  6522. return cachedClearTimeout.call(null, marker);
  6523. } catch (e){
  6524. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  6525. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  6526. return cachedClearTimeout.call(this, marker);
  6527. }
  6528. }
  6529.  
  6530.  
  6531.  
  6532. }
  6533. var queue = [];
  6534. var draining = false;
  6535. var currentQueue;
  6536. var queueIndex = -1;
  6537.  
  6538. function cleanUpNextTick() {
  6539. if (!draining || !currentQueue) {
  6540. return;
  6541. }
  6542. draining = false;
  6543. if (currentQueue.length) {
  6544. queue = currentQueue.concat(queue);
  6545. } else {
  6546. queueIndex = -1;
  6547. }
  6548. if (queue.length) {
  6549. drainQueue();
  6550. }
  6551. }
  6552.  
  6553. function drainQueue() {
  6554. if (draining) {
  6555. return;
  6556. }
  6557. var timeout = runTimeout(cleanUpNextTick);
  6558. draining = true;
  6559.  
  6560. var len = queue.length;
  6561. while(len) {
  6562. currentQueue = queue;
  6563. queue = [];
  6564. while (++queueIndex < len) {
  6565. if (currentQueue) {
  6566. currentQueue[queueIndex].run();
  6567. }
  6568. }
  6569. queueIndex = -1;
  6570. len = queue.length;
  6571. }
  6572. currentQueue = null;
  6573. draining = false;
  6574. runClearTimeout(timeout);
  6575. }
  6576.  
  6577. process.nextTick = function (fun) {
  6578. var args = new Array(arguments.length - 1);
  6579. if (arguments.length > 1) {
  6580. for (var i = 1; i < arguments.length; i++) {
  6581. args[i - 1] = arguments[i];
  6582. }
  6583. }
  6584. queue.push(new Item(fun, args));
  6585. if (queue.length === 1 && !draining) {
  6586. runTimeout(drainQueue);
  6587. }
  6588. };
  6589.  
  6590. // v8 likes predictible objects
  6591. function Item(fun, array) {
  6592. this.fun = fun;
  6593. this.array = array;
  6594. }
  6595. Item.prototype.run = function () {
  6596. this.fun.apply(null, this.array);
  6597. };
  6598. process.title = 'browser';
  6599. process.browser = true;
  6600. process.env = {};
  6601. process.argv = [];
  6602. process.version = ''; // empty string to avoid regexp issues
  6603. process.versions = {};
  6604.  
  6605. function noop() {}
  6606.  
  6607. process.on = noop;
  6608. process.addListener = noop;
  6609. process.once = noop;
  6610. process.off = noop;
  6611. process.removeListener = noop;
  6612. process.removeAllListeners = noop;
  6613. process.emit = noop;
  6614.  
  6615. process.binding = function (name) {
  6616. throw new Error('process.binding is not supported');
  6617. };
  6618.  
  6619. process.cwd = function () { return '/' };
  6620. process.chdir = function (dir) {
  6621. throw new Error('process.chdir is not supported');
  6622. };
  6623. process.umask = function() { return 0; };
  6624.  
  6625.  
  6626. /***/ }),
  6627. /* 32 */
  6628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6629.  
  6630. "use strict";
  6631. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__ = __webpack_require__(58);
  6632. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck__);
  6633. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__ = __webpack_require__(59);
  6634. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass__);
  6635. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_underscore__ = __webpack_require__(113);
  6636. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_underscore___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_underscore__);
  6637. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_bluebird__ = __webpack_require__(3);
  6638. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_bluebird___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_bluebird__);
  6639. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return http; });
  6640. /* unused harmony export timeout */
  6641.  
  6642.  
  6643.  
  6644.  
  6645.  
  6646.  
  6647.  
  6648.  
  6649.  
  6650.  
  6651. var Http = function () {
  6652. function Http(options) {
  6653. __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_classCallCheck___default()(this, Http);
  6654.  
  6655. this.options = options;
  6656. }
  6657.  
  6658. __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_createClass___default()(Http, [{
  6659. key: 'request',
  6660. value: function request(requestOptions) {
  6661. var options = __WEBPACK_IMPORTED_MODULE_2_underscore__["extend"]({}, this.options, requestOptions);
  6662. var onreadystatechange = options.onreadystatechange,
  6663. onerror = options.onerror,
  6664. onabort = options.onabort,
  6665. ontimeout = options.ontimeout;
  6666.  
  6667.  
  6668. return new __WEBPACK_IMPORTED_MODULE_3_bluebird___default.a(function (resolve, reject) {
  6669. // options.synchronous = true; // async
  6670. options.onreadystatechange = function (response) {
  6671. __WEBPACK_IMPORTED_MODULE_2_underscore__["isFunction"](onreadystatechange) && onreadystatechange.call(this, response);
  6672. if (response.readyState !== 4) return;
  6673. response.status >= 200 && response.status < 400 ? resolve(response) : reject(response);
  6674. };
  6675.  
  6676. options.onerror = function (response) {
  6677. __WEBPACK_IMPORTED_MODULE_2_underscore__["isFunction"](onerror) && onerror.call(this, response);
  6678. reject(response);
  6679. };
  6680.  
  6681. options.onabort = function (response) {
  6682. __WEBPACK_IMPORTED_MODULE_2_underscore__["isFunction"](onabort) && onabort.call(this, response);
  6683. reject(response);
  6684. };
  6685.  
  6686. options.ontimeout = function (response) {
  6687. __WEBPACK_IMPORTED_MODULE_2_underscore__["isFunction"](ontimeout) && ontimeout.call(this, response);
  6688. reject(response);
  6689. };
  6690.  
  6691. GM_xmlhttpRequest(__WEBPACK_IMPORTED_MODULE_2_underscore__["extend"]({}, options));
  6692. });
  6693. }
  6694. }, {
  6695. key: 'get',
  6696. value: function get(url, options) {
  6697. var requestOptions = __WEBPACK_IMPORTED_MODULE_2_underscore__["extend"](options || {}, { url: url, method: 'GET' });
  6698. return this.request(requestOptions);
  6699. }
  6700. }, {
  6701. key: 'post',
  6702. value: function post(url, data, options) {
  6703. return this.request(__WEBPACK_IMPORTED_MODULE_2_underscore__["extend"](options || {}, { url: url, method: 'POST', data: data }));
  6704. }
  6705. }, {
  6706. key: 'head',
  6707. value: function head(url, options) {
  6708. return this.request(__WEBPACK_IMPORTED_MODULE_2_underscore__["extend"](options || {}, { url: url, method: 'HEAD' }));
  6709. }
  6710. }]);
  6711.  
  6712. return Http;
  6713. }();
  6714.  
  6715. var timeout = 5000;
  6716. var http = new Http({ timeout: timeout });
  6717.  
  6718.  
  6719.  
  6720. /***/ }),
  6721. /* 33 */
  6722. /***/ (function(module, exports, __webpack_require__) {
  6723.  
  6724. module.exports = { "default": __webpack_require__(64), __esModule: true };
  6725.  
  6726. /***/ }),
  6727. /* 34 */
  6728. /***/ (function(module, exports, __webpack_require__) {
  6729.  
  6730. // getting tag from 19.1.3.6 Object.prototype.toString()
  6731. var cof = __webpack_require__(16)
  6732. , TAG = __webpack_require__(0)('toStringTag')
  6733. // ES3 wrong here
  6734. , ARG = cof(function(){ return arguments; }()) == 'Arguments';
  6735.  
  6736. // fallback for IE11 Script Access Denied error
  6737. var tryGet = function(it, key){
  6738. try {
  6739. return it[key];
  6740. } catch(e){ /* empty */ }
  6741. };
  6742.  
  6743. module.exports = function(it){
  6744. var O, T, B;
  6745. return it === undefined ? 'Undefined' : it === null ? 'Null'
  6746. // @@toStringTag case
  6747. : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T
  6748. // builtinTag case
  6749. : ARG ? cof(O)
  6750. // ES3 arguments fallback
  6751. : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B;
  6752. };
  6753.  
  6754. /***/ }),
  6755. /* 35 */
  6756. /***/ (function(module, exports) {
  6757.  
  6758. // IE 8- don't enum bug keys
  6759. module.exports = (
  6760. 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'
  6761. ).split(',');
  6762.  
  6763. /***/ }),
  6764. /* 36 */
  6765. /***/ (function(module, exports) {
  6766.  
  6767. module.exports = function(exec){
  6768. try {
  6769. return !!exec();
  6770. } catch(e){
  6771. return true;
  6772. }
  6773. };
  6774.  
  6775. /***/ }),
  6776. /* 37 */
  6777. /***/ (function(module, exports, __webpack_require__) {
  6778.  
  6779. module.exports = __webpack_require__(1).document && document.documentElement;
  6780.  
  6781. /***/ }),
  6782. /* 38 */
  6783. /***/ (function(module, exports, __webpack_require__) {
  6784.  
  6785. // check on default Array iterator
  6786. var Iterators = __webpack_require__(13)
  6787. , ITERATOR = __webpack_require__(0)('iterator')
  6788. , ArrayProto = Array.prototype;
  6789.  
  6790. module.exports = function(it){
  6791. return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it);
  6792. };
  6793.  
  6794. /***/ }),
  6795. /* 39 */
  6796. /***/ (function(module, exports, __webpack_require__) {
  6797.  
  6798. // call something on iterator step with safe closing on error
  6799. var anObject = __webpack_require__(4);
  6800. module.exports = function(iterator, fn, value, entries){
  6801. try {
  6802. return entries ? fn(anObject(value)[0], value[1]) : fn(value);
  6803. // 7.4.6 IteratorClose(iterator, completion)
  6804. } catch(e){
  6805. var ret = iterator['return'];
  6806. if(ret !== undefined)anObject(ret.call(iterator));
  6807. throw e;
  6808. }
  6809. };
  6810.  
  6811. /***/ }),
  6812. /* 40 */
  6813. /***/ (function(module, exports, __webpack_require__) {
  6814.  
  6815. "use strict";
  6816.  
  6817. var LIBRARY = __webpack_require__(42)
  6818. , $export = __webpack_require__(17)
  6819. , redefine = __webpack_require__(84)
  6820. , hide = __webpack_require__(6)
  6821. , has = __webpack_require__(18)
  6822. , Iterators = __webpack_require__(13)
  6823. , $iterCreate = __webpack_require__(75)
  6824. , setToStringTag = __webpack_require__(25)
  6825. , getPrototypeOf = __webpack_require__(80)
  6826. , ITERATOR = __webpack_require__(0)('iterator')
  6827. , BUGGY = !([].keys && 'next' in [].keys()) // Safari has buggy iterators w/o `next`
  6828. , FF_ITERATOR = '@@iterator'
  6829. , KEYS = 'keys'
  6830. , VALUES = 'values';
  6831.  
  6832. var returnThis = function(){ return this; };
  6833.  
  6834. module.exports = function(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED){
  6835. $iterCreate(Constructor, NAME, next);
  6836. var getMethod = function(kind){
  6837. if(!BUGGY && kind in proto)return proto[kind];
  6838. switch(kind){
  6839. case KEYS: return function keys(){ return new Constructor(this, kind); };
  6840. case VALUES: return function values(){ return new Constructor(this, kind); };
  6841. } return function entries(){ return new Constructor(this, kind); };
  6842. };
  6843. var TAG = NAME + ' Iterator'
  6844. , DEF_VALUES = DEFAULT == VALUES
  6845. , VALUES_BUG = false
  6846. , proto = Base.prototype
  6847. , $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]
  6848. , $default = $native || getMethod(DEFAULT)
  6849. , $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined
  6850. , $anyNative = NAME == 'Array' ? proto.entries || $native : $native
  6851. , methods, key, IteratorPrototype;
  6852. // Fix native
  6853. if($anyNative){
  6854. IteratorPrototype = getPrototypeOf($anyNative.call(new Base));
  6855. if(IteratorPrototype !== Object.prototype){
  6856. // Set @@toStringTag to native iterators
  6857. setToStringTag(IteratorPrototype, TAG, true);
  6858. // fix for some old engines
  6859. if(!LIBRARY && !has(IteratorPrototype, ITERATOR))hide(IteratorPrototype, ITERATOR, returnThis);
  6860. }
  6861. }
  6862. // fix Array#{values, @@iterator}.name in V8 / FF
  6863. if(DEF_VALUES && $native && $native.name !== VALUES){
  6864. VALUES_BUG = true;
  6865. $default = function values(){ return $native.call(this); };
  6866. }
  6867. // Define iterator
  6868. if((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])){
  6869. hide(proto, ITERATOR, $default);
  6870. }
  6871. // Plug for library
  6872. Iterators[NAME] = $default;
  6873. Iterators[TAG] = returnThis;
  6874. if(DEFAULT){
  6875. methods = {
  6876. values: DEF_VALUES ? $default : getMethod(VALUES),
  6877. keys: IS_SET ? $default : getMethod(KEYS),
  6878. entries: $entries
  6879. };
  6880. if(FORCED)for(key in methods){
  6881. if(!(key in proto))redefine(proto, key, methods[key]);
  6882. } else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods);
  6883. }
  6884. return methods;
  6885. };
  6886.  
  6887. /***/ }),
  6888. /* 41 */
  6889. /***/ (function(module, exports, __webpack_require__) {
  6890.  
  6891. var ITERATOR = __webpack_require__(0)('iterator')
  6892. , SAFE_CLOSING = false;
  6893.  
  6894. try {
  6895. var riter = [7][ITERATOR]();
  6896. riter['return'] = function(){ SAFE_CLOSING = true; };
  6897. Array.from(riter, function(){ throw 2; });
  6898. } catch(e){ /* empty */ }
  6899.  
  6900. module.exports = function(exec, skipClosing){
  6901. if(!skipClosing && !SAFE_CLOSING)return false;
  6902. var safe = false;
  6903. try {
  6904. var arr = [7]
  6905. , iter = arr[ITERATOR]();
  6906. iter.next = function(){ return {done: safe = true}; };
  6907. arr[ITERATOR] = function(){ return iter; };
  6908. exec(arr);
  6909. } catch(e){ /* empty */ }
  6910. return safe;
  6911. };
  6912.  
  6913. /***/ }),
  6914. /* 42 */
  6915. /***/ (function(module, exports) {
  6916.  
  6917. module.exports = true;
  6918.  
  6919. /***/ }),
  6920. /* 43 */
  6921. /***/ (function(module, exports, __webpack_require__) {
  6922.  
  6923. var global = __webpack_require__(1)
  6924. , SHARED = '__core-js_shared__'
  6925. , store = global[SHARED] || (global[SHARED] = {});
  6926. module.exports = function(key){
  6927. return store[key] || (store[key] = {});
  6928. };
  6929.  
  6930. /***/ }),
  6931. /* 44 */
  6932. /***/ (function(module, exports, __webpack_require__) {
  6933.  
  6934. var ctx = __webpack_require__(12)
  6935. , invoke = __webpack_require__(73)
  6936. , html = __webpack_require__(37)
  6937. , cel = __webpack_require__(23)
  6938. , global = __webpack_require__(1)
  6939. , process = global.process
  6940. , setTask = global.setImmediate
  6941. , clearTask = global.clearImmediate
  6942. , MessageChannel = global.MessageChannel
  6943. , counter = 0
  6944. , queue = {}
  6945. , ONREADYSTATECHANGE = 'onreadystatechange'
  6946. , defer, channel, port;
  6947. var run = function(){
  6948. var id = +this;
  6949. if(queue.hasOwnProperty(id)){
  6950. var fn = queue[id];
  6951. delete queue[id];
  6952. fn();
  6953. }
  6954. };
  6955. var listener = function(event){
  6956. run.call(event.data);
  6957. };
  6958. // Node.js 0.9+ & IE10+ has setImmediate, otherwise:
  6959. if(!setTask || !clearTask){
  6960. setTask = function setImmediate(fn){
  6961. var args = [], i = 1;
  6962. while(arguments.length > i)args.push(arguments[i++]);
  6963. queue[++counter] = function(){
  6964. invoke(typeof fn == 'function' ? fn : Function(fn), args);
  6965. };
  6966. defer(counter);
  6967. return counter;
  6968. };
  6969. clearTask = function clearImmediate(id){
  6970. delete queue[id];
  6971. };
  6972. // Node.js 0.8-
  6973. if(__webpack_require__(16)(process) == 'process'){
  6974. defer = function(id){
  6975. process.nextTick(ctx(run, id, 1));
  6976. };
  6977. // Browsers with MessageChannel, includes WebWorkers
  6978. } else if(MessageChannel){
  6979. channel = new MessageChannel;
  6980. port = channel.port2;
  6981. channel.port1.onmessage = listener;
  6982. defer = ctx(port.postMessage, port, 1);
  6983. // Browsers with postMessage, skip WebWorkers
  6984. // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'
  6985. } else if(global.addEventListener && typeof postMessage == 'function' && !global.importScripts){
  6986. defer = function(id){
  6987. global.postMessage(id + '', '*');
  6988. };
  6989. global.addEventListener('message', listener, false);
  6990. // IE8-
  6991. } else if(ONREADYSTATECHANGE in cel('script')){
  6992. defer = function(id){
  6993. html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function(){
  6994. html.removeChild(this);
  6995. run.call(id);
  6996. };
  6997. };
  6998. // Rest old browsers
  6999. } else {
  7000. defer = function(id){
  7001. setTimeout(ctx(run, id, 1), 0);
  7002. };
  7003. }
  7004. }
  7005. module.exports = {
  7006. set: setTask,
  7007. clear: clearTask
  7008. };
  7009.  
  7010. /***/ }),
  7011. /* 45 */
  7012. /***/ (function(module, exports, __webpack_require__) {
  7013.  
  7014. // 7.1.13 ToObject(argument)
  7015. var defined = __webpack_require__(22);
  7016. module.exports = function(it){
  7017. return Object(defined(it));
  7018. };
  7019.  
  7020. /***/ }),
  7021. /* 46 */
  7022. /***/ (function(module, exports) {
  7023.  
  7024. var id = 0
  7025. , px = Math.random();
  7026. module.exports = function(key){
  7027. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
  7028. };
  7029.  
  7030. /***/ }),
  7031. /* 47 */
  7032. /***/ (function(module, exports, __webpack_require__) {
  7033.  
  7034. var classof = __webpack_require__(34)
  7035. , ITERATOR = __webpack_require__(0)('iterator')
  7036. , Iterators = __webpack_require__(13);
  7037. module.exports = __webpack_require__(2).getIteratorMethod = function(it){
  7038. if(it != undefined)return it[ITERATOR]
  7039. || it['@@iterator']
  7040. || Iterators[classof(it)];
  7041. };
  7042.  
  7043. /***/ }),
  7044. /* 48 */
  7045. /***/ (function(module, exports, __webpack_require__) {
  7046.  
  7047. "use strict";
  7048.  
  7049. var $at = __webpack_require__(87)(true);
  7050.  
  7051. // 21.1.3.27 String.prototype[@@iterator]()
  7052. __webpack_require__(40)(String, 'String', function(iterated){
  7053. this._t = String(iterated); // target
  7054. this._i = 0; // next index
  7055. // 21.1.5.2.1 %StringIteratorPrototype%.next()
  7056. }, function(){
  7057. var O = this._t
  7058. , index = this._i
  7059. , point;
  7060. if(index >= O.length)return {value: undefined, done: true};
  7061. point = $at(O, index);
  7062. this._i += point.length;
  7063. return {value: point, done: false};
  7064. });
  7065.  
  7066. /***/ }),
  7067. /* 49 */
  7068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7069.  
  7070. "use strict";
  7071. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator__ = __webpack_require__(11);
  7072. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator__);
  7073. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify__ = __webpack_require__(33);
  7074. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify__);
  7075. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator__ = __webpack_require__(10);
  7076. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator__);
  7077. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_parse_github_url__ = __webpack_require__(30);
  7078. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_parse_github_url___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_parse_github_url__);
  7079. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_bluebird__ = __webpack_require__(3);
  7080. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_bluebird___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_bluebird__);
  7081. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__npm__ = __webpack_require__(20);
  7082. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__github__ = __webpack_require__(15);
  7083. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__env__ = __webpack_require__(14);
  7084.  
  7085.  
  7086.  
  7087.  
  7088.  
  7089.  
  7090.  
  7091.  
  7092.  
  7093.  
  7094.  
  7095. /* harmony default export */ __webpack_exports__["a"] = function () {
  7096. return function () {
  7097. var _ref = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default()(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.mark(function _callee2() {
  7098. var _this = this;
  7099.  
  7100. var span;
  7101. return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.wrap(function _callee2$(_context2) {
  7102. while (1) {
  7103. switch (_context2.prev = _context2.next) {
  7104. case 0:
  7105. span = document.createElement('span');
  7106.  
  7107.  
  7108. document.querySelectorAll('ul.columnar>li .description').forEach(function (ele) {
  7109. return ele.title = ele.innerText || ele.textContent;
  7110. });
  7111.  
  7112. document.querySelectorAll('ul.columnar>li').forEach(function () {
  7113. var _ref2 = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default()(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.mark(function _callee(ele) {
  7114. var aEle, name, npmPackage, repoInfo, gitRepoInfo, _github$createWidget, container;
  7115.  
  7116. return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.wrap(function _callee$(_context) {
  7117. while (1) {
  7118. switch (_context.prev = _context.next) {
  7119. case 0:
  7120. aEle = ele.querySelector('a.name');
  7121. name = aEle.innerText || aEle.textContent;
  7122. _context.next = 4;
  7123. return __WEBPACK_IMPORTED_MODULE_5__npm__["a" /* default */].fetchPackageInfo(name);
  7124.  
  7125. case 4:
  7126. npmPackage = _context.sent;
  7127.  
  7128.  
  7129. __WEBPACK_IMPORTED_MODULE_7__env__["a" /* default */].dev && ele.setAttribute('package', __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify___default()(npmPackage));
  7130.  
  7131. if (npmPackage.repository) {
  7132. _context.next = 8;
  7133. break;
  7134. }
  7135.  
  7136. return _context.abrupt('return', console.error(npmPackage.name + ' doesn\'t has repository field'));
  7137.  
  7138. case 8:
  7139. repoInfo = __WEBPACK_IMPORTED_MODULE_3_parse_github_url___default()(npmPackage.repository.url);
  7140.  
  7141.  
  7142. __WEBPACK_IMPORTED_MODULE_7__env__["a" /* default */].dev && ele.setAttribute('repository-info', __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify___default()(repoInfo));
  7143.  
  7144. if (repoInfo) {
  7145. _context.next = 12;
  7146. break;
  7147. }
  7148.  
  7149. return _context.abrupt('return', console.error('can\'t parse ' + npmPackage.repository.url));
  7150.  
  7151. case 12:
  7152. if (!(repoInfo.host !== 'github.com')) {
  7153. _context.next = 14;
  7154. break;
  7155. }
  7156.  
  7157. return _context.abrupt('return', console.error(repoInfo.href + ' is not a github repository'));
  7158.  
  7159. case 14:
  7160. _context.next = 16;
  7161. return __WEBPACK_IMPORTED_MODULE_6__github__["a" /* default */].fetchRepoInfo(repoInfo.repo);
  7162.  
  7163. case 16:
  7164. gitRepoInfo = _context.sent;
  7165.  
  7166.  
  7167. __WEBPACK_IMPORTED_MODULE_7__env__["a" /* default */].dev && ele.setAttribute('github-info', __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify___default()(gitRepoInfo));
  7168.  
  7169. _github$createWidget = __WEBPACK_IMPORTED_MODULE_6__github__["a" /* default */].createWidget('span')({
  7170. watch: gitRepoInfo.subscribers_count,
  7171. star: gitRepoInfo.watchers_count,
  7172. fork: gitRepoInfo.forks_count
  7173. }), container = _github$createWidget.container;
  7174.  
  7175. container.classList.add('description');
  7176. ele.querySelector('.package-details h3').appendChild(container);
  7177.  
  7178. case 21:
  7179. case 'end':
  7180. return _context.stop();
  7181. }
  7182. }
  7183. }, _callee, _this);
  7184. }));
  7185.  
  7186. return function (_x) {
  7187. return _ref2.apply(this, arguments);
  7188. };
  7189. }());
  7190.  
  7191. case 3:
  7192. case 'end':
  7193. return _context2.stop();
  7194. }
  7195. }
  7196. }, _callee2, this);
  7197. }));
  7198.  
  7199. function browserPageHandler() {
  7200. return _ref.apply(this, arguments);
  7201. }
  7202.  
  7203. return browserPageHandler;
  7204. }();
  7205. };
  7206.  
  7207. /***/ }),
  7208. /* 50 */
  7209. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7210.  
  7211. "use strict";
  7212. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_toConsumableArray__ = __webpack_require__(60);
  7213. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_toConsumableArray___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_toConsumableArray__);
  7214. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator__ = __webpack_require__(11);
  7215. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator__);
  7216. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator__ = __webpack_require__(10);
  7217. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator__);
  7218. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_bluebird__ = __webpack_require__(3);
  7219. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_bluebird___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_bluebird__);
  7220. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__github__ = __webpack_require__(15);
  7221. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_timeago_js__ = __webpack_require__(111);
  7222. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_timeago_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_5_timeago_js__);
  7223. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils__ = __webpack_require__(9);
  7224. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__env__ = __webpack_require__(14);
  7225.  
  7226.  
  7227.  
  7228.  
  7229.  
  7230.  
  7231.  
  7232.  
  7233.  
  7234.  
  7235.  
  7236. function generateOutdatedWarning(date, diffDays) {
  7237. var span = document.createElement('span');
  7238. var tags = {
  7239. deprecated: { name: "Deprecated", color: "red" },
  7240. outdated: { name: "Outdated", color: "blue" }
  7241. };
  7242. var tag = null;
  7243. if (diffDays > 365) {
  7244. tag = tags.deprecated;
  7245. } else if (diffDays > 180) {
  7246. tag = tags.outdated;
  7247. }
  7248. span.innerHTML = (tag ? '<strong style="color: ' + tag.color + '">@' + tag.name + '</strong> ' : '') + ('last commit at <strong style="color: #283546;">' + new __WEBPACK_IMPORTED_MODULE_5_timeago_js___default.a().format(date) + '</strong>');
  7249. span.style.color = 'rgba(0, 0, 0, 0.6)';
  7250. span.style.fontSize = '16px';
  7251. span.style.verticalAlign = 'middle';
  7252. return span;
  7253. }
  7254.  
  7255. /* harmony default export */ __webpack_exports__["a"] = function () {
  7256.  
  7257. return function () {
  7258. var _ref = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default()(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.mark(function _callee() {
  7259. var githubLink, gitRepoInfo, _github$createWidget, container, gitBranchInfo, lastCommit, lastCommitter, commitFromNowDiffDays, span;
  7260.  
  7261. return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_regenerator___default.a.wrap(function _callee$(_context) {
  7262. while (1) {
  7263. switch (_context.prev = _context.next) {
  7264. case 0:
  7265.  
  7266. parseJSCodeBlock(); // parse require('xxx') | import xxx from
  7267. parseShellCodeBlock(); // parse require('xxx') | import xxx from
  7268.  
  7269. githubLink = window.document.querySelector('.box a[href*=github]');
  7270.  
  7271. if (githubLink) {
  7272. _context.next = 5;
  7273. break;
  7274. }
  7275.  
  7276. return _context.abrupt('return');
  7277.  
  7278. case 5:
  7279. githubLink.title = githubLink.href;
  7280. _context.next = 8;
  7281. return __WEBPACK_IMPORTED_MODULE_4__github__["a" /* default */].fetchRepoInfo(githubLink.pathname);
  7282.  
  7283. case 8:
  7284. gitRepoInfo = _context.sent;
  7285. _github$createWidget = __WEBPACK_IMPORTED_MODULE_4__github__["a" /* default */].createWidget('li')({
  7286. watch: gitRepoInfo.subscribers_count,
  7287. star: gitRepoInfo.watchers_count,
  7288. fork: gitRepoInfo.forks_count
  7289. }), container = _github$createWidget.container;
  7290. _context.next = 12;
  7291. return __WEBPACK_IMPORTED_MODULE_4__github__["a" /* default */].fetchRepoBranchInfo(githubLink.pathname, 'master');
  7292.  
  7293. case 12:
  7294. gitBranchInfo = _context.sent;
  7295. lastCommit = gitBranchInfo.commit.commit;
  7296. lastCommitter = lastCommit.committer;
  7297. commitFromNowDiffDays = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__utils__["e" /* diffDays */])(new Date(), lastCommitter.date);
  7298.  
  7299. // warning
  7300.  
  7301. span = generateOutdatedWarning(lastCommitter.date, commitFromNowDiffDays);
  7302.  
  7303. document.querySelector('.package-name').appendChild(span);
  7304.  
  7305. window.document.querySelector('.box').insertBefore(container, githubLink.parentNode);
  7306.  
  7307. case 19:
  7308. case 'end':
  7309. return _context.stop();
  7310. }
  7311. }
  7312. }, _callee, this);
  7313. }));
  7314.  
  7315. function detailPageHandler() {
  7316. return _ref.apply(this, arguments);
  7317. }
  7318.  
  7319. return detailPageHandler;
  7320. }();
  7321. };
  7322.  
  7323. function getElementText(ele) {
  7324. return ele.innerText || ele.textContent;
  7325. }
  7326.  
  7327. function parseJSCodeBlock() {
  7328. var _slice$call;
  7329.  
  7330. var js = document.querySelectorAll('.highlight.js pre .line .source');
  7331. var javascript = document.querySelectorAll('.highlight.javascript pre .line .source');
  7332. var lines = (_slice$call = [].slice.call(js)).concat.apply(_slice$call, __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_toConsumableArray___default()(javascript));
  7333.  
  7334. try {
  7335. lines.forEach(function (line) {
  7336. if (line.innerHTML.match(/require|from|import/g)) {
  7337.  
  7338. (line.querySelectorAll('.string.quoted') || line.querySelectorAll('.import .string.quoted')).forEach(function (stringQuotedEle) {
  7339. if (!stringQuotedEle) return;
  7340.  
  7341. var requireName = getElementText(stringQuotedEle).trim().replace(/^['"]|['"]$/g, '');
  7342.  
  7343. if (/^\./.test(requireName)) return; // 不支持相对路径
  7344.  
  7345. var packageNameMatch = requireName.match(/(^\@[^\/]+\/[^\/]+)|([^\/]+)/) || [];
  7346. var packageName = packageNameMatch[0];
  7347.  
  7348. if (__WEBPACK_IMPORTED_MODULE_7__env__["a" /* default */].dev) {
  7349. console.info('[Parse Javascript]: ' + requireName + ' >>> ' + packageName);
  7350. }
  7351.  
  7352. // 正确解析才渲染页面
  7353. if (packageName) {
  7354. var childNodes = stringQuotedEle.children;
  7355. var stringQuotedStartEle = childNodes[0];
  7356. var stringQuotedEndEle = childNodes[childNodes.length - 1];
  7357. var packageUrl = 'https://www.npmjs.com/package/' + packageName;
  7358. stringQuotedEle.innerHTML = stringQuotedStartEle.innerHTML + ('<a title="' + packageUrl + '" style="text-decoration: underline" href="' + packageUrl + '">' + requireName + '</a>') + stringQuotedEndEle.innerHTML;
  7359. }
  7360. });
  7361. }
  7362. });
  7363. } catch (err) {
  7364. console.error(err);
  7365. }
  7366. }
  7367.  
  7368. function parseShellCodeBlock() {
  7369. var _slice$call$concat, _slice$call2;
  7370.  
  7371. var sh = document.querySelectorAll('.highlight.sh pre .line .source');
  7372. var bash = document.querySelectorAll('.highlight.bash pre .line');
  7373. var noTag = document.querySelectorAll('pre:not(.highlight) code');
  7374. var lines = (_slice$call$concat = (_slice$call2 = [].slice.call(sh)).concat.apply(_slice$call2, __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_toConsumableArray___default()(bash))).concat.apply(_slice$call$concat, __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_toConsumableArray___default()(noTag));
  7375.  
  7376. try {
  7377. lines.forEach(function (line) {
  7378. var match = getElementText(line).trim().replace(/^\$\s*/, '').match(/(npm)\s+(install)\s+((--?[\w]+\s)?|\s+)+([\w\-\@\.\_\/]+)/g);
  7379. if (match && match.length) {
  7380.  
  7381. var matchStr = match[0].trim();
  7382.  
  7383. var commands = matchStr.split(/\s+/g).map(function (v) {
  7384. return v.trim();
  7385. });
  7386. var command = '',
  7387. action = '',
  7388. target = '';
  7389. var argv = [];
  7390.  
  7391. commands.forEach(function (str, index) {
  7392. if (index === 0) return command = str;
  7393. if (index === 1) return action = str;
  7394.  
  7395. // argv
  7396. if (/^\-/.test(str)) {
  7397. argv.push(str);
  7398. } else {
  7399. target = str;
  7400. }
  7401. });
  7402.  
  7403. var packageName = (target || '').trim();
  7404.  
  7405. // 处理一些带有版本的命令
  7406. // example: npm install @reactivex/rxjs@5.0.0
  7407. // example: npm install -g express-generator@4
  7408. packageName = packageName.replace(/([^\s])\@[\.\w\-]+$/, '$1');
  7409.  
  7410. if (__WEBPACK_IMPORTED_MODULE_7__env__["a" /* default */].dev) {
  7411. console.log('[Parse Shell]: ' + matchStr + ' >>> ' + packageName);
  7412. }
  7413.  
  7414. if (packageName) {
  7415. var packageUrl = 'https://www.npmjs.com/package/' + packageName;
  7416. line.innerHTML = line.innerHTML.replace(/\&nbsp\;/g, ' ') // remove empty string
  7417. .replace(target, '<a style="text-decoration: underline" title="' + packageUrl + '" href="' + packageUrl + '">' + target + '</a>');
  7418. }
  7419. }
  7420. });
  7421. } catch (err) {
  7422. console.error(err);
  7423. }
  7424. }
  7425.  
  7426. /***/ }),
  7427. /* 51 */
  7428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7429.  
  7430. "use strict";
  7431. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator__ = __webpack_require__(11);
  7432. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator__);
  7433. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_asyncToGenerator__ = __webpack_require__(10);
  7434. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_asyncToGenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_asyncToGenerator__);
  7435. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_parse_github_url__ = __webpack_require__(30);
  7436. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_parse_github_url___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_parse_github_url__);
  7437. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_bluebird__ = __webpack_require__(3);
  7438. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_bluebird___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_bluebird__);
  7439. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__npm__ = __webpack_require__(20);
  7440. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__github__ = __webpack_require__(15);
  7441. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__env__ = __webpack_require__(14);
  7442.  
  7443.  
  7444.  
  7445.  
  7446.  
  7447.  
  7448.  
  7449.  
  7450.  
  7451.  
  7452. /* harmony default export */ __webpack_exports__["a"] = function () {
  7453. return function () {
  7454. var _ref = __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_asyncToGenerator___default()(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.mark(function _callee() {
  7455. return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.wrap(function _callee$(_context) {
  7456. while (1) {
  7457. switch (_context.prev = _context.next) {
  7458. case 0:
  7459. document.querySelectorAll('.package-details .description').forEach(function (ele) {
  7460. return ele.title = ele.innerText || ele.textContent;
  7461. });
  7462.  
  7463. case 1:
  7464. case 'end':
  7465. return _context.stop();
  7466. }
  7467. }
  7468. }, _callee, this);
  7469. }));
  7470.  
  7471. function homePageHandler() {
  7472. return _ref.apply(this, arguments);
  7473. }
  7474.  
  7475. return homePageHandler;
  7476. }();
  7477. };
  7478.  
  7479. /***/ }),
  7480. /* 52 */
  7481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7482.  
  7483. "use strict";
  7484. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator__ = __webpack_require__(11);
  7485. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator__);
  7486. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify__ = __webpack_require__(33);
  7487. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify__);
  7488. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator__ = __webpack_require__(10);
  7489. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator__);
  7490. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_parse_github_url__ = __webpack_require__(30);
  7491. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_parse_github_url___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_parse_github_url__);
  7492. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_bluebird__ = __webpack_require__(3);
  7493. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_bluebird___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_bluebird__);
  7494. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__npm__ = __webpack_require__(20);
  7495. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__github__ = __webpack_require__(15);
  7496. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils__ = __webpack_require__(9);
  7497. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__env__ = __webpack_require__(14);
  7498.  
  7499.  
  7500.  
  7501.  
  7502.  
  7503.  
  7504. var searchPageHandler = function () {
  7505. var _ref = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default()(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.mark(function _callee2() {
  7506. var _this = this;
  7507.  
  7508. var searchResults;
  7509. return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.wrap(function _callee2$(_context2) {
  7510. while (1) {
  7511. switch (_context2.prev = _context2.next) {
  7512. case 0:
  7513. document.querySelectorAll('.github-info').forEach(function (ele) {
  7514. return ele.remove();
  7515. });
  7516. searchResults = document.querySelectorAll('.package-details');
  7517.  
  7518. searchResults.forEach(function () {
  7519. var _ref2 = __WEBPACK_IMPORTED_MODULE_2_babel_runtime_helpers_asyncToGenerator___default()(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.mark(function _callee(detailEle) {
  7520. var nameEle, name, npmPackage, repoInfo, gitRepoInfo, _github$createWidget, container;
  7521.  
  7522. return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.wrap(function _callee$(_context) {
  7523. while (1) {
  7524. switch (_context.prev = _context.next) {
  7525. case 0:
  7526. nameEle = detailEle.querySelector('.packageName');
  7527. name = nameEle.innerText || nameEle.textContent;
  7528. _context.next = 4;
  7529. return __WEBPACK_IMPORTED_MODULE_5__npm__["a" /* default */].fetchPackageInfo(name);
  7530.  
  7531. case 4:
  7532. npmPackage = _context.sent;
  7533. repoInfo = __WEBPACK_IMPORTED_MODULE_3_parse_github_url___default()(npmPackage.repository.url);
  7534.  
  7535.  
  7536. __WEBPACK_IMPORTED_MODULE_8__env__["a" /* default */].dev && detailEle.setAttribute('repository-info', __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify___default()(repoInfo));
  7537.  
  7538. if (repoInfo) {
  7539. _context.next = 9;
  7540. break;
  7541. }
  7542.  
  7543. return _context.abrupt('return', console.error('can\'t parse ' + npmPackage.repository.url));
  7544.  
  7545. case 9:
  7546. if (!(repoInfo.host !== 'github.com')) {
  7547. _context.next = 11;
  7548. break;
  7549. }
  7550.  
  7551. return _context.abrupt('return', console.error(repoInfo.href + ' is not a github repository'));
  7552.  
  7553. case 11:
  7554. _context.next = 13;
  7555. return __WEBPACK_IMPORTED_MODULE_6__github__["a" /* default */].fetchRepoInfo(repoInfo.repo);
  7556.  
  7557. case 13:
  7558. gitRepoInfo = _context.sent;
  7559.  
  7560.  
  7561. __WEBPACK_IMPORTED_MODULE_8__env__["a" /* default */].dev && detailEle.setAttribute('github-info', __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_json_stringify___default()(gitRepoInfo));
  7562.  
  7563. _github$createWidget = __WEBPACK_IMPORTED_MODULE_6__github__["a" /* default */].createWidget('span')({
  7564. watch: gitRepoInfo.subscribers_count,
  7565. star: gitRepoInfo.watchers_count,
  7566. fork: gitRepoInfo.forks_count
  7567. }), container = _github$createWidget.container;
  7568.  
  7569. container.style.display = 'inline-block';
  7570. container.style.marginLeft = '5px';
  7571. detailEle.querySelector('h3').appendChild(container);
  7572.  
  7573. case 19:
  7574. case 'end':
  7575. return _context.stop();
  7576. }
  7577. }
  7578. }, _callee, _this);
  7579. }));
  7580.  
  7581. return function (_x) {
  7582. return _ref2.apply(this, arguments);
  7583. };
  7584. }());
  7585.  
  7586. case 3:
  7587. case 'end':
  7588. return _context2.stop();
  7589. }
  7590. }
  7591. }, _callee2, this);
  7592. }));
  7593.  
  7594. return function searchPageHandler() {
  7595. return _ref.apply(this, arguments);
  7596. };
  7597. }();
  7598.  
  7599.  
  7600.  
  7601.  
  7602.  
  7603.  
  7604.  
  7605.  
  7606. var __pushState__ = history.pushState;
  7607.  
  7608. window.history["pushState"] = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_7__utils__["d" /* debounce */])(function () {
  7609. searchPageHandler();
  7610. return __pushState__.apply(this, arguments);
  7611. }, 100);
  7612.  
  7613. /* harmony default export */ __webpack_exports__["a"] = function () {
  7614. return searchPageHandler;
  7615. };
  7616.  
  7617. /***/ }),
  7618. /* 53 */
  7619. /***/ (function(module, exports, __webpack_require__) {
  7620.  
  7621. // style-loader: Adds some css to the DOM by adding a <style> tag
  7622.  
  7623. // load the styles
  7624. var content = __webpack_require__(96);
  7625. if(typeof content === 'string') content = [[module.i, content, '']];
  7626. // add the styles to the DOM
  7627. var update = __webpack_require__(109)(content, {});
  7628. if(content.locals) module.exports = content.locals;
  7629. // Hot Module Replacement
  7630. if(false) {
  7631. // When the styles change, update the <style> tags
  7632. if(!content.locals) {
  7633. module.hot.accept("!!../node_modules/css-loader/index.js!./index.css", function() {
  7634. var newContent = require("!!../node_modules/css-loader/index.js!./index.css");
  7635. if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
  7636. update(newContent);
  7637. });
  7638. }
  7639. // When the module is disposed, remove the <style> tags
  7640. module.hot.dispose(function() { update(); });
  7641. }
  7642.  
  7643. /***/ }),
  7644. /* 54 */
  7645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7646.  
  7647. "use strict";
  7648.  
  7649.  
  7650. function createSvg(_ref) {
  7651. var path = _ref.path,
  7652. width = _ref.width,
  7653. height = _ref.height;
  7654.  
  7655. var NS = "http://www.w3.org/2000/svg";
  7656. var svg = document.createElementNS(NS, "svg");
  7657. var p = document.createElementNS(NS, "path");
  7658. svg.setAttribute('version', '1.1');
  7659. svg.setAttribute('width', width + '');
  7660. svg.setAttribute('height', height + '');
  7661.  
  7662. p.setAttributeNS(null, "fill-rule", "evenodd");
  7663. p.setAttributeNS(null, "d", path);
  7664. svg.appendChild(p);
  7665. return svg;
  7666. }
  7667.  
  7668. var svg = {
  7669. github: createSvg({
  7670. path: 'M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z',
  7671. width: 14,
  7672. height: 14
  7673. }),
  7674. watch: createSvg({
  7675. path: 'M8.06 2C3 2 0 8 0 8s3 6 8.06 6C13 14 16 8 16 8s-3-6-7.94-6zM8 12c-2.2 0-4-1.78-4-4 0-2.2 1.8-4 4-4 2.22 0 4 1.8 4 4 0 2.22-1.78 4-4 4zm2-4c0 1.11-.89 2-2 2-1.11 0-2-.89-2-2 0-1.11.89-2 2-2 1.11 0 2 .89 2 2z',
  7676. width: 16,
  7677. height: 14
  7678. }),
  7679. star: createSvg({
  7680. path: 'M14 6l-4.9-.64L7 1 4.9 5.36 0 6l3.6 3.26L2.67 14 7 11.67 11.33 14l-.93-4.74z',
  7681. width: 14,
  7682. height: 14
  7683. }),
  7684. fork: createSvg({
  7685. path: 'M8 1a1.993 1.993 0 0 0-1 3.72V6L5 8 3 6V4.72A1.993 1.993 0 0 0 2 1a1.993 1.993 0 0 0-1 3.72V6.5l3 3v1.78A1.993 1.993 0 0 0 5 15a1.993 1.993 0 0 0 1-3.72V9.5l3-3V4.72A1.993 1.993 0 0 0 8 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2 0-.65.55-1.2 1.2-1.2.65 0 1.2.55 1.2 1.2 0 .65-.55 1.2-1.2 1.2z',
  7686. width: 12,
  7687. height: 14
  7688. })
  7689. };
  7690.  
  7691. /* harmony default export */ __webpack_exports__["a"] = svg;
  7692.  
  7693. /***/ }),
  7694. /* 55 */
  7695. /***/ (function(module, exports, __webpack_require__) {
  7696.  
  7697. module.exports = { "default": __webpack_require__(63), __esModule: true };
  7698.  
  7699. /***/ }),
  7700. /* 56 */
  7701. /***/ (function(module, exports, __webpack_require__) {
  7702.  
  7703. module.exports = { "default": __webpack_require__(65), __esModule: true };
  7704.  
  7705. /***/ }),
  7706. /* 57 */
  7707. /***/ (function(module, exports, __webpack_require__) {
  7708.  
  7709. module.exports = { "default": __webpack_require__(66), __esModule: true };
  7710.  
  7711. /***/ }),
  7712. /* 58 */
  7713. /***/ (function(module, exports, __webpack_require__) {
  7714.  
  7715. "use strict";
  7716.  
  7717.  
  7718. exports.__esModule = true;
  7719.  
  7720. exports.default = function (instance, Constructor) {
  7721. if (!(instance instanceof Constructor)) {
  7722. throw new TypeError("Cannot call a class as a function");
  7723. }
  7724. };
  7725.  
  7726. /***/ }),
  7727. /* 59 */
  7728. /***/ (function(module, exports, __webpack_require__) {
  7729.  
  7730. "use strict";
  7731.  
  7732.  
  7733. exports.__esModule = true;
  7734.  
  7735. var _defineProperty = __webpack_require__(56);
  7736.  
  7737. var _defineProperty2 = _interopRequireDefault(_defineProperty);
  7738.  
  7739. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7740.  
  7741. exports.default = function () {
  7742. function defineProperties(target, props) {
  7743. for (var i = 0; i < props.length; i++) {
  7744. var descriptor = props[i];
  7745. descriptor.enumerable = descriptor.enumerable || false;
  7746. descriptor.configurable = true;
  7747. if ("value" in descriptor) descriptor.writable = true;
  7748. (0, _defineProperty2.default)(target, descriptor.key, descriptor);
  7749. }
  7750. }
  7751.  
  7752. return function (Constructor, protoProps, staticProps) {
  7753. if (protoProps) defineProperties(Constructor.prototype, protoProps);
  7754. if (staticProps) defineProperties(Constructor, staticProps);
  7755. return Constructor;
  7756. };
  7757. }();
  7758.  
  7759. /***/ }),
  7760. /* 60 */
  7761. /***/ (function(module, exports, __webpack_require__) {
  7762.  
  7763. "use strict";
  7764.  
  7765.  
  7766. exports.__esModule = true;
  7767.  
  7768. var _from = __webpack_require__(55);
  7769.  
  7770. var _from2 = _interopRequireDefault(_from);
  7771.  
  7772. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  7773.  
  7774. exports.default = function (arr) {
  7775. if (Array.isArray(arr)) {
  7776. for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
  7777. arr2[i] = arr[i];
  7778. }
  7779.  
  7780. return arr2;
  7781. } else {
  7782. return (0, _from2.default)(arr);
  7783. }
  7784. };
  7785.  
  7786. /***/ }),
  7787. /* 61 */
  7788. /***/ (function(module, exports, __webpack_require__) {
  7789.  
  7790. "use strict";
  7791.  
  7792.  
  7793. exports.byteLength = byteLength
  7794. exports.toByteArray = toByteArray
  7795. exports.fromByteArray = fromByteArray
  7796.  
  7797. var lookup = []
  7798. var revLookup = []
  7799. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  7800.  
  7801. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  7802. for (var i = 0, len = code.length; i < len; ++i) {
  7803. lookup[i] = code[i]
  7804. revLookup[code.charCodeAt(i)] = i
  7805. }
  7806.  
  7807. revLookup['-'.charCodeAt(0)] = 62
  7808. revLookup['_'.charCodeAt(0)] = 63
  7809.  
  7810. function placeHoldersCount (b64) {
  7811. var len = b64.length
  7812. if (len % 4 > 0) {
  7813. throw new Error('Invalid string. Length must be a multiple of 4')
  7814. }
  7815.  
  7816. // the number of equal signs (place holders)
  7817. // if there are two placeholders, than the two characters before it
  7818. // represent one byte
  7819. // if there is only one, then the three characters before it represent 2 bytes
  7820. // this is just a cheap hack to not do indexOf twice
  7821. return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
  7822. }
  7823.  
  7824. function byteLength (b64) {
  7825. // base64 is 4/3 + up to two characters of the original data
  7826. return b64.length * 3 / 4 - placeHoldersCount(b64)
  7827. }
  7828.  
  7829. function toByteArray (b64) {
  7830. var i, j, l, tmp, placeHolders, arr
  7831. var len = b64.length
  7832. placeHolders = placeHoldersCount(b64)
  7833.  
  7834. arr = new Arr(len * 3 / 4 - placeHolders)
  7835.  
  7836. // if there are placeholders, only get up to the last complete 4 chars
  7837. l = placeHolders > 0 ? len - 4 : len
  7838.  
  7839. var L = 0
  7840.  
  7841. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  7842. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
  7843. arr[L++] = (tmp >> 16) & 0xFF
  7844. arr[L++] = (tmp >> 8) & 0xFF
  7845. arr[L++] = tmp & 0xFF
  7846. }
  7847.  
  7848. if (placeHolders === 2) {
  7849. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
  7850. arr[L++] = tmp & 0xFF
  7851. } else if (placeHolders === 1) {
  7852. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
  7853. arr[L++] = (tmp >> 8) & 0xFF
  7854. arr[L++] = tmp & 0xFF
  7855. }
  7856.  
  7857. return arr
  7858. }
  7859.  
  7860. function tripletToBase64 (num) {
  7861. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  7862. }
  7863.  
  7864. function encodeChunk (uint8, start, end) {
  7865. var tmp
  7866. var output = []
  7867. for (var i = start; i < end; i += 3) {
  7868. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
  7869. output.push(tripletToBase64(tmp))
  7870. }
  7871. return output.join('')
  7872. }
  7873.  
  7874. function fromByteArray (uint8) {
  7875. var tmp
  7876. var len = uint8.length
  7877. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  7878. var output = ''
  7879. var parts = []
  7880. var maxChunkLength = 16383 // must be multiple of 3
  7881.  
  7882. // go through the array every three bytes, we'll deal with trailing stuff later
  7883. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  7884. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  7885. }
  7886.  
  7887. // pad the end with zeros, but make sure to not forget the extra bytes
  7888. if (extraBytes === 1) {
  7889. tmp = uint8[len - 1]
  7890. output += lookup[tmp >> 2]
  7891. output += lookup[(tmp << 4) & 0x3F]
  7892. output += '=='
  7893. } else if (extraBytes === 2) {
  7894. tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
  7895. output += lookup[tmp >> 10]
  7896. output += lookup[(tmp >> 4) & 0x3F]
  7897. output += lookup[(tmp << 2) & 0x3F]
  7898. output += '='
  7899. }
  7900.  
  7901. parts.push(output)
  7902.  
  7903. return parts.join('')
  7904. }
  7905.  
  7906.  
  7907. /***/ }),
  7908. /* 62 */
  7909. /***/ (function(module, exports, __webpack_require__) {
  7910.  
  7911. "use strict";
  7912. /* WEBPACK VAR INJECTION */(function(global) {/*!
  7913. * The buffer module from node.js, for the browser.
  7914. *
  7915. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  7916. * @license MIT
  7917. */
  7918. /* eslint-disable no-proto */
  7919.  
  7920.  
  7921.  
  7922. var base64 = __webpack_require__(61)
  7923. var ieee754 = __webpack_require__(100)
  7924. var isArray = __webpack_require__(101)
  7925.  
  7926. exports.Buffer = Buffer
  7927. exports.SlowBuffer = SlowBuffer
  7928. exports.INSPECT_MAX_BYTES = 50
  7929.  
  7930. /**
  7931. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  7932. * === true Use Uint8Array implementation (fastest)
  7933. * === false Use Object implementation (most compatible, even IE6)
  7934. *
  7935. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  7936. * Opera 11.6+, iOS 4.2+.
  7937. *
  7938. * Due to various browser bugs, sometimes the Object implementation will be used even
  7939. * when the browser supports typed arrays.
  7940. *
  7941. * Note:
  7942. *
  7943. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  7944. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  7945. *
  7946. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  7947. *
  7948. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  7949. * incorrect length in some situations.
  7950.  
  7951. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  7952. * get the Object implementation, which is slower but behaves correctly.
  7953. */
  7954. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  7955. ? global.TYPED_ARRAY_SUPPORT
  7956. : typedArraySupport()
  7957.  
  7958. /*
  7959. * Export kMaxLength after typed array support is determined.
  7960. */
  7961. exports.kMaxLength = kMaxLength()
  7962.  
  7963. function typedArraySupport () {
  7964. try {
  7965. var arr = new Uint8Array(1)
  7966. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  7967. return arr.foo() === 42 && // typed array instances can be augmented
  7968. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  7969. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  7970. } catch (e) {
  7971. return false
  7972. }
  7973. }
  7974.  
  7975. function kMaxLength () {
  7976. return Buffer.TYPED_ARRAY_SUPPORT
  7977. ? 0x7fffffff
  7978. : 0x3fffffff
  7979. }
  7980.  
  7981. function createBuffer (that, length) {
  7982. if (kMaxLength() < length) {
  7983. throw new RangeError('Invalid typed array length')
  7984. }
  7985. if (Buffer.TYPED_ARRAY_SUPPORT) {
  7986. // Return an augmented `Uint8Array` instance, for best performance
  7987. that = new Uint8Array(length)
  7988. that.__proto__ = Buffer.prototype
  7989. } else {
  7990. // Fallback: Return an object instance of the Buffer class
  7991. if (that === null) {
  7992. that = new Buffer(length)
  7993. }
  7994. that.length = length
  7995. }
  7996.  
  7997. return that
  7998. }
  7999.  
  8000. /**
  8001. * The Buffer constructor returns instances of `Uint8Array` that have their
  8002. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  8003. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  8004. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  8005. * returns a single octet.
  8006. *
  8007. * The `Uint8Array` prototype remains unmodified.
  8008. */
  8009.  
  8010. function Buffer (arg, encodingOrOffset, length) {
  8011. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  8012. return new Buffer(arg, encodingOrOffset, length)
  8013. }
  8014.  
  8015. // Common case.
  8016. if (typeof arg === 'number') {
  8017. if (typeof encodingOrOffset === 'string') {
  8018. throw new Error(
  8019. 'If encoding is specified then the first argument must be a string'
  8020. )
  8021. }
  8022. return allocUnsafe(this, arg)
  8023. }
  8024. return from(this, arg, encodingOrOffset, length)
  8025. }
  8026.  
  8027. Buffer.poolSize = 8192 // not used by this implementation
  8028.  
  8029. // TODO: Legacy, not needed anymore. Remove in next major version.
  8030. Buffer._augment = function (arr) {
  8031. arr.__proto__ = Buffer.prototype
  8032. return arr
  8033. }
  8034.  
  8035. function from (that, value, encodingOrOffset, length) {
  8036. if (typeof value === 'number') {
  8037. throw new TypeError('"value" argument must not be a number')
  8038. }
  8039.  
  8040. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  8041. return fromArrayBuffer(that, value, encodingOrOffset, length)
  8042. }
  8043.  
  8044. if (typeof value === 'string') {
  8045. return fromString(that, value, encodingOrOffset)
  8046. }
  8047.  
  8048. return fromObject(that, value)
  8049. }
  8050.  
  8051. /**
  8052. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  8053. * if value is a number.
  8054. * Buffer.from(str[, encoding])
  8055. * Buffer.from(array)
  8056. * Buffer.from(buffer)
  8057. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  8058. **/
  8059. Buffer.from = function (value, encodingOrOffset, length) {
  8060. return from(null, value, encodingOrOffset, length)
  8061. }
  8062.  
  8063. if (Buffer.TYPED_ARRAY_SUPPORT) {
  8064. Buffer.prototype.__proto__ = Uint8Array.prototype
  8065. Buffer.__proto__ = Uint8Array
  8066. if (typeof Symbol !== 'undefined' && Symbol.species &&
  8067. Buffer[Symbol.species] === Buffer) {
  8068. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  8069. Object.defineProperty(Buffer, Symbol.species, {
  8070. value: null,
  8071. configurable: true
  8072. })
  8073. }
  8074. }
  8075.  
  8076. function assertSize (size) {
  8077. if (typeof size !== 'number') {
  8078. throw new TypeError('"size" argument must be a number')
  8079. } else if (size < 0) {
  8080. throw new RangeError('"size" argument must not be negative')
  8081. }
  8082. }
  8083.  
  8084. function alloc (that, size, fill, encoding) {
  8085. assertSize(size)
  8086. if (size <= 0) {
  8087. return createBuffer(that, size)
  8088. }
  8089. if (fill !== undefined) {
  8090. // Only pay attention to encoding if it's a string. This
  8091. // prevents accidentally sending in a number that would
  8092. // be interpretted as a start offset.
  8093. return typeof encoding === 'string'
  8094. ? createBuffer(that, size).fill(fill, encoding)
  8095. : createBuffer(that, size).fill(fill)
  8096. }
  8097. return createBuffer(that, size)
  8098. }
  8099.  
  8100. /**
  8101. * Creates a new filled Buffer instance.
  8102. * alloc(size[, fill[, encoding]])
  8103. **/
  8104. Buffer.alloc = function (size, fill, encoding) {
  8105. return alloc(null, size, fill, encoding)
  8106. }
  8107.  
  8108. function allocUnsafe (that, size) {
  8109. assertSize(size)
  8110. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  8111. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  8112. for (var i = 0; i < size; ++i) {
  8113. that[i] = 0
  8114. }
  8115. }
  8116. return that
  8117. }
  8118.  
  8119. /**
  8120. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  8121. * */
  8122. Buffer.allocUnsafe = function (size) {
  8123. return allocUnsafe(null, size)
  8124. }
  8125. /**
  8126. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  8127. */
  8128. Buffer.allocUnsafeSlow = function (size) {
  8129. return allocUnsafe(null, size)
  8130. }
  8131.  
  8132. function fromString (that, string, encoding) {
  8133. if (typeof encoding !== 'string' || encoding === '') {
  8134. encoding = 'utf8'
  8135. }
  8136.  
  8137. if (!Buffer.isEncoding(encoding)) {
  8138. throw new TypeError('"encoding" must be a valid string encoding')
  8139. }
  8140.  
  8141. var length = byteLength(string, encoding) | 0
  8142. that = createBuffer(that, length)
  8143.  
  8144. var actual = that.write(string, encoding)
  8145.  
  8146. if (actual !== length) {
  8147. // Writing a hex string, for example, that contains invalid characters will
  8148. // cause everything after the first invalid character to be ignored. (e.g.
  8149. // 'abxxcd' will be treated as 'ab')
  8150. that = that.slice(0, actual)
  8151. }
  8152.  
  8153. return that
  8154. }
  8155.  
  8156. function fromArrayLike (that, array) {
  8157. var length = array.length < 0 ? 0 : checked(array.length) | 0
  8158. that = createBuffer(that, length)
  8159. for (var i = 0; i < length; i += 1) {
  8160. that[i] = array[i] & 255
  8161. }
  8162. return that
  8163. }
  8164.  
  8165. function fromArrayBuffer (that, array, byteOffset, length) {
  8166. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  8167.  
  8168. if (byteOffset < 0 || array.byteLength < byteOffset) {
  8169. throw new RangeError('\'offset\' is out of bounds')
  8170. }
  8171.  
  8172. if (array.byteLength < byteOffset + (length || 0)) {
  8173. throw new RangeError('\'length\' is out of bounds')
  8174. }
  8175.  
  8176. if (byteOffset === undefined && length === undefined) {
  8177. array = new Uint8Array(array)
  8178. } else if (length === undefined) {
  8179. array = new Uint8Array(array, byteOffset)
  8180. } else {
  8181. array = new Uint8Array(array, byteOffset, length)
  8182. }
  8183.  
  8184. if (Buffer.TYPED_ARRAY_SUPPORT) {
  8185. // Return an augmented `Uint8Array` instance, for best performance
  8186. that = array
  8187. that.__proto__ = Buffer.prototype
  8188. } else {
  8189. // Fallback: Return an object instance of the Buffer class
  8190. that = fromArrayLike(that, array)
  8191. }
  8192. return that
  8193. }
  8194.  
  8195. function fromObject (that, obj) {
  8196. if (Buffer.isBuffer(obj)) {
  8197. var len = checked(obj.length) | 0
  8198. that = createBuffer(that, len)
  8199.  
  8200. if (that.length === 0) {
  8201. return that
  8202. }
  8203.  
  8204. obj.copy(that, 0, 0, len)
  8205. return that
  8206. }
  8207.  
  8208. if (obj) {
  8209. if ((typeof ArrayBuffer !== 'undefined' &&
  8210. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  8211. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  8212. return createBuffer(that, 0)
  8213. }
  8214. return fromArrayLike(that, obj)
  8215. }
  8216.  
  8217. if (obj.type === 'Buffer' && isArray(obj.data)) {
  8218. return fromArrayLike(that, obj.data)
  8219. }
  8220. }
  8221.  
  8222. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  8223. }
  8224.  
  8225. function checked (length) {
  8226. // Note: cannot use `length < kMaxLength()` here because that fails when
  8227. // length is NaN (which is otherwise coerced to zero.)
  8228. if (length >= kMaxLength()) {
  8229. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  8230. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  8231. }
  8232. return length | 0
  8233. }
  8234.  
  8235. function SlowBuffer (length) {
  8236. if (+length != length) { // eslint-disable-line eqeqeq
  8237. length = 0
  8238. }
  8239. return Buffer.alloc(+length)
  8240. }
  8241.  
  8242. Buffer.isBuffer = function isBuffer (b) {
  8243. return !!(b != null && b._isBuffer)
  8244. }
  8245.  
  8246. Buffer.compare = function compare (a, b) {
  8247. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  8248. throw new TypeError('Arguments must be Buffers')
  8249. }
  8250.  
  8251. if (a === b) return 0
  8252.  
  8253. var x = a.length
  8254. var y = b.length
  8255.  
  8256. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  8257. if (a[i] !== b[i]) {
  8258. x = a[i]
  8259. y = b[i]
  8260. break
  8261. }
  8262. }
  8263.  
  8264. if (x < y) return -1
  8265. if (y < x) return 1
  8266. return 0
  8267. }
  8268.  
  8269. Buffer.isEncoding = function isEncoding (encoding) {
  8270. switch (String(encoding).toLowerCase()) {
  8271. case 'hex':
  8272. case 'utf8':
  8273. case 'utf-8':
  8274. case 'ascii':
  8275. case 'latin1':
  8276. case 'binary':
  8277. case 'base64':
  8278. case 'ucs2':
  8279. case 'ucs-2':
  8280. case 'utf16le':
  8281. case 'utf-16le':
  8282. return true
  8283. default:
  8284. return false
  8285. }
  8286. }
  8287.  
  8288. Buffer.concat = function concat (list, length) {
  8289. if (!isArray(list)) {
  8290. throw new TypeError('"list" argument must be an Array of Buffers')
  8291. }
  8292.  
  8293. if (list.length === 0) {
  8294. return Buffer.alloc(0)
  8295. }
  8296.  
  8297. var i
  8298. if (length === undefined) {
  8299. length = 0
  8300. for (i = 0; i < list.length; ++i) {
  8301. length += list[i].length
  8302. }
  8303. }
  8304.  
  8305. var buffer = Buffer.allocUnsafe(length)
  8306. var pos = 0
  8307. for (i = 0; i < list.length; ++i) {
  8308. var buf = list[i]
  8309. if (!Buffer.isBuffer(buf)) {
  8310. throw new TypeError('"list" argument must be an Array of Buffers')
  8311. }
  8312. buf.copy(buffer, pos)
  8313. pos += buf.length
  8314. }
  8315. return buffer
  8316. }
  8317.  
  8318. function byteLength (string, encoding) {
  8319. if (Buffer.isBuffer(string)) {
  8320. return string.length
  8321. }
  8322. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  8323. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  8324. return string.byteLength
  8325. }
  8326. if (typeof string !== 'string') {
  8327. string = '' + string
  8328. }
  8329.  
  8330. var len = string.length
  8331. if (len === 0) return 0
  8332.  
  8333. // Use a for loop to avoid recursion
  8334. var loweredCase = false
  8335. for (;;) {
  8336. switch (encoding) {
  8337. case 'ascii':
  8338. case 'latin1':
  8339. case 'binary':
  8340. return len
  8341. case 'utf8':
  8342. case 'utf-8':
  8343. case undefined:
  8344. return utf8ToBytes(string).length
  8345. case 'ucs2':
  8346. case 'ucs-2':
  8347. case 'utf16le':
  8348. case 'utf-16le':
  8349. return len * 2
  8350. case 'hex':
  8351. return len >>> 1
  8352. case 'base64':
  8353. return base64ToBytes(string).length
  8354. default:
  8355. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  8356. encoding = ('' + encoding).toLowerCase()
  8357. loweredCase = true
  8358. }
  8359. }
  8360. }
  8361. Buffer.byteLength = byteLength
  8362.  
  8363. function slowToString (encoding, start, end) {
  8364. var loweredCase = false
  8365.  
  8366. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  8367. // property of a typed array.
  8368.  
  8369. // This behaves neither like String nor Uint8Array in that we set start/end
  8370. // to their upper/lower bounds if the value passed is out of range.
  8371. // undefined is handled specially as per ECMA-262 6th Edition,
  8372. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  8373. if (start === undefined || start < 0) {
  8374. start = 0
  8375. }
  8376. // Return early if start > this.length. Done here to prevent potential uint32
  8377. // coercion fail below.
  8378. if (start > this.length) {
  8379. return ''
  8380. }
  8381.  
  8382. if (end === undefined || end > this.length) {
  8383. end = this.length
  8384. }
  8385.  
  8386. if (end <= 0) {
  8387. return ''
  8388. }
  8389.  
  8390. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  8391. end >>>= 0
  8392. start >>>= 0
  8393.  
  8394. if (end <= start) {
  8395. return ''
  8396. }
  8397.  
  8398. if (!encoding) encoding = 'utf8'
  8399.  
  8400. while (true) {
  8401. switch (encoding) {
  8402. case 'hex':
  8403. return hexSlice(this, start, end)
  8404.  
  8405. case 'utf8':
  8406. case 'utf-8':
  8407. return utf8Slice(this, start, end)
  8408.  
  8409. case 'ascii':
  8410. return asciiSlice(this, start, end)
  8411.  
  8412. case 'latin1':
  8413. case 'binary':
  8414. return latin1Slice(this, start, end)
  8415.  
  8416. case 'base64':
  8417. return base64Slice(this, start, end)
  8418.  
  8419. case 'ucs2':
  8420. case 'ucs-2':
  8421. case 'utf16le':
  8422. case 'utf-16le':
  8423. return utf16leSlice(this, start, end)
  8424.  
  8425. default:
  8426. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  8427. encoding = (encoding + '').toLowerCase()
  8428. loweredCase = true
  8429. }
  8430. }
  8431. }
  8432.  
  8433. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  8434. // Buffer instances.
  8435. Buffer.prototype._isBuffer = true
  8436.  
  8437. function swap (b, n, m) {
  8438. var i = b[n]
  8439. b[n] = b[m]
  8440. b[m] = i
  8441. }
  8442.  
  8443. Buffer.prototype.swap16 = function swap16 () {
  8444. var len = this.length
  8445. if (len % 2 !== 0) {
  8446. throw new RangeError('Buffer size must be a multiple of 16-bits')
  8447. }
  8448. for (var i = 0; i < len; i += 2) {
  8449. swap(this, i, i + 1)
  8450. }
  8451. return this
  8452. }
  8453.  
  8454. Buffer.prototype.swap32 = function swap32 () {
  8455. var len = this.length
  8456. if (len % 4 !== 0) {
  8457. throw new RangeError('Buffer size must be a multiple of 32-bits')
  8458. }
  8459. for (var i = 0; i < len; i += 4) {
  8460. swap(this, i, i + 3)
  8461. swap(this, i + 1, i + 2)
  8462. }
  8463. return this
  8464. }
  8465.  
  8466. Buffer.prototype.swap64 = function swap64 () {
  8467. var len = this.length
  8468. if (len % 8 !== 0) {
  8469. throw new RangeError('Buffer size must be a multiple of 64-bits')
  8470. }
  8471. for (var i = 0; i < len; i += 8) {
  8472. swap(this, i, i + 7)
  8473. swap(this, i + 1, i + 6)
  8474. swap(this, i + 2, i + 5)
  8475. swap(this, i + 3, i + 4)
  8476. }
  8477. return this
  8478. }
  8479.  
  8480. Buffer.prototype.toString = function toString () {
  8481. var length = this.length | 0
  8482. if (length === 0) return ''
  8483. if (arguments.length === 0) return utf8Slice(this, 0, length)
  8484. return slowToString.apply(this, arguments)
  8485. }
  8486.  
  8487. Buffer.prototype.equals = function equals (b) {
  8488. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  8489. if (this === b) return true
  8490. return Buffer.compare(this, b) === 0
  8491. }
  8492.  
  8493. Buffer.prototype.inspect = function inspect () {
  8494. var str = ''
  8495. var max = exports.INSPECT_MAX_BYTES
  8496. if (this.length > 0) {
  8497. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  8498. if (this.length > max) str += ' ... '
  8499. }
  8500. return '<Buffer ' + str + '>'
  8501. }
  8502.  
  8503. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  8504. if (!Buffer.isBuffer(target)) {
  8505. throw new TypeError('Argument must be a Buffer')
  8506. }
  8507.  
  8508. if (start === undefined) {
  8509. start = 0
  8510. }
  8511. if (end === undefined) {
  8512. end = target ? target.length : 0
  8513. }
  8514. if (thisStart === undefined) {
  8515. thisStart = 0
  8516. }
  8517. if (thisEnd === undefined) {
  8518. thisEnd = this.length
  8519. }
  8520.  
  8521. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  8522. throw new RangeError('out of range index')
  8523. }
  8524.  
  8525. if (thisStart >= thisEnd && start >= end) {
  8526. return 0
  8527. }
  8528. if (thisStart >= thisEnd) {
  8529. return -1
  8530. }
  8531. if (start >= end) {
  8532. return 1
  8533. }
  8534.  
  8535. start >>>= 0
  8536. end >>>= 0
  8537. thisStart >>>= 0
  8538. thisEnd >>>= 0
  8539.  
  8540. if (this === target) return 0
  8541.  
  8542. var x = thisEnd - thisStart
  8543. var y = end - start
  8544. var len = Math.min(x, y)
  8545.  
  8546. var thisCopy = this.slice(thisStart, thisEnd)
  8547. var targetCopy = target.slice(start, end)
  8548.  
  8549. for (var i = 0; i < len; ++i) {
  8550. if (thisCopy[i] !== targetCopy[i]) {
  8551. x = thisCopy[i]
  8552. y = targetCopy[i]
  8553. break
  8554. }
  8555. }
  8556.  
  8557. if (x < y) return -1
  8558. if (y < x) return 1
  8559. return 0
  8560. }
  8561.  
  8562. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  8563. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  8564. //
  8565. // Arguments:
  8566. // - buffer - a Buffer to search
  8567. // - val - a string, Buffer, or number
  8568. // - byteOffset - an index into `buffer`; will be clamped to an int32
  8569. // - encoding - an optional encoding, relevant is val is a string
  8570. // - dir - true for indexOf, false for lastIndexOf
  8571. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  8572. // Empty buffer means no match
  8573. if (buffer.length === 0) return -1
  8574.  
  8575. // Normalize byteOffset
  8576. if (typeof byteOffset === 'string') {
  8577. encoding = byteOffset
  8578. byteOffset = 0
  8579. } else if (byteOffset > 0x7fffffff) {
  8580. byteOffset = 0x7fffffff
  8581. } else if (byteOffset < -0x80000000) {
  8582. byteOffset = -0x80000000
  8583. }
  8584. byteOffset = +byteOffset // Coerce to Number.
  8585. if (isNaN(byteOffset)) {
  8586. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  8587. byteOffset = dir ? 0 : (buffer.length - 1)
  8588. }
  8589.  
  8590. // Normalize byteOffset: negative offsets start from the end of the buffer
  8591. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  8592. if (byteOffset >= buffer.length) {
  8593. if (dir) return -1
  8594. else byteOffset = buffer.length - 1
  8595. } else if (byteOffset < 0) {
  8596. if (dir) byteOffset = 0
  8597. else return -1
  8598. }
  8599.  
  8600. // Normalize val
  8601. if (typeof val === 'string') {
  8602. val = Buffer.from(val, encoding)
  8603. }
  8604.  
  8605. // Finally, search either indexOf (if dir is true) or lastIndexOf
  8606. if (Buffer.isBuffer(val)) {
  8607. // Special case: looking for empty string/buffer always fails
  8608. if (val.length === 0) {
  8609. return -1
  8610. }
  8611. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  8612. } else if (typeof val === 'number') {
  8613. val = val & 0xFF // Search for a byte value [0-255]
  8614. if (Buffer.TYPED_ARRAY_SUPPORT &&
  8615. typeof Uint8Array.prototype.indexOf === 'function') {
  8616. if (dir) {
  8617. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  8618. } else {
  8619. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  8620. }
  8621. }
  8622. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  8623. }
  8624.  
  8625. throw new TypeError('val must be string, number or Buffer')
  8626. }
  8627.  
  8628. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  8629. var indexSize = 1
  8630. var arrLength = arr.length
  8631. var valLength = val.length
  8632.  
  8633. if (encoding !== undefined) {
  8634. encoding = String(encoding).toLowerCase()
  8635. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  8636. encoding === 'utf16le' || encoding === 'utf-16le') {
  8637. if (arr.length < 2 || val.length < 2) {
  8638. return -1
  8639. }
  8640. indexSize = 2
  8641. arrLength /= 2
  8642. valLength /= 2
  8643. byteOffset /= 2
  8644. }
  8645. }
  8646.  
  8647. function read (buf, i) {
  8648. if (indexSize === 1) {
  8649. return buf[i]
  8650. } else {
  8651. return buf.readUInt16BE(i * indexSize)
  8652. }
  8653. }
  8654.  
  8655. var i
  8656. if (dir) {
  8657. var foundIndex = -1
  8658. for (i = byteOffset; i < arrLength; i++) {
  8659. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  8660. if (foundIndex === -1) foundIndex = i
  8661. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  8662. } else {
  8663. if (foundIndex !== -1) i -= i - foundIndex
  8664. foundIndex = -1
  8665. }
  8666. }
  8667. } else {
  8668. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  8669. for (i = byteOffset; i >= 0; i--) {
  8670. var found = true
  8671. for (var j = 0; j < valLength; j++) {
  8672. if (read(arr, i + j) !== read(val, j)) {
  8673. found = false
  8674. break
  8675. }
  8676. }
  8677. if (found) return i
  8678. }
  8679. }
  8680.  
  8681. return -1
  8682. }
  8683.  
  8684. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  8685. return this.indexOf(val, byteOffset, encoding) !== -1
  8686. }
  8687.  
  8688. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  8689. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  8690. }
  8691.  
  8692. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  8693. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  8694. }
  8695.  
  8696. function hexWrite (buf, string, offset, length) {
  8697. offset = Number(offset) || 0
  8698. var remaining = buf.length - offset
  8699. if (!length) {
  8700. length = remaining
  8701. } else {
  8702. length = Number(length)
  8703. if (length > remaining) {
  8704. length = remaining
  8705. }
  8706. }
  8707.  
  8708. // must be an even number of digits
  8709. var strLen = string.length
  8710. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  8711.  
  8712. if (length > strLen / 2) {
  8713. length = strLen / 2
  8714. }
  8715. for (var i = 0; i < length; ++i) {
  8716. var parsed = parseInt(string.substr(i * 2, 2), 16)
  8717. if (isNaN(parsed)) return i
  8718. buf[offset + i] = parsed
  8719. }
  8720. return i
  8721. }
  8722.  
  8723. function utf8Write (buf, string, offset, length) {
  8724. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  8725. }
  8726.  
  8727. function asciiWrite (buf, string, offset, length) {
  8728. return blitBuffer(asciiToBytes(string), buf, offset, length)
  8729. }
  8730.  
  8731. function latin1Write (buf, string, offset, length) {
  8732. return asciiWrite(buf, string, offset, length)
  8733. }
  8734.  
  8735. function base64Write (buf, string, offset, length) {
  8736. return blitBuffer(base64ToBytes(string), buf, offset, length)
  8737. }
  8738.  
  8739. function ucs2Write (buf, string, offset, length) {
  8740. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  8741. }
  8742.  
  8743. Buffer.prototype.write = function write (string, offset, length, encoding) {
  8744. // Buffer#write(string)
  8745. if (offset === undefined) {
  8746. encoding = 'utf8'
  8747. length = this.length
  8748. offset = 0
  8749. // Buffer#write(string, encoding)
  8750. } else if (length === undefined && typeof offset === 'string') {
  8751. encoding = offset
  8752. length = this.length
  8753. offset = 0
  8754. // Buffer#write(string, offset[, length][, encoding])
  8755. } else if (isFinite(offset)) {
  8756. offset = offset | 0
  8757. if (isFinite(length)) {
  8758. length = length | 0
  8759. if (encoding === undefined) encoding = 'utf8'
  8760. } else {
  8761. encoding = length
  8762. length = undefined
  8763. }
  8764. // legacy write(string, encoding, offset, length) - remove in v0.13
  8765. } else {
  8766. throw new Error(
  8767. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  8768. )
  8769. }
  8770.  
  8771. var remaining = this.length - offset
  8772. if (length === undefined || length > remaining) length = remaining
  8773.  
  8774. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  8775. throw new RangeError('Attempt to write outside buffer bounds')
  8776. }
  8777.  
  8778. if (!encoding) encoding = 'utf8'
  8779.  
  8780. var loweredCase = false
  8781. for (;;) {
  8782. switch (encoding) {
  8783. case 'hex':
  8784. return hexWrite(this, string, offset, length)
  8785.  
  8786. case 'utf8':
  8787. case 'utf-8':
  8788. return utf8Write(this, string, offset, length)
  8789.  
  8790. case 'ascii':
  8791. return asciiWrite(this, string, offset, length)
  8792.  
  8793. case 'latin1':
  8794. case 'binary':
  8795. return latin1Write(this, string, offset, length)
  8796.  
  8797. case 'base64':
  8798. // Warning: maxLength not taken into account in base64Write
  8799. return base64Write(this, string, offset, length)
  8800.  
  8801. case 'ucs2':
  8802. case 'ucs-2':
  8803. case 'utf16le':
  8804. case 'utf-16le':
  8805. return ucs2Write(this, string, offset, length)
  8806.  
  8807. default:
  8808. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  8809. encoding = ('' + encoding).toLowerCase()
  8810. loweredCase = true
  8811. }
  8812. }
  8813. }
  8814.  
  8815. Buffer.prototype.toJSON = function toJSON () {
  8816. return {
  8817. type: 'Buffer',
  8818. data: Array.prototype.slice.call(this._arr || this, 0)
  8819. }
  8820. }
  8821.  
  8822. function base64Slice (buf, start, end) {
  8823. if (start === 0 && end === buf.length) {
  8824. return base64.fromByteArray(buf)
  8825. } else {
  8826. return base64.fromByteArray(buf.slice(start, end))
  8827. }
  8828. }
  8829.  
  8830. function utf8Slice (buf, start, end) {
  8831. end = Math.min(buf.length, end)
  8832. var res = []
  8833.  
  8834. var i = start
  8835. while (i < end) {
  8836. var firstByte = buf[i]
  8837. var codePoint = null
  8838. var bytesPerSequence = (firstByte > 0xEF) ? 4
  8839. : (firstByte > 0xDF) ? 3
  8840. : (firstByte > 0xBF) ? 2
  8841. : 1
  8842.  
  8843. if (i + bytesPerSequence <= end) {
  8844. var secondByte, thirdByte, fourthByte, tempCodePoint
  8845.  
  8846. switch (bytesPerSequence) {
  8847. case 1:
  8848. if (firstByte < 0x80) {
  8849. codePoint = firstByte
  8850. }
  8851. break
  8852. case 2:
  8853. secondByte = buf[i + 1]
  8854. if ((secondByte & 0xC0) === 0x80) {
  8855. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  8856. if (tempCodePoint > 0x7F) {
  8857. codePoint = tempCodePoint
  8858. }
  8859. }
  8860. break
  8861. case 3:
  8862. secondByte = buf[i + 1]
  8863. thirdByte = buf[i + 2]
  8864. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  8865. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  8866. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  8867. codePoint = tempCodePoint
  8868. }
  8869. }
  8870. break
  8871. case 4:
  8872. secondByte = buf[i + 1]
  8873. thirdByte = buf[i + 2]
  8874. fourthByte = buf[i + 3]
  8875. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  8876. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  8877. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  8878. codePoint = tempCodePoint
  8879. }
  8880. }
  8881. }
  8882. }
  8883.  
  8884. if (codePoint === null) {
  8885. // we did not generate a valid codePoint so insert a
  8886. // replacement char (U+FFFD) and advance only 1 byte
  8887. codePoint = 0xFFFD
  8888. bytesPerSequence = 1
  8889. } else if (codePoint > 0xFFFF) {
  8890. // encode to utf16 (surrogate pair dance)
  8891. codePoint -= 0x10000
  8892. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  8893. codePoint = 0xDC00 | codePoint & 0x3FF
  8894. }
  8895.  
  8896. res.push(codePoint)
  8897. i += bytesPerSequence
  8898. }
  8899.  
  8900. return decodeCodePointsArray(res)
  8901. }
  8902.  
  8903. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  8904. // the lowest limit is Chrome, with 0x10000 args.
  8905. // We go 1 magnitude less, for safety
  8906. var MAX_ARGUMENTS_LENGTH = 0x1000
  8907.  
  8908. function decodeCodePointsArray (codePoints) {
  8909. var len = codePoints.length
  8910. if (len <= MAX_ARGUMENTS_LENGTH) {
  8911. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  8912. }
  8913.  
  8914. // Decode in chunks to avoid "call stack size exceeded".
  8915. var res = ''
  8916. var i = 0
  8917. while (i < len) {
  8918. res += String.fromCharCode.apply(
  8919. String,
  8920. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  8921. )
  8922. }
  8923. return res
  8924. }
  8925.  
  8926. function asciiSlice (buf, start, end) {
  8927. var ret = ''
  8928. end = Math.min(buf.length, end)
  8929.  
  8930. for (var i = start; i < end; ++i) {
  8931. ret += String.fromCharCode(buf[i] & 0x7F)
  8932. }
  8933. return ret
  8934. }
  8935.  
  8936. function latin1Slice (buf, start, end) {
  8937. var ret = ''
  8938. end = Math.min(buf.length, end)
  8939.  
  8940. for (var i = start; i < end; ++i) {
  8941. ret += String.fromCharCode(buf[i])
  8942. }
  8943. return ret
  8944. }
  8945.  
  8946. function hexSlice (buf, start, end) {
  8947. var len = buf.length
  8948.  
  8949. if (!start || start < 0) start = 0
  8950. if (!end || end < 0 || end > len) end = len
  8951.  
  8952. var out = ''
  8953. for (var i = start; i < end; ++i) {
  8954. out += toHex(buf[i])
  8955. }
  8956. return out
  8957. }
  8958.  
  8959. function utf16leSlice (buf, start, end) {
  8960. var bytes = buf.slice(start, end)
  8961. var res = ''
  8962. for (var i = 0; i < bytes.length; i += 2) {
  8963. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  8964. }
  8965. return res
  8966. }
  8967.  
  8968. Buffer.prototype.slice = function slice (start, end) {
  8969. var len = this.length
  8970. start = ~~start
  8971. end = end === undefined ? len : ~~end
  8972.  
  8973. if (start < 0) {
  8974. start += len
  8975. if (start < 0) start = 0
  8976. } else if (start > len) {
  8977. start = len
  8978. }
  8979.  
  8980. if (end < 0) {
  8981. end += len
  8982. if (end < 0) end = 0
  8983. } else if (end > len) {
  8984. end = len
  8985. }
  8986.  
  8987. if (end < start) end = start
  8988.  
  8989. var newBuf
  8990. if (Buffer.TYPED_ARRAY_SUPPORT) {
  8991. newBuf = this.subarray(start, end)
  8992. newBuf.__proto__ = Buffer.prototype
  8993. } else {
  8994. var sliceLen = end - start
  8995. newBuf = new Buffer(sliceLen, undefined)
  8996. for (var i = 0; i < sliceLen; ++i) {
  8997. newBuf[i] = this[i + start]
  8998. }
  8999. }
  9000.  
  9001. return newBuf
  9002. }
  9003.  
  9004. /*
  9005. * Need to make sure that buffer isn't trying to write out of bounds.
  9006. */
  9007. function checkOffset (offset, ext, length) {
  9008. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  9009. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  9010. }
  9011.  
  9012. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  9013. offset = offset | 0
  9014. byteLength = byteLength | 0
  9015. if (!noAssert) checkOffset(offset, byteLength, this.length)
  9016.  
  9017. var val = this[offset]
  9018. var mul = 1
  9019. var i = 0
  9020. while (++i < byteLength && (mul *= 0x100)) {
  9021. val += this[offset + i] * mul
  9022. }
  9023.  
  9024. return val
  9025. }
  9026.  
  9027. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  9028. offset = offset | 0
  9029. byteLength = byteLength | 0
  9030. if (!noAssert) {
  9031. checkOffset(offset, byteLength, this.length)
  9032. }
  9033.  
  9034. var val = this[offset + --byteLength]
  9035. var mul = 1
  9036. while (byteLength > 0 && (mul *= 0x100)) {
  9037. val += this[offset + --byteLength] * mul
  9038. }
  9039.  
  9040. return val
  9041. }
  9042.  
  9043. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  9044. if (!noAssert) checkOffset(offset, 1, this.length)
  9045. return this[offset]
  9046. }
  9047.  
  9048. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  9049. if (!noAssert) checkOffset(offset, 2, this.length)
  9050. return this[offset] | (this[offset + 1] << 8)
  9051. }
  9052.  
  9053. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  9054. if (!noAssert) checkOffset(offset, 2, this.length)
  9055. return (this[offset] << 8) | this[offset + 1]
  9056. }
  9057.  
  9058. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  9059. if (!noAssert) checkOffset(offset, 4, this.length)
  9060.  
  9061. return ((this[offset]) |
  9062. (this[offset + 1] << 8) |
  9063. (this[offset + 2] << 16)) +
  9064. (this[offset + 3] * 0x1000000)
  9065. }
  9066.  
  9067. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  9068. if (!noAssert) checkOffset(offset, 4, this.length)
  9069.  
  9070. return (this[offset] * 0x1000000) +
  9071. ((this[offset + 1] << 16) |
  9072. (this[offset + 2] << 8) |
  9073. this[offset + 3])
  9074. }
  9075.  
  9076. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  9077. offset = offset | 0
  9078. byteLength = byteLength | 0
  9079. if (!noAssert) checkOffset(offset, byteLength, this.length)
  9080.  
  9081. var val = this[offset]
  9082. var mul = 1
  9083. var i = 0
  9084. while (++i < byteLength && (mul *= 0x100)) {
  9085. val += this[offset + i] * mul
  9086. }
  9087. mul *= 0x80
  9088.  
  9089. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  9090.  
  9091. return val
  9092. }
  9093.  
  9094. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  9095. offset = offset | 0
  9096. byteLength = byteLength | 0
  9097. if (!noAssert) checkOffset(offset, byteLength, this.length)
  9098.  
  9099. var i = byteLength
  9100. var mul = 1
  9101. var val = this[offset + --i]
  9102. while (i > 0 && (mul *= 0x100)) {
  9103. val += this[offset + --i] * mul
  9104. }
  9105. mul *= 0x80
  9106.  
  9107. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  9108.  
  9109. return val
  9110. }
  9111.  
  9112. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  9113. if (!noAssert) checkOffset(offset, 1, this.length)
  9114. if (!(this[offset] & 0x80)) return (this[offset])
  9115. return ((0xff - this[offset] + 1) * -1)
  9116. }
  9117.  
  9118. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  9119. if (!noAssert) checkOffset(offset, 2, this.length)
  9120. var val = this[offset] | (this[offset + 1] << 8)
  9121. return (val & 0x8000) ? val | 0xFFFF0000 : val
  9122. }
  9123.  
  9124. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  9125. if (!noAssert) checkOffset(offset, 2, this.length)
  9126. var val = this[offset + 1] | (this[offset] << 8)
  9127. return (val & 0x8000) ? val | 0xFFFF0000 : val
  9128. }
  9129.  
  9130. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  9131. if (!noAssert) checkOffset(offset, 4, this.length)
  9132.  
  9133. return (this[offset]) |
  9134. (this[offset + 1] << 8) |
  9135. (this[offset + 2] << 16) |
  9136. (this[offset + 3] << 24)
  9137. }
  9138.  
  9139. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  9140. if (!noAssert) checkOffset(offset, 4, this.length)
  9141.  
  9142. return (this[offset] << 24) |
  9143. (this[offset + 1] << 16) |
  9144. (this[offset + 2] << 8) |
  9145. (this[offset + 3])
  9146. }
  9147.  
  9148. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  9149. if (!noAssert) checkOffset(offset, 4, this.length)
  9150. return ieee754.read(this, offset, true, 23, 4)
  9151. }
  9152.  
  9153. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  9154. if (!noAssert) checkOffset(offset, 4, this.length)
  9155. return ieee754.read(this, offset, false, 23, 4)
  9156. }
  9157.  
  9158. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  9159. if (!noAssert) checkOffset(offset, 8, this.length)
  9160. return ieee754.read(this, offset, true, 52, 8)
  9161. }
  9162.  
  9163. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  9164. if (!noAssert) checkOffset(offset, 8, this.length)
  9165. return ieee754.read(this, offset, false, 52, 8)
  9166. }
  9167.  
  9168. function checkInt (buf, value, offset, ext, max, min) {
  9169. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  9170. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  9171. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  9172. }
  9173.  
  9174. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  9175. value = +value
  9176. offset = offset | 0
  9177. byteLength = byteLength | 0
  9178. if (!noAssert) {
  9179. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  9180. checkInt(this, value, offset, byteLength, maxBytes, 0)
  9181. }
  9182.  
  9183. var mul = 1
  9184. var i = 0
  9185. this[offset] = value & 0xFF
  9186. while (++i < byteLength && (mul *= 0x100)) {
  9187. this[offset + i] = (value / mul) & 0xFF
  9188. }
  9189.  
  9190. return offset + byteLength
  9191. }
  9192.  
  9193. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  9194. value = +value
  9195. offset = offset | 0
  9196. byteLength = byteLength | 0
  9197. if (!noAssert) {
  9198. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  9199. checkInt(this, value, offset, byteLength, maxBytes, 0)
  9200. }
  9201.  
  9202. var i = byteLength - 1
  9203. var mul = 1
  9204. this[offset + i] = value & 0xFF
  9205. while (--i >= 0 && (mul *= 0x100)) {
  9206. this[offset + i] = (value / mul) & 0xFF
  9207. }
  9208.  
  9209. return offset + byteLength
  9210. }
  9211.  
  9212. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  9213. value = +value
  9214. offset = offset | 0
  9215. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  9216. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  9217. this[offset] = (value & 0xff)
  9218. return offset + 1
  9219. }
  9220.  
  9221. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  9222. if (value < 0) value = 0xffff + value + 1
  9223. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  9224. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  9225. (littleEndian ? i : 1 - i) * 8
  9226. }
  9227. }
  9228.  
  9229. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  9230. value = +value
  9231. offset = offset | 0
  9232. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  9233. if (Buffer.TYPED_ARRAY_SUPPORT) {
  9234. this[offset] = (value & 0xff)
  9235. this[offset + 1] = (value >>> 8)
  9236. } else {
  9237. objectWriteUInt16(this, value, offset, true)
  9238. }
  9239. return offset + 2
  9240. }
  9241.  
  9242. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  9243. value = +value
  9244. offset = offset | 0
  9245. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  9246. if (Buffer.TYPED_ARRAY_SUPPORT) {
  9247. this[offset] = (value >>> 8)
  9248. this[offset + 1] = (value & 0xff)
  9249. } else {
  9250. objectWriteUInt16(this, value, offset, false)
  9251. }
  9252. return offset + 2
  9253. }
  9254.  
  9255. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  9256. if (value < 0) value = 0xffffffff + value + 1
  9257. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  9258. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  9259. }
  9260. }
  9261.  
  9262. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  9263. value = +value
  9264. offset = offset | 0
  9265. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  9266. if (Buffer.TYPED_ARRAY_SUPPORT) {
  9267. this[offset + 3] = (value >>> 24)
  9268. this[offset + 2] = (value >>> 16)
  9269. this[offset + 1] = (value >>> 8)
  9270. this[offset] = (value & 0xff)
  9271. } else {
  9272. objectWriteUInt32(this, value, offset, true)
  9273. }
  9274. return offset + 4
  9275. }
  9276.  
  9277. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  9278. value = +value
  9279. offset = offset | 0
  9280. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  9281. if (Buffer.TYPED_ARRAY_SUPPORT) {
  9282. this[offset] = (value >>> 24)
  9283. this[offset + 1] = (value >>> 16)
  9284. this[offset + 2] = (value >>> 8)
  9285. this[offset + 3] = (value & 0xff)
  9286. } else {
  9287. objectWriteUInt32(this, value, offset, false)
  9288. }
  9289. return offset + 4
  9290. }
  9291.  
  9292. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  9293. value = +value
  9294. offset = offset | 0
  9295. if (!noAssert) {
  9296. var limit = Math.pow(2, 8 * byteLength - 1)
  9297.  
  9298. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  9299. }
  9300.  
  9301. var i = 0
  9302. var mul = 1
  9303. var sub = 0
  9304. this[offset] = value & 0xFF
  9305. while (++i < byteLength && (mul *= 0x100)) {
  9306. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  9307. sub = 1
  9308. }
  9309. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  9310. }
  9311.  
  9312. return offset + byteLength
  9313. }
  9314.  
  9315. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  9316. value = +value
  9317. offset = offset | 0
  9318. if (!noAssert) {
  9319. var limit = Math.pow(2, 8 * byteLength - 1)
  9320.  
  9321. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  9322. }
  9323.  
  9324. var i = byteLength - 1
  9325. var mul = 1
  9326. var sub = 0
  9327. this[offset + i] = value & 0xFF
  9328. while (--i >= 0 && (mul *= 0x100)) {
  9329. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  9330. sub = 1
  9331. }
  9332. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  9333. }
  9334.  
  9335. return offset + byteLength
  9336. }
  9337.  
  9338. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  9339. value = +value
  9340. offset = offset | 0
  9341. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  9342. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  9343. if (value < 0) value = 0xff + value + 1
  9344. this[offset] = (value & 0xff)
  9345. return offset + 1
  9346. }
  9347.  
  9348. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  9349. value = +value
  9350. offset = offset | 0
  9351. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  9352. if (Buffer.TYPED_ARRAY_SUPPORT) {
  9353. this[offset] = (value & 0xff)
  9354. this[offset + 1] = (value >>> 8)
  9355. } else {
  9356. objectWriteUInt16(this, value, offset, true)
  9357. }
  9358. return offset + 2
  9359. }
  9360.  
  9361. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  9362. value = +value
  9363. offset = offset | 0
  9364. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  9365. if (Buffer.TYPED_ARRAY_SUPPORT) {
  9366. this[offset] = (value >>> 8)
  9367. this[offset + 1] = (value & 0xff)
  9368. } else {
  9369. objectWriteUInt16(this, value, offset, false)
  9370. }
  9371. return offset + 2
  9372. }
  9373.  
  9374. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  9375. value = +value
  9376. offset = offset | 0
  9377. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  9378. if (Buffer.TYPED_ARRAY_SUPPORT) {
  9379. this[offset] = (value & 0xff)
  9380. this[offset + 1] = (value >>> 8)
  9381. this[offset + 2] = (value >>> 16)
  9382. this[offset + 3] = (value >>> 24)
  9383. } else {
  9384. objectWriteUInt32(this, value, offset, true)
  9385. }
  9386. return offset + 4
  9387. }
  9388.  
  9389. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  9390. value = +value
  9391. offset = offset | 0
  9392. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  9393. if (value < 0) value = 0xffffffff + value + 1
  9394. if (Buffer.TYPED_ARRAY_SUPPORT) {
  9395. this[offset] = (value >>> 24)
  9396. this[offset + 1] = (value >>> 16)
  9397. this[offset + 2] = (value >>> 8)
  9398. this[offset + 3] = (value & 0xff)
  9399. } else {
  9400. objectWriteUInt32(this, value, offset, false)
  9401. }
  9402. return offset + 4
  9403. }
  9404.  
  9405. function checkIEEE754 (buf, value, offset, ext, max, min) {
  9406. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  9407. if (offset < 0) throw new RangeError('Index out of range')
  9408. }
  9409.  
  9410. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  9411. if (!noAssert) {
  9412. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  9413. }
  9414. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  9415. return offset + 4
  9416. }
  9417.  
  9418. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  9419. return writeFloat(this, value, offset, true, noAssert)
  9420. }
  9421.  
  9422. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  9423. return writeFloat(this, value, offset, false, noAssert)
  9424. }
  9425.  
  9426. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  9427. if (!noAssert) {
  9428. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  9429. }
  9430. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  9431. return offset + 8
  9432. }
  9433.  
  9434. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  9435. return writeDouble(this, value, offset, true, noAssert)
  9436. }
  9437.  
  9438. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  9439. return writeDouble(this, value, offset, false, noAssert)
  9440. }
  9441.  
  9442. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  9443. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  9444. if (!start) start = 0
  9445. if (!end && end !== 0) end = this.length
  9446. if (targetStart >= target.length) targetStart = target.length
  9447. if (!targetStart) targetStart = 0
  9448. if (end > 0 && end < start) end = start
  9449.  
  9450. // Copy 0 bytes; we're done
  9451. if (end === start) return 0
  9452. if (target.length === 0 || this.length === 0) return 0
  9453.  
  9454. // Fatal error conditions
  9455. if (targetStart < 0) {
  9456. throw new RangeError('targetStart out of bounds')
  9457. }
  9458. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  9459. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  9460.  
  9461. // Are we oob?
  9462. if (end > this.length) end = this.length
  9463. if (target.length - targetStart < end - start) {
  9464. end = target.length - targetStart + start
  9465. }
  9466.  
  9467. var len = end - start
  9468. var i
  9469.  
  9470. if (this === target && start < targetStart && targetStart < end) {
  9471. // descending copy from end
  9472. for (i = len - 1; i >= 0; --i) {
  9473. target[i + targetStart] = this[i + start]
  9474. }
  9475. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  9476. // ascending copy from start
  9477. for (i = 0; i < len; ++i) {
  9478. target[i + targetStart] = this[i + start]
  9479. }
  9480. } else {
  9481. Uint8Array.prototype.set.call(
  9482. target,
  9483. this.subarray(start, start + len),
  9484. targetStart
  9485. )
  9486. }
  9487.  
  9488. return len
  9489. }
  9490.  
  9491. // Usage:
  9492. // buffer.fill(number[, offset[, end]])
  9493. // buffer.fill(buffer[, offset[, end]])
  9494. // buffer.fill(string[, offset[, end]][, encoding])
  9495. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  9496. // Handle string cases:
  9497. if (typeof val === 'string') {
  9498. if (typeof start === 'string') {
  9499. encoding = start
  9500. start = 0
  9501. end = this.length
  9502. } else if (typeof end === 'string') {
  9503. encoding = end
  9504. end = this.length
  9505. }
  9506. if (val.length === 1) {
  9507. var code = val.charCodeAt(0)
  9508. if (code < 256) {
  9509. val = code
  9510. }
  9511. }
  9512. if (encoding !== undefined && typeof encoding !== 'string') {
  9513. throw new TypeError('encoding must be a string')
  9514. }
  9515. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  9516. throw new TypeError('Unknown encoding: ' + encoding)
  9517. }
  9518. } else if (typeof val === 'number') {
  9519. val = val & 255
  9520. }
  9521.  
  9522. // Invalid ranges are not set to a default, so can range check early.
  9523. if (start < 0 || this.length < start || this.length < end) {
  9524. throw new RangeError('Out of range index')
  9525. }
  9526.  
  9527. if (end <= start) {
  9528. return this
  9529. }
  9530.  
  9531. start = start >>> 0
  9532. end = end === undefined ? this.length : end >>> 0
  9533.  
  9534. if (!val) val = 0
  9535.  
  9536. var i
  9537. if (typeof val === 'number') {
  9538. for (i = start; i < end; ++i) {
  9539. this[i] = val
  9540. }
  9541. } else {
  9542. var bytes = Buffer.isBuffer(val)
  9543. ? val
  9544. : utf8ToBytes(new Buffer(val, encoding).toString())
  9545. var len = bytes.length
  9546. for (i = 0; i < end - start; ++i) {
  9547. this[i + start] = bytes[i % len]
  9548. }
  9549. }
  9550.  
  9551. return this
  9552. }
  9553.  
  9554. // HELPER FUNCTIONS
  9555. // ================
  9556.  
  9557. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  9558.  
  9559. function base64clean (str) {
  9560. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  9561. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  9562. // Node converts strings with length < 2 to ''
  9563. if (str.length < 2) return ''
  9564. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  9565. while (str.length % 4 !== 0) {
  9566. str = str + '='
  9567. }
  9568. return str
  9569. }
  9570.  
  9571. function stringtrim (str) {
  9572. if (str.trim) return str.trim()
  9573. return str.replace(/^\s+|\s+$/g, '')
  9574. }
  9575.  
  9576. function toHex (n) {
  9577. if (n < 16) return '0' + n.toString(16)
  9578. return n.toString(16)
  9579. }
  9580.  
  9581. function utf8ToBytes (string, units) {
  9582. units = units || Infinity
  9583. var codePoint
  9584. var length = string.length
  9585. var leadSurrogate = null
  9586. var bytes = []
  9587.  
  9588. for (var i = 0; i < length; ++i) {
  9589. codePoint = string.charCodeAt(i)
  9590.  
  9591. // is surrogate component
  9592. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  9593. // last char was a lead
  9594. if (!leadSurrogate) {
  9595. // no lead yet
  9596. if (codePoint > 0xDBFF) {
  9597. // unexpected trail
  9598. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  9599. continue
  9600. } else if (i + 1 === length) {
  9601. // unpaired lead
  9602. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  9603. continue
  9604. }
  9605.  
  9606. // valid lead
  9607. leadSurrogate = codePoint
  9608.  
  9609. continue
  9610. }
  9611.  
  9612. // 2 leads in a row
  9613. if (codePoint < 0xDC00) {
  9614. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  9615. leadSurrogate = codePoint
  9616. continue
  9617. }
  9618.  
  9619. // valid surrogate pair
  9620. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  9621. } else if (leadSurrogate) {
  9622. // valid bmp char, but last char was a lead
  9623. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  9624. }
  9625.  
  9626. leadSurrogate = null
  9627.  
  9628. // encode utf8
  9629. if (codePoint < 0x80) {
  9630. if ((units -= 1) < 0) break
  9631. bytes.push(codePoint)
  9632. } else if (codePoint < 0x800) {
  9633. if ((units -= 2) < 0) break
  9634. bytes.push(
  9635. codePoint >> 0x6 | 0xC0,
  9636. codePoint & 0x3F | 0x80
  9637. )
  9638. } else if (codePoint < 0x10000) {
  9639. if ((units -= 3) < 0) break
  9640. bytes.push(
  9641. codePoint >> 0xC | 0xE0,
  9642. codePoint >> 0x6 & 0x3F | 0x80,
  9643. codePoint & 0x3F | 0x80
  9644. )
  9645. } else if (codePoint < 0x110000) {
  9646. if ((units -= 4) < 0) break
  9647. bytes.push(
  9648. codePoint >> 0x12 | 0xF0,
  9649. codePoint >> 0xC & 0x3F | 0x80,
  9650. codePoint >> 0x6 & 0x3F | 0x80,
  9651. codePoint & 0x3F | 0x80
  9652. )
  9653. } else {
  9654. throw new Error('Invalid code point')
  9655. }
  9656. }
  9657.  
  9658. return bytes
  9659. }
  9660.  
  9661. function asciiToBytes (str) {
  9662. var byteArray = []
  9663. for (var i = 0; i < str.length; ++i) {
  9664. // Node's code seems to be doing this and not & 0x7F..
  9665. byteArray.push(str.charCodeAt(i) & 0xFF)
  9666. }
  9667. return byteArray
  9668. }
  9669.  
  9670. function utf16leToBytes (str, units) {
  9671. var c, hi, lo
  9672. var byteArray = []
  9673. for (var i = 0; i < str.length; ++i) {
  9674. if ((units -= 2) < 0) break
  9675.  
  9676. c = str.charCodeAt(i)
  9677. hi = c >> 8
  9678. lo = c % 256
  9679. byteArray.push(lo)
  9680. byteArray.push(hi)
  9681. }
  9682.  
  9683. return byteArray
  9684. }
  9685.  
  9686. function base64ToBytes (str) {
  9687. return base64.toByteArray(base64clean(str))
  9688. }
  9689.  
  9690. function blitBuffer (src, dst, offset, length) {
  9691. for (var i = 0; i < length; ++i) {
  9692. if ((i + offset >= dst.length) || (i >= src.length)) break
  9693. dst[i + offset] = src[i]
  9694. }
  9695. return i
  9696. }
  9697.  
  9698. function isnan (val) {
  9699. return val !== val // eslint-disable-line no-self-compare
  9700. }
  9701.  
  9702. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8)))
  9703.  
  9704. /***/ }),
  9705. /* 63 */
  9706. /***/ (function(module, exports, __webpack_require__) {
  9707.  
  9708. __webpack_require__(48);
  9709. __webpack_require__(90);
  9710. module.exports = __webpack_require__(2).Array.from;
  9711.  
  9712. /***/ }),
  9713. /* 64 */
  9714. /***/ (function(module, exports, __webpack_require__) {
  9715.  
  9716. var core = __webpack_require__(2)
  9717. , $JSON = core.JSON || (core.JSON = {stringify: JSON.stringify});
  9718. module.exports = function stringify(it){ // eslint-disable-line no-unused-vars
  9719. return $JSON.stringify.apply($JSON, arguments);
  9720. };
  9721.  
  9722. /***/ }),
  9723. /* 65 */
  9724. /***/ (function(module, exports, __webpack_require__) {
  9725.  
  9726. __webpack_require__(92);
  9727. var $Object = __webpack_require__(2).Object;
  9728. module.exports = function defineProperty(it, key, desc){
  9729. return $Object.defineProperty(it, key, desc);
  9730. };
  9731.  
  9732. /***/ }),
  9733. /* 66 */
  9734. /***/ (function(module, exports, __webpack_require__) {
  9735.  
  9736. __webpack_require__(93);
  9737. __webpack_require__(48);
  9738. __webpack_require__(95);
  9739. __webpack_require__(94);
  9740. module.exports = __webpack_require__(2).Promise;
  9741.  
  9742. /***/ }),
  9743. /* 67 */
  9744. /***/ (function(module, exports) {
  9745.  
  9746. module.exports = function(){ /* empty */ };
  9747.  
  9748. /***/ }),
  9749. /* 68 */
  9750. /***/ (function(module, exports) {
  9751.  
  9752. module.exports = function(it, Constructor, name, forbiddenField){
  9753. if(!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)){
  9754. throw TypeError(name + ': incorrect invocation!');
  9755. } return it;
  9756. };
  9757.  
  9758. /***/ }),
  9759. /* 69 */
  9760. /***/ (function(module, exports, __webpack_require__) {
  9761.  
  9762. // false -> Array#indexOf
  9763. // true -> Array#includes
  9764. var toIObject = __webpack_require__(28)
  9765. , toLength = __webpack_require__(29)
  9766. , toIndex = __webpack_require__(88);
  9767. module.exports = function(IS_INCLUDES){
  9768. return function($this, el, fromIndex){
  9769. var O = toIObject($this)
  9770. , length = toLength(O.length)
  9771. , index = toIndex(fromIndex, length)
  9772. , value;
  9773. // Array#includes uses SameValueZero equality algorithm
  9774. if(IS_INCLUDES && el != el)while(length > index){
  9775. value = O[index++];
  9776. if(value != value)return true;
  9777. // Array#toIndex ignores holes, Array#includes - not
  9778. } else for(;length > index; index++)if(IS_INCLUDES || index in O){
  9779. if(O[index] === el)return IS_INCLUDES || index || 0;
  9780. } return !IS_INCLUDES && -1;
  9781. };
  9782. };
  9783.  
  9784. /***/ }),
  9785. /* 70 */
  9786. /***/ (function(module, exports, __webpack_require__) {
  9787.  
  9788. "use strict";
  9789.  
  9790. var $defineProperty = __webpack_require__(7)
  9791. , createDesc = __webpack_require__(24);
  9792.  
  9793. module.exports = function(object, index, value){
  9794. if(index in object)$defineProperty.f(object, index, createDesc(0, value));
  9795. else object[index] = value;
  9796. };
  9797.  
  9798. /***/ }),
  9799. /* 71 */
  9800. /***/ (function(module, exports, __webpack_require__) {
  9801.  
  9802. var ctx = __webpack_require__(12)
  9803. , call = __webpack_require__(39)
  9804. , isArrayIter = __webpack_require__(38)
  9805. , anObject = __webpack_require__(4)
  9806. , toLength = __webpack_require__(29)
  9807. , getIterFn = __webpack_require__(47)
  9808. , BREAK = {}
  9809. , RETURN = {};
  9810. var exports = module.exports = function(iterable, entries, fn, that, ITERATOR){
  9811. var iterFn = ITERATOR ? function(){ return iterable; } : getIterFn(iterable)
  9812. , f = ctx(fn, that, entries ? 2 : 1)
  9813. , index = 0
  9814. , length, step, iterator, result;
  9815. if(typeof iterFn != 'function')throw TypeError(iterable + ' is not iterable!');
  9816. // fast case for arrays with default iterator
  9817. if(isArrayIter(iterFn))for(length = toLength(iterable.length); length > index; index++){
  9818. result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);
  9819. if(result === BREAK || result === RETURN)return result;
  9820. } else for(iterator = iterFn.call(iterable); !(step = iterator.next()).done; ){
  9821. result = call(iterator, f, step.value, entries);
  9822. if(result === BREAK || result === RETURN)return result;
  9823. }
  9824. };
  9825. exports.BREAK = BREAK;
  9826. exports.RETURN = RETURN;
  9827.  
  9828. /***/ }),
  9829. /* 72 */
  9830. /***/ (function(module, exports, __webpack_require__) {
  9831.  
  9832. module.exports = !__webpack_require__(5) && !__webpack_require__(36)(function(){
  9833. return Object.defineProperty(__webpack_require__(23)('div'), 'a', {get: function(){ return 7; }}).a != 7;
  9834. });
  9835.  
  9836. /***/ }),
  9837. /* 73 */
  9838. /***/ (function(module, exports) {
  9839.  
  9840. // fast apply, http://jsperf.lnkit.com/fast-apply/5
  9841. module.exports = function(fn, args, that){
  9842. var un = that === undefined;
  9843. switch(args.length){
  9844. case 0: return un ? fn()
  9845. : fn.call(that);
  9846. case 1: return un ? fn(args[0])
  9847. : fn.call(that, args[0]);
  9848. case 2: return un ? fn(args[0], args[1])
  9849. : fn.call(that, args[0], args[1]);
  9850. case 3: return un ? fn(args[0], args[1], args[2])
  9851. : fn.call(that, args[0], args[1], args[2]);
  9852. case 4: return un ? fn(args[0], args[1], args[2], args[3])
  9853. : fn.call(that, args[0], args[1], args[2], args[3]);
  9854. } return fn.apply(that, args);
  9855. };
  9856.  
  9857. /***/ }),
  9858. /* 74 */
  9859. /***/ (function(module, exports, __webpack_require__) {
  9860.  
  9861. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  9862. var cof = __webpack_require__(16);
  9863. module.exports = Object('z').propertyIsEnumerable(0) ? Object : function(it){
  9864. return cof(it) == 'String' ? it.split('') : Object(it);
  9865. };
  9866.  
  9867. /***/ }),
  9868. /* 75 */
  9869. /***/ (function(module, exports, __webpack_require__) {
  9870.  
  9871. "use strict";
  9872.  
  9873. var create = __webpack_require__(78)
  9874. , descriptor = __webpack_require__(24)
  9875. , setToStringTag = __webpack_require__(25)
  9876. , IteratorPrototype = {};
  9877.  
  9878. // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
  9879. __webpack_require__(6)(IteratorPrototype, __webpack_require__(0)('iterator'), function(){ return this; });
  9880.  
  9881. module.exports = function(Constructor, NAME, next){
  9882. Constructor.prototype = create(IteratorPrototype, {next: descriptor(1, next)});
  9883. setToStringTag(Constructor, NAME + ' Iterator');
  9884. };
  9885.  
  9886. /***/ }),
  9887. /* 76 */
  9888. /***/ (function(module, exports) {
  9889.  
  9890. module.exports = function(done, value){
  9891. return {value: value, done: !!done};
  9892. };
  9893.  
  9894. /***/ }),
  9895. /* 77 */
  9896. /***/ (function(module, exports, __webpack_require__) {
  9897.  
  9898. var global = __webpack_require__(1)
  9899. , macrotask = __webpack_require__(44).set
  9900. , Observer = global.MutationObserver || global.WebKitMutationObserver
  9901. , process = global.process
  9902. , Promise = global.Promise
  9903. , isNode = __webpack_require__(16)(process) == 'process';
  9904.  
  9905. module.exports = function(){
  9906. var head, last, notify;
  9907.  
  9908. var flush = function(){
  9909. var parent, fn;
  9910. if(isNode && (parent = process.domain))parent.exit();
  9911. while(head){
  9912. fn = head.fn;
  9913. head = head.next;
  9914. try {
  9915. fn();
  9916. } catch(e){
  9917. if(head)notify();
  9918. else last = undefined;
  9919. throw e;
  9920. }
  9921. } last = undefined;
  9922. if(parent)parent.enter();
  9923. };
  9924.  
  9925. // Node.js
  9926. if(isNode){
  9927. notify = function(){
  9928. process.nextTick(flush);
  9929. };
  9930. // browsers with MutationObserver
  9931. } else if(Observer){
  9932. var toggle = true
  9933. , node = document.createTextNode('');
  9934. new Observer(flush).observe(node, {characterData: true}); // eslint-disable-line no-new
  9935. notify = function(){
  9936. node.data = toggle = !toggle;
  9937. };
  9938. // environments with maybe non-completely correct, but existent Promise
  9939. } else if(Promise && Promise.resolve){
  9940. var promise = Promise.resolve();
  9941. notify = function(){
  9942. promise.then(flush);
  9943. };
  9944. // for other environments - macrotask based on:
  9945. // - setImmediate
  9946. // - MessageChannel
  9947. // - window.postMessag
  9948. // - onreadystatechange
  9949. // - setTimeout
  9950. } else {
  9951. notify = function(){
  9952. // strange IE + webpack dev server bug - use .call(global)
  9953. macrotask.call(global, flush);
  9954. };
  9955. }
  9956.  
  9957. return function(fn){
  9958. var task = {fn: fn, next: undefined};
  9959. if(last)last.next = task;
  9960. if(!head){
  9961. head = task;
  9962. notify();
  9963. } last = task;
  9964. };
  9965. };
  9966.  
  9967. /***/ }),
  9968. /* 78 */
  9969. /***/ (function(module, exports, __webpack_require__) {
  9970.  
  9971. // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties])
  9972. var anObject = __webpack_require__(4)
  9973. , dPs = __webpack_require__(79)
  9974. , enumBugKeys = __webpack_require__(35)
  9975. , IE_PROTO = __webpack_require__(26)('IE_PROTO')
  9976. , Empty = function(){ /* empty */ }
  9977. , PROTOTYPE = 'prototype';
  9978.  
  9979. // Create object with fake `null` prototype: use iframe Object with cleared prototype
  9980. var createDict = function(){
  9981. // Thrash, waste and sodomy: IE GC bug
  9982. var iframe = __webpack_require__(23)('iframe')
  9983. , i = enumBugKeys.length
  9984. , lt = '<'
  9985. , gt = '>'
  9986. , iframeDocument;
  9987. iframe.style.display = 'none';
  9988. __webpack_require__(37).appendChild(iframe);
  9989. iframe.src = 'javascript:'; // eslint-disable-line no-script-url
  9990. // createDict = iframe.contentWindow.Object;
  9991. // html.removeChild(iframe);
  9992. iframeDocument = iframe.contentWindow.document;
  9993. iframeDocument.open();
  9994. iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt);
  9995. iframeDocument.close();
  9996. createDict = iframeDocument.F;
  9997. while(i--)delete createDict[PROTOTYPE][enumBugKeys[i]];
  9998. return createDict();
  9999. };
  10000.  
  10001. module.exports = Object.create || function create(O, Properties){
  10002. var result;
  10003. if(O !== null){
  10004. Empty[PROTOTYPE] = anObject(O);
  10005. result = new Empty;
  10006. Empty[PROTOTYPE] = null;
  10007. // add "__proto__" for Object.getPrototypeOf polyfill
  10008. result[IE_PROTO] = O;
  10009. } else result = createDict();
  10010. return Properties === undefined ? result : dPs(result, Properties);
  10011. };
  10012.  
  10013.  
  10014. /***/ }),
  10015. /* 79 */
  10016. /***/ (function(module, exports, __webpack_require__) {
  10017.  
  10018. var dP = __webpack_require__(7)
  10019. , anObject = __webpack_require__(4)
  10020. , getKeys = __webpack_require__(82);
  10021.  
  10022. module.exports = __webpack_require__(5) ? Object.defineProperties : function defineProperties(O, Properties){
  10023. anObject(O);
  10024. var keys = getKeys(Properties)
  10025. , length = keys.length
  10026. , i = 0
  10027. , P;
  10028. while(length > i)dP.f(O, P = keys[i++], Properties[P]);
  10029. return O;
  10030. };
  10031.  
  10032. /***/ }),
  10033. /* 80 */
  10034. /***/ (function(module, exports, __webpack_require__) {
  10035.  
  10036. // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O)
  10037. var has = __webpack_require__(18)
  10038. , toObject = __webpack_require__(45)
  10039. , IE_PROTO = __webpack_require__(26)('IE_PROTO')
  10040. , ObjectProto = Object.prototype;
  10041.  
  10042. module.exports = Object.getPrototypeOf || function(O){
  10043. O = toObject(O);
  10044. if(has(O, IE_PROTO))return O[IE_PROTO];
  10045. if(typeof O.constructor == 'function' && O instanceof O.constructor){
  10046. return O.constructor.prototype;
  10047. } return O instanceof Object ? ObjectProto : null;
  10048. };
  10049.  
  10050. /***/ }),
  10051. /* 81 */
  10052. /***/ (function(module, exports, __webpack_require__) {
  10053.  
  10054. var has = __webpack_require__(18)
  10055. , toIObject = __webpack_require__(28)
  10056. , arrayIndexOf = __webpack_require__(69)(false)
  10057. , IE_PROTO = __webpack_require__(26)('IE_PROTO');
  10058.  
  10059. module.exports = function(object, names){
  10060. var O = toIObject(object)
  10061. , i = 0
  10062. , result = []
  10063. , key;
  10064. for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key);
  10065. // Don't enum bug & hidden keys
  10066. while(names.length > i)if(has(O, key = names[i++])){
  10067. ~arrayIndexOf(result, key) || result.push(key);
  10068. }
  10069. return result;
  10070. };
  10071.  
  10072. /***/ }),
  10073. /* 82 */
  10074. /***/ (function(module, exports, __webpack_require__) {
  10075.  
  10076. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  10077. var $keys = __webpack_require__(81)
  10078. , enumBugKeys = __webpack_require__(35);
  10079.  
  10080. module.exports = Object.keys || function keys(O){
  10081. return $keys(O, enumBugKeys);
  10082. };
  10083.  
  10084. /***/ }),
  10085. /* 83 */
  10086. /***/ (function(module, exports, __webpack_require__) {
  10087.  
  10088. var hide = __webpack_require__(6);
  10089. module.exports = function(target, src, safe){
  10090. for(var key in src){
  10091. if(safe && target[key])target[key] = src[key];
  10092. else hide(target, key, src[key]);
  10093. } return target;
  10094. };
  10095.  
  10096. /***/ }),
  10097. /* 84 */
  10098. /***/ (function(module, exports, __webpack_require__) {
  10099.  
  10100. module.exports = __webpack_require__(6);
  10101.  
  10102. /***/ }),
  10103. /* 85 */
  10104. /***/ (function(module, exports, __webpack_require__) {
  10105.  
  10106. "use strict";
  10107.  
  10108. var global = __webpack_require__(1)
  10109. , core = __webpack_require__(2)
  10110. , dP = __webpack_require__(7)
  10111. , DESCRIPTORS = __webpack_require__(5)
  10112. , SPECIES = __webpack_require__(0)('species');
  10113.  
  10114. module.exports = function(KEY){
  10115. var C = typeof core[KEY] == 'function' ? core[KEY] : global[KEY];
  10116. if(DESCRIPTORS && C && !C[SPECIES])dP.f(C, SPECIES, {
  10117. configurable: true,
  10118. get: function(){ return this; }
  10119. });
  10120. };
  10121.  
  10122. /***/ }),
  10123. /* 86 */
  10124. /***/ (function(module, exports, __webpack_require__) {
  10125.  
  10126. // 7.3.20 SpeciesConstructor(O, defaultConstructor)
  10127. var anObject = __webpack_require__(4)
  10128. , aFunction = __webpack_require__(21)
  10129. , SPECIES = __webpack_require__(0)('species');
  10130. module.exports = function(O, D){
  10131. var C = anObject(O).constructor, S;
  10132. return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S);
  10133. };
  10134.  
  10135. /***/ }),
  10136. /* 87 */
  10137. /***/ (function(module, exports, __webpack_require__) {
  10138.  
  10139. var toInteger = __webpack_require__(27)
  10140. , defined = __webpack_require__(22);
  10141. // true -> String#at
  10142. // false -> String#codePointAt
  10143. module.exports = function(TO_STRING){
  10144. return function(that, pos){
  10145. var s = String(defined(that))
  10146. , i = toInteger(pos)
  10147. , l = s.length
  10148. , a, b;
  10149. if(i < 0 || i >= l)return TO_STRING ? '' : undefined;
  10150. a = s.charCodeAt(i);
  10151. return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
  10152. ? TO_STRING ? s.charAt(i) : a
  10153. : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
  10154. };
  10155. };
  10156.  
  10157. /***/ }),
  10158. /* 88 */
  10159. /***/ (function(module, exports, __webpack_require__) {
  10160.  
  10161. var toInteger = __webpack_require__(27)
  10162. , max = Math.max
  10163. , min = Math.min;
  10164. module.exports = function(index, length){
  10165. index = toInteger(index);
  10166. return index < 0 ? max(index + length, 0) : min(index, length);
  10167. };
  10168.  
  10169. /***/ }),
  10170. /* 89 */
  10171. /***/ (function(module, exports, __webpack_require__) {
  10172.  
  10173. // 7.1.1 ToPrimitive(input [, PreferredType])
  10174. var isObject = __webpack_require__(19);
  10175. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  10176. // and the second argument - flag - preferred type is a string
  10177. module.exports = function(it, S){
  10178. if(!isObject(it))return it;
  10179. var fn, val;
  10180. if(S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
  10181. if(typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it)))return val;
  10182. if(!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it)))return val;
  10183. throw TypeError("Can't convert object to primitive value");
  10184. };
  10185.  
  10186. /***/ }),
  10187. /* 90 */
  10188. /***/ (function(module, exports, __webpack_require__) {
  10189.  
  10190. "use strict";
  10191.  
  10192. var ctx = __webpack_require__(12)
  10193. , $export = __webpack_require__(17)
  10194. , toObject = __webpack_require__(45)
  10195. , call = __webpack_require__(39)
  10196. , isArrayIter = __webpack_require__(38)
  10197. , toLength = __webpack_require__(29)
  10198. , createProperty = __webpack_require__(70)
  10199. , getIterFn = __webpack_require__(47);
  10200.  
  10201. $export($export.S + $export.F * !__webpack_require__(41)(function(iter){ Array.from(iter); }), 'Array', {
  10202. // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined)
  10203. from: function from(arrayLike/*, mapfn = undefined, thisArg = undefined*/){
  10204. var O = toObject(arrayLike)
  10205. , C = typeof this == 'function' ? this : Array
  10206. , aLen = arguments.length
  10207. , mapfn = aLen > 1 ? arguments[1] : undefined
  10208. , mapping = mapfn !== undefined
  10209. , index = 0
  10210. , iterFn = getIterFn(O)
  10211. , length, result, step, iterator;
  10212. if(mapping)mapfn = ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2);
  10213. // if object isn't iterable or it's array with default iterator - use simple case
  10214. if(iterFn != undefined && !(C == Array && isArrayIter(iterFn))){
  10215. for(iterator = iterFn.call(O), result = new C; !(step = iterator.next()).done; index++){
  10216. createProperty(result, index, mapping ? call(iterator, mapfn, [step.value, index], true) : step.value);
  10217. }
  10218. } else {
  10219. length = toLength(O.length);
  10220. for(result = new C(length); length > index; index++){
  10221. createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]);
  10222. }
  10223. }
  10224. result.length = index;
  10225. return result;
  10226. }
  10227. });
  10228.  
  10229.  
  10230. /***/ }),
  10231. /* 91 */
  10232. /***/ (function(module, exports, __webpack_require__) {
  10233.  
  10234. "use strict";
  10235.  
  10236. var addToUnscopables = __webpack_require__(67)
  10237. , step = __webpack_require__(76)
  10238. , Iterators = __webpack_require__(13)
  10239. , toIObject = __webpack_require__(28);
  10240.  
  10241. // 22.1.3.4 Array.prototype.entries()
  10242. // 22.1.3.13 Array.prototype.keys()
  10243. // 22.1.3.29 Array.prototype.values()
  10244. // 22.1.3.30 Array.prototype[@@iterator]()
  10245. module.exports = __webpack_require__(40)(Array, 'Array', function(iterated, kind){
  10246. this._t = toIObject(iterated); // target
  10247. this._i = 0; // next index
  10248. this._k = kind; // kind
  10249. // 22.1.5.2.1 %ArrayIteratorPrototype%.next()
  10250. }, function(){
  10251. var O = this._t
  10252. , kind = this._k
  10253. , index = this._i++;
  10254. if(!O || index >= O.length){
  10255. this._t = undefined;
  10256. return step(1);
  10257. }
  10258. if(kind == 'keys' )return step(0, index);
  10259. if(kind == 'values')return step(0, O[index]);
  10260. return step(0, [index, O[index]]);
  10261. }, 'values');
  10262.  
  10263. // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7)
  10264. Iterators.Arguments = Iterators.Array;
  10265.  
  10266. addToUnscopables('keys');
  10267. addToUnscopables('values');
  10268. addToUnscopables('entries');
  10269.  
  10270. /***/ }),
  10271. /* 92 */
  10272. /***/ (function(module, exports, __webpack_require__) {
  10273.  
  10274. var $export = __webpack_require__(17);
  10275. // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes)
  10276. $export($export.S + $export.F * !__webpack_require__(5), 'Object', {defineProperty: __webpack_require__(7).f});
  10277.  
  10278. /***/ }),
  10279. /* 93 */
  10280. /***/ (function(module, exports) {
  10281.  
  10282.  
  10283.  
  10284. /***/ }),
  10285. /* 94 */
  10286. /***/ (function(module, exports, __webpack_require__) {
  10287.  
  10288. "use strict";
  10289.  
  10290. var LIBRARY = __webpack_require__(42)
  10291. , global = __webpack_require__(1)
  10292. , ctx = __webpack_require__(12)
  10293. , classof = __webpack_require__(34)
  10294. , $export = __webpack_require__(17)
  10295. , isObject = __webpack_require__(19)
  10296. , aFunction = __webpack_require__(21)
  10297. , anInstance = __webpack_require__(68)
  10298. , forOf = __webpack_require__(71)
  10299. , speciesConstructor = __webpack_require__(86)
  10300. , task = __webpack_require__(44).set
  10301. , microtask = __webpack_require__(77)()
  10302. , PROMISE = 'Promise'
  10303. , TypeError = global.TypeError
  10304. , process = global.process
  10305. , $Promise = global[PROMISE]
  10306. , process = global.process
  10307. , isNode = classof(process) == 'process'
  10308. , empty = function(){ /* empty */ }
  10309. , Internal, GenericPromiseCapability, Wrapper;
  10310.  
  10311. var USE_NATIVE = !!function(){
  10312. try {
  10313. // correct subclassing with @@species support
  10314. var promise = $Promise.resolve(1)
  10315. , FakePromise = (promise.constructor = {})[__webpack_require__(0)('species')] = function(exec){ exec(empty, empty); };
  10316. // unhandled rejections tracking support, NodeJS Promise without it fails @@species test
  10317. return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise;
  10318. } catch(e){ /* empty */ }
  10319. }();
  10320.  
  10321. // helpers
  10322. var sameConstructor = function(a, b){
  10323. // with library wrapper special case
  10324. return a === b || a === $Promise && b === Wrapper;
  10325. };
  10326. var isThenable = function(it){
  10327. var then;
  10328. return isObject(it) && typeof (then = it.then) == 'function' ? then : false;
  10329. };
  10330. var newPromiseCapability = function(C){
  10331. return sameConstructor($Promise, C)
  10332. ? new PromiseCapability(C)
  10333. : new GenericPromiseCapability(C);
  10334. };
  10335. var PromiseCapability = GenericPromiseCapability = function(C){
  10336. var resolve, reject;
  10337. this.promise = new C(function($$resolve, $$reject){
  10338. if(resolve !== undefined || reject !== undefined)throw TypeError('Bad Promise constructor');
  10339. resolve = $$resolve;
  10340. reject = $$reject;
  10341. });
  10342. this.resolve = aFunction(resolve);
  10343. this.reject = aFunction(reject);
  10344. };
  10345. var perform = function(exec){
  10346. try {
  10347. exec();
  10348. } catch(e){
  10349. return {error: e};
  10350. }
  10351. };
  10352. var notify = function(promise, isReject){
  10353. if(promise._n)return;
  10354. promise._n = true;
  10355. var chain = promise._c;
  10356. microtask(function(){
  10357. var value = promise._v
  10358. , ok = promise._s == 1
  10359. , i = 0;
  10360. var run = function(reaction){
  10361. var handler = ok ? reaction.ok : reaction.fail
  10362. , resolve = reaction.resolve
  10363. , reject = reaction.reject
  10364. , domain = reaction.domain
  10365. , result, then;
  10366. try {
  10367. if(handler){
  10368. if(!ok){
  10369. if(promise._h == 2)onHandleUnhandled(promise);
  10370. promise._h = 1;
  10371. }
  10372. if(handler === true)result = value;
  10373. else {
  10374. if(domain)domain.enter();
  10375. result = handler(value);
  10376. if(domain)domain.exit();
  10377. }
  10378. if(result === reaction.promise){
  10379. reject(TypeError('Promise-chain cycle'));
  10380. } else if(then = isThenable(result)){
  10381. then.call(result, resolve, reject);
  10382. } else resolve(result);
  10383. } else reject(value);
  10384. } catch(e){
  10385. reject(e);
  10386. }
  10387. };
  10388. while(chain.length > i)run(chain[i++]); // variable length - can't use forEach
  10389. promise._c = [];
  10390. promise._n = false;
  10391. if(isReject && !promise._h)onUnhandled(promise);
  10392. });
  10393. };
  10394. var onUnhandled = function(promise){
  10395. task.call(global, function(){
  10396. var value = promise._v
  10397. , abrupt, handler, console;
  10398. if(isUnhandled(promise)){
  10399. abrupt = perform(function(){
  10400. if(isNode){
  10401. process.emit('unhandledRejection', value, promise);
  10402. } else if(handler = global.onunhandledrejection){
  10403. handler({promise: promise, reason: value});
  10404. } else if((console = global.console) && console.error){
  10405. console.error('Unhandled promise rejection', value);
  10406. }
  10407. });
  10408. // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
  10409. promise._h = isNode || isUnhandled(promise) ? 2 : 1;
  10410. } promise._a = undefined;
  10411. if(abrupt)throw abrupt.error;
  10412. });
  10413. };
  10414. var isUnhandled = function(promise){
  10415. if(promise._h == 1)return false;
  10416. var chain = promise._a || promise._c
  10417. , i = 0
  10418. , reaction;
  10419. while(chain.length > i){
  10420. reaction = chain[i++];
  10421. if(reaction.fail || !isUnhandled(reaction.promise))return false;
  10422. } return true;
  10423. };
  10424. var onHandleUnhandled = function(promise){
  10425. task.call(global, function(){
  10426. var handler;
  10427. if(isNode){
  10428. process.emit('rejectionHandled', promise);
  10429. } else if(handler = global.onrejectionhandled){
  10430. handler({promise: promise, reason: promise._v});
  10431. }
  10432. });
  10433. };
  10434. var $reject = function(value){
  10435. var promise = this;
  10436. if(promise._d)return;
  10437. promise._d = true;
  10438. promise = promise._w || promise; // unwrap
  10439. promise._v = value;
  10440. promise._s = 2;
  10441. if(!promise._a)promise._a = promise._c.slice();
  10442. notify(promise, true);
  10443. };
  10444. var $resolve = function(value){
  10445. var promise = this
  10446. , then;
  10447. if(promise._d)return;
  10448. promise._d = true;
  10449. promise = promise._w || promise; // unwrap
  10450. try {
  10451. if(promise === value)throw TypeError("Promise can't be resolved itself");
  10452. if(then = isThenable(value)){
  10453. microtask(function(){
  10454. var wrapper = {_w: promise, _d: false}; // wrap
  10455. try {
  10456. then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1));
  10457. } catch(e){
  10458. $reject.call(wrapper, e);
  10459. }
  10460. });
  10461. } else {
  10462. promise._v = value;
  10463. promise._s = 1;
  10464. notify(promise, false);
  10465. }
  10466. } catch(e){
  10467. $reject.call({_w: promise, _d: false}, e); // wrap
  10468. }
  10469. };
  10470.  
  10471. // constructor polyfill
  10472. if(!USE_NATIVE){
  10473. // 25.4.3.1 Promise(executor)
  10474. $Promise = function Promise(executor){
  10475. anInstance(this, $Promise, PROMISE, '_h');
  10476. aFunction(executor);
  10477. Internal.call(this);
  10478. try {
  10479. executor(ctx($resolve, this, 1), ctx($reject, this, 1));
  10480. } catch(err){
  10481. $reject.call(this, err);
  10482. }
  10483. };
  10484. Internal = function Promise(executor){
  10485. this._c = []; // <- awaiting reactions
  10486. this._a = undefined; // <- checked in isUnhandled reactions
  10487. this._s = 0; // <- state
  10488. this._d = false; // <- done
  10489. this._v = undefined; // <- value
  10490. this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled
  10491. this._n = false; // <- notify
  10492. };
  10493. Internal.prototype = __webpack_require__(83)($Promise.prototype, {
  10494. // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)
  10495. then: function then(onFulfilled, onRejected){
  10496. var reaction = newPromiseCapability(speciesConstructor(this, $Promise));
  10497. reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;
  10498. reaction.fail = typeof onRejected == 'function' && onRejected;
  10499. reaction.domain = isNode ? process.domain : undefined;
  10500. this._c.push(reaction);
  10501. if(this._a)this._a.push(reaction);
  10502. if(this._s)notify(this, false);
  10503. return reaction.promise;
  10504. },
  10505. // 25.4.5.1 Promise.prototype.catch(onRejected)
  10506. 'catch': function(onRejected){
  10507. return this.then(undefined, onRejected);
  10508. }
  10509. });
  10510. PromiseCapability = function(){
  10511. var promise = new Internal;
  10512. this.promise = promise;
  10513. this.resolve = ctx($resolve, promise, 1);
  10514. this.reject = ctx($reject, promise, 1);
  10515. };
  10516. }
  10517.  
  10518. $export($export.G + $export.W + $export.F * !USE_NATIVE, {Promise: $Promise});
  10519. __webpack_require__(25)($Promise, PROMISE);
  10520. __webpack_require__(85)(PROMISE);
  10521. Wrapper = __webpack_require__(2)[PROMISE];
  10522.  
  10523. // statics
  10524. $export($export.S + $export.F * !USE_NATIVE, PROMISE, {
  10525. // 25.4.4.5 Promise.reject(r)
  10526. reject: function reject(r){
  10527. var capability = newPromiseCapability(this)
  10528. , $$reject = capability.reject;
  10529. $$reject(r);
  10530. return capability.promise;
  10531. }
  10532. });
  10533. $export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, {
  10534. // 25.4.4.6 Promise.resolve(x)
  10535. resolve: function resolve(x){
  10536. // instanceof instead of internal slot check because we should fix it without replacement native Promise core
  10537. if(x instanceof $Promise && sameConstructor(x.constructor, this))return x;
  10538. var capability = newPromiseCapability(this)
  10539. , $$resolve = capability.resolve;
  10540. $$resolve(x);
  10541. return capability.promise;
  10542. }
  10543. });
  10544. $export($export.S + $export.F * !(USE_NATIVE && __webpack_require__(41)(function(iter){
  10545. $Promise.all(iter)['catch'](empty);
  10546. })), PROMISE, {
  10547. // 25.4.4.1 Promise.all(iterable)
  10548. all: function all(iterable){
  10549. var C = this
  10550. , capability = newPromiseCapability(C)
  10551. , resolve = capability.resolve
  10552. , reject = capability.reject;
  10553. var abrupt = perform(function(){
  10554. var values = []
  10555. , index = 0
  10556. , remaining = 1;
  10557. forOf(iterable, false, function(promise){
  10558. var $index = index++
  10559. , alreadyCalled = false;
  10560. values.push(undefined);
  10561. remaining++;
  10562. C.resolve(promise).then(function(value){
  10563. if(alreadyCalled)return;
  10564. alreadyCalled = true;
  10565. values[$index] = value;
  10566. --remaining || resolve(values);
  10567. }, reject);
  10568. });
  10569. --remaining || resolve(values);
  10570. });
  10571. if(abrupt)reject(abrupt.error);
  10572. return capability.promise;
  10573. },
  10574. // 25.4.4.4 Promise.race(iterable)
  10575. race: function race(iterable){
  10576. var C = this
  10577. , capability = newPromiseCapability(C)
  10578. , reject = capability.reject;
  10579. var abrupt = perform(function(){
  10580. forOf(iterable, false, function(promise){
  10581. C.resolve(promise).then(capability.resolve, reject);
  10582. });
  10583. });
  10584. if(abrupt)reject(abrupt.error);
  10585. return capability.promise;
  10586. }
  10587. });
  10588.  
  10589. /***/ }),
  10590. /* 95 */
  10591. /***/ (function(module, exports, __webpack_require__) {
  10592.  
  10593. __webpack_require__(91);
  10594. var global = __webpack_require__(1)
  10595. , hide = __webpack_require__(6)
  10596. , Iterators = __webpack_require__(13)
  10597. , TO_STRING_TAG = __webpack_require__(0)('toStringTag');
  10598.  
  10599. for(var collections = ['NodeList', 'DOMTokenList', 'MediaList', 'StyleSheetList', 'CSSRuleList'], i = 0; i < 5; i++){
  10600. var NAME = collections[i]
  10601. , Collection = global[NAME]
  10602. , proto = Collection && Collection.prototype;
  10603. if(proto && !proto[TO_STRING_TAG])hide(proto, TO_STRING_TAG, NAME);
  10604. Iterators[NAME] = Iterators.Array;
  10605. }
  10606.  
  10607. /***/ }),
  10608. /* 96 */
  10609. /***/ (function(module, exports, __webpack_require__) {
  10610.  
  10611. exports = module.exports = __webpack_require__(97)(undefined);
  10612. // imports
  10613.  
  10614.  
  10615. // module
  10616. exports.push([module.i, "", ""]);
  10617.  
  10618. // exports
  10619.  
  10620.  
  10621. /***/ }),
  10622. /* 97 */
  10623. /***/ (function(module, exports, __webpack_require__) {
  10624.  
  10625. /* WEBPACK VAR INJECTION */(function(Buffer) {/*
  10626. MIT License http://www.opensource.org/licenses/mit-license.php
  10627. Author Tobias Koppers @sokra
  10628. */
  10629. // css base code, injected by the css-loader
  10630. module.exports = function(useSourceMap) {
  10631. var list = [];
  10632.  
  10633. // return the list of modules as css string
  10634. list.toString = function toString() {
  10635. return this.map(function (item) {
  10636. var content = cssWithMappingToString(item, useSourceMap);
  10637. if(item[2]) {
  10638. return "@media " + item[2] + "{" + content + "}";
  10639. } else {
  10640. return content;
  10641. }
  10642. }).join("");
  10643. };
  10644.  
  10645. // import a list of modules into the list
  10646. list.i = function(modules, mediaQuery) {
  10647. if(typeof modules === "string")
  10648. modules = [[null, modules, ""]];
  10649. var alreadyImportedModules = {};
  10650. for(var i = 0; i < this.length; i++) {
  10651. var id = this[i][0];
  10652. if(typeof id === "number")
  10653. alreadyImportedModules[id] = true;
  10654. }
  10655. for(i = 0; i < modules.length; i++) {
  10656. var item = modules[i];
  10657. // skip already imported module
  10658. // this implementation is not 100% perfect for weird media query combinations
  10659. // when a module is imported multiple times with different media queries.
  10660. // I hope this will never occur (Hey this way we have smaller bundles)
  10661. if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
  10662. if(mediaQuery && !item[2]) {
  10663. item[2] = mediaQuery;
  10664. } else if(mediaQuery) {
  10665. item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
  10666. }
  10667. list.push(item);
  10668. }
  10669. }
  10670. };
  10671. return list;
  10672. };
  10673.  
  10674. function cssWithMappingToString(item, useSourceMap) {
  10675. var content = item[1] || '';
  10676. var cssMapping = item[3];
  10677. if (!cssMapping) {
  10678. return content;
  10679. }
  10680.  
  10681. if (useSourceMap) {
  10682. var sourceMapping = toComment(cssMapping);
  10683. var sourceURLs = cssMapping.sources.map(function (source) {
  10684. return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
  10685. });
  10686.  
  10687. return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
  10688. }
  10689.  
  10690. return [content].join('\n');
  10691. }
  10692.  
  10693. // Adapted from convert-source-map (MIT)
  10694. function toComment(sourceMap) {
  10695. var base64 = new Buffer(JSON.stringify(sourceMap)).toString('base64');
  10696. var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
  10697.  
  10698. return '/*# ' + data + ' */';
  10699. }
  10700.  
  10701. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(62).Buffer))
  10702.  
  10703. /***/ }),
  10704. /* 98 */
  10705. /***/ (function(module, exports) {
  10706.  
  10707. module.exports = Date.now || now
  10708.  
  10709. function now() {
  10710. return new Date().getTime()
  10711. }
  10712.  
  10713.  
  10714. /***/ }),
  10715. /* 99 */
  10716. /***/ (function(module, exports, __webpack_require__) {
  10717.  
  10718.  
  10719. /**
  10720. * Module dependencies.
  10721. */
  10722.  
  10723. var now = __webpack_require__(98);
  10724.  
  10725. /**
  10726. * Returns a function, that, as long as it continues to be invoked, will not
  10727. * be triggered. The function will be called after it stops being called for
  10728. * N milliseconds. If `immediate` is passed, trigger the function on the
  10729. * leading edge, instead of the trailing.
  10730. *
  10731. * @source underscore.js
  10732. * @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/
  10733. * @param {Function} function to wrap
  10734. * @param {Number} timeout in ms (`100`)
  10735. * @param {Boolean} whether to execute at the beginning (`false`)
  10736. * @api public
  10737. */
  10738.  
  10739. module.exports = function debounce(func, wait, immediate){
  10740. var timeout, args, context, timestamp, result;
  10741. if (null == wait) wait = 100;
  10742.  
  10743. function later() {
  10744. var last = now() - timestamp;
  10745.  
  10746. if (last < wait && last > 0) {
  10747. timeout = setTimeout(later, wait - last);
  10748. } else {
  10749. timeout = null;
  10750. if (!immediate) {
  10751. result = func.apply(context, args);
  10752. if (!timeout) context = args = null;
  10753. }
  10754. }
  10755. };
  10756.  
  10757. return function debounced() {
  10758. context = this;
  10759. args = arguments;
  10760. timestamp = now();
  10761. var callNow = immediate && !timeout;
  10762. if (!timeout) timeout = setTimeout(later, wait);
  10763. if (callNow) {
  10764. result = func.apply(context, args);
  10765. context = args = null;
  10766. }
  10767.  
  10768. return result;
  10769. };
  10770. };
  10771.  
  10772.  
  10773. /***/ }),
  10774. /* 100 */
  10775. /***/ (function(module, exports) {
  10776.  
  10777. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  10778. var e, m
  10779. var eLen = nBytes * 8 - mLen - 1
  10780. var eMax = (1 << eLen) - 1
  10781. var eBias = eMax >> 1
  10782. var nBits = -7
  10783. var i = isLE ? (nBytes - 1) : 0
  10784. var d = isLE ? -1 : 1
  10785. var s = buffer[offset + i]
  10786.  
  10787. i += d
  10788.  
  10789. e = s & ((1 << (-nBits)) - 1)
  10790. s >>= (-nBits)
  10791. nBits += eLen
  10792. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  10793.  
  10794. m = e & ((1 << (-nBits)) - 1)
  10795. e >>= (-nBits)
  10796. nBits += mLen
  10797. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  10798.  
  10799. if (e === 0) {
  10800. e = 1 - eBias
  10801. } else if (e === eMax) {
  10802. return m ? NaN : ((s ? -1 : 1) * Infinity)
  10803. } else {
  10804. m = m + Math.pow(2, mLen)
  10805. e = e - eBias
  10806. }
  10807. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  10808. }
  10809.  
  10810. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  10811. var e, m, c
  10812. var eLen = nBytes * 8 - mLen - 1
  10813. var eMax = (1 << eLen) - 1
  10814. var eBias = eMax >> 1
  10815. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  10816. var i = isLE ? 0 : (nBytes - 1)
  10817. var d = isLE ? 1 : -1
  10818. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  10819.  
  10820. value = Math.abs(value)
  10821.  
  10822. if (isNaN(value) || value === Infinity) {
  10823. m = isNaN(value) ? 1 : 0
  10824. e = eMax
  10825. } else {
  10826. e = Math.floor(Math.log(value) / Math.LN2)
  10827. if (value * (c = Math.pow(2, -e)) < 1) {
  10828. e--
  10829. c *= 2
  10830. }
  10831. if (e + eBias >= 1) {
  10832. value += rt / c
  10833. } else {
  10834. value += rt * Math.pow(2, 1 - eBias)
  10835. }
  10836. if (value * c >= 2) {
  10837. e++
  10838. c /= 2
  10839. }
  10840.  
  10841. if (e + eBias >= eMax) {
  10842. m = 0
  10843. e = eMax
  10844. } else if (e + eBias >= 1) {
  10845. m = (value * c - 1) * Math.pow(2, mLen)
  10846. e = e + eBias
  10847. } else {
  10848. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  10849. e = 0
  10850. }
  10851. }
  10852.  
  10853. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  10854.  
  10855. e = (e << mLen) | m
  10856. eLen += mLen
  10857. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  10858.  
  10859. buffer[offset + i - d] |= s * 128
  10860. }
  10861.  
  10862.  
  10863. /***/ }),
  10864. /* 101 */
  10865. /***/ (function(module, exports) {
  10866.  
  10867. var toString = {}.toString;
  10868.  
  10869. module.exports = Array.isArray || function (arr) {
  10870. return toString.call(arr) == '[object Array]';
  10871. };
  10872.  
  10873.  
  10874. /***/ }),
  10875. /* 102 */
  10876. /***/ (function(module, exports, __webpack_require__) {
  10877.  
  10878. /* WEBPACK VAR INJECTION */(function(module, global) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.1 by @mathias */
  10879. ;(function(root) {
  10880.  
  10881. /** Detect free variables */
  10882. var freeExports = typeof exports == 'object' && exports &&
  10883. !exports.nodeType && exports;
  10884. var freeModule = typeof module == 'object' && module &&
  10885. !module.nodeType && module;
  10886. var freeGlobal = typeof global == 'object' && global;
  10887. if (
  10888. freeGlobal.global === freeGlobal ||
  10889. freeGlobal.window === freeGlobal ||
  10890. freeGlobal.self === freeGlobal
  10891. ) {
  10892. root = freeGlobal;
  10893. }
  10894.  
  10895. /**
  10896. * The `punycode` object.
  10897. * @name punycode
  10898. * @type Object
  10899. */
  10900. var punycode,
  10901.  
  10902. /** Highest positive signed 32-bit float value */
  10903. maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
  10904.  
  10905. /** Bootstring parameters */
  10906. base = 36,
  10907. tMin = 1,
  10908. tMax = 26,
  10909. skew = 38,
  10910. damp = 700,
  10911. initialBias = 72,
  10912. initialN = 128, // 0x80
  10913. delimiter = '-', // '\x2D'
  10914.  
  10915. /** Regular expressions */
  10916. regexPunycode = /^xn--/,
  10917. regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
  10918. regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
  10919.  
  10920. /** Error messages */
  10921. errors = {
  10922. 'overflow': 'Overflow: input needs wider integers to process',
  10923. 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
  10924. 'invalid-input': 'Invalid input'
  10925. },
  10926.  
  10927. /** Convenience shortcuts */
  10928. baseMinusTMin = base - tMin,
  10929. floor = Math.floor,
  10930. stringFromCharCode = String.fromCharCode,
  10931.  
  10932. /** Temporary variable */
  10933. key;
  10934.  
  10935. /*--------------------------------------------------------------------------*/
  10936.  
  10937. /**
  10938. * A generic error utility function.
  10939. * @private
  10940. * @param {String} type The error type.
  10941. * @returns {Error} Throws a `RangeError` with the applicable error message.
  10942. */
  10943. function error(type) {
  10944. throw new RangeError(errors[type]);
  10945. }
  10946.  
  10947. /**
  10948. * A generic `Array#map` utility function.
  10949. * @private
  10950. * @param {Array} array The array to iterate over.
  10951. * @param {Function} callback The function that gets called for every array
  10952. * item.
  10953. * @returns {Array} A new array of values returned by the callback function.
  10954. */
  10955. function map(array, fn) {
  10956. var length = array.length;
  10957. var result = [];
  10958. while (length--) {
  10959. result[length] = fn(array[length]);
  10960. }
  10961. return result;
  10962. }
  10963.  
  10964. /**
  10965. * A simple `Array#map`-like wrapper to work with domain name strings or email
  10966. * addresses.
  10967. * @private
  10968. * @param {String} domain The domain name or email address.
  10969. * @param {Function} callback The function that gets called for every
  10970. * character.
  10971. * @returns {Array} A new string of characters returned by the callback
  10972. * function.
  10973. */
  10974. function mapDomain(string, fn) {
  10975. var parts = string.split('@');
  10976. var result = '';
  10977. if (parts.length > 1) {
  10978. // In email addresses, only the domain name should be punycoded. Leave
  10979. // the local part (i.e. everything up to `@`) intact.
  10980. result = parts[0] + '@';
  10981. string = parts[1];
  10982. }
  10983. // Avoid `split(regex)` for IE8 compatibility. See #17.
  10984. string = string.replace(regexSeparators, '\x2E');
  10985. var labels = string.split('.');
  10986. var encoded = map(labels, fn).join('.');
  10987. return result + encoded;
  10988. }
  10989.  
  10990. /**
  10991. * Creates an array containing the numeric code points of each Unicode
  10992. * character in the string. While JavaScript uses UCS-2 internally,
  10993. * this function will convert a pair of surrogate halves (each of which
  10994. * UCS-2 exposes as separate characters) into a single code point,
  10995. * matching UTF-16.
  10996. * @see `punycode.ucs2.encode`
  10997. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  10998. * @memberOf punycode.ucs2
  10999. * @name decode
  11000. * @param {String} string The Unicode input string (UCS-2).
  11001. * @returns {Array} The new array of code points.
  11002. */
  11003. function ucs2decode(string) {
  11004. var output = [],
  11005. counter = 0,
  11006. length = string.length,
  11007. value,
  11008. extra;
  11009. while (counter < length) {
  11010. value = string.charCodeAt(counter++);
  11011. if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
  11012. // high surrogate, and there is a next character
  11013. extra = string.charCodeAt(counter++);
  11014. if ((extra & 0xFC00) == 0xDC00) { // low surrogate
  11015. output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
  11016. } else {
  11017. // unmatched surrogate; only append this code unit, in case the next
  11018. // code unit is the high surrogate of a surrogate pair
  11019. output.push(value);
  11020. counter--;
  11021. }
  11022. } else {
  11023. output.push(value);
  11024. }
  11025. }
  11026. return output;
  11027. }
  11028.  
  11029. /**
  11030. * Creates a string based on an array of numeric code points.
  11031. * @see `punycode.ucs2.decode`
  11032. * @memberOf punycode.ucs2
  11033. * @name encode
  11034. * @param {Array} codePoints The array of numeric code points.
  11035. * @returns {String} The new Unicode string (UCS-2).
  11036. */
  11037. function ucs2encode(array) {
  11038. return map(array, function(value) {
  11039. var output = '';
  11040. if (value > 0xFFFF) {
  11041. value -= 0x10000;
  11042. output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
  11043. value = 0xDC00 | value & 0x3FF;
  11044. }
  11045. output += stringFromCharCode(value);
  11046. return output;
  11047. }).join('');
  11048. }
  11049.  
  11050. /**
  11051. * Converts a basic code point into a digit/integer.
  11052. * @see `digitToBasic()`
  11053. * @private
  11054. * @param {Number} codePoint The basic numeric code point value.
  11055. * @returns {Number} The numeric value of a basic code point (for use in
  11056. * representing integers) in the range `0` to `base - 1`, or `base` if
  11057. * the code point does not represent a value.
  11058. */
  11059. function basicToDigit(codePoint) {
  11060. if (codePoint - 48 < 10) {
  11061. return codePoint - 22;
  11062. }
  11063. if (codePoint - 65 < 26) {
  11064. return codePoint - 65;
  11065. }
  11066. if (codePoint - 97 < 26) {
  11067. return codePoint - 97;
  11068. }
  11069. return base;
  11070. }
  11071.  
  11072. /**
  11073. * Converts a digit/integer into a basic code point.
  11074. * @see `basicToDigit()`
  11075. * @private
  11076. * @param {Number} digit The numeric value of a basic code point.
  11077. * @returns {Number} The basic code point whose value (when used for
  11078. * representing integers) is `digit`, which needs to be in the range
  11079. * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
  11080. * used; else, the lowercase form is used. The behavior is undefined
  11081. * if `flag` is non-zero and `digit` has no uppercase form.
  11082. */
  11083. function digitToBasic(digit, flag) {
  11084. // 0..25 map to ASCII a..z or A..Z
  11085. // 26..35 map to ASCII 0..9
  11086. return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
  11087. }
  11088.  
  11089. /**
  11090. * Bias adaptation function as per section 3.4 of RFC 3492.
  11091. * https://tools.ietf.org/html/rfc3492#section-3.4
  11092. * @private
  11093. */
  11094. function adapt(delta, numPoints, firstTime) {
  11095. var k = 0;
  11096. delta = firstTime ? floor(delta / damp) : delta >> 1;
  11097. delta += floor(delta / numPoints);
  11098. for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
  11099. delta = floor(delta / baseMinusTMin);
  11100. }
  11101. return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
  11102. }
  11103.  
  11104. /**
  11105. * Converts a Punycode string of ASCII-only symbols to a string of Unicode
  11106. * symbols.
  11107. * @memberOf punycode
  11108. * @param {String} input The Punycode string of ASCII-only symbols.
  11109. * @returns {String} The resulting string of Unicode symbols.
  11110. */
  11111. function decode(input) {
  11112. // Don't use UCS-2
  11113. var output = [],
  11114. inputLength = input.length,
  11115. out,
  11116. i = 0,
  11117. n = initialN,
  11118. bias = initialBias,
  11119. basic,
  11120. j,
  11121. index,
  11122. oldi,
  11123. w,
  11124. k,
  11125. digit,
  11126. t,
  11127. /** Cached calculation results */
  11128. baseMinusT;
  11129.  
  11130. // Handle the basic code points: let `basic` be the number of input code
  11131. // points before the last delimiter, or `0` if there is none, then copy
  11132. // the first basic code points to the output.
  11133.  
  11134. basic = input.lastIndexOf(delimiter);
  11135. if (basic < 0) {
  11136. basic = 0;
  11137. }
  11138.  
  11139. for (j = 0; j < basic; ++j) {
  11140. // if it's not a basic code point
  11141. if (input.charCodeAt(j) >= 0x80) {
  11142. error('not-basic');
  11143. }
  11144. output.push(input.charCodeAt(j));
  11145. }
  11146.  
  11147. // Main decoding loop: start just after the last delimiter if any basic code
  11148. // points were copied; start at the beginning otherwise.
  11149.  
  11150. for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
  11151.  
  11152. // `index` is the index of the next character to be consumed.
  11153. // Decode a generalized variable-length integer into `delta`,
  11154. // which gets added to `i`. The overflow checking is easier
  11155. // if we increase `i` as we go, then subtract off its starting
  11156. // value at the end to obtain `delta`.
  11157. for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
  11158.  
  11159. if (index >= inputLength) {
  11160. error('invalid-input');
  11161. }
  11162.  
  11163. digit = basicToDigit(input.charCodeAt(index++));
  11164.  
  11165. if (digit >= base || digit > floor((maxInt - i) / w)) {
  11166. error('overflow');
  11167. }
  11168.  
  11169. i += digit * w;
  11170. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  11171.  
  11172. if (digit < t) {
  11173. break;
  11174. }
  11175.  
  11176. baseMinusT = base - t;
  11177. if (w > floor(maxInt / baseMinusT)) {
  11178. error('overflow');
  11179. }
  11180.  
  11181. w *= baseMinusT;
  11182.  
  11183. }
  11184.  
  11185. out = output.length + 1;
  11186. bias = adapt(i - oldi, out, oldi == 0);
  11187.  
  11188. // `i` was supposed to wrap around from `out` to `0`,
  11189. // incrementing `n` each time, so we'll fix that now:
  11190. if (floor(i / out) > maxInt - n) {
  11191. error('overflow');
  11192. }
  11193.  
  11194. n += floor(i / out);
  11195. i %= out;
  11196.  
  11197. // Insert `n` at position `i` of the output
  11198. output.splice(i++, 0, n);
  11199.  
  11200. }
  11201.  
  11202. return ucs2encode(output);
  11203. }
  11204.  
  11205. /**
  11206. * Converts a string of Unicode symbols (e.g. a domain name label) to a
  11207. * Punycode string of ASCII-only symbols.
  11208. * @memberOf punycode
  11209. * @param {String} input The string of Unicode symbols.
  11210. * @returns {String} The resulting Punycode string of ASCII-only symbols.
  11211. */
  11212. function encode(input) {
  11213. var n,
  11214. delta,
  11215. handledCPCount,
  11216. basicLength,
  11217. bias,
  11218. j,
  11219. m,
  11220. q,
  11221. k,
  11222. t,
  11223. currentValue,
  11224. output = [],
  11225. /** `inputLength` will hold the number of code points in `input`. */
  11226. inputLength,
  11227. /** Cached calculation results */
  11228. handledCPCountPlusOne,
  11229. baseMinusT,
  11230. qMinusT;
  11231.  
  11232. // Convert the input in UCS-2 to Unicode
  11233. input = ucs2decode(input);
  11234.  
  11235. // Cache the length
  11236. inputLength = input.length;
  11237.  
  11238. // Initialize the state
  11239. n = initialN;
  11240. delta = 0;
  11241. bias = initialBias;
  11242.  
  11243. // Handle the basic code points
  11244. for (j = 0; j < inputLength; ++j) {
  11245. currentValue = input[j];
  11246. if (currentValue < 0x80) {
  11247. output.push(stringFromCharCode(currentValue));
  11248. }
  11249. }
  11250.  
  11251. handledCPCount = basicLength = output.length;
  11252.  
  11253. // `handledCPCount` is the number of code points that have been handled;
  11254. // `basicLength` is the number of basic code points.
  11255.  
  11256. // Finish the basic string - if it is not empty - with a delimiter
  11257. if (basicLength) {
  11258. output.push(delimiter);
  11259. }
  11260.  
  11261. // Main encoding loop:
  11262. while (handledCPCount < inputLength) {
  11263.  
  11264. // All non-basic code points < n have been handled already. Find the next
  11265. // larger one:
  11266. for (m = maxInt, j = 0; j < inputLength; ++j) {
  11267. currentValue = input[j];
  11268. if (currentValue >= n && currentValue < m) {
  11269. m = currentValue;
  11270. }
  11271. }
  11272.  
  11273. // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
  11274. // but guard against overflow
  11275. handledCPCountPlusOne = handledCPCount + 1;
  11276. if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
  11277. error('overflow');
  11278. }
  11279.  
  11280. delta += (m - n) * handledCPCountPlusOne;
  11281. n = m;
  11282.  
  11283. for (j = 0; j < inputLength; ++j) {
  11284. currentValue = input[j];
  11285.  
  11286. if (currentValue < n && ++delta > maxInt) {
  11287. error('overflow');
  11288. }
  11289.  
  11290. if (currentValue == n) {
  11291. // Represent delta as a generalized variable-length integer
  11292. for (q = delta, k = base; /* no condition */; k += base) {
  11293. t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
  11294. if (q < t) {
  11295. break;
  11296. }
  11297. qMinusT = q - t;
  11298. baseMinusT = base - t;
  11299. output.push(
  11300. stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
  11301. );
  11302. q = floor(qMinusT / baseMinusT);
  11303. }
  11304.  
  11305. output.push(stringFromCharCode(digitToBasic(q, 0)));
  11306. bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
  11307. delta = 0;
  11308. ++handledCPCount;
  11309. }
  11310. }
  11311.  
  11312. ++delta;
  11313. ++n;
  11314.  
  11315. }
  11316. return output.join('');
  11317. }
  11318.  
  11319. /**
  11320. * Converts a Punycode string representing a domain name or an email address
  11321. * to Unicode. Only the Punycoded parts of the input will be converted, i.e.
  11322. * it doesn't matter if you call it on a string that has already been
  11323. * converted to Unicode.
  11324. * @memberOf punycode
  11325. * @param {String} input The Punycoded domain name or email address to
  11326. * convert to Unicode.
  11327. * @returns {String} The Unicode representation of the given Punycode
  11328. * string.
  11329. */
  11330. function toUnicode(input) {
  11331. return mapDomain(input, function(string) {
  11332. return regexPunycode.test(string)
  11333. ? decode(string.slice(4).toLowerCase())
  11334. : string;
  11335. });
  11336. }
  11337.  
  11338. /**
  11339. * Converts a Unicode string representing a domain name or an email address to
  11340. * Punycode. Only the non-ASCII parts of the domain name will be converted,
  11341. * i.e. it doesn't matter if you call it with a domain that's already in
  11342. * ASCII.
  11343. * @memberOf punycode
  11344. * @param {String} input The domain name or email address to convert, as a
  11345. * Unicode string.
  11346. * @returns {String} The Punycode representation of the given domain name or
  11347. * email address.
  11348. */
  11349. function toASCII(input) {
  11350. return mapDomain(input, function(string) {
  11351. return regexNonASCII.test(string)
  11352. ? 'xn--' + encode(string)
  11353. : string;
  11354. });
  11355. }
  11356.  
  11357. /*--------------------------------------------------------------------------*/
  11358.  
  11359. /** Define the public API */
  11360. punycode = {
  11361. /**
  11362. * A string representing the current Punycode.js version number.
  11363. * @memberOf punycode
  11364. * @type String
  11365. */
  11366. 'version': '1.4.1',
  11367. /**
  11368. * An object of methods to convert from JavaScript's internal character
  11369. * representation (UCS-2) to Unicode code points, and back.
  11370. * @see <https://mathiasbynens.be/notes/javascript-encoding>
  11371. * @memberOf punycode
  11372. * @type Object
  11373. */
  11374. 'ucs2': {
  11375. 'decode': ucs2decode,
  11376. 'encode': ucs2encode
  11377. },
  11378. 'decode': decode,
  11379. 'encode': encode,
  11380. 'toASCII': toASCII,
  11381. 'toUnicode': toUnicode
  11382. };
  11383.  
  11384. /** Expose `punycode` */
  11385. // Some AMD build optimizers, like r.js, check for specific condition patterns
  11386. // like the following:
  11387. if (
  11388. true
  11389. ) {
  11390. !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {
  11391. return punycode;
  11392. }.call(exports, __webpack_require__, exports, module),
  11393. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  11394. } else if (freeExports && freeModule) {
  11395. if (module.exports == freeExports) {
  11396. // in Node.js, io.js, or RingoJS v0.8.0+
  11397. freeModule.exports = punycode;
  11398. } else {
  11399. // in Narwhal or RingoJS v0.7.0-
  11400. for (key in punycode) {
  11401. punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
  11402. }
  11403. }
  11404. } else {
  11405. // in Rhino or a web browser
  11406. root.punycode = punycode;
  11407. }
  11408.  
  11409. }(this));
  11410.  
  11411. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(116)(module), __webpack_require__(8)))
  11412.  
  11413. /***/ }),
  11414. /* 103 */
  11415. /***/ (function(module, exports, __webpack_require__) {
  11416.  
  11417. "use strict";
  11418. // Copyright Joyent, Inc. and other Node contributors.
  11419. //
  11420. // Permission is hereby granted, free of charge, to any person obtaining a
  11421. // copy of this software and associated documentation files (the
  11422. // "Software"), to deal in the Software without restriction, including
  11423. // without limitation the rights to use, copy, modify, merge, publish,
  11424. // distribute, sublicense, and/or sell copies of the Software, and to permit
  11425. // persons to whom the Software is furnished to do so, subject to the
  11426. // following conditions:
  11427. //
  11428. // The above copyright notice and this permission notice shall be included
  11429. // in all copies or substantial portions of the Software.
  11430. //
  11431. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  11432. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11433. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  11434. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  11435. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  11436. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  11437. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  11438.  
  11439.  
  11440.  
  11441. // If obj.hasOwnProperty has been overridden, then calling
  11442. // obj.hasOwnProperty(prop) will break.
  11443. // See: https://github.com/joyent/node/issues/1707
  11444. function hasOwnProperty(obj, prop) {
  11445. return Object.prototype.hasOwnProperty.call(obj, prop);
  11446. }
  11447.  
  11448. module.exports = function(qs, sep, eq, options) {
  11449. sep = sep || '&';
  11450. eq = eq || '=';
  11451. var obj = {};
  11452.  
  11453. if (typeof qs !== 'string' || qs.length === 0) {
  11454. return obj;
  11455. }
  11456.  
  11457. var regexp = /\+/g;
  11458. qs = qs.split(sep);
  11459.  
  11460. var maxKeys = 1000;
  11461. if (options && typeof options.maxKeys === 'number') {
  11462. maxKeys = options.maxKeys;
  11463. }
  11464.  
  11465. var len = qs.length;
  11466. // maxKeys <= 0 means that we should not limit keys count
  11467. if (maxKeys > 0 && len > maxKeys) {
  11468. len = maxKeys;
  11469. }
  11470.  
  11471. for (var i = 0; i < len; ++i) {
  11472. var x = qs[i].replace(regexp, '%20'),
  11473. idx = x.indexOf(eq),
  11474. kstr, vstr, k, v;
  11475.  
  11476. if (idx >= 0) {
  11477. kstr = x.substr(0, idx);
  11478. vstr = x.substr(idx + 1);
  11479. } else {
  11480. kstr = x;
  11481. vstr = '';
  11482. }
  11483.  
  11484. k = decodeURIComponent(kstr);
  11485. v = decodeURIComponent(vstr);
  11486.  
  11487. if (!hasOwnProperty(obj, k)) {
  11488. obj[k] = v;
  11489. } else if (isArray(obj[k])) {
  11490. obj[k].push(v);
  11491. } else {
  11492. obj[k] = [obj[k], v];
  11493. }
  11494. }
  11495.  
  11496. return obj;
  11497. };
  11498.  
  11499. var isArray = Array.isArray || function (xs) {
  11500. return Object.prototype.toString.call(xs) === '[object Array]';
  11501. };
  11502.  
  11503.  
  11504. /***/ }),
  11505. /* 104 */
  11506. /***/ (function(module, exports, __webpack_require__) {
  11507.  
  11508. "use strict";
  11509. // Copyright Joyent, Inc. and other Node contributors.
  11510. //
  11511. // Permission is hereby granted, free of charge, to any person obtaining a
  11512. // copy of this software and associated documentation files (the
  11513. // "Software"), to deal in the Software without restriction, including
  11514. // without limitation the rights to use, copy, modify, merge, publish,
  11515. // distribute, sublicense, and/or sell copies of the Software, and to permit
  11516. // persons to whom the Software is furnished to do so, subject to the
  11517. // following conditions:
  11518. //
  11519. // The above copyright notice and this permission notice shall be included
  11520. // in all copies or substantial portions of the Software.
  11521. //
  11522. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  11523. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  11524. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  11525. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  11526. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  11527. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  11528. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  11529.  
  11530.  
  11531.  
  11532. var stringifyPrimitive = function(v) {
  11533. switch (typeof v) {
  11534. case 'string':
  11535. return v;
  11536.  
  11537. case 'boolean':
  11538. return v ? 'true' : 'false';
  11539.  
  11540. case 'number':
  11541. return isFinite(v) ? v : '';
  11542.  
  11543. default:
  11544. return '';
  11545. }
  11546. };
  11547.  
  11548. module.exports = function(obj, sep, eq, name) {
  11549. sep = sep || '&';
  11550. eq = eq || '=';
  11551. if (obj === null) {
  11552. obj = undefined;
  11553. }
  11554.  
  11555. if (typeof obj === 'object') {
  11556. return map(objectKeys(obj), function(k) {
  11557. var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
  11558. if (isArray(obj[k])) {
  11559. return map(obj[k], function(v) {
  11560. return ks + encodeURIComponent(stringifyPrimitive(v));
  11561. }).join(sep);
  11562. } else {
  11563. return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
  11564. }
  11565. }).join(sep);
  11566.  
  11567. }
  11568.  
  11569. if (!name) return '';
  11570. return encodeURIComponent(stringifyPrimitive(name)) + eq +
  11571. encodeURIComponent(stringifyPrimitive(obj));
  11572. };
  11573.  
  11574. var isArray = Array.isArray || function (xs) {
  11575. return Object.prototype.toString.call(xs) === '[object Array]';
  11576. };
  11577.  
  11578. function map (xs, f) {
  11579. if (xs.map) return xs.map(f);
  11580. var res = [];
  11581. for (var i = 0; i < xs.length; i++) {
  11582. res.push(f(xs[i], i));
  11583. }
  11584. return res;
  11585. }
  11586.  
  11587. var objectKeys = Object.keys || function (obj) {
  11588. var res = [];
  11589. for (var key in obj) {
  11590. if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
  11591. }
  11592. return res;
  11593. };
  11594.  
  11595.  
  11596. /***/ }),
  11597. /* 105 */
  11598. /***/ (function(module, exports, __webpack_require__) {
  11599.  
  11600. "use strict";
  11601.  
  11602.  
  11603. exports.decode = exports.parse = __webpack_require__(103);
  11604. exports.encode = exports.stringify = __webpack_require__(104);
  11605.  
  11606.  
  11607. /***/ }),
  11608. /* 106 */
  11609. /***/ (function(module, exports, __webpack_require__) {
  11610.  
  11611. /* WEBPACK VAR INJECTION */(function(global) {// This method of obtaining a reference to the global object needs to be
  11612. // kept identical to the way it is obtained in runtime.js
  11613. var g =
  11614. typeof global === "object" ? global :
  11615. typeof window === "object" ? window :
  11616. typeof self === "object" ? self : this;
  11617.  
  11618. // Use `getOwnPropertyNames` because not all browsers support calling
  11619. // `hasOwnProperty` on the global `self` object in a worker. See #183.
  11620. var hadRuntime = g.regeneratorRuntime &&
  11621. Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0;
  11622.  
  11623. // Save the old regeneratorRuntime in case it needs to be restored later.
  11624. var oldRuntime = hadRuntime && g.regeneratorRuntime;
  11625.  
  11626. // Force reevalutation of runtime.js.
  11627. g.regeneratorRuntime = undefined;
  11628.  
  11629. module.exports = __webpack_require__(107);
  11630.  
  11631. if (hadRuntime) {
  11632. // Restore the original runtime.
  11633. g.regeneratorRuntime = oldRuntime;
  11634. } else {
  11635. // Remove the global property added by runtime.js.
  11636. try {
  11637. delete g.regeneratorRuntime;
  11638. } catch(e) {
  11639. g.regeneratorRuntime = undefined;
  11640. }
  11641. }
  11642.  
  11643. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8)))
  11644.  
  11645. /***/ }),
  11646. /* 107 */
  11647. /***/ (function(module, exports, __webpack_require__) {
  11648.  
  11649. /* WEBPACK VAR INJECTION */(function(global, process) {/**
  11650. * Copyright (c) 2014, Facebook, Inc.
  11651. * All rights reserved.
  11652. *
  11653. * This source code is licensed under the BSD-style license found in the
  11654. * https://raw.github.com/facebook/regenerator/master/LICENSE file. An
  11655. * additional grant of patent rights can be found in the PATENTS file in
  11656. * the same directory.
  11657. */
  11658.  
  11659. !(function(global) {
  11660. "use strict";
  11661.  
  11662. var Op = Object.prototype;
  11663. var hasOwn = Op.hasOwnProperty;
  11664. var undefined; // More compressible than void 0.
  11665. var $Symbol = typeof Symbol === "function" ? Symbol : {};
  11666. var iteratorSymbol = $Symbol.iterator || "@@iterator";
  11667. var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
  11668.  
  11669. var inModule = typeof module === "object";
  11670. var runtime = global.regeneratorRuntime;
  11671. if (runtime) {
  11672. if (inModule) {
  11673. // If regeneratorRuntime is defined globally and we're in a module,
  11674. // make the exports object identical to regeneratorRuntime.
  11675. module.exports = runtime;
  11676. }
  11677. // Don't bother evaluating the rest of this file if the runtime was
  11678. // already defined globally.
  11679. return;
  11680. }
  11681.  
  11682. // Define the runtime globally (as expected by generated code) as either
  11683. // module.exports (if we're in a module) or a new, empty object.
  11684. runtime = global.regeneratorRuntime = inModule ? module.exports : {};
  11685.  
  11686. function wrap(innerFn, outerFn, self, tryLocsList) {
  11687. // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
  11688. var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
  11689. var generator = Object.create(protoGenerator.prototype);
  11690. var context = new Context(tryLocsList || []);
  11691.  
  11692. // The ._invoke method unifies the implementations of the .next,
  11693. // .throw, and .return methods.
  11694. generator._invoke = makeInvokeMethod(innerFn, self, context);
  11695.  
  11696. return generator;
  11697. }
  11698. runtime.wrap = wrap;
  11699.  
  11700. // Try/catch helper to minimize deoptimizations. Returns a completion
  11701. // record like context.tryEntries[i].completion. This interface could
  11702. // have been (and was previously) designed to take a closure to be
  11703. // invoked without arguments, but in all the cases we care about we
  11704. // already have an existing method we want to call, so there's no need
  11705. // to create a new function object. We can even get away with assuming
  11706. // the method takes exactly one argument, since that happens to be true
  11707. // in every case, so we don't have to touch the arguments object. The
  11708. // only additional allocation required is the completion record, which
  11709. // has a stable shape and so hopefully should be cheap to allocate.
  11710. function tryCatch(fn, obj, arg) {
  11711. try {
  11712. return { type: "normal", arg: fn.call(obj, arg) };
  11713. } catch (err) {
  11714. return { type: "throw", arg: err };
  11715. }
  11716. }
  11717.  
  11718. var GenStateSuspendedStart = "suspendedStart";
  11719. var GenStateSuspendedYield = "suspendedYield";
  11720. var GenStateExecuting = "executing";
  11721. var GenStateCompleted = "completed";
  11722.  
  11723. // Returning this object from the innerFn has the same effect as
  11724. // breaking out of the dispatch switch statement.
  11725. var ContinueSentinel = {};
  11726.  
  11727. // Dummy constructor functions that we use as the .constructor and
  11728. // .constructor.prototype properties for functions that return Generator
  11729. // objects. For full spec compliance, you may wish to configure your
  11730. // minifier not to mangle the names of these two functions.
  11731. function Generator() {}
  11732. function GeneratorFunction() {}
  11733. function GeneratorFunctionPrototype() {}
  11734.  
  11735. // This is a polyfill for %IteratorPrototype% for environments that
  11736. // don't natively support it.
  11737. var IteratorPrototype = {};
  11738. IteratorPrototype[iteratorSymbol] = function () {
  11739. return this;
  11740. };
  11741.  
  11742. var getProto = Object.getPrototypeOf;
  11743. var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
  11744. if (NativeIteratorPrototype &&
  11745. NativeIteratorPrototype !== Op &&
  11746. hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
  11747. // This environment has a native %IteratorPrototype%; use it instead
  11748. // of the polyfill.
  11749. IteratorPrototype = NativeIteratorPrototype;
  11750. }
  11751.  
  11752. var Gp = GeneratorFunctionPrototype.prototype =
  11753. Generator.prototype = Object.create(IteratorPrototype);
  11754. GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
  11755. GeneratorFunctionPrototype.constructor = GeneratorFunction;
  11756. GeneratorFunctionPrototype[toStringTagSymbol] =
  11757. GeneratorFunction.displayName = "GeneratorFunction";
  11758.  
  11759. // Helper for defining the .next, .throw, and .return methods of the
  11760. // Iterator interface in terms of a single ._invoke method.
  11761. function defineIteratorMethods(prototype) {
  11762. ["next", "throw", "return"].forEach(function(method) {
  11763. prototype[method] = function(arg) {
  11764. return this._invoke(method, arg);
  11765. };
  11766. });
  11767. }
  11768.  
  11769. runtime.isGeneratorFunction = function(genFun) {
  11770. var ctor = typeof genFun === "function" && genFun.constructor;
  11771. return ctor
  11772. ? ctor === GeneratorFunction ||
  11773. // For the native GeneratorFunction constructor, the best we can
  11774. // do is to check its .name property.
  11775. (ctor.displayName || ctor.name) === "GeneratorFunction"
  11776. : false;
  11777. };
  11778.  
  11779. runtime.mark = function(genFun) {
  11780. if (Object.setPrototypeOf) {
  11781. Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
  11782. } else {
  11783. genFun.__proto__ = GeneratorFunctionPrototype;
  11784. if (!(toStringTagSymbol in genFun)) {
  11785. genFun[toStringTagSymbol] = "GeneratorFunction";
  11786. }
  11787. }
  11788. genFun.prototype = Object.create(Gp);
  11789. return genFun;
  11790. };
  11791.  
  11792. // Within the body of any async function, `await x` is transformed to
  11793. // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
  11794. // `hasOwn.call(value, "__await")` to determine if the yielded value is
  11795. // meant to be awaited.
  11796. runtime.awrap = function(arg) {
  11797. return { __await: arg };
  11798. };
  11799.  
  11800. function AsyncIterator(generator) {
  11801. function invoke(method, arg, resolve, reject) {
  11802. var record = tryCatch(generator[method], generator, arg);
  11803. if (record.type === "throw") {
  11804. reject(record.arg);
  11805. } else {
  11806. var result = record.arg;
  11807. var value = result.value;
  11808. if (value &&
  11809. typeof value === "object" &&
  11810. hasOwn.call(value, "__await")) {
  11811. return Promise.resolve(value.__await).then(function(value) {
  11812. invoke("next", value, resolve, reject);
  11813. }, function(err) {
  11814. invoke("throw", err, resolve, reject);
  11815. });
  11816. }
  11817.  
  11818. return Promise.resolve(value).then(function(unwrapped) {
  11819. // When a yielded Promise is resolved, its final value becomes
  11820. // the .value of the Promise<{value,done}> result for the
  11821. // current iteration. If the Promise is rejected, however, the
  11822. // result for this iteration will be rejected with the same
  11823. // reason. Note that rejections of yielded Promises are not
  11824. // thrown back into the generator function, as is the case
  11825. // when an awaited Promise is rejected. This difference in
  11826. // behavior between yield and await is important, because it
  11827. // allows the consumer to decide what to do with the yielded
  11828. // rejection (swallow it and continue, manually .throw it back
  11829. // into the generator, abandon iteration, whatever). With
  11830. // await, by contrast, there is no opportunity to examine the
  11831. // rejection reason outside the generator function, so the
  11832. // only option is to throw it from the await expression, and
  11833. // let the generator function handle the exception.
  11834. result.value = unwrapped;
  11835. resolve(result);
  11836. }, reject);
  11837. }
  11838. }
  11839.  
  11840. if (typeof process === "object" && process.domain) {
  11841. invoke = process.domain.bind(invoke);
  11842. }
  11843.  
  11844. var previousPromise;
  11845.  
  11846. function enqueue(method, arg) {
  11847. function callInvokeWithMethodAndArg() {
  11848. return new Promise(function(resolve, reject) {
  11849. invoke(method, arg, resolve, reject);
  11850. });
  11851. }
  11852.  
  11853. return previousPromise =
  11854. // If enqueue has been called before, then we want to wait until
  11855. // all previous Promises have been resolved before calling invoke,
  11856. // so that results are always delivered in the correct order. If
  11857. // enqueue has not been called before, then it is important to
  11858. // call invoke immediately, without waiting on a callback to fire,
  11859. // so that the async generator function has the opportunity to do
  11860. // any necessary setup in a predictable way. This predictability
  11861. // is why the Promise constructor synchronously invokes its
  11862. // executor callback, and why async functions synchronously
  11863. // execute code before the first await. Since we implement simple
  11864. // async functions in terms of async generators, it is especially
  11865. // important to get this right, even though it requires care.
  11866. previousPromise ? previousPromise.then(
  11867. callInvokeWithMethodAndArg,
  11868. // Avoid propagating failures to Promises returned by later
  11869. // invocations of the iterator.
  11870. callInvokeWithMethodAndArg
  11871. ) : callInvokeWithMethodAndArg();
  11872. }
  11873.  
  11874. // Define the unified helper method that is used to implement .next,
  11875. // .throw, and .return (see defineIteratorMethods).
  11876. this._invoke = enqueue;
  11877. }
  11878.  
  11879. defineIteratorMethods(AsyncIterator.prototype);
  11880. runtime.AsyncIterator = AsyncIterator;
  11881.  
  11882. // Note that simple async functions are implemented on top of
  11883. // AsyncIterator objects; they just return a Promise for the value of
  11884. // the final result produced by the iterator.
  11885. runtime.async = function(innerFn, outerFn, self, tryLocsList) {
  11886. var iter = new AsyncIterator(
  11887. wrap(innerFn, outerFn, self, tryLocsList)
  11888. );
  11889.  
  11890. return runtime.isGeneratorFunction(outerFn)
  11891. ? iter // If outerFn is a generator, return the full iterator.
  11892. : iter.next().then(function(result) {
  11893. return result.done ? result.value : iter.next();
  11894. });
  11895. };
  11896.  
  11897. function makeInvokeMethod(innerFn, self, context) {
  11898. var state = GenStateSuspendedStart;
  11899.  
  11900. return function invoke(method, arg) {
  11901. if (state === GenStateExecuting) {
  11902. throw new Error("Generator is already running");
  11903. }
  11904.  
  11905. if (state === GenStateCompleted) {
  11906. if (method === "throw") {
  11907. throw arg;
  11908. }
  11909.  
  11910. // Be forgiving, per 25.3.3.3.3 of the spec:
  11911. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
  11912. return doneResult();
  11913. }
  11914.  
  11915. context.method = method;
  11916. context.arg = arg;
  11917.  
  11918. while (true) {
  11919. var delegate = context.delegate;
  11920. if (delegate) {
  11921. var delegateResult = maybeInvokeDelegate(delegate, context);
  11922. if (delegateResult) {
  11923. if (delegateResult === ContinueSentinel) continue;
  11924. return delegateResult;
  11925. }
  11926. }
  11927.  
  11928. if (context.method === "next") {
  11929. // Setting context._sent for legacy support of Babel's
  11930. // function.sent implementation.
  11931. context.sent = context._sent = context.arg;
  11932.  
  11933. } else if (context.method === "throw") {
  11934. if (state === GenStateSuspendedStart) {
  11935. state = GenStateCompleted;
  11936. throw context.arg;
  11937. }
  11938.  
  11939. context.dispatchException(context.arg);
  11940.  
  11941. } else if (context.method === "return") {
  11942. context.abrupt("return", context.arg);
  11943. }
  11944.  
  11945. state = GenStateExecuting;
  11946.  
  11947. var record = tryCatch(innerFn, self, context);
  11948. if (record.type === "normal") {
  11949. // If an exception is thrown from innerFn, we leave state ===
  11950. // GenStateExecuting and loop back for another invocation.
  11951. state = context.done
  11952. ? GenStateCompleted
  11953. : GenStateSuspendedYield;
  11954.  
  11955. if (record.arg === ContinueSentinel) {
  11956. continue;
  11957. }
  11958.  
  11959. return {
  11960. value: record.arg,
  11961. done: context.done
  11962. };
  11963.  
  11964. } else if (record.type === "throw") {
  11965. state = GenStateCompleted;
  11966. // Dispatch the exception by looping back around to the
  11967. // context.dispatchException(context.arg) call above.
  11968. context.method = "throw";
  11969. context.arg = record.arg;
  11970. }
  11971. }
  11972. };
  11973. }
  11974.  
  11975. // Call delegate.iterator[context.method](context.arg) and handle the
  11976. // result, either by returning a { value, done } result from the
  11977. // delegate iterator, or by modifying context.method and context.arg,
  11978. // setting context.delegate to null, and returning the ContinueSentinel.
  11979. function maybeInvokeDelegate(delegate, context) {
  11980. var method = delegate.iterator[context.method];
  11981. if (method === undefined) {
  11982. // A .throw or .return when the delegate iterator has no .throw
  11983. // method always terminates the yield* loop.
  11984. context.delegate = null;
  11985.  
  11986. if (context.method === "throw") {
  11987. if (delegate.iterator.return) {
  11988. // If the delegate iterator has a return method, give it a
  11989. // chance to clean up.
  11990. context.method = "return";
  11991. context.arg = undefined;
  11992. maybeInvokeDelegate(delegate, context);
  11993.  
  11994. if (context.method === "throw") {
  11995. // If maybeInvokeDelegate(context) changed context.method from
  11996. // "return" to "throw", let that override the TypeError below.
  11997. return ContinueSentinel;
  11998. }
  11999. }
  12000.  
  12001. context.method = "throw";
  12002. context.arg = new TypeError(
  12003. "The iterator does not provide a 'throw' method");
  12004. }
  12005.  
  12006. return ContinueSentinel;
  12007. }
  12008.  
  12009. var record = tryCatch(method, delegate.iterator, context.arg);
  12010.  
  12011. if (record.type === "throw") {
  12012. context.method = "throw";
  12013. context.arg = record.arg;
  12014. context.delegate = null;
  12015. return ContinueSentinel;
  12016. }
  12017.  
  12018. var info = record.arg;
  12019.  
  12020. if (! info) {
  12021. context.method = "throw";
  12022. context.arg = new TypeError("iterator result is not an object");
  12023. context.delegate = null;
  12024. return ContinueSentinel;
  12025. }
  12026.  
  12027. if (info.done) {
  12028. // Assign the result of the finished delegate to the temporary
  12029. // variable specified by delegate.resultName (see delegateYield).
  12030. context[delegate.resultName] = info.value;
  12031.  
  12032. // Resume execution at the desired location (see delegateYield).
  12033. context.next = delegate.nextLoc;
  12034.  
  12035. // If context.method was "throw" but the delegate handled the
  12036. // exception, let the outer generator proceed normally. If
  12037. // context.method was "next", forget context.arg since it has been
  12038. // "consumed" by the delegate iterator. If context.method was
  12039. // "return", allow the original .return call to continue in the
  12040. // outer generator.
  12041. if (context.method !== "return") {
  12042. context.method = "next";
  12043. context.arg = undefined;
  12044. }
  12045.  
  12046. } else {
  12047. // Re-yield the result returned by the delegate method.
  12048. return info;
  12049. }
  12050.  
  12051. // The delegate iterator is finished, so forget it and continue with
  12052. // the outer generator.
  12053. context.delegate = null;
  12054. return ContinueSentinel;
  12055. }
  12056.  
  12057. // Define Generator.prototype.{next,throw,return} in terms of the
  12058. // unified ._invoke helper method.
  12059. defineIteratorMethods(Gp);
  12060.  
  12061. Gp[toStringTagSymbol] = "Generator";
  12062.  
  12063. Gp.toString = function() {
  12064. return "[object Generator]";
  12065. };
  12066.  
  12067. function pushTryEntry(locs) {
  12068. var entry = { tryLoc: locs[0] };
  12069.  
  12070. if (1 in locs) {
  12071. entry.catchLoc = locs[1];
  12072. }
  12073.  
  12074. if (2 in locs) {
  12075. entry.finallyLoc = locs[2];
  12076. entry.afterLoc = locs[3];
  12077. }
  12078.  
  12079. this.tryEntries.push(entry);
  12080. }
  12081.  
  12082. function resetTryEntry(entry) {
  12083. var record = entry.completion || {};
  12084. record.type = "normal";
  12085. delete record.arg;
  12086. entry.completion = record;
  12087. }
  12088.  
  12089. function Context(tryLocsList) {
  12090. // The root entry object (effectively a try statement without a catch
  12091. // or a finally block) gives us a place to store values thrown from
  12092. // locations where there is no enclosing try statement.
  12093. this.tryEntries = [{ tryLoc: "root" }];
  12094. tryLocsList.forEach(pushTryEntry, this);
  12095. this.reset(true);
  12096. }
  12097.  
  12098. runtime.keys = function(object) {
  12099. var keys = [];
  12100. for (var key in object) {
  12101. keys.push(key);
  12102. }
  12103. keys.reverse();
  12104.  
  12105. // Rather than returning an object with a next method, we keep
  12106. // things simple and return the next function itself.
  12107. return function next() {
  12108. while (keys.length) {
  12109. var key = keys.pop();
  12110. if (key in object) {
  12111. next.value = key;
  12112. next.done = false;
  12113. return next;
  12114. }
  12115. }
  12116.  
  12117. // To avoid creating an additional object, we just hang the .value
  12118. // and .done properties off the next function object itself. This
  12119. // also ensures that the minifier will not anonymize the function.
  12120. next.done = true;
  12121. return next;
  12122. };
  12123. };
  12124.  
  12125. function values(iterable) {
  12126. if (iterable) {
  12127. var iteratorMethod = iterable[iteratorSymbol];
  12128. if (iteratorMethod) {
  12129. return iteratorMethod.call(iterable);
  12130. }
  12131.  
  12132. if (typeof iterable.next === "function") {
  12133. return iterable;
  12134. }
  12135.  
  12136. if (!isNaN(iterable.length)) {
  12137. var i = -1, next = function next() {
  12138. while (++i < iterable.length) {
  12139. if (hasOwn.call(iterable, i)) {
  12140. next.value = iterable[i];
  12141. next.done = false;
  12142. return next;
  12143. }
  12144. }
  12145.  
  12146. next.value = undefined;
  12147. next.done = true;
  12148.  
  12149. return next;
  12150. };
  12151.  
  12152. return next.next = next;
  12153. }
  12154. }
  12155.  
  12156. // Return an iterator with no values.
  12157. return { next: doneResult };
  12158. }
  12159. runtime.values = values;
  12160.  
  12161. function doneResult() {
  12162. return { value: undefined, done: true };
  12163. }
  12164.  
  12165. Context.prototype = {
  12166. constructor: Context,
  12167.  
  12168. reset: function(skipTempReset) {
  12169. this.prev = 0;
  12170. this.next = 0;
  12171. // Resetting context._sent for legacy support of Babel's
  12172. // function.sent implementation.
  12173. this.sent = this._sent = undefined;
  12174. this.done = false;
  12175. this.delegate = null;
  12176.  
  12177. this.method = "next";
  12178. this.arg = undefined;
  12179.  
  12180. this.tryEntries.forEach(resetTryEntry);
  12181.  
  12182. if (!skipTempReset) {
  12183. for (var name in this) {
  12184. // Not sure about the optimal order of these conditions:
  12185. if (name.charAt(0) === "t" &&
  12186. hasOwn.call(this, name) &&
  12187. !isNaN(+name.slice(1))) {
  12188. this[name] = undefined;
  12189. }
  12190. }
  12191. }
  12192. },
  12193.  
  12194. stop: function() {
  12195. this.done = true;
  12196.  
  12197. var rootEntry = this.tryEntries[0];
  12198. var rootRecord = rootEntry.completion;
  12199. if (rootRecord.type === "throw") {
  12200. throw rootRecord.arg;
  12201. }
  12202.  
  12203. return this.rval;
  12204. },
  12205.  
  12206. dispatchException: function(exception) {
  12207. if (this.done) {
  12208. throw exception;
  12209. }
  12210.  
  12211. var context = this;
  12212. function handle(loc, caught) {
  12213. record.type = "throw";
  12214. record.arg = exception;
  12215. context.next = loc;
  12216.  
  12217. if (caught) {
  12218. // If the dispatched exception was caught by a catch block,
  12219. // then let that catch block handle the exception normally.
  12220. context.method = "next";
  12221. context.arg = undefined;
  12222. }
  12223.  
  12224. return !! caught;
  12225. }
  12226.  
  12227. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  12228. var entry = this.tryEntries[i];
  12229. var record = entry.completion;
  12230.  
  12231. if (entry.tryLoc === "root") {
  12232. // Exception thrown outside of any try block that could handle
  12233. // it, so set the completion value of the entire function to
  12234. // throw the exception.
  12235. return handle("end");
  12236. }
  12237.  
  12238. if (entry.tryLoc <= this.prev) {
  12239. var hasCatch = hasOwn.call(entry, "catchLoc");
  12240. var hasFinally = hasOwn.call(entry, "finallyLoc");
  12241.  
  12242. if (hasCatch && hasFinally) {
  12243. if (this.prev < entry.catchLoc) {
  12244. return handle(entry.catchLoc, true);
  12245. } else if (this.prev < entry.finallyLoc) {
  12246. return handle(entry.finallyLoc);
  12247. }
  12248.  
  12249. } else if (hasCatch) {
  12250. if (this.prev < entry.catchLoc) {
  12251. return handle(entry.catchLoc, true);
  12252. }
  12253.  
  12254. } else if (hasFinally) {
  12255. if (this.prev < entry.finallyLoc) {
  12256. return handle(entry.finallyLoc);
  12257. }
  12258.  
  12259. } else {
  12260. throw new Error("try statement without catch or finally");
  12261. }
  12262. }
  12263. }
  12264. },
  12265.  
  12266. abrupt: function(type, arg) {
  12267. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  12268. var entry = this.tryEntries[i];
  12269. if (entry.tryLoc <= this.prev &&
  12270. hasOwn.call(entry, "finallyLoc") &&
  12271. this.prev < entry.finallyLoc) {
  12272. var finallyEntry = entry;
  12273. break;
  12274. }
  12275. }
  12276.  
  12277. if (finallyEntry &&
  12278. (type === "break" ||
  12279. type === "continue") &&
  12280. finallyEntry.tryLoc <= arg &&
  12281. arg <= finallyEntry.finallyLoc) {
  12282. // Ignore the finally entry if control is not jumping to a
  12283. // location outside the try/catch block.
  12284. finallyEntry = null;
  12285. }
  12286.  
  12287. var record = finallyEntry ? finallyEntry.completion : {};
  12288. record.type = type;
  12289. record.arg = arg;
  12290.  
  12291. if (finallyEntry) {
  12292. this.method = "next";
  12293. this.next = finallyEntry.finallyLoc;
  12294. return ContinueSentinel;
  12295. }
  12296.  
  12297. return this.complete(record);
  12298. },
  12299.  
  12300. complete: function(record, afterLoc) {
  12301. if (record.type === "throw") {
  12302. throw record.arg;
  12303. }
  12304.  
  12305. if (record.type === "break" ||
  12306. record.type === "continue") {
  12307. this.next = record.arg;
  12308. } else if (record.type === "return") {
  12309. this.rval = this.arg = record.arg;
  12310. this.method = "return";
  12311. this.next = "end";
  12312. } else if (record.type === "normal" && afterLoc) {
  12313. this.next = afterLoc;
  12314. }
  12315.  
  12316. return ContinueSentinel;
  12317. },
  12318.  
  12319. finish: function(finallyLoc) {
  12320. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  12321. var entry = this.tryEntries[i];
  12322. if (entry.finallyLoc === finallyLoc) {
  12323. this.complete(entry.completion, entry.afterLoc);
  12324. resetTryEntry(entry);
  12325. return ContinueSentinel;
  12326. }
  12327. }
  12328. },
  12329.  
  12330. "catch": function(tryLoc) {
  12331. for (var i = this.tryEntries.length - 1; i >= 0; --i) {
  12332. var entry = this.tryEntries[i];
  12333. if (entry.tryLoc === tryLoc) {
  12334. var record = entry.completion;
  12335. if (record.type === "throw") {
  12336. var thrown = record.arg;
  12337. resetTryEntry(entry);
  12338. }
  12339. return thrown;
  12340. }
  12341. }
  12342.  
  12343. // The context.catch method must only be called with a location
  12344. // argument that corresponds to a known catch block.
  12345. throw new Error("illegal catch attempt");
  12346. },
  12347.  
  12348. delegateYield: function(iterable, resultName, nextLoc) {
  12349. this.delegate = {
  12350. iterator: values(iterable),
  12351. resultName: resultName,
  12352. nextLoc: nextLoc
  12353. };
  12354.  
  12355. if (this.method === "next") {
  12356. // Deliberately forget the last sent value so that we don't
  12357. // accidentally pass it on to the delegate.
  12358. this.arg = undefined;
  12359. }
  12360.  
  12361. return ContinueSentinel;
  12362. }
  12363. };
  12364. })(
  12365. // Among the various tricks for obtaining a reference to the global
  12366. // object, this seems to be the most reliable technique that does not
  12367. // use indirect eval (which violates Content Security Policy).
  12368. typeof global === "object" ? global :
  12369. typeof window === "object" ? window :
  12370. typeof self === "object" ? self : this
  12371. );
  12372.  
  12373. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8), __webpack_require__(31)))
  12374.  
  12375. /***/ }),
  12376. /* 108 */
  12377. /***/ (function(module, exports, __webpack_require__) {
  12378.  
  12379. /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
  12380. "use strict";
  12381.  
  12382. if (global.setImmediate) {
  12383. return;
  12384. }
  12385.  
  12386. var nextHandle = 1; // Spec says greater than zero
  12387. var tasksByHandle = {};
  12388. var currentlyRunningATask = false;
  12389. var doc = global.document;
  12390. var registerImmediate;
  12391.  
  12392. function setImmediate(callback) {
  12393. // Callback can either be a function or a string
  12394. if (typeof callback !== "function") {
  12395. callback = new Function("" + callback);
  12396. }
  12397. // Copy function arguments
  12398. var args = new Array(arguments.length - 1);
  12399. for (var i = 0; i < args.length; i++) {
  12400. args[i] = arguments[i + 1];
  12401. }
  12402. // Store and register the task
  12403. var task = { callback: callback, args: args };
  12404. tasksByHandle[nextHandle] = task;
  12405. registerImmediate(nextHandle);
  12406. return nextHandle++;
  12407. }
  12408.  
  12409. function clearImmediate(handle) {
  12410. delete tasksByHandle[handle];
  12411. }
  12412.  
  12413. function run(task) {
  12414. var callback = task.callback;
  12415. var args = task.args;
  12416. switch (args.length) {
  12417. case 0:
  12418. callback();
  12419. break;
  12420. case 1:
  12421. callback(args[0]);
  12422. break;
  12423. case 2:
  12424. callback(args[0], args[1]);
  12425. break;
  12426. case 3:
  12427. callback(args[0], args[1], args[2]);
  12428. break;
  12429. default:
  12430. callback.apply(undefined, args);
  12431. break;
  12432. }
  12433. }
  12434.  
  12435. function runIfPresent(handle) {
  12436. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  12437. // So if we're currently running a task, we'll need to delay this invocation.
  12438. if (currentlyRunningATask) {
  12439. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  12440. // "too much recursion" error.
  12441. setTimeout(runIfPresent, 0, handle);
  12442. } else {
  12443. var task = tasksByHandle[handle];
  12444. if (task) {
  12445. currentlyRunningATask = true;
  12446. try {
  12447. run(task);
  12448. } finally {
  12449. clearImmediate(handle);
  12450. currentlyRunningATask = false;
  12451. }
  12452. }
  12453. }
  12454. }
  12455.  
  12456. function installNextTickImplementation() {
  12457. registerImmediate = function(handle) {
  12458. process.nextTick(function () { runIfPresent(handle); });
  12459. };
  12460. }
  12461.  
  12462. function canUsePostMessage() {
  12463. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  12464. // where `global.postMessage` means something completely different and can't be used for this purpose.
  12465. if (global.postMessage && !global.importScripts) {
  12466. var postMessageIsAsynchronous = true;
  12467. var oldOnMessage = global.onmessage;
  12468. global.onmessage = function() {
  12469. postMessageIsAsynchronous = false;
  12470. };
  12471. global.postMessage("", "*");
  12472. global.onmessage = oldOnMessage;
  12473. return postMessageIsAsynchronous;
  12474. }
  12475. }
  12476.  
  12477. function installPostMessageImplementation() {
  12478. // Installs an event handler on `global` for the `message` event: see
  12479. // * https://developer.mozilla.org/en/DOM/window.postMessage
  12480. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  12481.  
  12482. var messagePrefix = "setImmediate$" + Math.random() + "$";
  12483. var onGlobalMessage = function(event) {
  12484. if (event.source === global &&
  12485. typeof event.data === "string" &&
  12486. event.data.indexOf(messagePrefix) === 0) {
  12487. runIfPresent(+event.data.slice(messagePrefix.length));
  12488. }
  12489. };
  12490.  
  12491. if (global.addEventListener) {
  12492. global.addEventListener("message", onGlobalMessage, false);
  12493. } else {
  12494. global.attachEvent("onmessage", onGlobalMessage);
  12495. }
  12496.  
  12497. registerImmediate = function(handle) {
  12498. global.postMessage(messagePrefix + handle, "*");
  12499. };
  12500. }
  12501.  
  12502. function installMessageChannelImplementation() {
  12503. var channel = new MessageChannel();
  12504. channel.port1.onmessage = function(event) {
  12505. var handle = event.data;
  12506. runIfPresent(handle);
  12507. };
  12508.  
  12509. registerImmediate = function(handle) {
  12510. channel.port2.postMessage(handle);
  12511. };
  12512. }
  12513.  
  12514. function installReadyStateChangeImplementation() {
  12515. var html = doc.documentElement;
  12516. registerImmediate = function(handle) {
  12517. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  12518. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  12519. var script = doc.createElement("script");
  12520. script.onreadystatechange = function () {
  12521. runIfPresent(handle);
  12522. script.onreadystatechange = null;
  12523. html.removeChild(script);
  12524. script = null;
  12525. };
  12526. html.appendChild(script);
  12527. };
  12528. }
  12529.  
  12530. function installSetTimeoutImplementation() {
  12531. registerImmediate = function(handle) {
  12532. setTimeout(runIfPresent, 0, handle);
  12533. };
  12534. }
  12535.  
  12536. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  12537. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  12538. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  12539.  
  12540. // Don't get fooled by e.g. browserify environments.
  12541. if ({}.toString.call(global.process) === "[object process]") {
  12542. // For Node.js before 0.9
  12543. installNextTickImplementation();
  12544.  
  12545. } else if (canUsePostMessage()) {
  12546. // For non-IE10 modern browsers
  12547. installPostMessageImplementation();
  12548.  
  12549. } else if (global.MessageChannel) {
  12550. // For web workers, where supported
  12551. installMessageChannelImplementation();
  12552.  
  12553. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  12554. // For IE 6–8
  12555. installReadyStateChangeImplementation();
  12556.  
  12557. } else {
  12558. // For older browsers
  12559. installSetTimeoutImplementation();
  12560. }
  12561.  
  12562. attachTo.setImmediate = setImmediate;
  12563. attachTo.clearImmediate = clearImmediate;
  12564. }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
  12565.  
  12566. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(8), __webpack_require__(31)))
  12567.  
  12568. /***/ }),
  12569. /* 109 */
  12570. /***/ (function(module, exports, __webpack_require__) {
  12571.  
  12572. /*
  12573. MIT License http://www.opensource.org/licenses/mit-license.php
  12574. Author Tobias Koppers @sokra
  12575. */
  12576. var stylesInDom = {},
  12577. memoize = function(fn) {
  12578. var memo;
  12579. return function () {
  12580. if (typeof memo === "undefined") memo = fn.apply(this, arguments);
  12581. return memo;
  12582. };
  12583. },
  12584. isOldIE = memoize(function() {
  12585. return /msie [6-9]\b/.test(self.navigator.userAgent.toLowerCase());
  12586. }),
  12587. getElement = (function(fn) {
  12588. var memo = {};
  12589. return function(selector) {
  12590. if (typeof memo[selector] === "undefined") {
  12591. memo[selector] = fn.call(this, selector);
  12592. }
  12593. return memo[selector]
  12594. };
  12595. })(function (styleTarget) {
  12596. return document.querySelector(styleTarget)
  12597. }),
  12598. singletonElement = null,
  12599. singletonCounter = 0,
  12600. styleElementsInsertedAtTop = [],
  12601. fixUrls = __webpack_require__(110);
  12602.  
  12603. module.exports = function(list, options) {
  12604. if(typeof DEBUG !== "undefined" && DEBUG) {
  12605. if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
  12606. }
  12607.  
  12608. options = options || {};
  12609. options.attrs = typeof options.attrs === "object" ? options.attrs : {};
  12610.  
  12611. // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
  12612. // tags it will allow on a page
  12613. if (typeof options.singleton === "undefined") options.singleton = isOldIE();
  12614.  
  12615. // By default, add <style> tags to the <head> element
  12616. if (typeof options.insertInto === "undefined") options.insertInto = "head";
  12617.  
  12618. // By default, add <style> tags to the bottom of the target
  12619. if (typeof options.insertAt === "undefined") options.insertAt = "bottom";
  12620.  
  12621. var styles = listToStyles(list);
  12622. addStylesToDom(styles, options);
  12623.  
  12624. return function update(newList) {
  12625. var mayRemove = [];
  12626. for(var i = 0; i < styles.length; i++) {
  12627. var item = styles[i];
  12628. var domStyle = stylesInDom[item.id];
  12629. domStyle.refs--;
  12630. mayRemove.push(domStyle);
  12631. }
  12632. if(newList) {
  12633. var newStyles = listToStyles(newList);
  12634. addStylesToDom(newStyles, options);
  12635. }
  12636. for(var i = 0; i < mayRemove.length; i++) {
  12637. var domStyle = mayRemove[i];
  12638. if(domStyle.refs === 0) {
  12639. for(var j = 0; j < domStyle.parts.length; j++)
  12640. domStyle.parts[j]();
  12641. delete stylesInDom[domStyle.id];
  12642. }
  12643. }
  12644. };
  12645. };
  12646.  
  12647. function addStylesToDom(styles, options) {
  12648. for(var i = 0; i < styles.length; i++) {
  12649. var item = styles[i];
  12650. var domStyle = stylesInDom[item.id];
  12651. if(domStyle) {
  12652. domStyle.refs++;
  12653. for(var j = 0; j < domStyle.parts.length; j++) {
  12654. domStyle.parts[j](item.parts[j]);
  12655. }
  12656. for(; j < item.parts.length; j++) {
  12657. domStyle.parts.push(addStyle(item.parts[j], options));
  12658. }
  12659. } else {
  12660. var parts = [];
  12661. for(var j = 0; j < item.parts.length; j++) {
  12662. parts.push(addStyle(item.parts[j], options));
  12663. }
  12664. stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
  12665. }
  12666. }
  12667. }
  12668.  
  12669. function listToStyles(list) {
  12670. var styles = [];
  12671. var newStyles = {};
  12672. for(var i = 0; i < list.length; i++) {
  12673. var item = list[i];
  12674. var id = item[0];
  12675. var css = item[1];
  12676. var media = item[2];
  12677. var sourceMap = item[3];
  12678. var part = {css: css, media: media, sourceMap: sourceMap};
  12679. if(!newStyles[id])
  12680. styles.push(newStyles[id] = {id: id, parts: [part]});
  12681. else
  12682. newStyles[id].parts.push(part);
  12683. }
  12684. return styles;
  12685. }
  12686.  
  12687. function insertStyleElement(options, styleElement) {
  12688. var styleTarget = getElement(options.insertInto)
  12689. if (!styleTarget) {
  12690. throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
  12691. }
  12692. var lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
  12693. if (options.insertAt === "top") {
  12694. if(!lastStyleElementInsertedAtTop) {
  12695. styleTarget.insertBefore(styleElement, styleTarget.firstChild);
  12696. } else if(lastStyleElementInsertedAtTop.nextSibling) {
  12697. styleTarget.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling);
  12698. } else {
  12699. styleTarget.appendChild(styleElement);
  12700. }
  12701. styleElementsInsertedAtTop.push(styleElement);
  12702. } else if (options.insertAt === "bottom") {
  12703. styleTarget.appendChild(styleElement);
  12704. } else {
  12705. throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");
  12706. }
  12707. }
  12708.  
  12709. function removeStyleElement(styleElement) {
  12710. styleElement.parentNode.removeChild(styleElement);
  12711. var idx = styleElementsInsertedAtTop.indexOf(styleElement);
  12712. if(idx >= 0) {
  12713. styleElementsInsertedAtTop.splice(idx, 1);
  12714. }
  12715. }
  12716.  
  12717. function createStyleElement(options) {
  12718. var styleElement = document.createElement("style");
  12719. options.attrs.type = "text/css";
  12720.  
  12721. attachTagAttrs(styleElement, options.attrs);
  12722. insertStyleElement(options, styleElement);
  12723. return styleElement;
  12724. }
  12725.  
  12726. function createLinkElement(options) {
  12727. var linkElement = document.createElement("link");
  12728. options.attrs.type = "text/css";
  12729. options.attrs.rel = "stylesheet";
  12730.  
  12731. attachTagAttrs(linkElement, options.attrs);
  12732. insertStyleElement(options, linkElement);
  12733. return linkElement;
  12734. }
  12735.  
  12736. function attachTagAttrs(element, attrs) {
  12737. Object.keys(attrs).forEach(function (key) {
  12738. element.setAttribute(key, attrs[key]);
  12739. });
  12740. }
  12741.  
  12742. function addStyle(obj, options) {
  12743. var styleElement, update, remove;
  12744.  
  12745. if (options.singleton) {
  12746. var styleIndex = singletonCounter++;
  12747. styleElement = singletonElement || (singletonElement = createStyleElement(options));
  12748. update = applyToSingletonTag.bind(null, styleElement, styleIndex, false);
  12749. remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true);
  12750. } else if(obj.sourceMap &&
  12751. typeof URL === "function" &&
  12752. typeof URL.createObjectURL === "function" &&
  12753. typeof URL.revokeObjectURL === "function" &&
  12754. typeof Blob === "function" &&
  12755. typeof btoa === "function") {
  12756. styleElement = createLinkElement(options);
  12757. update = updateLink.bind(null, styleElement, options);
  12758. remove = function() {
  12759. removeStyleElement(styleElement);
  12760. if(styleElement.href)
  12761. URL.revokeObjectURL(styleElement.href);
  12762. };
  12763. } else {
  12764. styleElement = createStyleElement(options);
  12765. update = applyToTag.bind(null, styleElement);
  12766. remove = function() {
  12767. removeStyleElement(styleElement);
  12768. };
  12769. }
  12770.  
  12771. update(obj);
  12772.  
  12773. return function updateStyle(newObj) {
  12774. if(newObj) {
  12775. if(newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap)
  12776. return;
  12777. update(obj = newObj);
  12778. } else {
  12779. remove();
  12780. }
  12781. };
  12782. }
  12783.  
  12784. var replaceText = (function () {
  12785. var textStore = [];
  12786.  
  12787. return function (index, replacement) {
  12788. textStore[index] = replacement;
  12789. return textStore.filter(Boolean).join('\n');
  12790. };
  12791. })();
  12792.  
  12793. function applyToSingletonTag(styleElement, index, remove, obj) {
  12794. var css = remove ? "" : obj.css;
  12795.  
  12796. if (styleElement.styleSheet) {
  12797. styleElement.styleSheet.cssText = replaceText(index, css);
  12798. } else {
  12799. var cssNode = document.createTextNode(css);
  12800. var childNodes = styleElement.childNodes;
  12801. if (childNodes[index]) styleElement.removeChild(childNodes[index]);
  12802. if (childNodes.length) {
  12803. styleElement.insertBefore(cssNode, childNodes[index]);
  12804. } else {
  12805. styleElement.appendChild(cssNode);
  12806. }
  12807. }
  12808. }
  12809.  
  12810. function applyToTag(styleElement, obj) {
  12811. var css = obj.css;
  12812. var media = obj.media;
  12813.  
  12814. if(media) {
  12815. styleElement.setAttribute("media", media)
  12816. }
  12817.  
  12818. if(styleElement.styleSheet) {
  12819. styleElement.styleSheet.cssText = css;
  12820. } else {
  12821. while(styleElement.firstChild) {
  12822. styleElement.removeChild(styleElement.firstChild);
  12823. }
  12824. styleElement.appendChild(document.createTextNode(css));
  12825. }
  12826. }
  12827.  
  12828. function updateLink(linkElement, options, obj) {
  12829. var css = obj.css;
  12830. var sourceMap = obj.sourceMap;
  12831.  
  12832. /* If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
  12833. and there is no publicPath defined then lets turn convertToAbsoluteUrls
  12834. on by default. Otherwise default to the convertToAbsoluteUrls option
  12835. directly
  12836. */
  12837. var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;
  12838.  
  12839. if (options.convertToAbsoluteUrls || autoFixUrls){
  12840. css = fixUrls(css);
  12841. }
  12842.  
  12843. if(sourceMap) {
  12844. // http://stackoverflow.com/a/26603875
  12845. css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
  12846. }
  12847.  
  12848. var blob = new Blob([css], { type: "text/css" });
  12849.  
  12850. var oldSrc = linkElement.href;
  12851.  
  12852. linkElement.href = URL.createObjectURL(blob);
  12853.  
  12854. if(oldSrc)
  12855. URL.revokeObjectURL(oldSrc);
  12856. }
  12857.  
  12858.  
  12859. /***/ }),
  12860. /* 110 */
  12861. /***/ (function(module, exports) {
  12862.  
  12863.  
  12864. /**
  12865. * When source maps are enabled, `style-loader` uses a link element with a data-uri to
  12866. * embed the css on the page. This breaks all relative urls because now they are relative to a
  12867. * bundle instead of the current page.
  12868. *
  12869. * One solution is to only use full urls, but that may be impossible.
  12870. *
  12871. * Instead, this function "fixes" the relative urls to be absolute according to the current page location.
  12872. *
  12873. * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
  12874. *
  12875. */
  12876.  
  12877. module.exports = function (css) {
  12878. // get current location
  12879. var location = typeof window !== "undefined" && window.location;
  12880.  
  12881. if (!location) {
  12882. throw new Error("fixUrls requires window.location");
  12883. }
  12884.  
  12885. // blank or null?
  12886. if (!css || typeof css !== "string") {
  12887. return css;
  12888. }
  12889.  
  12890. var baseUrl = location.protocol + "//" + location.host;
  12891. var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/");
  12892.  
  12893. // convert each url(...)
  12894. /*
  12895. This regular expression is just a way to recursively match brackets within
  12896. a string.
  12897.  
  12898. /url\s*\( = Match on the word "url" with any whitespace after it and then a parens
  12899. ( = Start a capturing group
  12900. (?: = Start a non-capturing group
  12901. [^)(] = Match anything that isn't a parentheses
  12902. | = OR
  12903. \( = Match a start parentheses
  12904. (?: = Start another non-capturing groups
  12905. [^)(]+ = Match anything that isn't a parentheses
  12906. | = OR
  12907. \( = Match a start parentheses
  12908. [^)(]* = Match anything that isn't a parentheses
  12909. \) = Match a end parentheses
  12910. ) = End Group
  12911. *\) = Match anything and then a close parens
  12912. ) = Close non-capturing group
  12913. * = Match anything
  12914. ) = Close capturing group
  12915. \) = Match a close parens
  12916.  
  12917. /gi = Get all matches, not the first. Be case insensitive.
  12918. */
  12919. var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function(fullMatch, origUrl) {
  12920. // strip quotes (if they exist)
  12921. var unquotedOrigUrl = origUrl
  12922. .trim()
  12923. .replace(/^"(.*)"$/, function(o, $1){ return $1; })
  12924. .replace(/^'(.*)'$/, function(o, $1){ return $1; });
  12925.  
  12926. // already a full url? no change
  12927. if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/)/i.test(unquotedOrigUrl)) {
  12928. return fullMatch;
  12929. }
  12930.  
  12931. // convert the url to a full url
  12932. var newUrl;
  12933.  
  12934. if (unquotedOrigUrl.indexOf("//") === 0) {
  12935. //TODO: should we add protocol?
  12936. newUrl = unquotedOrigUrl;
  12937. } else if (unquotedOrigUrl.indexOf("/") === 0) {
  12938. // path should be relative to the base url
  12939. newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'
  12940. } else {
  12941. // path should be relative to current directory
  12942. newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'
  12943. }
  12944.  
  12945. // send back the fixed url(...)
  12946. return "url(" + JSON.stringify(newUrl) + ")";
  12947. });
  12948.  
  12949. // send back the fixed css
  12950. return fixedCss;
  12951. };
  12952.  
  12953.  
  12954. /***/ }),
  12955. /* 111 */
  12956. /***/ (function(module, exports) {
  12957.  
  12958. !function(t,e){"object"==typeof module&&module.exports?(module.exports=e(),module.exports.default=module.exports):t.timeago=e()}("undefined"!=typeof window?window:this,function(){function t(t){return t instanceof Date?t:isNaN(t)?/^\d+$/.test(t)?new Date(e(t)):(t=(t||"").trim().replace(/\.\d+/,"").replace(/-/,"/").replace(/-/,"/").replace(/(\d)T(\d)/,"$1 $2").replace(/Z/," UTC").replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"),new Date(t)):new Date(e(t))}function e(t){return parseInt(t)}function n(t,n,r){n=p[n]?n:p[r]?r:"en";for(var o=0,i=t<0?1:0,a=t=Math.abs(t);t>=h[o]&&o<m;o++)t/=h[o];return t=e(t),o*=2,t>(0===o?9:1)&&(o+=1),p[n](t,o,a)[i].replace("%s",t)}function r(e,n){return((n=n?t(n):new Date)-t(e))/1e3}function o(t){for(var e=1,n=0,r=Math.abs(t);t>=h[n]&&n<m;n++)t/=h[n],e*=h[n];return r%=e,r=r?e-r:e,Math.ceil(r)}function i(t){return t.dataset.timeago?t.dataset.timeago:a(t,w)}function a(t,e){return t.getAttribute?t.getAttribute(e):t.attr?t.attr(e):void 0}function u(t,e){return t.setAttribute?t.setAttribute(_,e):t.attr?t.attr(_,e):void 0}function c(t){return a(t,_)}function d(t,e){this.nowDate=t,this.defaultLocale=e||"en"}function f(t,e){return new d(t,e)}var s="second_minute_hour_day_week_month_year".split("_"),l="秒_分钟_小时_天_周_月_年".split("_"),p={en:function(t,e){if(0===e)return["just now","right now"];var n=s[parseInt(e/2)];return t>1&&(n+="s"),[t+" "+n+" ago","in "+t+" "+n]},zh_CN:function(t,e){if(0===e)return["刚刚","片刻后"];var n=l[parseInt(e/2)];return[t+n+"前",t+n+"后"]}},h=[60,60,24,7,365/7/12,12],m=6,w="datetime",_="data-tid",v={};return d.prototype.doRender=function(t,e,i){var a,c=r(e,this.nowDate),d=this;t.innerHTML=n(c,i,this.defaultLocale),v[a=setTimeout(function(){d.doRender(t,e,i),delete v[a]},Math.min(1e3*o(c),2147483647))]=0,u(t,a)},d.prototype.format=function(t,e){return n(r(t,this.nowDate),e,this.defaultLocale)},d.prototype.render=function(t,e){void 0===t.length&&(t=[t]);for(var n=0,r=t.length;n<r;n++)this.doRender(t[n],i(t[n]),e)},d.prototype.setLocale=function(t){this.defaultLocale=t},f.register=function(t,e){p[t]=e},f.cancel=function(t){var e;if(t)(e=c(t))&&(clearTimeout(e),delete v[e]);else{for(e in v)clearTimeout(e);v={}}},f});
  12959.  
  12960. /***/ }),
  12961. /* 112 */
  12962. /***/ (function(module, exports, __webpack_require__) {
  12963.  
  12964. var apply = Function.prototype.apply;
  12965.  
  12966. // DOM APIs, for completeness
  12967.  
  12968. exports.setTimeout = function() {
  12969. return new Timeout(apply.call(setTimeout, window, arguments), clearTimeout);
  12970. };
  12971. exports.setInterval = function() {
  12972. return new Timeout(apply.call(setInterval, window, arguments), clearInterval);
  12973. };
  12974. exports.clearTimeout =
  12975. exports.clearInterval = function(timeout) {
  12976. if (timeout) {
  12977. timeout.close();
  12978. }
  12979. };
  12980.  
  12981. function Timeout(id, clearFn) {
  12982. this._id = id;
  12983. this._clearFn = clearFn;
  12984. }
  12985. Timeout.prototype.unref = Timeout.prototype.ref = function() {};
  12986. Timeout.prototype.close = function() {
  12987. this._clearFn.call(window, this._id);
  12988. };
  12989.  
  12990. // Does not start the time, just sets up the members needed.
  12991. exports.enroll = function(item, msecs) {
  12992. clearTimeout(item._idleTimeoutId);
  12993. item._idleTimeout = msecs;
  12994. };
  12995.  
  12996. exports.unenroll = function(item) {
  12997. clearTimeout(item._idleTimeoutId);
  12998. item._idleTimeout = -1;
  12999. };
  13000.  
  13001. exports._unrefActive = exports.active = function(item) {
  13002. clearTimeout(item._idleTimeoutId);
  13003.  
  13004. var msecs = item._idleTimeout;
  13005. if (msecs >= 0) {
  13006. item._idleTimeoutId = setTimeout(function onTimeout() {
  13007. if (item._onTimeout)
  13008. item._onTimeout();
  13009. }, msecs);
  13010. }
  13011. };
  13012.  
  13013. // setimmediate attaches itself to the global object
  13014. __webpack_require__(108);
  13015. exports.setImmediate = setImmediate;
  13016. exports.clearImmediate = clearImmediate;
  13017.  
  13018.  
  13019. /***/ }),
  13020. /* 113 */
  13021. /***/ (function(module, exports, __webpack_require__) {
  13022.  
  13023. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscore.js 1.8.3
  13024. // http://underscorejs.org
  13025. // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  13026. // Underscore may be freely distributed under the MIT license.
  13027.  
  13028. (function() {
  13029.  
  13030. // Baseline setup
  13031. // --------------
  13032.  
  13033. // Establish the root object, `window` in the browser, or `exports` on the server.
  13034. var root = this;
  13035.  
  13036. // Save the previous value of the `_` variable.
  13037. var previousUnderscore = root._;
  13038.  
  13039. // Save bytes in the minified (but not gzipped) version:
  13040. var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
  13041.  
  13042. // Create quick reference variables for speed access to core prototypes.
  13043. var
  13044. push = ArrayProto.push,
  13045. slice = ArrayProto.slice,
  13046. toString = ObjProto.toString,
  13047. hasOwnProperty = ObjProto.hasOwnProperty;
  13048.  
  13049. // All **ECMAScript 5** native function implementations that we hope to use
  13050. // are declared here.
  13051. var
  13052. nativeIsArray = Array.isArray,
  13053. nativeKeys = Object.keys,
  13054. nativeBind = FuncProto.bind,
  13055. nativeCreate = Object.create;
  13056.  
  13057. // Naked function reference for surrogate-prototype-swapping.
  13058. var Ctor = function(){};
  13059.  
  13060. // Create a safe reference to the Underscore object for use below.
  13061. var _ = function(obj) {
  13062. if (obj instanceof _) return obj;
  13063. if (!(this instanceof _)) return new _(obj);
  13064. this._wrapped = obj;
  13065. };
  13066.  
  13067. // Export the Underscore object for **Node.js**, with
  13068. // backwards-compatibility for the old `require()` API. If we're in
  13069. // the browser, add `_` as a global object.
  13070. if (true) {
  13071. if (typeof module !== 'undefined' && module.exports) {
  13072. exports = module.exports = _;
  13073. }
  13074. exports._ = _;
  13075. } else {
  13076. root._ = _;
  13077. }
  13078.  
  13079. // Current version.
  13080. _.VERSION = '1.8.3';
  13081.  
  13082. // Internal function that returns an efficient (for current engines) version
  13083. // of the passed-in callback, to be repeatedly applied in other Underscore
  13084. // functions.
  13085. var optimizeCb = function(func, context, argCount) {
  13086. if (context === void 0) return func;
  13087. switch (argCount == null ? 3 : argCount) {
  13088. case 1: return function(value) {
  13089. return func.call(context, value);
  13090. };
  13091. case 2: return function(value, other) {
  13092. return func.call(context, value, other);
  13093. };
  13094. case 3: return function(value, index, collection) {
  13095. return func.call(context, value, index, collection);
  13096. };
  13097. case 4: return function(accumulator, value, index, collection) {
  13098. return func.call(context, accumulator, value, index, collection);
  13099. };
  13100. }
  13101. return function() {
  13102. return func.apply(context, arguments);
  13103. };
  13104. };
  13105.  
  13106. // A mostly-internal function to generate callbacks that can be applied
  13107. // to each element in a collection, returning the desired result — either
  13108. // identity, an arbitrary callback, a property matcher, or a property accessor.
  13109. var cb = function(value, context, argCount) {
  13110. if (value == null) return _.identity;
  13111. if (_.isFunction(value)) return optimizeCb(value, context, argCount);
  13112. if (_.isObject(value)) return _.matcher(value);
  13113. return _.property(value);
  13114. };
  13115. _.iteratee = function(value, context) {
  13116. return cb(value, context, Infinity);
  13117. };
  13118.  
  13119. // An internal function for creating assigner functions.
  13120. var createAssigner = function(keysFunc, undefinedOnly) {
  13121. return function(obj) {
  13122. var length = arguments.length;
  13123. if (length < 2 || obj == null) return obj;
  13124. for (var index = 1; index < length; index++) {
  13125. var source = arguments[index],
  13126. keys = keysFunc(source),
  13127. l = keys.length;
  13128. for (var i = 0; i < l; i++) {
  13129. var key = keys[i];
  13130. if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key];
  13131. }
  13132. }
  13133. return obj;
  13134. };
  13135. };
  13136.  
  13137. // An internal function for creating a new object that inherits from another.
  13138. var baseCreate = function(prototype) {
  13139. if (!_.isObject(prototype)) return {};
  13140. if (nativeCreate) return nativeCreate(prototype);
  13141. Ctor.prototype = prototype;
  13142. var result = new Ctor;
  13143. Ctor.prototype = null;
  13144. return result;
  13145. };
  13146.  
  13147. var property = function(key) {
  13148. return function(obj) {
  13149. return obj == null ? void 0 : obj[key];
  13150. };
  13151. };
  13152.  
  13153. // Helper for collection methods to determine whether a collection
  13154. // should be iterated as an array or as an object
  13155. // Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
  13156. // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
  13157. var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
  13158. var getLength = property('length');
  13159. var isArrayLike = function(collection) {
  13160. var length = getLength(collection);
  13161. return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
  13162. };
  13163.  
  13164. // Collection Functions
  13165. // --------------------
  13166.  
  13167. // The cornerstone, an `each` implementation, aka `forEach`.
  13168. // Handles raw objects in addition to array-likes. Treats all
  13169. // sparse array-likes as if they were dense.
  13170. _.each = _.forEach = function(obj, iteratee, context) {
  13171. iteratee = optimizeCb(iteratee, context);
  13172. var i, length;
  13173. if (isArrayLike(obj)) {
  13174. for (i = 0, length = obj.length; i < length; i++) {
  13175. iteratee(obj[i], i, obj);
  13176. }
  13177. } else {
  13178. var keys = _.keys(obj);
  13179. for (i = 0, length = keys.length; i < length; i++) {
  13180. iteratee(obj[keys[i]], keys[i], obj);
  13181. }
  13182. }
  13183. return obj;
  13184. };
  13185.  
  13186. // Return the results of applying the iteratee to each element.
  13187. _.map = _.collect = function(obj, iteratee, context) {
  13188. iteratee = cb(iteratee, context);
  13189. var keys = !isArrayLike(obj) && _.keys(obj),
  13190. length = (keys || obj).length,
  13191. results = Array(length);
  13192. for (var index = 0; index < length; index++) {
  13193. var currentKey = keys ? keys[index] : index;
  13194. results[index] = iteratee(obj[currentKey], currentKey, obj);
  13195. }
  13196. return results;
  13197. };
  13198.  
  13199. // Create a reducing function iterating left or right.
  13200. function createReduce(dir) {
  13201. // Optimized iterator function as using arguments.length
  13202. // in the main function will deoptimize the, see #1991.
  13203. function iterator(obj, iteratee, memo, keys, index, length) {
  13204. for (; index >= 0 && index < length; index += dir) {
  13205. var currentKey = keys ? keys[index] : index;
  13206. memo = iteratee(memo, obj[currentKey], currentKey, obj);
  13207. }
  13208. return memo;
  13209. }
  13210.  
  13211. return function(obj, iteratee, memo, context) {
  13212. iteratee = optimizeCb(iteratee, context, 4);
  13213. var keys = !isArrayLike(obj) && _.keys(obj),
  13214. length = (keys || obj).length,
  13215. index = dir > 0 ? 0 : length - 1;
  13216. // Determine the initial value if none is provided.
  13217. if (arguments.length < 3) {
  13218. memo = obj[keys ? keys[index] : index];
  13219. index += dir;
  13220. }
  13221. return iterator(obj, iteratee, memo, keys, index, length);
  13222. };
  13223. }
  13224.  
  13225. // **Reduce** builds up a single result from a list of values, aka `inject`,
  13226. // or `foldl`.
  13227. _.reduce = _.foldl = _.inject = createReduce(1);
  13228.  
  13229. // The right-associative version of reduce, also known as `foldr`.
  13230. _.reduceRight = _.foldr = createReduce(-1);
  13231.  
  13232. // Return the first value which passes a truth test. Aliased as `detect`.
  13233. _.find = _.detect = function(obj, predicate, context) {
  13234. var key;
  13235. if (isArrayLike(obj)) {
  13236. key = _.findIndex(obj, predicate, context);
  13237. } else {
  13238. key = _.findKey(obj, predicate, context);
  13239. }
  13240. if (key !== void 0 && key !== -1) return obj[key];
  13241. };
  13242.  
  13243. // Return all the elements that pass a truth test.
  13244. // Aliased as `select`.
  13245. _.filter = _.select = function(obj, predicate, context) {
  13246. var results = [];
  13247. predicate = cb(predicate, context);
  13248. _.each(obj, function(value, index, list) {
  13249. if (predicate(value, index, list)) results.push(value);
  13250. });
  13251. return results;
  13252. };
  13253.  
  13254. // Return all the elements for which a truth test fails.
  13255. _.reject = function(obj, predicate, context) {
  13256. return _.filter(obj, _.negate(cb(predicate)), context);
  13257. };
  13258.  
  13259. // Determine whether all of the elements match a truth test.
  13260. // Aliased as `all`.
  13261. _.every = _.all = function(obj, predicate, context) {
  13262. predicate = cb(predicate, context);
  13263. var keys = !isArrayLike(obj) && _.keys(obj),
  13264. length = (keys || obj).length;
  13265. for (var index = 0; index < length; index++) {
  13266. var currentKey = keys ? keys[index] : index;
  13267. if (!predicate(obj[currentKey], currentKey, obj)) return false;
  13268. }
  13269. return true;
  13270. };
  13271.  
  13272. // Determine if at least one element in the object matches a truth test.
  13273. // Aliased as `any`.
  13274. _.some = _.any = function(obj, predicate, context) {
  13275. predicate = cb(predicate, context);
  13276. var keys = !isArrayLike(obj) && _.keys(obj),
  13277. length = (keys || obj).length;
  13278. for (var index = 0; index < length; index++) {
  13279. var currentKey = keys ? keys[index] : index;
  13280. if (predicate(obj[currentKey], currentKey, obj)) return true;
  13281. }
  13282. return false;
  13283. };
  13284.  
  13285. // Determine if the array or object contains a given item (using `===`).
  13286. // Aliased as `includes` and `include`.
  13287. _.contains = _.includes = _.include = function(obj, item, fromIndex, guard) {
  13288. if (!isArrayLike(obj)) obj = _.values(obj);
  13289. if (typeof fromIndex != 'number' || guard) fromIndex = 0;
  13290. return _.indexOf(obj, item, fromIndex) >= 0;
  13291. };
  13292.  
  13293. // Invoke a method (with arguments) on every item in a collection.
  13294. _.invoke = function(obj, method) {
  13295. var args = slice.call(arguments, 2);
  13296. var isFunc = _.isFunction(method);
  13297. return _.map(obj, function(value) {
  13298. var func = isFunc ? method : value[method];
  13299. return func == null ? func : func.apply(value, args);
  13300. });
  13301. };
  13302.  
  13303. // Convenience version of a common use case of `map`: fetching a property.
  13304. _.pluck = function(obj, key) {
  13305. return _.map(obj, _.property(key));
  13306. };
  13307.  
  13308. // Convenience version of a common use case of `filter`: selecting only objects
  13309. // containing specific `key:value` pairs.
  13310. _.where = function(obj, attrs) {
  13311. return _.filter(obj, _.matcher(attrs));
  13312. };
  13313.  
  13314. // Convenience version of a common use case of `find`: getting the first object
  13315. // containing specific `key:value` pairs.
  13316. _.findWhere = function(obj, attrs) {
  13317. return _.find(obj, _.matcher(attrs));
  13318. };
  13319.  
  13320. // Return the maximum element (or element-based computation).
  13321. _.max = function(obj, iteratee, context) {
  13322. var result = -Infinity, lastComputed = -Infinity,
  13323. value, computed;
  13324. if (iteratee == null && obj != null) {
  13325. obj = isArrayLike(obj) ? obj : _.values(obj);
  13326. for (var i = 0, length = obj.length; i < length; i++) {
  13327. value = obj[i];
  13328. if (value > result) {
  13329. result = value;
  13330. }
  13331. }
  13332. } else {
  13333. iteratee = cb(iteratee, context);
  13334. _.each(obj, function(value, index, list) {
  13335. computed = iteratee(value, index, list);
  13336. if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
  13337. result = value;
  13338. lastComputed = computed;
  13339. }
  13340. });
  13341. }
  13342. return result;
  13343. };
  13344.  
  13345. // Return the minimum element (or element-based computation).
  13346. _.min = function(obj, iteratee, context) {
  13347. var result = Infinity, lastComputed = Infinity,
  13348. value, computed;
  13349. if (iteratee == null && obj != null) {
  13350. obj = isArrayLike(obj) ? obj : _.values(obj);
  13351. for (var i = 0, length = obj.length; i < length; i++) {
  13352. value = obj[i];
  13353. if (value < result) {
  13354. result = value;
  13355. }
  13356. }
  13357. } else {
  13358. iteratee = cb(iteratee, context);
  13359. _.each(obj, function(value, index, list) {
  13360. computed = iteratee(value, index, list);
  13361. if (computed < lastComputed || computed === Infinity && result === Infinity) {
  13362. result = value;
  13363. lastComputed = computed;
  13364. }
  13365. });
  13366. }
  13367. return result;
  13368. };
  13369.  
  13370. // Shuffle a collection, using the modern version of the
  13371. // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
  13372. _.shuffle = function(obj) {
  13373. var set = isArrayLike(obj) ? obj : _.values(obj);
  13374. var length = set.length;
  13375. var shuffled = Array(length);
  13376. for (var index = 0, rand; index < length; index++) {
  13377. rand = _.random(0, index);
  13378. if (rand !== index) shuffled[index] = shuffled[rand];
  13379. shuffled[rand] = set[index];
  13380. }
  13381. return shuffled;
  13382. };
  13383.  
  13384. // Sample **n** random values from a collection.
  13385. // If **n** is not specified, returns a single random element.
  13386. // The internal `guard` argument allows it to work with `map`.
  13387. _.sample = function(obj, n, guard) {
  13388. if (n == null || guard) {
  13389. if (!isArrayLike(obj)) obj = _.values(obj);
  13390. return obj[_.random(obj.length - 1)];
  13391. }
  13392. return _.shuffle(obj).slice(0, Math.max(0, n));
  13393. };
  13394.  
  13395. // Sort the object's values by a criterion produced by an iteratee.
  13396. _.sortBy = function(obj, iteratee, context) {
  13397. iteratee = cb(iteratee, context);
  13398. return _.pluck(_.map(obj, function(value, index, list) {
  13399. return {
  13400. value: value,
  13401. index: index,
  13402. criteria: iteratee(value, index, list)
  13403. };
  13404. }).sort(function(left, right) {
  13405. var a = left.criteria;
  13406. var b = right.criteria;
  13407. if (a !== b) {
  13408. if (a > b || a === void 0) return 1;
  13409. if (a < b || b === void 0) return -1;
  13410. }
  13411. return left.index - right.index;
  13412. }), 'value');
  13413. };
  13414.  
  13415. // An internal function used for aggregate "group by" operations.
  13416. var group = function(behavior) {
  13417. return function(obj, iteratee, context) {
  13418. var result = {};
  13419. iteratee = cb(iteratee, context);
  13420. _.each(obj, function(value, index) {
  13421. var key = iteratee(value, index, obj);
  13422. behavior(result, value, key);
  13423. });
  13424. return result;
  13425. };
  13426. };
  13427.  
  13428. // Groups the object's values by a criterion. Pass either a string attribute
  13429. // to group by, or a function that returns the criterion.
  13430. _.groupBy = group(function(result, value, key) {
  13431. if (_.has(result, key)) result[key].push(value); else result[key] = [value];
  13432. });
  13433.  
  13434. // Indexes the object's values by a criterion, similar to `groupBy`, but for
  13435. // when you know that your index values will be unique.
  13436. _.indexBy = group(function(result, value, key) {
  13437. result[key] = value;
  13438. });
  13439.  
  13440. // Counts instances of an object that group by a certain criterion. Pass
  13441. // either a string attribute to count by, or a function that returns the
  13442. // criterion.
  13443. _.countBy = group(function(result, value, key) {
  13444. if (_.has(result, key)) result[key]++; else result[key] = 1;
  13445. });
  13446.  
  13447. // Safely create a real, live array from anything iterable.
  13448. _.toArray = function(obj) {
  13449. if (!obj) return [];
  13450. if (_.isArray(obj)) return slice.call(obj);
  13451. if (isArrayLike(obj)) return _.map(obj, _.identity);
  13452. return _.values(obj);
  13453. };
  13454.  
  13455. // Return the number of elements in an object.
  13456. _.size = function(obj) {
  13457. if (obj == null) return 0;
  13458. return isArrayLike(obj) ? obj.length : _.keys(obj).length;
  13459. };
  13460.  
  13461. // Split a collection into two arrays: one whose elements all satisfy the given
  13462. // predicate, and one whose elements all do not satisfy the predicate.
  13463. _.partition = function(obj, predicate, context) {
  13464. predicate = cb(predicate, context);
  13465. var pass = [], fail = [];
  13466. _.each(obj, function(value, key, obj) {
  13467. (predicate(value, key, obj) ? pass : fail).push(value);
  13468. });
  13469. return [pass, fail];
  13470. };
  13471.  
  13472. // Array Functions
  13473. // ---------------
  13474.  
  13475. // Get the first element of an array. Passing **n** will return the first N
  13476. // values in the array. Aliased as `head` and `take`. The **guard** check
  13477. // allows it to work with `_.map`.
  13478. _.first = _.head = _.take = function(array, n, guard) {
  13479. if (array == null) return void 0;
  13480. if (n == null || guard) return array[0];
  13481. return _.initial(array, array.length - n);
  13482. };
  13483.  
  13484. // Returns everything but the last entry of the array. Especially useful on
  13485. // the arguments object. Passing **n** will return all the values in
  13486. // the array, excluding the last N.
  13487. _.initial = function(array, n, guard) {
  13488. return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
  13489. };
  13490.  
  13491. // Get the last element of an array. Passing **n** will return the last N
  13492. // values in the array.
  13493. _.last = function(array, n, guard) {
  13494. if (array == null) return void 0;
  13495. if (n == null || guard) return array[array.length - 1];
  13496. return _.rest(array, Math.max(0, array.length - n));
  13497. };
  13498.  
  13499. // Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
  13500. // Especially useful on the arguments object. Passing an **n** will return
  13501. // the rest N values in the array.
  13502. _.rest = _.tail = _.drop = function(array, n, guard) {
  13503. return slice.call(array, n == null || guard ? 1 : n);
  13504. };
  13505.  
  13506. // Trim out all falsy values from an array.
  13507. _.compact = function(array) {
  13508. return _.filter(array, _.identity);
  13509. };
  13510.  
  13511. // Internal implementation of a recursive `flatten` function.
  13512. var flatten = function(input, shallow, strict, startIndex) {
  13513. var output = [], idx = 0;
  13514. for (var i = startIndex || 0, length = getLength(input); i < length; i++) {
  13515. var value = input[i];
  13516. if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) {
  13517. //flatten current level of array or arguments object
  13518. if (!shallow) value = flatten(value, shallow, strict);
  13519. var j = 0, len = value.length;
  13520. output.length += len;
  13521. while (j < len) {
  13522. output[idx++] = value[j++];
  13523. }
  13524. } else if (!strict) {
  13525. output[idx++] = value;
  13526. }
  13527. }
  13528. return output;
  13529. };
  13530.  
  13531. // Flatten out an array, either recursively (by default), or just one level.
  13532. _.flatten = function(array, shallow) {
  13533. return flatten(array, shallow, false);
  13534. };
  13535.  
  13536. // Return a version of the array that does not contain the specified value(s).
  13537. _.without = function(array) {
  13538. return _.difference(array, slice.call(arguments, 1));
  13539. };
  13540.  
  13541. // Produce a duplicate-free version of the array. If the array has already
  13542. // been sorted, you have the option of using a faster algorithm.
  13543. // Aliased as `unique`.
  13544. _.uniq = _.unique = function(array, isSorted, iteratee, context) {
  13545. if (!_.isBoolean(isSorted)) {
  13546. context = iteratee;
  13547. iteratee = isSorted;
  13548. isSorted = false;
  13549. }
  13550. if (iteratee != null) iteratee = cb(iteratee, context);
  13551. var result = [];
  13552. var seen = [];
  13553. for (var i = 0, length = getLength(array); i < length; i++) {
  13554. var value = array[i],
  13555. computed = iteratee ? iteratee(value, i, array) : value;
  13556. if (isSorted) {
  13557. if (!i || seen !== computed) result.push(value);
  13558. seen = computed;
  13559. } else if (iteratee) {
  13560. if (!_.contains(seen, computed)) {
  13561. seen.push(computed);
  13562. result.push(value);
  13563. }
  13564. } else if (!_.contains(result, value)) {
  13565. result.push(value);
  13566. }
  13567. }
  13568. return result;
  13569. };
  13570.  
  13571. // Produce an array that contains the union: each distinct element from all of
  13572. // the passed-in arrays.
  13573. _.union = function() {
  13574. return _.uniq(flatten(arguments, true, true));
  13575. };
  13576.  
  13577. // Produce an array that contains every item shared between all the
  13578. // passed-in arrays.
  13579. _.intersection = function(array) {
  13580. var result = [];
  13581. var argsLength = arguments.length;
  13582. for (var i = 0, length = getLength(array); i < length; i++) {
  13583. var item = array[i];
  13584. if (_.contains(result, item)) continue;
  13585. for (var j = 1; j < argsLength; j++) {
  13586. if (!_.contains(arguments[j], item)) break;
  13587. }
  13588. if (j === argsLength) result.push(item);
  13589. }
  13590. return result;
  13591. };
  13592.  
  13593. // Take the difference between one array and a number of other arrays.
  13594. // Only the elements present in just the first array will remain.
  13595. _.difference = function(array) {
  13596. var rest = flatten(arguments, true, true, 1);
  13597. return _.filter(array, function(value){
  13598. return !_.contains(rest, value);
  13599. });
  13600. };
  13601.  
  13602. // Zip together multiple lists into a single array -- elements that share
  13603. // an index go together.
  13604. _.zip = function() {
  13605. return _.unzip(arguments);
  13606. };
  13607.  
  13608. // Complement of _.zip. Unzip accepts an array of arrays and groups
  13609. // each array's elements on shared indices
  13610. _.unzip = function(array) {
  13611. var length = array && _.max(array, getLength).length || 0;
  13612. var result = Array(length);
  13613.  
  13614. for (var index = 0; index < length; index++) {
  13615. result[index] = _.pluck(array, index);
  13616. }
  13617. return result;
  13618. };
  13619.  
  13620. // Converts lists into objects. Pass either a single array of `[key, value]`
  13621. // pairs, or two parallel arrays of the same length -- one of keys, and one of
  13622. // the corresponding values.
  13623. _.object = function(list, values) {
  13624. var result = {};
  13625. for (var i = 0, length = getLength(list); i < length; i++) {
  13626. if (values) {
  13627. result[list[i]] = values[i];
  13628. } else {
  13629. result[list[i][0]] = list[i][1];
  13630. }
  13631. }
  13632. return result;
  13633. };
  13634.  
  13635. // Generator function to create the findIndex and findLastIndex functions
  13636. function createPredicateIndexFinder(dir) {
  13637. return function(array, predicate, context) {
  13638. predicate = cb(predicate, context);
  13639. var length = getLength(array);
  13640. var index = dir > 0 ? 0 : length - 1;
  13641. for (; index >= 0 && index < length; index += dir) {
  13642. if (predicate(array[index], index, array)) return index;
  13643. }
  13644. return -1;
  13645. };
  13646. }
  13647.  
  13648. // Returns the first index on an array-like that passes a predicate test
  13649. _.findIndex = createPredicateIndexFinder(1);
  13650. _.findLastIndex = createPredicateIndexFinder(-1);
  13651.  
  13652. // Use a comparator function to figure out the smallest index at which
  13653. // an object should be inserted so as to maintain order. Uses binary search.
  13654. _.sortedIndex = function(array, obj, iteratee, context) {
  13655. iteratee = cb(iteratee, context, 1);
  13656. var value = iteratee(obj);
  13657. var low = 0, high = getLength(array);
  13658. while (low < high) {
  13659. var mid = Math.floor((low + high) / 2);
  13660. if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
  13661. }
  13662. return low;
  13663. };
  13664.  
  13665. // Generator function to create the indexOf and lastIndexOf functions
  13666. function createIndexFinder(dir, predicateFind, sortedIndex) {
  13667. return function(array, item, idx) {
  13668. var i = 0, length = getLength(array);
  13669. if (typeof idx == 'number') {
  13670. if (dir > 0) {
  13671. i = idx >= 0 ? idx : Math.max(idx + length, i);
  13672. } else {
  13673. length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
  13674. }
  13675. } else if (sortedIndex && idx && length) {
  13676. idx = sortedIndex(array, item);
  13677. return array[idx] === item ? idx : -1;
  13678. }
  13679. if (item !== item) {
  13680. idx = predicateFind(slice.call(array, i, length), _.isNaN);
  13681. return idx >= 0 ? idx + i : -1;
  13682. }
  13683. for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
  13684. if (array[idx] === item) return idx;
  13685. }
  13686. return -1;
  13687. };
  13688. }
  13689.  
  13690. // Return the position of the first occurrence of an item in an array,
  13691. // or -1 if the item is not included in the array.
  13692. // If the array is large and already in sort order, pass `true`
  13693. // for **isSorted** to use binary search.
  13694. _.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex);
  13695. _.lastIndexOf = createIndexFinder(-1, _.findLastIndex);
  13696.  
  13697. // Generate an integer Array containing an arithmetic progression. A port of
  13698. // the native Python `range()` function. See
  13699. // [the Python documentation](http://docs.python.org/library/functions.html#range).
  13700. _.range = function(start, stop, step) {
  13701. if (stop == null) {
  13702. stop = start || 0;
  13703. start = 0;
  13704. }
  13705. step = step || 1;
  13706.  
  13707. var length = Math.max(Math.ceil((stop - start) / step), 0);
  13708. var range = Array(length);
  13709.  
  13710. for (var idx = 0; idx < length; idx++, start += step) {
  13711. range[idx] = start;
  13712. }
  13713.  
  13714. return range;
  13715. };
  13716.  
  13717. // Function (ahem) Functions
  13718. // ------------------
  13719.  
  13720. // Determines whether to execute a function as a constructor
  13721. // or a normal function with the provided arguments
  13722. var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) {
  13723. if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
  13724. var self = baseCreate(sourceFunc.prototype);
  13725. var result = sourceFunc.apply(self, args);
  13726. if (_.isObject(result)) return result;
  13727. return self;
  13728. };
  13729.  
  13730. // Create a function bound to a given object (assigning `this`, and arguments,
  13731. // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
  13732. // available.
  13733. _.bind = function(func, context) {
  13734. if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
  13735. if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function');
  13736. var args = slice.call(arguments, 2);
  13737. var bound = function() {
  13738. return executeBound(func, bound, context, this, args.concat(slice.call(arguments)));
  13739. };
  13740. return bound;
  13741. };
  13742.  
  13743. // Partially apply a function by creating a version that has had some of its
  13744. // arguments pre-filled, without changing its dynamic `this` context. _ acts
  13745. // as a placeholder, allowing any combination of arguments to be pre-filled.
  13746. _.partial = function(func) {
  13747. var boundArgs = slice.call(arguments, 1);
  13748. var bound = function() {
  13749. var position = 0, length = boundArgs.length;
  13750. var args = Array(length);
  13751. for (var i = 0; i < length; i++) {
  13752. args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i];
  13753. }
  13754. while (position < arguments.length) args.push(arguments[position++]);
  13755. return executeBound(func, bound, this, this, args);
  13756. };
  13757. return bound;
  13758. };
  13759.  
  13760. // Bind a number of an object's methods to that object. Remaining arguments
  13761. // are the method names to be bound. Useful for ensuring that all callbacks
  13762. // defined on an object belong to it.
  13763. _.bindAll = function(obj) {
  13764. var i, length = arguments.length, key;
  13765. if (length <= 1) throw new Error('bindAll must be passed function names');
  13766. for (i = 1; i < length; i++) {
  13767. key = arguments[i];
  13768. obj[key] = _.bind(obj[key], obj);
  13769. }
  13770. return obj;
  13771. };
  13772.  
  13773. // Memoize an expensive function by storing its results.
  13774. _.memoize = function(func, hasher) {
  13775. var memoize = function(key) {
  13776. var cache = memoize.cache;
  13777. var address = '' + (hasher ? hasher.apply(this, arguments) : key);
  13778. if (!_.has(cache, address)) cache[address] = func.apply(this, arguments);
  13779. return cache[address];
  13780. };
  13781. memoize.cache = {};
  13782. return memoize;
  13783. };
  13784.  
  13785. // Delays a function for the given number of milliseconds, and then calls
  13786. // it with the arguments supplied.
  13787. _.delay = function(func, wait) {
  13788. var args = slice.call(arguments, 2);
  13789. return setTimeout(function(){
  13790. return func.apply(null, args);
  13791. }, wait);
  13792. };
  13793.  
  13794. // Defers a function, scheduling it to run after the current call stack has
  13795. // cleared.
  13796. _.defer = _.partial(_.delay, _, 1);
  13797.  
  13798. // Returns a function, that, when invoked, will only be triggered at most once
  13799. // during a given window of time. Normally, the throttled function will run
  13800. // as much as it can, without ever going more than once per `wait` duration;
  13801. // but if you'd like to disable the execution on the leading edge, pass
  13802. // `{leading: false}`. To disable execution on the trailing edge, ditto.
  13803. _.throttle = function(func, wait, options) {
  13804. var context, args, result;
  13805. var timeout = null;
  13806. var previous = 0;
  13807. if (!options) options = {};
  13808. var later = function() {
  13809. previous = options.leading === false ? 0 : _.now();
  13810. timeout = null;
  13811. result = func.apply(context, args);
  13812. if (!timeout) context = args = null;
  13813. };
  13814. return function() {
  13815. var now = _.now();
  13816. if (!previous && options.leading === false) previous = now;
  13817. var remaining = wait - (now - previous);
  13818. context = this;
  13819. args = arguments;
  13820. if (remaining <= 0 || remaining > wait) {
  13821. if (timeout) {
  13822. clearTimeout(timeout);
  13823. timeout = null;
  13824. }
  13825. previous = now;
  13826. result = func.apply(context, args);
  13827. if (!timeout) context = args = null;
  13828. } else if (!timeout && options.trailing !== false) {
  13829. timeout = setTimeout(later, remaining);
  13830. }
  13831. return result;
  13832. };
  13833. };
  13834.  
  13835. // Returns a function, that, as long as it continues to be invoked, will not
  13836. // be triggered. The function will be called after it stops being called for
  13837. // N milliseconds. If `immediate` is passed, trigger the function on the
  13838. // leading edge, instead of the trailing.
  13839. _.debounce = function(func, wait, immediate) {
  13840. var timeout, args, context, timestamp, result;
  13841.  
  13842. var later = function() {
  13843. var last = _.now() - timestamp;
  13844.  
  13845. if (last < wait && last >= 0) {
  13846. timeout = setTimeout(later, wait - last);
  13847. } else {
  13848. timeout = null;
  13849. if (!immediate) {
  13850. result = func.apply(context, args);
  13851. if (!timeout) context = args = null;
  13852. }
  13853. }
  13854. };
  13855.  
  13856. return function() {
  13857. context = this;
  13858. args = arguments;
  13859. timestamp = _.now();
  13860. var callNow = immediate && !timeout;
  13861. if (!timeout) timeout = setTimeout(later, wait);
  13862. if (callNow) {
  13863. result = func.apply(context, args);
  13864. context = args = null;
  13865. }
  13866.  
  13867. return result;
  13868. };
  13869. };
  13870.  
  13871. // Returns the first function passed as an argument to the second,
  13872. // allowing you to adjust arguments, run code before and after, and
  13873. // conditionally execute the original function.
  13874. _.wrap = function(func, wrapper) {
  13875. return _.partial(wrapper, func);
  13876. };
  13877.  
  13878. // Returns a negated version of the passed-in predicate.
  13879. _.negate = function(predicate) {
  13880. return function() {
  13881. return !predicate.apply(this, arguments);
  13882. };
  13883. };
  13884.  
  13885. // Returns a function that is the composition of a list of functions, each
  13886. // consuming the return value of the function that follows.
  13887. _.compose = function() {
  13888. var args = arguments;
  13889. var start = args.length - 1;
  13890. return function() {
  13891. var i = start;
  13892. var result = args[start].apply(this, arguments);
  13893. while (i--) result = args[i].call(this, result);
  13894. return result;
  13895. };
  13896. };
  13897.  
  13898. // Returns a function that will only be executed on and after the Nth call.
  13899. _.after = function(times, func) {
  13900. return function() {
  13901. if (--times < 1) {
  13902. return func.apply(this, arguments);
  13903. }
  13904. };
  13905. };
  13906.  
  13907. // Returns a function that will only be executed up to (but not including) the Nth call.
  13908. _.before = function(times, func) {
  13909. var memo;
  13910. return function() {
  13911. if (--times > 0) {
  13912. memo = func.apply(this, arguments);
  13913. }
  13914. if (times <= 1) func = null;
  13915. return memo;
  13916. };
  13917. };
  13918.  
  13919. // Returns a function that will be executed at most one time, no matter how
  13920. // often you call it. Useful for lazy initialization.
  13921. _.once = _.partial(_.before, 2);
  13922.  
  13923. // Object Functions
  13924. // ----------------
  13925.  
  13926. // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
  13927. var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
  13928. var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
  13929. 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
  13930.  
  13931. function collectNonEnumProps(obj, keys) {
  13932. var nonEnumIdx = nonEnumerableProps.length;
  13933. var constructor = obj.constructor;
  13934. var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto;
  13935.  
  13936. // Constructor is a special case.
  13937. var prop = 'constructor';
  13938. if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop);
  13939.  
  13940. while (nonEnumIdx--) {
  13941. prop = nonEnumerableProps[nonEnumIdx];
  13942. if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) {
  13943. keys.push(prop);
  13944. }
  13945. }
  13946. }
  13947.  
  13948. // Retrieve the names of an object's own properties.
  13949. // Delegates to **ECMAScript 5**'s native `Object.keys`
  13950. _.keys = function(obj) {
  13951. if (!_.isObject(obj)) return [];
  13952. if (nativeKeys) return nativeKeys(obj);
  13953. var keys = [];
  13954. for (var key in obj) if (_.has(obj, key)) keys.push(key);
  13955. // Ahem, IE < 9.
  13956. if (hasEnumBug) collectNonEnumProps(obj, keys);
  13957. return keys;
  13958. };
  13959.  
  13960. // Retrieve all the property names of an object.
  13961. _.allKeys = function(obj) {
  13962. if (!_.isObject(obj)) return [];
  13963. var keys = [];
  13964. for (var key in obj) keys.push(key);
  13965. // Ahem, IE < 9.
  13966. if (hasEnumBug) collectNonEnumProps(obj, keys);
  13967. return keys;
  13968. };
  13969.  
  13970. // Retrieve the values of an object's properties.
  13971. _.values = function(obj) {
  13972. var keys = _.keys(obj);
  13973. var length = keys.length;
  13974. var values = Array(length);
  13975. for (var i = 0; i < length; i++) {
  13976. values[i] = obj[keys[i]];
  13977. }
  13978. return values;
  13979. };
  13980.  
  13981. // Returns the results of applying the iteratee to each element of the object
  13982. // In contrast to _.map it returns an object
  13983. _.mapObject = function(obj, iteratee, context) {
  13984. iteratee = cb(iteratee, context);
  13985. var keys = _.keys(obj),
  13986. length = keys.length,
  13987. results = {},
  13988. currentKey;
  13989. for (var index = 0; index < length; index++) {
  13990. currentKey = keys[index];
  13991. results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
  13992. }
  13993. return results;
  13994. };
  13995.  
  13996. // Convert an object into a list of `[key, value]` pairs.
  13997. _.pairs = function(obj) {
  13998. var keys = _.keys(obj);
  13999. var length = keys.length;
  14000. var pairs = Array(length);
  14001. for (var i = 0; i < length; i++) {
  14002. pairs[i] = [keys[i], obj[keys[i]]];
  14003. }
  14004. return pairs;
  14005. };
  14006.  
  14007. // Invert the keys and values of an object. The values must be serializable.
  14008. _.invert = function(obj) {
  14009. var result = {};
  14010. var keys = _.keys(obj);
  14011. for (var i = 0, length = keys.length; i < length; i++) {
  14012. result[obj[keys[i]]] = keys[i];
  14013. }
  14014. return result;
  14015. };
  14016.  
  14017. // Return a sorted list of the function names available on the object.
  14018. // Aliased as `methods`
  14019. _.functions = _.methods = function(obj) {
  14020. var names = [];
  14021. for (var key in obj) {
  14022. if (_.isFunction(obj[key])) names.push(key);
  14023. }
  14024. return names.sort();
  14025. };
  14026.  
  14027. // Extend a given object with all the properties in passed-in object(s).
  14028. _.extend = createAssigner(_.allKeys);
  14029.  
  14030. // Assigns a given object with all the own properties in the passed-in object(s)
  14031. // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
  14032. _.extendOwn = _.assign = createAssigner(_.keys);
  14033.  
  14034. // Returns the first key on an object that passes a predicate test
  14035. _.findKey = function(obj, predicate, context) {
  14036. predicate = cb(predicate, context);
  14037. var keys = _.keys(obj), key;
  14038. for (var i = 0, length = keys.length; i < length; i++) {
  14039. key = keys[i];
  14040. if (predicate(obj[key], key, obj)) return key;
  14041. }
  14042. };
  14043.  
  14044. // Return a copy of the object only containing the whitelisted properties.
  14045. _.pick = function(object, oiteratee, context) {
  14046. var result = {}, obj = object, iteratee, keys;
  14047. if (obj == null) return result;
  14048. if (_.isFunction(oiteratee)) {
  14049. keys = _.allKeys(obj);
  14050. iteratee = optimizeCb(oiteratee, context);
  14051. } else {
  14052. keys = flatten(arguments, false, false, 1);
  14053. iteratee = function(value, key, obj) { return key in obj; };
  14054. obj = Object(obj);
  14055. }
  14056. for (var i = 0, length = keys.length; i < length; i++) {
  14057. var key = keys[i];
  14058. var value = obj[key];
  14059. if (iteratee(value, key, obj)) result[key] = value;
  14060. }
  14061. return result;
  14062. };
  14063.  
  14064. // Return a copy of the object without the blacklisted properties.
  14065. _.omit = function(obj, iteratee, context) {
  14066. if (_.isFunction(iteratee)) {
  14067. iteratee = _.negate(iteratee);
  14068. } else {
  14069. var keys = _.map(flatten(arguments, false, false, 1), String);
  14070. iteratee = function(value, key) {
  14071. return !_.contains(keys, key);
  14072. };
  14073. }
  14074. return _.pick(obj, iteratee, context);
  14075. };
  14076.  
  14077. // Fill in a given object with default properties.
  14078. _.defaults = createAssigner(_.allKeys, true);
  14079.  
  14080. // Creates an object that inherits from the given prototype object.
  14081. // If additional properties are provided then they will be added to the
  14082. // created object.
  14083. _.create = function(prototype, props) {
  14084. var result = baseCreate(prototype);
  14085. if (props) _.extendOwn(result, props);
  14086. return result;
  14087. };
  14088.  
  14089. // Create a (shallow-cloned) duplicate of an object.
  14090. _.clone = function(obj) {
  14091. if (!_.isObject(obj)) return obj;
  14092. return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
  14093. };
  14094.  
  14095. // Invokes interceptor with the obj, and then returns obj.
  14096. // The primary purpose of this method is to "tap into" a method chain, in
  14097. // order to perform operations on intermediate results within the chain.
  14098. _.tap = function(obj, interceptor) {
  14099. interceptor(obj);
  14100. return obj;
  14101. };
  14102.  
  14103. // Returns whether an object has a given set of `key:value` pairs.
  14104. _.isMatch = function(object, attrs) {
  14105. var keys = _.keys(attrs), length = keys.length;
  14106. if (object == null) return !length;
  14107. var obj = Object(object);
  14108. for (var i = 0; i < length; i++) {
  14109. var key = keys[i];
  14110. if (attrs[key] !== obj[key] || !(key in obj)) return false;
  14111. }
  14112. return true;
  14113. };
  14114.  
  14115.  
  14116. // Internal recursive comparison function for `isEqual`.
  14117. var eq = function(a, b, aStack, bStack) {
  14118. // Identical objects are equal. `0 === -0`, but they aren't identical.
  14119. // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
  14120. if (a === b) return a !== 0 || 1 / a === 1 / b;
  14121. // A strict comparison is necessary because `null == undefined`.
  14122. if (a == null || b == null) return a === b;
  14123. // Unwrap any wrapped objects.
  14124. if (a instanceof _) a = a._wrapped;
  14125. if (b instanceof _) b = b._wrapped;
  14126. // Compare `[[Class]]` names.
  14127. var className = toString.call(a);
  14128. if (className !== toString.call(b)) return false;
  14129. switch (className) {
  14130. // Strings, numbers, regular expressions, dates, and booleans are compared by value.
  14131. case '[object RegExp]':
  14132. // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
  14133. case '[object String]':
  14134. // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
  14135. // equivalent to `new String("5")`.
  14136. return '' + a === '' + b;
  14137. case '[object Number]':
  14138. // `NaN`s are equivalent, but non-reflexive.
  14139. // Object(NaN) is equivalent to NaN
  14140. if (+a !== +a) return +b !== +b;
  14141. // An `egal` comparison is performed for other numeric values.
  14142. return +a === 0 ? 1 / +a === 1 / b : +a === +b;
  14143. case '[object Date]':
  14144. case '[object Boolean]':
  14145. // Coerce dates and booleans to numeric primitive values. Dates are compared by their
  14146. // millisecond representations. Note that invalid dates with millisecond representations
  14147. // of `NaN` are not equivalent.
  14148. return +a === +b;
  14149. }
  14150.  
  14151. var areArrays = className === '[object Array]';
  14152. if (!areArrays) {
  14153. if (typeof a != 'object' || typeof b != 'object') return false;
  14154.  
  14155. // Objects with different constructors are not equivalent, but `Object`s or `Array`s
  14156. // from different frames are.
  14157. var aCtor = a.constructor, bCtor = b.constructor;
  14158. if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor &&
  14159. _.isFunction(bCtor) && bCtor instanceof bCtor)
  14160. && ('constructor' in a && 'constructor' in b)) {
  14161. return false;
  14162. }
  14163. }
  14164. // Assume equality for cyclic structures. The algorithm for detecting cyclic
  14165. // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
  14166.  
  14167. // Initializing stack of traversed objects.
  14168. // It's done here since we only need them for objects and arrays comparison.
  14169. aStack = aStack || [];
  14170. bStack = bStack || [];
  14171. var length = aStack.length;
  14172. while (length--) {
  14173. // Linear search. Performance is inversely proportional to the number of
  14174. // unique nested structures.
  14175. if (aStack[length] === a) return bStack[length] === b;
  14176. }
  14177.  
  14178. // Add the first object to the stack of traversed objects.
  14179. aStack.push(a);
  14180. bStack.push(b);
  14181.  
  14182. // Recursively compare objects and arrays.
  14183. if (areArrays) {
  14184. // Compare array lengths to determine if a deep comparison is necessary.
  14185. length = a.length;
  14186. if (length !== b.length) return false;
  14187. // Deep compare the contents, ignoring non-numeric properties.
  14188. while (length--) {
  14189. if (!eq(a[length], b[length], aStack, bStack)) return false;
  14190. }
  14191. } else {
  14192. // Deep compare objects.
  14193. var keys = _.keys(a), key;
  14194. length = keys.length;
  14195. // Ensure that both objects contain the same number of properties before comparing deep equality.
  14196. if (_.keys(b).length !== length) return false;
  14197. while (length--) {
  14198. // Deep compare each member
  14199. key = keys[length];
  14200. if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
  14201. }
  14202. }
  14203. // Remove the first object from the stack of traversed objects.
  14204. aStack.pop();
  14205. bStack.pop();
  14206. return true;
  14207. };
  14208.  
  14209. // Perform a deep comparison to check if two objects are equal.
  14210. _.isEqual = function(a, b) {
  14211. return eq(a, b);
  14212. };
  14213.  
  14214. // Is a given array, string, or object empty?
  14215. // An "empty" object has no enumerable own-properties.
  14216. _.isEmpty = function(obj) {
  14217. if (obj == null) return true;
  14218. if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0;
  14219. return _.keys(obj).length === 0;
  14220. };
  14221.  
  14222. // Is a given value a DOM element?
  14223. _.isElement = function(obj) {
  14224. return !!(obj && obj.nodeType === 1);
  14225. };
  14226.  
  14227. // Is a given value an array?
  14228. // Delegates to ECMA5's native Array.isArray
  14229. _.isArray = nativeIsArray || function(obj) {
  14230. return toString.call(obj) === '[object Array]';
  14231. };
  14232.  
  14233. // Is a given variable an object?
  14234. _.isObject = function(obj) {
  14235. var type = typeof obj;
  14236. return type === 'function' || type === 'object' && !!obj;
  14237. };
  14238.  
  14239. // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError.
  14240. _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) {
  14241. _['is' + name] = function(obj) {
  14242. return toString.call(obj) === '[object ' + name + ']';
  14243. };
  14244. });
  14245.  
  14246. // Define a fallback version of the method in browsers (ahem, IE < 9), where
  14247. // there isn't any inspectable "Arguments" type.
  14248. if (!_.isArguments(arguments)) {
  14249. _.isArguments = function(obj) {
  14250. return _.has(obj, 'callee');
  14251. };
  14252. }
  14253.  
  14254. // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8,
  14255. // IE 11 (#1621), and in Safari 8 (#1929).
  14256. if (typeof /./ != 'function' && typeof Int8Array != 'object') {
  14257. _.isFunction = function(obj) {
  14258. return typeof obj == 'function' || false;
  14259. };
  14260. }
  14261.  
  14262. // Is a given object a finite number?
  14263. _.isFinite = function(obj) {
  14264. return isFinite(obj) && !isNaN(parseFloat(obj));
  14265. };
  14266.  
  14267. // Is the given value `NaN`? (NaN is the only number which does not equal itself).
  14268. _.isNaN = function(obj) {
  14269. return _.isNumber(obj) && obj !== +obj;
  14270. };
  14271.  
  14272. // Is a given value a boolean?
  14273. _.isBoolean = function(obj) {
  14274. return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
  14275. };
  14276.  
  14277. // Is a given value equal to null?
  14278. _.isNull = function(obj) {
  14279. return obj === null;
  14280. };
  14281.  
  14282. // Is a given variable undefined?
  14283. _.isUndefined = function(obj) {
  14284. return obj === void 0;
  14285. };
  14286.  
  14287. // Shortcut function for checking if an object has a given property directly
  14288. // on itself (in other words, not on a prototype).
  14289. _.has = function(obj, key) {
  14290. return obj != null && hasOwnProperty.call(obj, key);
  14291. };
  14292.  
  14293. // Utility Functions
  14294. // -----------------
  14295.  
  14296. // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
  14297. // previous owner. Returns a reference to the Underscore object.
  14298. _.noConflict = function() {
  14299. root._ = previousUnderscore;
  14300. return this;
  14301. };
  14302.  
  14303. // Keep the identity function around for default iteratees.
  14304. _.identity = function(value) {
  14305. return value;
  14306. };
  14307.  
  14308. // Predicate-generating functions. Often useful outside of Underscore.
  14309. _.constant = function(value) {
  14310. return function() {
  14311. return value;
  14312. };
  14313. };
  14314.  
  14315. _.noop = function(){};
  14316.  
  14317. _.property = property;
  14318.  
  14319. // Generates a function for a given object that returns a given property.
  14320. _.propertyOf = function(obj) {
  14321. return obj == null ? function(){} : function(key) {
  14322. return obj[key];
  14323. };
  14324. };
  14325.  
  14326. // Returns a predicate for checking whether an object has a given set of
  14327. // `key:value` pairs.
  14328. _.matcher = _.matches = function(attrs) {
  14329. attrs = _.extendOwn({}, attrs);
  14330. return function(obj) {
  14331. return _.isMatch(obj, attrs);
  14332. };
  14333. };
  14334.  
  14335. // Run a function **n** times.
  14336. _.times = function(n, iteratee, context) {
  14337. var accum = Array(Math.max(0, n));
  14338. iteratee = optimizeCb(iteratee, context, 1);
  14339. for (var i = 0; i < n; i++) accum[i] = iteratee(i);
  14340. return accum;
  14341. };
  14342.  
  14343. // Return a random integer between min and max (inclusive).
  14344. _.random = function(min, max) {
  14345. if (max == null) {
  14346. max = min;
  14347. min = 0;
  14348. }
  14349. return min + Math.floor(Math.random() * (max - min + 1));
  14350. };
  14351.  
  14352. // A (possibly faster) way to get the current timestamp as an integer.
  14353. _.now = Date.now || function() {
  14354. return new Date().getTime();
  14355. };
  14356.  
  14357. // List of HTML entities for escaping.
  14358. var escapeMap = {
  14359. '&': '&amp;',
  14360. '<': '&lt;',
  14361. '>': '&gt;',
  14362. '"': '&quot;',
  14363. "'": '&#x27;',
  14364. '`': '&#x60;'
  14365. };
  14366. var unescapeMap = _.invert(escapeMap);
  14367.  
  14368. // Functions for escaping and unescaping strings to/from HTML interpolation.
  14369. var createEscaper = function(map) {
  14370. var escaper = function(match) {
  14371. return map[match];
  14372. };
  14373. // Regexes for identifying a key that needs to be escaped
  14374. var source = '(?:' + _.keys(map).join('|') + ')';
  14375. var testRegexp = RegExp(source);
  14376. var replaceRegexp = RegExp(source, 'g');
  14377. return function(string) {
  14378. string = string == null ? '' : '' + string;
  14379. return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
  14380. };
  14381. };
  14382. _.escape = createEscaper(escapeMap);
  14383. _.unescape = createEscaper(unescapeMap);
  14384.  
  14385. // If the value of the named `property` is a function then invoke it with the
  14386. // `object` as context; otherwise, return it.
  14387. _.result = function(object, property, fallback) {
  14388. var value = object == null ? void 0 : object[property];
  14389. if (value === void 0) {
  14390. value = fallback;
  14391. }
  14392. return _.isFunction(value) ? value.call(object) : value;
  14393. };
  14394.  
  14395. // Generate a unique integer id (unique within the entire client session).
  14396. // Useful for temporary DOM ids.
  14397. var idCounter = 0;
  14398. _.uniqueId = function(prefix) {
  14399. var id = ++idCounter + '';
  14400. return prefix ? prefix + id : id;
  14401. };
  14402.  
  14403. // By default, Underscore uses ERB-style template delimiters, change the
  14404. // following template settings to use alternative delimiters.
  14405. _.templateSettings = {
  14406. evaluate : /<%([\s\S]+?)%>/g,
  14407. interpolate : /<%=([\s\S]+?)%>/g,
  14408. escape : /<%-([\s\S]+?)%>/g
  14409. };
  14410.  
  14411. // When customizing `templateSettings`, if you don't want to define an
  14412. // interpolation, evaluation or escaping regex, we need one that is
  14413. // guaranteed not to match.
  14414. var noMatch = /(.)^/;
  14415.  
  14416. // Certain characters need to be escaped so that they can be put into a
  14417. // string literal.
  14418. var escapes = {
  14419. "'": "'",
  14420. '\\': '\\',
  14421. '\r': 'r',
  14422. '\n': 'n',
  14423. '\u2028': 'u2028',
  14424. '\u2029': 'u2029'
  14425. };
  14426.  
  14427. var escaper = /\\|'|\r|\n|\u2028|\u2029/g;
  14428.  
  14429. var escapeChar = function(match) {
  14430. return '\\' + escapes[match];
  14431. };
  14432.  
  14433. // JavaScript micro-templating, similar to John Resig's implementation.
  14434. // Underscore templating handles arbitrary delimiters, preserves whitespace,
  14435. // and correctly escapes quotes within interpolated code.
  14436. // NB: `oldSettings` only exists for backwards compatibility.
  14437. _.template = function(text, settings, oldSettings) {
  14438. if (!settings && oldSettings) settings = oldSettings;
  14439. settings = _.defaults({}, settings, _.templateSettings);
  14440.  
  14441. // Combine delimiters into one regular expression via alternation.
  14442. var matcher = RegExp([
  14443. (settings.escape || noMatch).source,
  14444. (settings.interpolate || noMatch).source,
  14445. (settings.evaluate || noMatch).source
  14446. ].join('|') + '|$', 'g');
  14447.  
  14448. // Compile the template source, escaping string literals appropriately.
  14449. var index = 0;
  14450. var source = "__p+='";
  14451. text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
  14452. source += text.slice(index, offset).replace(escaper, escapeChar);
  14453. index = offset + match.length;
  14454.  
  14455. if (escape) {
  14456. source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
  14457. } else if (interpolate) {
  14458. source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
  14459. } else if (evaluate) {
  14460. source += "';\n" + evaluate + "\n__p+='";
  14461. }
  14462.  
  14463. // Adobe VMs need the match returned to produce the correct offest.
  14464. return match;
  14465. });
  14466. source += "';\n";
  14467.  
  14468. // If a variable is not specified, place data values in local scope.
  14469. if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
  14470.  
  14471. source = "var __t,__p='',__j=Array.prototype.join," +
  14472. "print=function(){__p+=__j.call(arguments,'');};\n" +
  14473. source + 'return __p;\n';
  14474.  
  14475. try {
  14476. var render = new Function(settings.variable || 'obj', '_', source);
  14477. } catch (e) {
  14478. e.source = source;
  14479. throw e;
  14480. }
  14481.  
  14482. var template = function(data) {
  14483. return render.call(this, data, _);
  14484. };
  14485.  
  14486. // Provide the compiled source as a convenience for precompilation.
  14487. var argument = settings.variable || 'obj';
  14488. template.source = 'function(' + argument + '){\n' + source + '}';
  14489.  
  14490. return template;
  14491. };
  14492.  
  14493. // Add a "chain" function. Start chaining a wrapped Underscore object.
  14494. _.chain = function(obj) {
  14495. var instance = _(obj);
  14496. instance._chain = true;
  14497. return instance;
  14498. };
  14499.  
  14500. // OOP
  14501. // ---------------
  14502. // If Underscore is called as a function, it returns a wrapped object that
  14503. // can be used OO-style. This wrapper holds altered versions of all the
  14504. // underscore functions. Wrapped objects may be chained.
  14505.  
  14506. // Helper function to continue chaining intermediate results.
  14507. var result = function(instance, obj) {
  14508. return instance._chain ? _(obj).chain() : obj;
  14509. };
  14510.  
  14511. // Add your own custom functions to the Underscore object.
  14512. _.mixin = function(obj) {
  14513. _.each(_.functions(obj), function(name) {
  14514. var func = _[name] = obj[name];
  14515. _.prototype[name] = function() {
  14516. var args = [this._wrapped];
  14517. push.apply(args, arguments);
  14518. return result(this, func.apply(_, args));
  14519. };
  14520. });
  14521. };
  14522.  
  14523. // Add all of the Underscore functions to the wrapper object.
  14524. _.mixin(_);
  14525.  
  14526. // Add all mutator Array functions to the wrapper.
  14527. _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
  14528. var method = ArrayProto[name];
  14529. _.prototype[name] = function() {
  14530. var obj = this._wrapped;
  14531. method.apply(obj, arguments);
  14532. if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0];
  14533. return result(this, obj);
  14534. };
  14535. });
  14536.  
  14537. // Add all accessor Array functions to the wrapper.
  14538. _.each(['concat', 'join', 'slice'], function(name) {
  14539. var method = ArrayProto[name];
  14540. _.prototype[name] = function() {
  14541. return result(this, method.apply(this._wrapped, arguments));
  14542. };
  14543. });
  14544.  
  14545. // Extracts the result from a wrapped and chained object.
  14546. _.prototype.value = function() {
  14547. return this._wrapped;
  14548. };
  14549.  
  14550. // Provide unwrapping proxy for some methods used in engine operations
  14551. // such as arithmetic and JSON stringification.
  14552. _.prototype.valueOf = _.prototype.toJSON = _.prototype.value;
  14553.  
  14554. _.prototype.toString = function() {
  14555. return '' + this._wrapped;
  14556. };
  14557.  
  14558. // AMD registration happens at the end for compatibility with AMD loaders
  14559. // that may not enforce next-turn semantics on modules. Even though general
  14560. // practice for AMD registration is to be anonymous, underscore registers
  14561. // as a named module because, like jQuery, it is a base library that is
  14562. // popular enough to be bundled in a third party lib, but not be part of
  14563. // an AMD load request. Those cases could generate an error when an
  14564. // anonymous define() is called outside of a loader request.
  14565. if (true) {
  14566. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
  14567. return _;
  14568. }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  14569. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  14570. }
  14571. }.call(this));
  14572.  
  14573.  
  14574. /***/ }),
  14575. /* 114 */
  14576. /***/ (function(module, exports, __webpack_require__) {
  14577.  
  14578. "use strict";
  14579. // Copyright Joyent, Inc. and other Node contributors.
  14580. //
  14581. // Permission is hereby granted, free of charge, to any person obtaining a
  14582. // copy of this software and associated documentation files (the
  14583. // "Software"), to deal in the Software without restriction, including
  14584. // without limitation the rights to use, copy, modify, merge, publish,
  14585. // distribute, sublicense, and/or sell copies of the Software, and to permit
  14586. // persons to whom the Software is furnished to do so, subject to the
  14587. // following conditions:
  14588. //
  14589. // The above copyright notice and this permission notice shall be included
  14590. // in all copies or substantial portions of the Software.
  14591. //
  14592. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  14593. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14594. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  14595. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  14596. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  14597. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  14598. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  14599.  
  14600.  
  14601.  
  14602. var punycode = __webpack_require__(102);
  14603. var util = __webpack_require__(115);
  14604.  
  14605. exports.parse = urlParse;
  14606. exports.resolve = urlResolve;
  14607. exports.resolveObject = urlResolveObject;
  14608. exports.format = urlFormat;
  14609.  
  14610. exports.Url = Url;
  14611.  
  14612. function Url() {
  14613. this.protocol = null;
  14614. this.slashes = null;
  14615. this.auth = null;
  14616. this.host = null;
  14617. this.port = null;
  14618. this.hostname = null;
  14619. this.hash = null;
  14620. this.search = null;
  14621. this.query = null;
  14622. this.pathname = null;
  14623. this.path = null;
  14624. this.href = null;
  14625. }
  14626.  
  14627. // Reference: RFC 3986, RFC 1808, RFC 2396
  14628.  
  14629. // define these here so at least they only have to be
  14630. // compiled once on the first module load.
  14631. var protocolPattern = /^([a-z0-9.+-]+:)/i,
  14632. portPattern = /:[0-9]*$/,
  14633.  
  14634. // Special case for a simple path URL
  14635. simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
  14636.  
  14637. // RFC 2396: characters reserved for delimiting URLs.
  14638. // We actually just auto-escape these.
  14639. delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
  14640.  
  14641. // RFC 2396: characters not allowed for various reasons.
  14642. unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
  14643.  
  14644. // Allowed by RFCs, but cause of XSS attacks. Always escape these.
  14645. autoEscape = ['\''].concat(unwise),
  14646. // Characters that are never ever allowed in a hostname.
  14647. // Note that any invalid chars are also handled, but these
  14648. // are the ones that are *expected* to be seen, so we fast-path
  14649. // them.
  14650. nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
  14651. hostEndingChars = ['/', '?', '#'],
  14652. hostnameMaxLen = 255,
  14653. hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
  14654. hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
  14655. // protocols that can allow "unsafe" and "unwise" chars.
  14656. unsafeProtocol = {
  14657. 'javascript': true,
  14658. 'javascript:': true
  14659. },
  14660. // protocols that never have a hostname.
  14661. hostlessProtocol = {
  14662. 'javascript': true,
  14663. 'javascript:': true
  14664. },
  14665. // protocols that always contain a // bit.
  14666. slashedProtocol = {
  14667. 'http': true,
  14668. 'https': true,
  14669. 'ftp': true,
  14670. 'gopher': true,
  14671. 'file': true,
  14672. 'http:': true,
  14673. 'https:': true,
  14674. 'ftp:': true,
  14675. 'gopher:': true,
  14676. 'file:': true
  14677. },
  14678. querystring = __webpack_require__(105);
  14679.  
  14680. function urlParse(url, parseQueryString, slashesDenoteHost) {
  14681. if (url && util.isObject(url) && url instanceof Url) return url;
  14682.  
  14683. var u = new Url;
  14684. u.parse(url, parseQueryString, slashesDenoteHost);
  14685. return u;
  14686. }
  14687.  
  14688. Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
  14689. if (!util.isString(url)) {
  14690. throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
  14691. }
  14692.  
  14693. // Copy chrome, IE, opera backslash-handling behavior.
  14694. // Back slashes before the query string get converted to forward slashes
  14695. // See: https://code.google.com/p/chromium/issues/detail?id=25916
  14696. var queryIndex = url.indexOf('?'),
  14697. splitter =
  14698. (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
  14699. uSplit = url.split(splitter),
  14700. slashRegex = /\\/g;
  14701. uSplit[0] = uSplit[0].replace(slashRegex, '/');
  14702. url = uSplit.join(splitter);
  14703.  
  14704. var rest = url;
  14705.  
  14706. // trim before proceeding.
  14707. // This is to support parse stuff like " http://foo.com \n"
  14708. rest = rest.trim();
  14709.  
  14710. if (!slashesDenoteHost && url.split('#').length === 1) {
  14711. // Try fast path regexp
  14712. var simplePath = simplePathPattern.exec(rest);
  14713. if (simplePath) {
  14714. this.path = rest;
  14715. this.href = rest;
  14716. this.pathname = simplePath[1];
  14717. if (simplePath[2]) {
  14718. this.search = simplePath[2];
  14719. if (parseQueryString) {
  14720. this.query = querystring.parse(this.search.substr(1));
  14721. } else {
  14722. this.query = this.search.substr(1);
  14723. }
  14724. } else if (parseQueryString) {
  14725. this.search = '';
  14726. this.query = {};
  14727. }
  14728. return this;
  14729. }
  14730. }
  14731.  
  14732. var proto = protocolPattern.exec(rest);
  14733. if (proto) {
  14734. proto = proto[0];
  14735. var lowerProto = proto.toLowerCase();
  14736. this.protocol = lowerProto;
  14737. rest = rest.substr(proto.length);
  14738. }
  14739.  
  14740. // figure out if it's got a host
  14741. // user@server is *always* interpreted as a hostname, and url
  14742. // resolution will treat //foo/bar as host=foo,path=bar because that's
  14743. // how the browser resolves relative URLs.
  14744. if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
  14745. var slashes = rest.substr(0, 2) === '//';
  14746. if (slashes && !(proto && hostlessProtocol[proto])) {
  14747. rest = rest.substr(2);
  14748. this.slashes = true;
  14749. }
  14750. }
  14751.  
  14752. if (!hostlessProtocol[proto] &&
  14753. (slashes || (proto && !slashedProtocol[proto]))) {
  14754.  
  14755. // there's a hostname.
  14756. // the first instance of /, ?, ;, or # ends the host.
  14757. //
  14758. // If there is an @ in the hostname, then non-host chars *are* allowed
  14759. // to the left of the last @ sign, unless some host-ending character
  14760. // comes *before* the @-sign.
  14761. // URLs are obnoxious.
  14762. //
  14763. // ex:
  14764. // http://a@b@c/ => user:a@b host:c
  14765. // http://a@b?@c => user:a host:c path:/?@c
  14766.  
  14767. // v0.12 TODO(isaacs): This is not quite how Chrome does things.
  14768. // Review our test case against browsers more comprehensively.
  14769.  
  14770. // find the first instance of any hostEndingChars
  14771. var hostEnd = -1;
  14772. for (var i = 0; i < hostEndingChars.length; i++) {
  14773. var hec = rest.indexOf(hostEndingChars[i]);
  14774. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  14775. hostEnd = hec;
  14776. }
  14777.  
  14778. // at this point, either we have an explicit point where the
  14779. // auth portion cannot go past, or the last @ char is the decider.
  14780. var auth, atSign;
  14781. if (hostEnd === -1) {
  14782. // atSign can be anywhere.
  14783. atSign = rest.lastIndexOf('@');
  14784. } else {
  14785. // atSign must be in auth portion.
  14786. // http://a@b/c@d => host:b auth:a path:/c@d
  14787. atSign = rest.lastIndexOf('@', hostEnd);
  14788. }
  14789.  
  14790. // Now we have a portion which is definitely the auth.
  14791. // Pull that off.
  14792. if (atSign !== -1) {
  14793. auth = rest.slice(0, atSign);
  14794. rest = rest.slice(atSign + 1);
  14795. this.auth = decodeURIComponent(auth);
  14796. }
  14797.  
  14798. // the host is the remaining to the left of the first non-host char
  14799. hostEnd = -1;
  14800. for (var i = 0; i < nonHostChars.length; i++) {
  14801. var hec = rest.indexOf(nonHostChars[i]);
  14802. if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
  14803. hostEnd = hec;
  14804. }
  14805. // if we still have not hit it, then the entire thing is a host.
  14806. if (hostEnd === -1)
  14807. hostEnd = rest.length;
  14808.  
  14809. this.host = rest.slice(0, hostEnd);
  14810. rest = rest.slice(hostEnd);
  14811.  
  14812. // pull out port.
  14813. this.parseHost();
  14814.  
  14815. // we've indicated that there is a hostname,
  14816. // so even if it's empty, it has to be present.
  14817. this.hostname = this.hostname || '';
  14818.  
  14819. // if hostname begins with [ and ends with ]
  14820. // assume that it's an IPv6 address.
  14821. var ipv6Hostname = this.hostname[0] === '[' &&
  14822. this.hostname[this.hostname.length - 1] === ']';
  14823.  
  14824. // validate a little.
  14825. if (!ipv6Hostname) {
  14826. var hostparts = this.hostname.split(/\./);
  14827. for (var i = 0, l = hostparts.length; i < l; i++) {
  14828. var part = hostparts[i];
  14829. if (!part) continue;
  14830. if (!part.match(hostnamePartPattern)) {
  14831. var newpart = '';
  14832. for (var j = 0, k = part.length; j < k; j++) {
  14833. if (part.charCodeAt(j) > 127) {
  14834. // we replace non-ASCII char with a temporary placeholder
  14835. // we need this to make sure size of hostname is not
  14836. // broken by replacing non-ASCII by nothing
  14837. newpart += 'x';
  14838. } else {
  14839. newpart += part[j];
  14840. }
  14841. }
  14842. // we test again with ASCII char only
  14843. if (!newpart.match(hostnamePartPattern)) {
  14844. var validParts = hostparts.slice(0, i);
  14845. var notHost = hostparts.slice(i + 1);
  14846. var bit = part.match(hostnamePartStart);
  14847. if (bit) {
  14848. validParts.push(bit[1]);
  14849. notHost.unshift(bit[2]);
  14850. }
  14851. if (notHost.length) {
  14852. rest = '/' + notHost.join('.') + rest;
  14853. }
  14854. this.hostname = validParts.join('.');
  14855. break;
  14856. }
  14857. }
  14858. }
  14859. }
  14860.  
  14861. if (this.hostname.length > hostnameMaxLen) {
  14862. this.hostname = '';
  14863. } else {
  14864. // hostnames are always lower case.
  14865. this.hostname = this.hostname.toLowerCase();
  14866. }
  14867.  
  14868. if (!ipv6Hostname) {
  14869. // IDNA Support: Returns a punycoded representation of "domain".
  14870. // It only converts parts of the domain name that
  14871. // have non-ASCII characters, i.e. it doesn't matter if
  14872. // you call it with a domain that already is ASCII-only.
  14873. this.hostname = punycode.toASCII(this.hostname);
  14874. }
  14875.  
  14876. var p = this.port ? ':' + this.port : '';
  14877. var h = this.hostname || '';
  14878. this.host = h + p;
  14879. this.href += this.host;
  14880.  
  14881. // strip [ and ] from the hostname
  14882. // the host field still retains them, though
  14883. if (ipv6Hostname) {
  14884. this.hostname = this.hostname.substr(1, this.hostname.length - 2);
  14885. if (rest[0] !== '/') {
  14886. rest = '/' + rest;
  14887. }
  14888. }
  14889. }
  14890.  
  14891. // now rest is set to the post-host stuff.
  14892. // chop off any delim chars.
  14893. if (!unsafeProtocol[lowerProto]) {
  14894.  
  14895. // First, make 100% sure that any "autoEscape" chars get
  14896. // escaped, even if encodeURIComponent doesn't think they
  14897. // need to be.
  14898. for (var i = 0, l = autoEscape.length; i < l; i++) {
  14899. var ae = autoEscape[i];
  14900. if (rest.indexOf(ae) === -1)
  14901. continue;
  14902. var esc = encodeURIComponent(ae);
  14903. if (esc === ae) {
  14904. esc = escape(ae);
  14905. }
  14906. rest = rest.split(ae).join(esc);
  14907. }
  14908. }
  14909.  
  14910.  
  14911. // chop off from the tail first.
  14912. var hash = rest.indexOf('#');
  14913. if (hash !== -1) {
  14914. // got a fragment string.
  14915. this.hash = rest.substr(hash);
  14916. rest = rest.slice(0, hash);
  14917. }
  14918. var qm = rest.indexOf('?');
  14919. if (qm !== -1) {
  14920. this.search = rest.substr(qm);
  14921. this.query = rest.substr(qm + 1);
  14922. if (parseQueryString) {
  14923. this.query = querystring.parse(this.query);
  14924. }
  14925. rest = rest.slice(0, qm);
  14926. } else if (parseQueryString) {
  14927. // no query string, but parseQueryString still requested
  14928. this.search = '';
  14929. this.query = {};
  14930. }
  14931. if (rest) this.pathname = rest;
  14932. if (slashedProtocol[lowerProto] &&
  14933. this.hostname && !this.pathname) {
  14934. this.pathname = '/';
  14935. }
  14936.  
  14937. //to support http.request
  14938. if (this.pathname || this.search) {
  14939. var p = this.pathname || '';
  14940. var s = this.search || '';
  14941. this.path = p + s;
  14942. }
  14943.  
  14944. // finally, reconstruct the href based on what has been validated.
  14945. this.href = this.format();
  14946. return this;
  14947. };
  14948.  
  14949. // format a parsed object into a url string
  14950. function urlFormat(obj) {
  14951. // ensure it's an object, and not a string url.
  14952. // If it's an obj, this is a no-op.
  14953. // this way, you can call url_format() on strings
  14954. // to clean up potentially wonky urls.
  14955. if (util.isString(obj)) obj = urlParse(obj);
  14956. if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
  14957. return obj.format();
  14958. }
  14959.  
  14960. Url.prototype.format = function() {
  14961. var auth = this.auth || '';
  14962. if (auth) {
  14963. auth = encodeURIComponent(auth);
  14964. auth = auth.replace(/%3A/i, ':');
  14965. auth += '@';
  14966. }
  14967.  
  14968. var protocol = this.protocol || '',
  14969. pathname = this.pathname || '',
  14970. hash = this.hash || '',
  14971. host = false,
  14972. query = '';
  14973.  
  14974. if (this.host) {
  14975. host = auth + this.host;
  14976. } else if (this.hostname) {
  14977. host = auth + (this.hostname.indexOf(':') === -1 ?
  14978. this.hostname :
  14979. '[' + this.hostname + ']');
  14980. if (this.port) {
  14981. host += ':' + this.port;
  14982. }
  14983. }
  14984.  
  14985. if (this.query &&
  14986. util.isObject(this.query) &&
  14987. Object.keys(this.query).length) {
  14988. query = querystring.stringify(this.query);
  14989. }
  14990.  
  14991. var search = this.search || (query && ('?' + query)) || '';
  14992.  
  14993. if (protocol && protocol.substr(-1) !== ':') protocol += ':';
  14994.  
  14995. // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
  14996. // unless they had them to begin with.
  14997. if (this.slashes ||
  14998. (!protocol || slashedProtocol[protocol]) && host !== false) {
  14999. host = '//' + (host || '');
  15000. if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
  15001. } else if (!host) {
  15002. host = '';
  15003. }
  15004.  
  15005. if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
  15006. if (search && search.charAt(0) !== '?') search = '?' + search;
  15007.  
  15008. pathname = pathname.replace(/[?#]/g, function(match) {
  15009. return encodeURIComponent(match);
  15010. });
  15011. search = search.replace('#', '%23');
  15012.  
  15013. return protocol + host + pathname + search + hash;
  15014. };
  15015.  
  15016. function urlResolve(source, relative) {
  15017. return urlParse(source, false, true).resolve(relative);
  15018. }
  15019.  
  15020. Url.prototype.resolve = function(relative) {
  15021. return this.resolveObject(urlParse(relative, false, true)).format();
  15022. };
  15023.  
  15024. function urlResolveObject(source, relative) {
  15025. if (!source) return relative;
  15026. return urlParse(source, false, true).resolveObject(relative);
  15027. }
  15028.  
  15029. Url.prototype.resolveObject = function(relative) {
  15030. if (util.isString(relative)) {
  15031. var rel = new Url();
  15032. rel.parse(relative, false, true);
  15033. relative = rel;
  15034. }
  15035.  
  15036. var result = new Url();
  15037. var tkeys = Object.keys(this);
  15038. for (var tk = 0; tk < tkeys.length; tk++) {
  15039. var tkey = tkeys[tk];
  15040. result[tkey] = this[tkey];
  15041. }
  15042.  
  15043. // hash is always overridden, no matter what.
  15044. // even href="" will remove it.
  15045. result.hash = relative.hash;
  15046.  
  15047. // if the relative url is empty, then there's nothing left to do here.
  15048. if (relative.href === '') {
  15049. result.href = result.format();
  15050. return result;
  15051. }
  15052.  
  15053. // hrefs like //foo/bar always cut to the protocol.
  15054. if (relative.slashes && !relative.protocol) {
  15055. // take everything except the protocol from relative
  15056. var rkeys = Object.keys(relative);
  15057. for (var rk = 0; rk < rkeys.length; rk++) {
  15058. var rkey = rkeys[rk];
  15059. if (rkey !== 'protocol')
  15060. result[rkey] = relative[rkey];
  15061. }
  15062.  
  15063. //urlParse appends trailing / to urls like http://www.example.com
  15064. if (slashedProtocol[result.protocol] &&
  15065. result.hostname && !result.pathname) {
  15066. result.path = result.pathname = '/';
  15067. }
  15068.  
  15069. result.href = result.format();
  15070. return result;
  15071. }
  15072.  
  15073. if (relative.protocol && relative.protocol !== result.protocol) {
  15074. // if it's a known url protocol, then changing
  15075. // the protocol does weird things
  15076. // first, if it's not file:, then we MUST have a host,
  15077. // and if there was a path
  15078. // to begin with, then we MUST have a path.
  15079. // if it is file:, then the host is dropped,
  15080. // because that's known to be hostless.
  15081. // anything else is assumed to be absolute.
  15082. if (!slashedProtocol[relative.protocol]) {
  15083. var keys = Object.keys(relative);
  15084. for (var v = 0; v < keys.length; v++) {
  15085. var k = keys[v];
  15086. result[k] = relative[k];
  15087. }
  15088. result.href = result.format();
  15089. return result;
  15090. }
  15091.  
  15092. result.protocol = relative.protocol;
  15093. if (!relative.host && !hostlessProtocol[relative.protocol]) {
  15094. var relPath = (relative.pathname || '').split('/');
  15095. while (relPath.length && !(relative.host = relPath.shift()));
  15096. if (!relative.host) relative.host = '';
  15097. if (!relative.hostname) relative.hostname = '';
  15098. if (relPath[0] !== '') relPath.unshift('');
  15099. if (relPath.length < 2) relPath.unshift('');
  15100. result.pathname = relPath.join('/');
  15101. } else {
  15102. result.pathname = relative.pathname;
  15103. }
  15104. result.search = relative.search;
  15105. result.query = relative.query;
  15106. result.host = relative.host || '';
  15107. result.auth = relative.auth;
  15108. result.hostname = relative.hostname || relative.host;
  15109. result.port = relative.port;
  15110. // to support http.request
  15111. if (result.pathname || result.search) {
  15112. var p = result.pathname || '';
  15113. var s = result.search || '';
  15114. result.path = p + s;
  15115. }
  15116. result.slashes = result.slashes || relative.slashes;
  15117. result.href = result.format();
  15118. return result;
  15119. }
  15120.  
  15121. var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
  15122. isRelAbs = (
  15123. relative.host ||
  15124. relative.pathname && relative.pathname.charAt(0) === '/'
  15125. ),
  15126. mustEndAbs = (isRelAbs || isSourceAbs ||
  15127. (result.host && relative.pathname)),
  15128. removeAllDots = mustEndAbs,
  15129. srcPath = result.pathname && result.pathname.split('/') || [],
  15130. relPath = relative.pathname && relative.pathname.split('/') || [],
  15131. psychotic = result.protocol && !slashedProtocol[result.protocol];
  15132.  
  15133. // if the url is a non-slashed url, then relative
  15134. // links like ../.. should be able
  15135. // to crawl up to the hostname, as well. This is strange.
  15136. // result.protocol has already been set by now.
  15137. // Later on, put the first path part into the host field.
  15138. if (psychotic) {
  15139. result.hostname = '';
  15140. result.port = null;
  15141. if (result.host) {
  15142. if (srcPath[0] === '') srcPath[0] = result.host;
  15143. else srcPath.unshift(result.host);
  15144. }
  15145. result.host = '';
  15146. if (relative.protocol) {
  15147. relative.hostname = null;
  15148. relative.port = null;
  15149. if (relative.host) {
  15150. if (relPath[0] === '') relPath[0] = relative.host;
  15151. else relPath.unshift(relative.host);
  15152. }
  15153. relative.host = null;
  15154. }
  15155. mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
  15156. }
  15157.  
  15158. if (isRelAbs) {
  15159. // it's absolute.
  15160. result.host = (relative.host || relative.host === '') ?
  15161. relative.host : result.host;
  15162. result.hostname = (relative.hostname || relative.hostname === '') ?
  15163. relative.hostname : result.hostname;
  15164. result.search = relative.search;
  15165. result.query = relative.query;
  15166. srcPath = relPath;
  15167. // fall through to the dot-handling below.
  15168. } else if (relPath.length) {
  15169. // it's relative
  15170. // throw away the existing file, and take the new path instead.
  15171. if (!srcPath) srcPath = [];
  15172. srcPath.pop();
  15173. srcPath = srcPath.concat(relPath);
  15174. result.search = relative.search;
  15175. result.query = relative.query;
  15176. } else if (!util.isNullOrUndefined(relative.search)) {
  15177. // just pull out the search.
  15178. // like href='?foo'.
  15179. // Put this after the other two cases because it simplifies the booleans
  15180. if (psychotic) {
  15181. result.hostname = result.host = srcPath.shift();
  15182. //occationaly the auth can get stuck only in host
  15183. //this especially happens in cases like
  15184. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  15185. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  15186. result.host.split('@') : false;
  15187. if (authInHost) {
  15188. result.auth = authInHost.shift();
  15189. result.host = result.hostname = authInHost.shift();
  15190. }
  15191. }
  15192. result.search = relative.search;
  15193. result.query = relative.query;
  15194. //to support http.request
  15195. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  15196. result.path = (result.pathname ? result.pathname : '') +
  15197. (result.search ? result.search : '');
  15198. }
  15199. result.href = result.format();
  15200. return result;
  15201. }
  15202.  
  15203. if (!srcPath.length) {
  15204. // no path at all. easy.
  15205. // we've already handled the other stuff above.
  15206. result.pathname = null;
  15207. //to support http.request
  15208. if (result.search) {
  15209. result.path = '/' + result.search;
  15210. } else {
  15211. result.path = null;
  15212. }
  15213. result.href = result.format();
  15214. return result;
  15215. }
  15216.  
  15217. // if a url ENDs in . or .., then it must get a trailing slash.
  15218. // however, if it ends in anything else non-slashy,
  15219. // then it must NOT get a trailing slash.
  15220. var last = srcPath.slice(-1)[0];
  15221. var hasTrailingSlash = (
  15222. (result.host || relative.host || srcPath.length > 1) &&
  15223. (last === '.' || last === '..') || last === '');
  15224.  
  15225. // strip single dots, resolve double dots to parent dir
  15226. // if the path tries to go above the root, `up` ends up > 0
  15227. var up = 0;
  15228. for (var i = srcPath.length; i >= 0; i--) {
  15229. last = srcPath[i];
  15230. if (last === '.') {
  15231. srcPath.splice(i, 1);
  15232. } else if (last === '..') {
  15233. srcPath.splice(i, 1);
  15234. up++;
  15235. } else if (up) {
  15236. srcPath.splice(i, 1);
  15237. up--;
  15238. }
  15239. }
  15240.  
  15241. // if the path is allowed to go above the root, restore leading ..s
  15242. if (!mustEndAbs && !removeAllDots) {
  15243. for (; up--; up) {
  15244. srcPath.unshift('..');
  15245. }
  15246. }
  15247.  
  15248. if (mustEndAbs && srcPath[0] !== '' &&
  15249. (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
  15250. srcPath.unshift('');
  15251. }
  15252.  
  15253. if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
  15254. srcPath.push('');
  15255. }
  15256.  
  15257. var isAbsolute = srcPath[0] === '' ||
  15258. (srcPath[0] && srcPath[0].charAt(0) === '/');
  15259.  
  15260. // put the host back
  15261. if (psychotic) {
  15262. result.hostname = result.host = isAbsolute ? '' :
  15263. srcPath.length ? srcPath.shift() : '';
  15264. //occationaly the auth can get stuck only in host
  15265. //this especially happens in cases like
  15266. //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
  15267. var authInHost = result.host && result.host.indexOf('@') > 0 ?
  15268. result.host.split('@') : false;
  15269. if (authInHost) {
  15270. result.auth = authInHost.shift();
  15271. result.host = result.hostname = authInHost.shift();
  15272. }
  15273. }
  15274.  
  15275. mustEndAbs = mustEndAbs || (result.host && srcPath.length);
  15276.  
  15277. if (mustEndAbs && !isAbsolute) {
  15278. srcPath.unshift('');
  15279. }
  15280.  
  15281. if (!srcPath.length) {
  15282. result.pathname = null;
  15283. result.path = null;
  15284. } else {
  15285. result.pathname = srcPath.join('/');
  15286. }
  15287.  
  15288. //to support request.http
  15289. if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
  15290. result.path = (result.pathname ? result.pathname : '') +
  15291. (result.search ? result.search : '');
  15292. }
  15293. result.auth = relative.auth || result.auth;
  15294. result.slashes = result.slashes || relative.slashes;
  15295. result.href = result.format();
  15296. return result;
  15297. };
  15298.  
  15299. Url.prototype.parseHost = function() {
  15300. var host = this.host;
  15301. var port = portPattern.exec(host);
  15302. if (port) {
  15303. port = port[0];
  15304. if (port !== ':') {
  15305. this.port = port.substr(1);
  15306. }
  15307. host = host.substr(0, host.length - port.length);
  15308. }
  15309. if (host) this.hostname = host;
  15310. };
  15311.  
  15312.  
  15313. /***/ }),
  15314. /* 115 */
  15315. /***/ (function(module, exports, __webpack_require__) {
  15316.  
  15317. "use strict";
  15318.  
  15319.  
  15320. module.exports = {
  15321. isString: function(arg) {
  15322. return typeof(arg) === 'string';
  15323. },
  15324. isObject: function(arg) {
  15325. return typeof(arg) === 'object' && arg !== null;
  15326. },
  15327. isNull: function(arg) {
  15328. return arg === null;
  15329. },
  15330. isNullOrUndefined: function(arg) {
  15331. return arg == null;
  15332. }
  15333. };
  15334.  
  15335.  
  15336. /***/ }),
  15337. /* 116 */
  15338. /***/ (function(module, exports) {
  15339.  
  15340. module.exports = function(module) {
  15341. if(!module.webpackPolyfill) {
  15342. module.deprecate = function() {};
  15343. module.paths = [];
  15344. // module.parent = undefined by default
  15345. if(!module.children) module.children = [];
  15346. Object.defineProperty(module, "loaded", {
  15347. enumerable: true,
  15348. get: function() {
  15349. return module.l;
  15350. }
  15351. });
  15352. Object.defineProperty(module, "id", {
  15353. enumerable: true,
  15354. get: function() {
  15355. return module.i;
  15356. }
  15357. });
  15358. module.webpackPolyfill = 1;
  15359. }
  15360. return module;
  15361. };
  15362.  
  15363.  
  15364. /***/ }),
  15365. /* 117 */
  15366. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15367.  
  15368. "use strict";
  15369. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  15370. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator__ = __webpack_require__(11);
  15371. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator__);
  15372. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_asyncToGenerator__ = __webpack_require__(10);
  15373. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_asyncToGenerator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_asyncToGenerator__);
  15374. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__utils__ = __webpack_require__(9);
  15375. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__pages_detail__ = __webpack_require__(50);
  15376. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__pages_search__ = __webpack_require__(52);
  15377. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__pages_browse__ = __webpack_require__(49);
  15378. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__pages_home__ = __webpack_require__(51);
  15379.  
  15380.  
  15381.  
  15382.  
  15383.  
  15384. var init = function () {
  15385. var _ref = __WEBPACK_IMPORTED_MODULE_1_babel_runtime_helpers_asyncToGenerator___default()(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.mark(function _callee() {
  15386. var href;
  15387. return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_regenerator___default.a.wrap(function _callee$(_context) {
  15388. while (1) {
  15389. switch (_context.prev = _context.next) {
  15390. case 0:
  15391. href = window.location.href;
  15392.  
  15393. if (href.indexOf("package") >= 0) {
  15394. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__pages_detail__["a" /* default */])()().catch(__WEBPACK_IMPORTED_MODULE_2__utils__["a" /* printError */]);
  15395. } else if (href.indexOf('search') >= 0) {
  15396. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4__pages_search__["a" /* default */])()().catch(__WEBPACK_IMPORTED_MODULE_2__utils__["a" /* printError */]);
  15397. } else if (href.indexOf('browse') >= 0) {
  15398. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_5__pages_browse__["a" /* default */])()().catch(__WEBPACK_IMPORTED_MODULE_2__utils__["a" /* printError */]);
  15399. } else {
  15400. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__pages_home__["a" /* default */])()().catch(__WEBPACK_IMPORTED_MODULE_2__utils__["a" /* printError */]);
  15401. }
  15402.  
  15403. case 2:
  15404. case 'end':
  15405. return _context.stop();
  15406. }
  15407. }
  15408. }, _callee, this);
  15409. }));
  15410.  
  15411. return function init() {
  15412. return _ref.apply(this, arguments);
  15413. };
  15414. }();
  15415.  
  15416.  
  15417.  
  15418.  
  15419.  
  15420.  
  15421.  
  15422.  
  15423. __webpack_require__(53);
  15424.  
  15425. init();
  15426.  
  15427. /***/ })
  15428. /******/ ]);