doipjs/dist/doip.min.js

2 lines
24 KiB
JavaScript
Raw Normal View History

2020-11-05 04:14:26 -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,o){function i(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 u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[s]={exports:{}};t[s][0].call(l.exports,(function(e){return i(t[s][1][e]||e)}),l,l.exports,e,t,r,o)}return r[s].exports}for(var n="function"==typeof require&&require,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(e,t,r){"use strict";const o=e("./core");class i extends Error{constructor(e,...t){let r;super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,i),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=o(((e,t,r,o,n)=>async(s,a,c={})=>{s=n+(s||"");let u=new URL(s);if(o||(o={}),u.username&&(o.Authorization="Basic "+btoa(u.username+":"+u.password),u=new URL(u.protocol+"//"+u.host+u.pathname+u.search)),"https:"!==u.protocol&&"http:"!==u.protocol)throw new Error("Unknown protocol, "+u.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),o["Content-Type"]="application/json"}c=new Headers({...o||{},...c});const l=await fetch(u,{method:t,headers:c,body:a});if(l.statusCode=l.status,!e.has(l.status))throw new i(l);return"json"===r?l.json():"buffer"===r?l.arrayBuffer():"string"===r?l.text():l}))},{"./core":2}],2:[function(e,t,r){"use strict";const o=new Set(["json","buffer","string"]);t.exports=e=>(...t)=>{const r=new Set;let i,n,s,a="";return t.forEach((e=>{if("string"==typeof e)if(e.toUpperCase()===e){if(i){throw new Error(`Can't set method to ${e}, already set to ${i}.`)}i=e}else if(e.startsWith("http:")||e.startsWith("https:"))a=e;else{if(!o.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}}})),i||(i="GET"),0===r.size&&r.add(200),e(r,i,n,s,a)}},{}],3:[function(e,t,r){},{}],4:[function(e,t,r){(function(r){(function(){const o=e("fs"),i=e("path");function n(e){console.log("[dotenv][DEBUG] "+e)}const s=/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/,a=/\\n/g,c=/\n|\r|\r\n/;function u(e,t){const r=Boolean(t&&t.debug),o={};return e.toString().split(c).forEach((function(e,t){const i=e.match(s);if(null!=i){const e=i[1];let t=i[2]||"";const r=t.length-1,n='"'===t[0]&&'"'===t[r];"'"===t[0]&&"'"===t[r]||n?(t=t.substring(1,r),n&&(t=t.replace(a,"\n"))):t=t.trim(),o[e]=t}else r&&n(`did not match key and value when parsing line ${t+1}: ${e}`)})),o}t.exports.config=function(e){let t=i.resolve(r.cwd(),".env"),s="utf8",a=!1;e&&(null!=e.path&&(t=e.path),null!=e.encoding&&(s=e.encoding),null!=e.debug&&(a=!0));try{const e=u(o.readFileSync(t,{encoding:s}),{debug:a});return Object.keys(e).forEach((function(t){Object.prototype.hasOwnProperty.call(r.env,t)?a&&n(`"${t}" is already defined in \`process.env\` and will not be overwritten`):r.env[t]=e[t]})),{parsed:e}}catch(e){return{error:e}}},t.exports.parse=u}).call(this)}).call(this,e("_process"))},{_process:6,fs:3,path:5}],5:[function(e,t,r){(function(e){(function(){"use strict";function r(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function o(e,t){for(var r,o="",i=0,n=-1,s=0,a=0;a<=e.length;++a){if(a<e.length)r=e.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(n===a-1||1===s);else if(n!==a-1