doipjs/dist/doip.min.js

2 lines
42 KiB
JavaScript
Raw Normal View History

2021-03-06 15:34:20 -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 c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(n)return n(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=r[s]={exports:{}};t[s][0].call(u.exports,(function(e){return o(t[s][1][e]||e)}),u,u.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){"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,c={})=>{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"}c=new Headers({...i||{},...c});const u=await fetch(l,{method:t,headers:c,body:a});if(u.statusCode=u.status,!e.has(u.status))throw new o(u);return"json"===r?u.json():"buffer"===r?u.arrayBuffer():"string"===r?u.text():u}))},{"./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 to ${o}.`)}o=e}else if(e.startsWith("http:")||e.startsWith("https:"))a=e;else{if(!i.has(e))throw new Error("Unknown encoding, "+e);n=e}else if("number"==typeof e)r.add(e);else{if("object"!=typeof e)throw new Error("Unknown type: "+typeof e);if(Array.isArray(e)||e instanceof Set)e.forEach((e=>r.add(e)));else{if(s)throw new Error("Cannot set headers twice.");s=e}}})),o||(o="GET"),0===r.size&&r.add(200),e(r,o,n,s,a)}},{}],3:[function(e,t,r){},{}],4:[function(e,t,r){"use strict";var i="%[a-f0-9]{2}",o=new RegExp(i,"gi"),n=new RegExp("("+i+")+","gi");function s(e,t){try{return decodeURIComponent(e.join(""))}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),i=e.slice(t);return Array.prototype.concat.call([],s(r),s(i))}function a(e){try{return decodeURIComponent(e)}catch(i){for(var t=e.match(o),r=1;r<t.length;r++)t=(e=s(t,r).join("")).match(o);return e}}t.exports=function(e){if("string"!=typeof e)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return e=e.replace(/\+/g," "),decodeURIComponent(e)}catch(t){return function(e){for(var t={"%FE%FF":"<22><>","%FF%FE":"<22><>"},r=n.exec(e);r;){try{t[r[0]]=decodeURIComponent(r[0])}catch(e){var i=a(r[0]);i!==r[0]&&(t[r[0]]=i)}r=n.exec(e)}t["%C2"]="<22>";for(var o=Object.keys(t),s=0;s<o.length;s++){var c=o[s];e=e.replace(new RegExp(c,"g"),t[c])}return e}(e)}}},{}],5:[function(e,t,r){"use strict";t.exports=function(e,t){for(var r={},i=Object.keys(e),o=Array.isArray(t),n=0;n<i.length;n++){var s=i[n],a=e[s];(o?-1!==t.indexOf(s):t(s,a,e))&&(r[s]=a)}return r}},{}],6:[function(e,t,r){"use strict";t.exports=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}},{}],7:[function(e,t,r){"use strict";const i=e("is-plain-obj"),{hasOwnProperty:o}=Object.prototype,{propertyIs