You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
2.3 KiB

2 weeks ago
  1. // ../../../../../work/questionbankvue3/node_modules/vue-jsonp/dist/index.esm.js
  2. function e(t2, n2) {
  3. t2 = t2.replace(/=/g, "");
  4. var o2 = [];
  5. switch (n2.constructor) {
  6. case String:
  7. case Number:
  8. case Boolean:
  9. o2.push(encodeURIComponent(t2) + "=" + encodeURIComponent(n2));
  10. break;
  11. case Array:
  12. n2.forEach(function(n3) {
  13. o2 = o2.concat(e(t2 + "[]=", n3));
  14. });
  15. break;
  16. case Object:
  17. Object.keys(n2).forEach(function(r) {
  18. var a = n2[r];
  19. o2 = o2.concat(e(t2 + "[" + r + "]", a));
  20. });
  21. }
  22. return o2;
  23. }
  24. function t(e2) {
  25. var n2 = [];
  26. return e2.forEach(function(e3) {
  27. "string" == typeof e3 ? n2.push(e3) : n2 = n2.concat(t(e3));
  28. }), n2;
  29. }
  30. var n = { install: function(e2) {
  31. e2.prototype.$jsonp = o;
  32. } };
  33. function o(n2, o2, r) {
  34. if (void 0 === o2 && (o2 = {}), "string" != typeof n2)
  35. throw new Error('[Vue-jsonp] Type of param "url" is not string.');
  36. if ("object" != typeof o2 || !o2)
  37. throw new Error("[Vue-jsonp] Invalid params, should be an object.");
  38. return r = "number" == typeof r ? r : 5e3, new Promise(function(a, c) {
  39. var u = "string" == typeof o2.callbackQuery ? o2.callbackQuery : "callback", i = "string" == typeof o2.callbackName ? o2.callbackName : "jsonp_" + (Math.floor(1e5 * Math.random()) * Date.now()).toString(16);
  40. o2[u] = i, delete o2.callbackQuery, delete o2.callbackName;
  41. var s = [];
  42. Object.keys(o2).forEach(function(t2) {
  43. s = s.concat(e(t2, o2[t2]));
  44. });
  45. var l = t(s).join("&"), f = function() {
  46. p(), clearTimeout(m), c({ status: 400, statusText: "Bad Request" });
  47. }, p = function() {
  48. b.removeEventListener("error", f);
  49. }, d = function() {
  50. document.body.removeChild(b), delete window[i];
  51. }, m = null;
  52. r > -1 && (m = setTimeout(function() {
  53. p(), d(), c({ statusText: "Request Timeout", status: 408 });
  54. }, r)), window[i] = function(e2) {
  55. clearTimeout(m), p(), d(), a(e2);
  56. };
  57. var b = document.createElement("script");
  58. b.addEventListener("error", f), b.src = n2 + (/\?/.test(n2) ? "&" : "?") + l, document.body.appendChild(b);
  59. });
  60. }
  61. export {
  62. n as VueJsonp,
  63. o as jsonp
  64. };
  65. /*! Bundled license information:
  66. vue-jsonp/dist/index.esm.js:
  67. (**
  68. * Vue Jsonp.
  69. * # Carry Your World #
  70. *
  71. * @author: LancerComet
  72. * @license: MIT
  73. *)
  74. */
  75. //# sourceMappingURL=vue-jsonp.js.map