@st-graphics/premium
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -43,4 +43,2 @@ const inProduction = process.env.NODE_ENV === 'production' | ||
window.fetch = window.fetch || fetch | ||
function PremiumClient () {} | ||
@@ -101,48 +99,2 @@ | ||
function fetch (url, options) { | ||
options = options || {} | ||
options.method = options.method || 'GET' | ||
options.headers = options.headers || {} | ||
return new Promise(function (resolve, reject) { | ||
const xhr = new window.XMLHttpRequest() | ||
xhr.open(options.method, url) | ||
Object.keys(options.headers).forEach(function (key) { | ||
xhr.setRequestHeader(key, options.headers[key]) | ||
}) | ||
xhr.withCredentials = options.credentials === 'include' | ||
xhr.onreadystatechange = function () { | ||
if (xhr.readyState === 4) { | ||
try { | ||
const response = Object.create({ | ||
text () { | ||
return xhr.responseText | ||
}, | ||
json () { | ||
return JSON.parse(xhr.responseText) | ||
} | ||
}) | ||
response.ok = xhr.status === 200 | ||
response.status = xhr.status | ||
response.statusText = xhr.statusText | ||
response.url = xhr.responseURL | ||
response.headers = xhr.getAllResponseHeaders() | ||
resolve(response) | ||
} catch (err) { | ||
reject(err) | ||
} | ||
} | ||
} | ||
xhr.onerror = function () { | ||
reject(new Error('Network error')) | ||
} | ||
xhr.onabort = function () { | ||
reject(new Error('Aborted')) | ||
} | ||
xhr.ontimeout = function () { | ||
reject(new Error('Timed out')) | ||
} | ||
xhr.send(options.body) | ||
}) | ||
} | ||
function getLocation () { | ||
@@ -149,0 +101,0 @@ const w = window.top |
{ | ||
"name": "@st-graphics/premium", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "ST Graphics Premium implementation", | ||
@@ -5,0 +5,0 @@ "main": "client/premium.js", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
0
55617
244