doipjs/dist/doip.min.js

2 lines
148 KiB
JavaScript
Raw Normal View History

2022-02-25 14:20:22 -07:00
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).doip=e()}}((function(){return function e(t,r,i){function o(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(n)return n(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=r[s]={exports:{}};t[s][0].call(c.exports,(function(e){return o(t[s][1][e]||e)}),c,c.exports,e,t,r,i)}return r[s].exports}for(var n="function"==typeof require&&require,s=0;s<i.length;s++)o(i[s]);return o}({1:[function(e,t,r){(function(i){(function(){!function(e){"object"==typeof r&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==i?i:"undefined"!=typeof self?self:this).doip=e()}((function(){return function t(r,i,o){function n(a,u){if(!i[a]){if(!r[a]){var l="function"==typeof e&&e;if(!u&&l)return l(a,!0);if(s)return s(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var d=i[a]={exports:{}};r[a][0].call(d.exports,(function(e){return n(r[a][1][e]||e)}),d,d.exports,t,r,i,o)}return i[a].exports}for(var s="function"==typeof e&&e,a=0;a<o.length;a++)n(o[a]);return n}({1:[function(e,t,r){(function(i){(function(){!function(e){"object"==typeof r&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==i?i:"undefined"!=typeof self?self:this).doip=e()}((function(){return function t(r,i,o){function n(a,u){if(!i[a]){if(!r[a]){var l="function"==typeof e&&e;if(!u&&l)return l(a,!0);if(s)return s(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var d=i[a]={exports:{}};r[a][0].call(d.exports,(function(e){return n(r[a][1][e]||e)}),d,d.exports,t,r,i,o)}return i[a].exports}for(var s="function"==typeof e&&e,a=0;a<o.length;a++)n(o[a]);return n}({1:[function(e,t,r){(function(i){(function(){!function(e){"object"==typeof r&&void 0!==t?t.exports=e():("undefined"!=typeof window?window:void 0!==i?i:"undefined"!=typeof self?self:this).doip=e()}((function(){return function t(r,i,o){function n(a,u){if(!i[a]){if(!r[a]){var l="function"==typeof e&&e;if(!u&&l)return l(a,!0);if(s)return s(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var d=i[a]={exports:{}};r[a][0].call(d.exports,(function(e){return n(r[a][1][e]||e)}),d,d.exports,t,r,i,o)}return i[a].exports}for(var s="function"==typeof e&&e,a=0;a<o.length;a++)n(o[a]);return n}({1:[function(e,t,r){"use strict";const i=e("./core");class o extends Error{constructor(e,...t){let r;super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,o),this.name="StatusError",this.message=e.statusMessage,this.statusCode=e.status,this.res=e,this.json=e.json.bind(e),this.text=e.text.bind(e),this.arrayBuffer=e.arrayBuffer.bind(e),Object.defineProperty(this,"responseBody",{get:()=>(r||(r=this.arrayBuffer()),r)}),this.headers={};for(const[t,r]of e.headers.entries())this.headers[t.toLowerCase()]=r}}t.exports=i(((e,t,r,i,n)=>async(s,a,u={})=>{s=n+(s||"");let l=new URL(s);if(i||(i={}),l.username&&(i.Authorization="Basic "+btoa(l.username+":"+l.password),l=new URL(l.protocol+"//"+l.host+l.pathname+l.search)),"https:"!==l.protocol&&"http:"!==l.protocol)throw new Error("Unknown protocol, "+l.protocol);if(a)if(a instanceof ArrayBuffer||ArrayBuffer.isView(a)||"string"==typeof a);else{if("object"!=typeof a)throw new Error("Unknown body type.");a=JSON.stringify(a),i["Content-Type"]="application/json"}u=new Headers({...i||{},...u});const c=await fetch(l,{method:t,headers:u,body:a});if(c.statusCode=c.status,!e.has(c.status))throw new o(c);return"json"===r?c.json():"buffer"===r?c.arrayBuffer():"string"===r?c.text():c}))},{"./core":2}],2:[function(e,t,r){"use strict";const i=new Set(["json","buffer","string"]);t.exports=e=>(...t)=>{const r=new Set;let o,n,s,a="";return t.forEach((e=>{if("string"==typeof e)if(e.toUpperCase()===e){if(o)throw new Error(`Can't set method to ${e}, already set