PageRenderTime 56ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/ajax/libs/axios/0.1.0/axios.amd.js

https://gitlab.com/Mirros/cdnjs
JavaScript | 1355 lines | 795 code | 207 blank | 353 comment | 121 complexity | 9bae8454c845d62e07849953d4323191 MD5 | raw file
  1. define("axios", [], function() { return /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/
  8. /******/ // Check if module is in cache
  9. /******/ if(installedModules[moduleId])
  10. /******/ return installedModules[moduleId].exports;
  11. /******/
  12. /******/ // Create a new module (and put it into the cache)
  13. /******/ var module = installedModules[moduleId] = {
  14. /******/ exports: {},
  15. /******/ id: moduleId,
  16. /******/ loaded: false
  17. /******/ };
  18. /******/
  19. /******/ // Execute the module function
  20. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  21. /******/
  22. /******/ // Flag the module as loaded
  23. /******/ module.loaded = true;
  24. /******/
  25. /******/ // Return the exports of the module
  26. /******/ return module.exports;
  27. /******/ }
  28. /******/
  29. /******/
  30. /******/ // expose the modules object (__webpack_modules__)
  31. /******/ __webpack_require__.m = modules;
  32. /******/
  33. /******/ // expose the module cache
  34. /******/ __webpack_require__.c = installedModules;
  35. /******/
  36. /******/ // __webpack_public_path__
  37. /******/ __webpack_require__.p = "";
  38. /******/
  39. /******/ // Load entry module and return exports
  40. /******/ return __webpack_require__(0);
  41. /******/ })
  42. /************************************************************************/
  43. /******/ ([
  44. /* 0 */
  45. /***/ function(module, exports, __webpack_require__) {
  46. module.exports = __webpack_require__(1);
  47. /***/ },
  48. /* 1 */
  49. /***/ function(module, exports, __webpack_require__) {
  50. var Promise = __webpack_require__(9).Promise;
  51. var buildUrl = __webpack_require__(2);
  52. var cookies = __webpack_require__(3);
  53. var defaults = __webpack_require__(4);
  54. var parseHeaders = __webpack_require__(5);
  55. var transformData = __webpack_require__(6);
  56. var urlIsSameOrigin = __webpack_require__(7);
  57. var utils = __webpack_require__(8);
  58. var axios = module.exports = function axios(config) {
  59. config = utils.merge({
  60. method: 'get',
  61. transformRequest: defaults.transformRequest,
  62. transformResponse: defaults.transformResponse
  63. }, config);
  64. // Don't allow overriding defaults.withCredentials
  65. config.withCredentials = config.withCredentials || defaults.withCredentials;
  66. var promise = new Promise(function (resolve, reject) {
  67. // Create the request
  68. var request = new(XMLHttpRequest || ActiveXObject)('Microsoft.XMLHTTP');
  69. var data = transformData(
  70. config.data,
  71. config.headers,
  72. config.transformRequest
  73. );
  74. // Open the request
  75. request.open(config.method, buildUrl(config.url, config.params), true);
  76. // Listen for ready state
  77. request.onreadystatechange = function () {
  78. if (request && request.readyState === 4) {
  79. // Prepare the response
  80. var headers = parseHeaders(request.getAllResponseHeaders());
  81. var response = {
  82. data: transformData(
  83. request.responseText,
  84. headers,
  85. config.transformResponse
  86. ),
  87. status: request.status,
  88. headers: headers,
  89. config: config
  90. };
  91. // Resolve or reject the Promise based on the status
  92. (request.status >= 200 && request.status < 300
  93. ? resolve
  94. : reject)(
  95. response.data,
  96. response.status,
  97. response.headers,
  98. response.config
  99. );
  100. // Clean up request
  101. request = null;
  102. }
  103. };
  104. // Merge headers and add to request
  105. var headers = utils.merge(
  106. defaults.headers.common,
  107. defaults.headers[config.method] || {},
  108. config.headers || {}
  109. );
  110. // Add xsrf header
  111. var xsrfValue = urlIsSameOrigin(config.url)
  112. ? cookies.read(config.xsrfCookieName || defaults.xsrfCookieName)
  113. : undefined;
  114. if (xsrfValue) {
  115. headers[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue;
  116. }
  117. utils.forEach(headers, function (val, key) {
  118. // Remove Content-Type if data is undefined
  119. if (!data && key.toLowerCase() === 'content-type') {
  120. delete headers[key];
  121. }
  122. // Otherwise add header to the request
  123. else {
  124. request.setRequestHeader(key, val);
  125. }
  126. });
  127. // Add withCredentials to request if needed
  128. if (config.withCredentials) {
  129. request.withCredentials = true;
  130. }
  131. // Add responseType to request if needed
  132. if (config.responseType) {
  133. try {
  134. request.responseType = config.responseType;
  135. } catch (e) {
  136. if (request.responseType !== 'json') {
  137. throw e;
  138. }
  139. }
  140. }
  141. // Send the request
  142. request.send(data);
  143. });
  144. // Provide alias for success
  145. promise.success = function success(fn) {
  146. promise.then(function(response) {
  147. fn(response);
  148. });
  149. return promise;
  150. };
  151. // Provide alias for error
  152. promise.error = function error(fn) {
  153. promise.then(null, function(response) {
  154. fn(response);
  155. });
  156. return promise;
  157. };
  158. return promise;
  159. };
  160. // Expose defaults
  161. axios.defaults = defaults;
  162. // Provide aliases for supported request methods
  163. createShortMethods('delete', 'get', 'head');
  164. createShortMethodsWithData('post', 'put', 'patch');
  165. function createShortMethods() {
  166. utils.forEach(arguments, function (method) {
  167. axios[method] = function (url, config) {
  168. return axios(utils.merge(config || {}, {
  169. method: method,
  170. url: url
  171. }));
  172. };
  173. });
  174. }
  175. function createShortMethodsWithData() {
  176. utils.forEach(arguments, function (method) {
  177. axios[method] = function (url, data, config) {
  178. return axios(utils.merge(config || {}, {
  179. method: method,
  180. url: url,
  181. data: data
  182. }));
  183. };
  184. });
  185. }
  186. /***/ },
  187. /* 2 */
  188. /***/ function(module, exports, __webpack_require__) {
  189. 'use strict';
  190. var utils = __webpack_require__(8);
  191. function encode(val) {
  192. return encodeURIComponent(val).
  193. replace(/%40/gi, '@').
  194. replace(/%3A/gi, ':').
  195. replace(/%24/g, '$').
  196. replace(/%2C/gi, ',').
  197. replace(/%20/g, '+');
  198. }
  199. module.exports = function buildUrl(url, params) {
  200. if (!params) {
  201. return url;
  202. }
  203. var parts = [];
  204. utils.forEach(params, function (val, key) {
  205. if (val === null || typeof val === 'undefined') {
  206. return;
  207. }
  208. if (!utils.isArray(val)) {
  209. val = [val];
  210. }
  211. utils.forEach(val, function (v) {
  212. if (utils.isDate(v)) {
  213. v = v.toISOString();
  214. }
  215. else if (utils.isObject(v)) {
  216. v = JSON.stringify(v);
  217. }
  218. parts.push(encode(key) + '=' + encode(v));
  219. });
  220. });
  221. if (parts.length > 0) {
  222. url += (url.indexOf('?') === -1 ? '?' : '&') + parts.join('&');
  223. }
  224. return url;
  225. };
  226. /***/ },
  227. /* 3 */
  228. /***/ function(module, exports, __webpack_require__) {
  229. 'use strict';
  230. var utils = __webpack_require__(8);
  231. module.exports = {
  232. write: function write(name, value, expires, path, domain, secure) {
  233. var cookie = [];
  234. cookie.push(name + '=' + encodeURIComponent(value));
  235. if (utils.isNumber(expires)) {
  236. cookie.push('expires=' + new Date(expires).toGMTString());
  237. }
  238. if (utils.isString(path)) {
  239. cookie.push('path=' + path);
  240. }
  241. if (utils.isString(domain)) {
  242. cookie.push('domain=' + domain);
  243. }
  244. if (secure === true) {
  245. cookie.push('secure');
  246. }
  247. document.cookie = cookie.join('; ');
  248. },
  249. read: function read(name) {
  250. var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
  251. return (match ? decodeURIComponent(match[3]) : null);
  252. },
  253. remove: function remove(name) {
  254. this.write(name, '', Date.now() - 86400000);
  255. }
  256. };
  257. /***/ },
  258. /* 4 */
  259. /***/ function(module, exports, __webpack_require__) {
  260. 'use strict';
  261. var utils = __webpack_require__(8);
  262. var JSON_START = /^\s*(\[|\{[^\{])/;
  263. var JSON_END = /[\}\]]\s*$/;
  264. var PROTECTION_PREFIX = /^\)\]\}',?\n/;
  265. var CONTENT_TYPE_APPLICATION_JSON = {
  266. 'Content-Type': 'application/json;charset=utf-8'
  267. };
  268. module.exports = {
  269. transformRequest: [function (data) {
  270. return utils.isObject(data) &&
  271. !utils.isFile(data) &&
  272. !utils.isBlob(data) ?
  273. JSON.stringify(data) : null;
  274. }],
  275. transformResponse: [function (data) {
  276. if (typeof data === 'string') {
  277. data = data.replace(PROTECTION_PREFIX, '');
  278. if (JSON_START.test(data) && JSON_END.test(data)) {
  279. data = JSON.parse(data);
  280. }
  281. }
  282. return data;
  283. }],
  284. headers: {
  285. common: {
  286. 'Accept': 'application/json, text/plain, */*'
  287. },
  288. patch: utils.merge(CONTENT_TYPE_APPLICATION_JSON),
  289. post: utils.merge(CONTENT_TYPE_APPLICATION_JSON),
  290. put: utils.merge(CONTENT_TYPE_APPLICATION_JSON)
  291. },
  292. xsrfCookieName: 'XSRF-TOKEN',
  293. xsrfHeaderName: 'X-XSRF-TOKEN'
  294. };
  295. /***/ },
  296. /* 5 */
  297. /***/ function(module, exports, __webpack_require__) {
  298. 'use strict';
  299. var utils = __webpack_require__(8);
  300. /**
  301. * Parse headers into an object
  302. *
  303. * ```
  304. * Date: Wed, 27 Aug 2014 08:58:49 GMT
  305. * Content-Type: application/json
  306. * Connection: keep-alive
  307. * Transfer-Encoding: chunked
  308. * ```
  309. *
  310. * @param {String} headers Headers needing to be parsed
  311. * @returns {Object} Headers parsed into an object
  312. */
  313. module.exports = function parseHeaders(headers) {
  314. var parsed = {}, key, val, i;
  315. if (!headers) return parsed;
  316. utils.forEach(headers.split('\n'), function(line) {
  317. i = line.indexOf(':');
  318. key = utils.trim(line.substr(0, i)).toLowerCase();
  319. val = utils.trim(line.substr(i + 1));
  320. if (key) {
  321. parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
  322. }
  323. });
  324. return parsed;
  325. };
  326. /***/ },
  327. /* 6 */
  328. /***/ function(module, exports, __webpack_require__) {
  329. 'use strict';
  330. var utils = __webpack_require__(8);
  331. /**
  332. * Transform the data for a request or a response
  333. *
  334. * @param {Object|String} data The data to be transformed
  335. * @param {Array} headers The headers for the request or response
  336. * @param {Array|Function} fns A single function or Array of functions
  337. * @returns {*} The resulting transformed data
  338. */
  339. module.exports = function transformData(data, headers, fns) {
  340. utils.forEach(fns, function (fn) {
  341. data = fn(data, headers);
  342. });
  343. return data;
  344. };
  345. /***/ },
  346. /* 7 */
  347. /***/ function(module, exports, __webpack_require__) {
  348. 'use strict';
  349. var msie = /(msie|trident)/i.test(navigator.userAgent);
  350. var utils = __webpack_require__(8);
  351. var urlParsingNode = document.createElement('a');
  352. var originUrl = urlResolve(window.location.href);
  353. /**
  354. * Parse a URL to discover it's components
  355. *
  356. * @param {String} url The URL to be parsed
  357. * @returns {Object}
  358. */
  359. function urlResolve(url) {
  360. var href = url;
  361. if (msie) {
  362. // IE needs attribute set twice to normalize properties
  363. urlParsingNode.setAttribute('href', href);
  364. href = urlParsingNode.href;
  365. }
  366. urlParsingNode.setAttribute('href', href);
  367. // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
  368. return {
  369. href: urlParsingNode.href,
  370. protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
  371. host: urlParsingNode.host,
  372. search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
  373. hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
  374. hostname: urlParsingNode.hostname,
  375. port: urlParsingNode.port,
  376. pathname: (urlParsingNode.pathname.charAt(0) === '/')
  377. ? urlParsingNode.pathname
  378. : '/' + urlParsingNode.pathname
  379. };
  380. }
  381. /**
  382. * Determine if a URL shares the same origin as the current location
  383. *
  384. * @param {String} requestUrl The URL to test
  385. * @returns {boolean} True if URL shares the same origin, otherwise false
  386. */
  387. module.exports = function urlIsSameOrigin(requestUrl) {
  388. var parsed = (utils.isString(requestUrl)) ? urlResolve(requestUrl) : requestUrl;
  389. return (parsed.protocol === originUrl.protocol &&
  390. parsed.host === originUrl.host);
  391. };
  392. /***/ },
  393. /* 8 */
  394. /***/ function(module, exports, __webpack_require__) {
  395. // utils is a library of generic helper functions non-specific to axios
  396. var toString = Object.prototype.toString;
  397. /**
  398. * Determine if a value is an Array
  399. *
  400. * @param {Object} val The value to test
  401. * @returns {boolean} True if value is an Array, otherwise false
  402. */
  403. function isArray(val) {
  404. return toString.call(val) === '[object Array]';
  405. }
  406. /**
  407. * Determine if a value is a String
  408. *
  409. * @param {Object} val The value to test
  410. * @returns {boolean} True if value is a String, otherwise false
  411. */
  412. function isString(val) {
  413. return typeof val === 'string';
  414. }
  415. /**
  416. * Determine if a value is a Number
  417. *
  418. * @param {Object} val The value to test
  419. * @returns {boolean} True if value is a Number, otherwise false
  420. */
  421. function isNumber(val) {
  422. return typeof val === 'number';
  423. }
  424. /**
  425. * Determine if a value is an Object
  426. *
  427. * @param {Object} val The value to test
  428. * @returns {boolean} True if value is an Object, otherwise false
  429. */
  430. function isObject(val) {
  431. return val !== null && typeof val === 'object';
  432. }
  433. /**
  434. * Determine if a value is a Date
  435. *
  436. * @param {Object} val The value to test
  437. * @returns {boolean} True if value is a Date, otherwise false
  438. */
  439. function isDate(val) {
  440. return toString.call(val) === '[object Date]';
  441. }
  442. /**
  443. * Determine if a value is a File
  444. *
  445. * @param {Object} val The value to test
  446. * @returns {boolean} True if value is a File, otherwise false
  447. */
  448. function isFile(val) {
  449. return toString.call(val) === '[object File]';
  450. }
  451. /**
  452. * Determine if a value is a Blob
  453. *
  454. * @param {Object} val The value to test
  455. * @returns {boolean} True if value is a Blob, otherwise false
  456. */
  457. function isBlob(val) {
  458. return toString.call(val) === '[object Blob]';
  459. }
  460. /**
  461. * Trim excess whitespace off the beginning and end of a string
  462. *
  463. * @param {String} str The String to trim
  464. * @returns {String} The String freed of excess whitespace
  465. */
  466. function trim(str) {
  467. return str.replace(/^\s*/, '').replace(/\s*$/, '');
  468. }
  469. /**
  470. * Iterate over an Array or an Object invoking a function for each item.
  471. *
  472. * If `obj` is an Array or arguments callback will be called passing
  473. * the value, index, and complete array for each item.
  474. *
  475. * If 'obj' is an Object callback will be called passing
  476. * the value, key, and complete object for each property.
  477. *
  478. * @param {Object|Array} obj The object to iterate
  479. * @param {Function} fn The callback to invoke for each item
  480. */
  481. function forEach(obj, fn) {
  482. // Don't bother if no value provided
  483. if (obj === null || typeof obj === 'undefined') {
  484. return;
  485. }
  486. // Check if obj is array-like
  487. var isArray = obj.constructor === Array || typeof obj.callee === 'function';
  488. // Force an array if not already something iterable
  489. if (typeof obj !== 'object' && !isArray) {
  490. obj = [obj];
  491. }
  492. // Iterate over array values
  493. if (isArray) {
  494. for (var i=0, l=obj.length; i<l; i++) {
  495. fn.call(null, obj[i], i, obj);
  496. }
  497. }
  498. // Iterate over object keys
  499. else {
  500. for (var key in obj) {
  501. if (obj.hasOwnProperty(key)) {
  502. fn.call(null, obj[key], key, obj);
  503. }
  504. }
  505. }
  506. }
  507. /**
  508. * Accepts varargs expecting each argument to be an object, then
  509. * immutably merges the properties of each object and returns result.
  510. *
  511. * When multiple objects contain the same key the later object in
  512. * the arguments list will take precedence.
  513. *
  514. * Example:
  515. *
  516. * ```js
  517. * var result = merge({foo: 123}, {foo: 456});
  518. * console.log(result.foo); // outputs 456
  519. * ```
  520. *
  521. * @param {Object} obj1 Object to merge
  522. * @returns {Object} Result of all merge properties
  523. */
  524. function merge(obj1/*, obj2, obj3, ...*/) {
  525. var result = {};
  526. forEach(arguments, function (obj) {
  527. forEach(obj, function (val, key) {
  528. result[key] = val;
  529. });
  530. });
  531. return result;
  532. }
  533. module.exports = {
  534. isArray: isArray,
  535. isString: isString,
  536. isNumber: isNumber,
  537. isObject: isObject,
  538. isDate: isDate,
  539. isFile: isFile,
  540. isBlob: isBlob,
  541. forEach: forEach,
  542. merge: merge,
  543. trim: trim
  544. };
  545. /***/ },
  546. /* 9 */
  547. /***/ function(module, exports, __webpack_require__) {
  548. "use strict";
  549. var Promise = __webpack_require__(10).Promise;
  550. var polyfill = __webpack_require__(11).polyfill;
  551. exports.Promise = Promise;
  552. exports.polyfill = polyfill;
  553. /***/ },
  554. /* 10 */
  555. /***/ function(module, exports, __webpack_require__) {
  556. "use strict";
  557. var config = __webpack_require__(12).config;
  558. var configure = __webpack_require__(12).configure;
  559. var objectOrFunction = __webpack_require__(13).objectOrFunction;
  560. var isFunction = __webpack_require__(13).isFunction;
  561. var now = __webpack_require__(13).now;
  562. var all = __webpack_require__(14).all;
  563. var race = __webpack_require__(15).race;
  564. var staticResolve = __webpack_require__(16).resolve;
  565. var staticReject = __webpack_require__(17).reject;
  566. var asap = __webpack_require__(18).asap;
  567. var counter = 0;
  568. config.async = asap; // default async is asap;
  569. function Promise(resolver) {
  570. if (!isFunction(resolver)) {
  571. throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
  572. }
  573. if (!(this instanceof Promise)) {
  574. throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
  575. }
  576. this._subscribers = [];
  577. invokeResolver(resolver, this);
  578. }
  579. function invokeResolver(resolver, promise) {
  580. function resolvePromise(value) {
  581. resolve(promise, value);
  582. }
  583. function rejectPromise(reason) {
  584. reject(promise, reason);
  585. }
  586. try {
  587. resolver(resolvePromise, rejectPromise);
  588. } catch(e) {
  589. rejectPromise(e);
  590. }
  591. }
  592. function invokeCallback(settled, promise, callback, detail) {
  593. var hasCallback = isFunction(callback),
  594. value, error, succeeded, failed;
  595. if (hasCallback) {
  596. try {
  597. value = callback(detail);
  598. succeeded = true;
  599. } catch(e) {
  600. failed = true;
  601. error = e;
  602. }
  603. } else {
  604. value = detail;
  605. succeeded = true;
  606. }
  607. if (handleThenable(promise, value)) {
  608. return;
  609. } else if (hasCallback && succeeded) {
  610. resolve(promise, value);
  611. } else if (failed) {
  612. reject(promise, error);
  613. } else if (settled === FULFILLED) {
  614. resolve(promise, value);
  615. } else if (settled === REJECTED) {
  616. reject(promise, value);
  617. }
  618. }
  619. var PENDING = void 0;
  620. var SEALED = 0;
  621. var FULFILLED = 1;
  622. var REJECTED = 2;
  623. function subscribe(parent, child, onFulfillment, onRejection) {
  624. var subscribers = parent._subscribers;
  625. var length = subscribers.length;
  626. subscribers[length] = child;
  627. subscribers[length + FULFILLED] = onFulfillment;
  628. subscribers[length + REJECTED] = onRejection;
  629. }
  630. function publish(promise, settled) {
  631. var child, callback, subscribers = promise._subscribers, detail = promise._detail;
  632. for (var i = 0; i < subscribers.length; i += 3) {
  633. child = subscribers[i];
  634. callback = subscribers[i + settled];
  635. invokeCallback(settled, child, callback, detail);
  636. }
  637. promise._subscribers = null;
  638. }
  639. Promise.prototype = {
  640. constructor: Promise,
  641. _state: undefined,
  642. _detail: undefined,
  643. _subscribers: undefined,
  644. then: function(onFulfillment, onRejection) {
  645. var promise = this;
  646. var thenPromise = new this.constructor(function() {});
  647. if (this._state) {
  648. var callbacks = arguments;
  649. config.async(function invokePromiseCallback() {
  650. invokeCallback(promise._state, thenPromise, callbacks[promise._state - 1], promise._detail);
  651. });
  652. } else {
  653. subscribe(this, thenPromise, onFulfillment, onRejection);
  654. }
  655. return thenPromise;
  656. },
  657. 'catch': function(onRejection) {
  658. return this.then(null, onRejection);
  659. }
  660. };
  661. Promise.all = all;
  662. Promise.race = race;
  663. Promise.resolve = staticResolve;
  664. Promise.reject = staticReject;
  665. function handleThenable(promise, value) {
  666. var then = null,
  667. resolved;
  668. try {
  669. if (promise === value) {
  670. throw new TypeError("A promises callback cannot return that same promise.");
  671. }
  672. if (objectOrFunction(value)) {
  673. then = value.then;
  674. if (isFunction(then)) {
  675. then.call(value, function(val) {
  676. if (resolved) { return true; }
  677. resolved = true;
  678. if (value !== val) {
  679. resolve(promise, val);
  680. } else {
  681. fulfill(promise, val);
  682. }
  683. }, function(val) {
  684. if (resolved) { return true; }
  685. resolved = true;
  686. reject(promise, val);
  687. });
  688. return true;
  689. }
  690. }
  691. } catch (error) {
  692. if (resolved) { return true; }
  693. reject(promise, error);
  694. return true;
  695. }
  696. return false;
  697. }
  698. function resolve(promise, value) {
  699. if (promise === value) {
  700. fulfill(promise, value);
  701. } else if (!handleThenable(promise, value)) {
  702. fulfill(promise, value);
  703. }
  704. }
  705. function fulfill(promise, value) {
  706. if (promise._state !== PENDING) { return; }
  707. promise._state = SEALED;
  708. promise._detail = value;
  709. config.async(publishFulfillment, promise);
  710. }
  711. function reject(promise, reason) {
  712. if (promise._state !== PENDING) { return; }
  713. promise._state = SEALED;
  714. promise._detail = reason;
  715. config.async(publishRejection, promise);
  716. }
  717. function publishFulfillment(promise) {
  718. publish(promise, promise._state = FULFILLED);
  719. }
  720. function publishRejection(promise) {
  721. publish(promise, promise._state = REJECTED);
  722. }
  723. exports.Promise = Promise;
  724. /***/ },
  725. /* 11 */
  726. /***/ function(module, exports, __webpack_require__) {
  727. /* WEBPACK VAR INJECTION */(function(global) {"use strict";
  728. /*global self*/
  729. var RSVPPromise = __webpack_require__(10).Promise;
  730. var isFunction = __webpack_require__(13).isFunction;
  731. function polyfill() {
  732. var local;
  733. if (typeof global !== 'undefined') {
  734. local = global;
  735. } else if (typeof window !== 'undefined' && window.document) {
  736. local = window;
  737. } else {
  738. local = self;
  739. }
  740. var es6PromiseSupport =
  741. "Promise" in local &&
  742. // Some of these methods are missing from
  743. // Firefox/Chrome experimental implementations
  744. "resolve" in local.Promise &&
  745. "reject" in local.Promise &&
  746. "all" in local.Promise &&
  747. "race" in local.Promise &&
  748. // Older version of the spec had a resolver object
  749. // as the arg rather than a function
  750. (function() {
  751. var resolve;
  752. new local.Promise(function(r) { resolve = r; });
  753. return isFunction(resolve);
  754. }());
  755. if (!es6PromiseSupport) {
  756. local.Promise = RSVPPromise;
  757. }
  758. }
  759. exports.polyfill = polyfill;
  760. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  761. /***/ },
  762. /* 12 */
  763. /***/ function(module, exports, __webpack_require__) {
  764. "use strict";
  765. var config = {
  766. instrument: false
  767. };
  768. function configure(name, value) {
  769. if (arguments.length === 2) {
  770. config[name] = value;
  771. } else {
  772. return config[name];
  773. }
  774. }
  775. exports.config = config;
  776. exports.configure = configure;
  777. /***/ },
  778. /* 13 */
  779. /***/ function(module, exports, __webpack_require__) {
  780. "use strict";
  781. function objectOrFunction(x) {
  782. return isFunction(x) || (typeof x === "object" && x !== null);
  783. }
  784. function isFunction(x) {
  785. return typeof x === "function";
  786. }
  787. function isArray(x) {
  788. return Object.prototype.toString.call(x) === "[object Array]";
  789. }
  790. // Date.now is not available in browsers < IE9
  791. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility
  792. var now = Date.now || function() { return new Date().getTime(); };
  793. exports.objectOrFunction = objectOrFunction;
  794. exports.isFunction = isFunction;
  795. exports.isArray = isArray;
  796. exports.now = now;
  797. /***/ },
  798. /* 14 */
  799. /***/ function(module, exports, __webpack_require__) {
  800. "use strict";
  801. /* global toString */
  802. var isArray = __webpack_require__(13).isArray;
  803. var isFunction = __webpack_require__(13).isFunction;
  804. /**
  805. Returns a promise that is fulfilled when all the given promises have been
  806. fulfilled, or rejected if any of them become rejected. The return promise
  807. is fulfilled with an array that gives all the values in the order they were
  808. passed in the `promises` array argument.
  809. Example:
  810. ```javascript
  811. var promise1 = RSVP.resolve(1);
  812. var promise2 = RSVP.resolve(2);
  813. var promise3 = RSVP.resolve(3);
  814. var promises = [ promise1, promise2, promise3 ];
  815. RSVP.all(promises).then(function(array){
  816. // The array here would be [ 1, 2, 3 ];
  817. });
  818. ```
  819. If any of the `promises` given to `RSVP.all` are rejected, the first promise
  820. that is rejected will be given as an argument to the returned promises's
  821. rejection handler. For example:
  822. Example:
  823. ```javascript
  824. var promise1 = RSVP.resolve(1);
  825. var promise2 = RSVP.reject(new Error("2"));
  826. var promise3 = RSVP.reject(new Error("3"));
  827. var promises = [ promise1, promise2, promise3 ];
  828. RSVP.all(promises).then(function(array){
  829. // Code here never runs because there are rejected promises!
  830. }, function(error) {
  831. // error.message === "2"
  832. });
  833. ```
  834. @method all
  835. @for RSVP
  836. @param {Array} promises
  837. @param {String} label
  838. @return {Promise} promise that is fulfilled when all `promises` have been
  839. fulfilled, or rejected if any of them become rejected.
  840. */
  841. function all(promises) {
  842. /*jshint validthis:true */
  843. var Promise = this;
  844. if (!isArray(promises)) {
  845. throw new TypeError('You must pass an array to all.');
  846. }
  847. return new Promise(function(resolve, reject) {
  848. var results = [], remaining = promises.length,
  849. promise;
  850. if (remaining === 0) {
  851. resolve([]);
  852. }
  853. function resolver(index) {
  854. return function(value) {
  855. resolveAll(index, value);
  856. };
  857. }
  858. function resolveAll(index, value) {
  859. results[index] = value;
  860. if (--remaining === 0) {
  861. resolve(results);
  862. }
  863. }
  864. for (var i = 0; i < promises.length; i++) {
  865. promise = promises[i];
  866. if (promise && isFunction(promise.then)) {
  867. promise.then(resolver(i), reject);
  868. } else {
  869. resolveAll(i, promise);
  870. }
  871. }
  872. });
  873. }
  874. exports.all = all;
  875. /***/ },
  876. /* 15 */
  877. /***/ function(module, exports, __webpack_require__) {
  878. "use strict";
  879. /* global toString */
  880. var isArray = __webpack_require__(13).isArray;
  881. /**
  882. `RSVP.race` allows you to watch a series of promises and act as soon as the
  883. first promise given to the `promises` argument fulfills or rejects.
  884. Example:
  885. ```javascript
  886. var promise1 = new RSVP.Promise(function(resolve, reject){
  887. setTimeout(function(){
  888. resolve("promise 1");
  889. }, 200);
  890. });
  891. var promise2 = new RSVP.Promise(function(resolve, reject){
  892. setTimeout(function(){
  893. resolve("promise 2");
  894. }, 100);
  895. });
  896. RSVP.race([promise1, promise2]).then(function(result){
  897. // result === "promise 2" because it was resolved before promise1
  898. // was resolved.
  899. });
  900. ```
  901. `RSVP.race` is deterministic in that only the state of the first completed
  902. promise matters. For example, even if other promises given to the `promises`
  903. array argument are resolved, but the first completed promise has become
  904. rejected before the other promises became fulfilled, the returned promise
  905. will become rejected:
  906. ```javascript
  907. var promise1 = new RSVP.Promise(function(resolve, reject){
  908. setTimeout(function(){
  909. resolve("promise 1");
  910. }, 200);
  911. });
  912. var promise2 = new RSVP.Promise(function(resolve, reject){
  913. setTimeout(function(){
  914. reject(new Error("promise 2"));
  915. }, 100);
  916. });
  917. RSVP.race([promise1, promise2]).then(function(result){
  918. // Code here never runs because there are rejected promises!
  919. }, function(reason){
  920. // reason.message === "promise2" because promise 2 became rejected before
  921. // promise 1 became fulfilled
  922. });
  923. ```
  924. @method race
  925. @for RSVP
  926. @param {Array} promises array of promises to observe
  927. @param {String} label optional string for describing the promise returned.
  928. Useful for tooling.
  929. @return {Promise} a promise that becomes fulfilled with the value the first
  930. completed promises is resolved with if the first completed promise was
  931. fulfilled, or rejected with the reason that the first completed promise
  932. was rejected with.
  933. */
  934. function race(promises) {
  935. /*jshint validthis:true */
  936. var Promise = this;
  937. if (!isArray(promises)) {
  938. throw new TypeError('You must pass an array to race.');
  939. }
  940. return new Promise(function(resolve, reject) {
  941. var results = [], promise;
  942. for (var i = 0; i < promises.length; i++) {
  943. promise = promises[i];
  944. if (promise && typeof promise.then === 'function') {
  945. promise.then(resolve, reject);
  946. } else {
  947. resolve(promise);
  948. }
  949. }
  950. });
  951. }
  952. exports.race = race;
  953. /***/ },
  954. /* 16 */
  955. /***/ function(module, exports, __webpack_require__) {
  956. "use strict";
  957. function resolve(value) {
  958. /*jshint validthis:true */
  959. if (value && typeof value === 'object' && value.constructor === this) {
  960. return value;
  961. }
  962. var Promise = this;
  963. return new Promise(function(resolve) {
  964. resolve(value);
  965. });
  966. }
  967. exports.resolve = resolve;
  968. /***/ },
  969. /* 17 */
  970. /***/ function(module, exports, __webpack_require__) {
  971. "use strict";
  972. /**
  973. `RSVP.reject` returns a promise that will become rejected with the passed
  974. `reason`. `RSVP.reject` is essentially shorthand for the following:
  975. ```javascript
  976. var promise = new RSVP.Promise(function(resolve, reject){
  977. reject(new Error('WHOOPS'));
  978. });
  979. promise.then(function(value){
  980. // Code here doesn't run because the promise is rejected!
  981. }, function(reason){
  982. // reason.message === 'WHOOPS'
  983. });
  984. ```
  985. Instead of writing the above, your code now simply becomes the following:
  986. ```javascript
  987. var promise = RSVP.reject(new Error('WHOOPS'));
  988. promise.then(function(value){
  989. // Code here doesn't run because the promise is rejected!
  990. }, function(reason){
  991. // reason.message === 'WHOOPS'
  992. });
  993. ```
  994. @method reject
  995. @for RSVP
  996. @param {Any} reason value that the returned promise will be rejected with.
  997. @param {String} label optional string for identifying the returned promise.
  998. Useful for tooling.
  999. @return {Promise} a promise that will become rejected with the given
  1000. `reason`.
  1001. */
  1002. function reject(reason) {
  1003. /*jshint validthis:true */
  1004. var Promise = this;
  1005. return new Promise(function (resolve, reject) {
  1006. reject(reason);
  1007. });
  1008. }
  1009. exports.reject = reject;
  1010. /***/ },
  1011. /* 18 */
  1012. /***/ function(module, exports, __webpack_require__) {
  1013. /* WEBPACK VAR INJECTION */(function(global, process) {"use strict";
  1014. var browserGlobal = (typeof window !== 'undefined') ? window : {};
  1015. var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
  1016. var local = (typeof global !== 'undefined') ? global : (this === undefined? window:this);
  1017. // node
  1018. function useNextTick() {
  1019. return function() {
  1020. process.nextTick(flush);
  1021. };
  1022. }
  1023. function useMutationObserver() {
  1024. var iterations = 0;
  1025. var observer = new BrowserMutationObserver(flush);
  1026. var node = document.createTextNode('');
  1027. observer.observe(node, { characterData: true });
  1028. return function() {
  1029. node.data = (iterations = ++iterations % 2);
  1030. };
  1031. }
  1032. function useSetTimeout() {
  1033. return function() {
  1034. local.setTimeout(flush, 1);
  1035. };
  1036. }
  1037. var queue = [];
  1038. function flush() {
  1039. for (var i = 0; i < queue.length; i++) {
  1040. var tuple = queue[i];
  1041. var callback = tuple[0], arg = tuple[1];
  1042. callback(arg);
  1043. }
  1044. queue = [];
  1045. }
  1046. var scheduleFlush;
  1047. // Decide what async method to use to triggering processing of queued callbacks:
  1048. if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') {
  1049. scheduleFlush = useNextTick();
  1050. } else if (BrowserMutationObserver) {
  1051. scheduleFlush = useMutationObserver();
  1052. } else {
  1053. scheduleFlush = useSetTimeout();
  1054. }
  1055. function asap(callback, arg) {
  1056. var length = queue.push([callback, arg]);
  1057. if (length === 1) {
  1058. // If length is 1, that means that we need to schedule an async flush.
  1059. // If additional callbacks are queued before the queue is flushed, they
  1060. // will be processed by this flush that we are scheduling.
  1061. scheduleFlush();
  1062. }
  1063. }
  1064. exports.asap = asap;
  1065. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(19)))
  1066. /***/ },
  1067. /* 19 */
  1068. /***/ function(module, exports, __webpack_require__) {
  1069. // shim for using process in browser
  1070. var process = module.exports = {};
  1071. process.nextTick = (function () {
  1072. var canSetImmediate = typeof window !== 'undefined'
  1073. && window.setImmediate;
  1074. var canPost = typeof window !== 'undefined'
  1075. && window.postMessage && window.addEventListener
  1076. ;
  1077. if (canSetImmediate) {
  1078. return function (f) { return window.setImmediate(f) };
  1079. }
  1080. if (canPost) {
  1081. var queue = [];
  1082. window.addEventListener('message', function (ev) {
  1083. var source = ev.source;
  1084. if ((source === window || source === null) && ev.data === 'process-tick') {
  1085. ev.stopPropagation();
  1086. if (queue.length > 0) {
  1087. var fn = queue.shift();
  1088. fn();
  1089. }
  1090. }
  1091. }, true);
  1092. return function nextTick(fn) {
  1093. queue.push(fn);
  1094. window.postMessage('process-tick', '*');
  1095. };
  1096. }
  1097. return function nextTick(fn) {
  1098. setTimeout(fn, 0);
  1099. };
  1100. })();
  1101. process.title = 'browser';
  1102. process.browser = true;
  1103. process.env = {};
  1104. process.argv = [];
  1105. function noop() {}
  1106. process.on = noop;
  1107. process.addListener = noop;
  1108. process.once = noop;
  1109. process.off = noop;
  1110. process.removeListener = noop;
  1111. process.removeAllListeners = noop;
  1112. process.emit = noop;
  1113. process.binding = function (name) {
  1114. throw new Error('process.binding is not supported');
  1115. }
  1116. // TODO(shtylman)
  1117. process.cwd = function () { return '/' };
  1118. process.chdir = function (dir) {
  1119. throw new Error('process.chdir is not supported');
  1120. };
  1121. /***/ }
  1122. /******/ ])});
  1123. //# sourceMappingURL=axios.amd.map