@minotaur-ergo/http
Advanced tools
Comparing version 0.0.6 to 0.0.7
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.request = exports.buildRequestInit = exports.decode = exports.encode = exports.readBlobAsBase64 = void 0; | ||
/** | ||
@@ -19,18 +18,3 @@ * Read in a Blob value and return it as a base64 string | ||
}); | ||
exports.readBlobAsBase64 = readBlobAsBase64; | ||
/** | ||
* Safely web encode a string value (inspired by js-cookie) | ||
* @param str The string value to encode | ||
*/ | ||
const encode = (str) => encodeURIComponent(str) | ||
.replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent) | ||
.replace(/[()]/g, escape); | ||
exports.encode = encode; | ||
/** | ||
* Safely web decode a string value (inspired by js-cookie) | ||
* @param str The string value to decode | ||
*/ | ||
const decode = (str) => str.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent); | ||
exports.decode = decode; | ||
/** | ||
* Normalize an HttpHeaders map by lowercasing all of the values | ||
@@ -123,3 +107,2 @@ * @param headers The HttpHeaders object to normalize | ||
}; | ||
exports.buildRequestInit = buildRequestInit; | ||
/** | ||
@@ -130,3 +113,3 @@ * Perform an Http request given a set of options | ||
const request = async (options) => { | ||
const requestInit = exports.buildRequestInit(options, options.webFetchExtra); | ||
const requestInit = buildRequestInit(options, options.webFetchExtra); | ||
const urlParams = buildUrlParams(options.params, options.shouldEncodeUrlParams); | ||
@@ -146,3 +129,3 @@ const url = urlParams ? `${options.url}?${urlParams}` : options.url; | ||
case 'blob': | ||
data = await exports.readBlobAsBase64(await response.blob()); | ||
data = await readBlobAsBase64(await response.blob()); | ||
break; | ||
@@ -169,21 +152,20 @@ case 'json': | ||
}; | ||
exports.request = request; | ||
class HttpElectron { | ||
request(options) { | ||
return exports.request(options); | ||
return request(options); | ||
} | ||
get(options) { | ||
return exports.request(Object.assign(Object.assign({}, options), { method: 'GET' })); | ||
return request(Object.assign(Object.assign({}, options), { method: 'GET' })); | ||
} | ||
post(options) { | ||
return exports.request(Object.assign(Object.assign({}, options), { method: 'POST' })); | ||
return request(Object.assign(Object.assign({}, options), { method: 'POST' })); | ||
} | ||
put(options) { | ||
return exports.request(Object.assign(Object.assign({}, options), { method: 'PUT' })); | ||
return request(Object.assign(Object.assign({}, options), { method: 'PUT' })); | ||
} | ||
patch(options) { | ||
return exports.request(Object.assign(Object.assign({}, options), { method: 'PATCH' })); | ||
return request(Object.assign(Object.assign({}, options), { method: 'PATCH' })); | ||
} | ||
delete(options) { | ||
return exports.request(Object.assign(Object.assign({}, options), { method: 'DELETE' })); | ||
return request(Object.assign(Object.assign({}, options), { method: 'DELETE' })); | ||
} | ||
@@ -190,0 +172,0 @@ } |
@@ -8,3 +8,3 @@ export default { | ||
sourcemap: true, | ||
inlineDynamicImports: false | ||
inlineDynamicImports: true | ||
}, | ||
@@ -11,0 +11,0 @@ ], |
{ | ||
"name": "@minotaur-ergo/http", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Cors Free Http Client", | ||
@@ -5,0 +5,0 @@ "main": "dist/plugin.cjs.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120385
1224