@ideal-postcodes/core-browser
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -0,1 +1,8 @@ | ||
## [1.2.1](https://github.com/ideal-postcodes/core-browser/compare/1.2.0...1.2.1) (2020-02-20) | ||
### Performance Improvements | ||
* **Request:** Drop use of Request ([3a328f6](https://github.com/ideal-postcodes/core-browser/commit/3a328f6634820e87c19c8ba3694416970507f928)) | ||
# [1.2.0](https://github.com/ideal-postcodes/core-browser/compare/1.1.0...1.2.0) (2020-02-07) | ||
@@ -2,0 +9,0 @@ |
@@ -87,3 +87,3 @@ "use strict"; | ||
const { body, method, url, header, query, timeout } = httpRequest; | ||
const requestInfo = { | ||
const requestInit = { | ||
method, | ||
@@ -96,6 +96,6 @@ headers: header, | ||
if (abortController) | ||
requestInfo.signal = abortController.signal; | ||
requestInit.signal = abortController.signal; | ||
try { | ||
if (body !== undefined) | ||
requestInfo.body = JSON.stringify(body); | ||
requestInit.body = JSON.stringify(body); | ||
} | ||
@@ -105,5 +105,5 @@ catch (error) { | ||
} | ||
const request = new Request(`${url}${exports.parseQuery(query)}`, requestInfo); | ||
const uri = `${url}${exports.parseQuery(query)}`; | ||
let response; | ||
return timed_fetch_1.timedFetch(request, timeout, abortController) | ||
return timed_fetch_1.timedFetch(uri, requestInit, timeout, abortController) | ||
.then(r => { | ||
@@ -110,0 +110,0 @@ response = r; |
@@ -8,2 +8,2 @@ /** | ||
*/ | ||
export declare const timedFetch: (request: RequestInfo, timeout: number, abortController?: AbortController | undefined) => Promise<Response>; | ||
export declare const timedFetch: (url: string, requestInit: RequestInit, timeout: number, abortController?: AbortController | undefined) => Promise<Response>; |
@@ -10,6 +10,6 @@ "use strict"; | ||
*/ | ||
const timeoutError = (timeout, request) => new IdealPostcodesError({ | ||
const timeoutError = (timeout, request, url) => new IdealPostcodesError({ | ||
message: `Request timed out after ${timeout}ms`, | ||
httpStatus: 0, | ||
metadata: { request }, | ||
metadata: { request, url }, | ||
}); | ||
@@ -23,10 +23,10 @@ /** | ||
*/ | ||
exports.timedFetch = (request, timeout, abortController) => new Promise((resolve, reject) => { | ||
exports.timedFetch = (url, requestInit, timeout, abortController) => new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
if (abortController) | ||
abortController.abort(); | ||
reject(timeoutError(timeout, request)); | ||
reject(timeoutError(timeout, requestInit, url)); | ||
}, timeout); | ||
fetch(request).then(resolve, reject); | ||
fetch(url, requestInit).then(resolve, reject); | ||
}); | ||
//# sourceMappingURL=timed_fetch.js.map |
{ | ||
"name": "@ideal-postcodes/core-browser", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Browser javascript client for api.ideal-postcodes.co.uk", | ||
@@ -65,3 +65,3 @@ "author": { | ||
"@ideal-postcodes/api-typings": "~1.1.0", | ||
"@ideal-postcodes/supported-browsers": "~1.2.0", | ||
"@ideal-postcodes/supported-browsers": "~2.1.1", | ||
"@types/chai": "~4.2.3", | ||
@@ -73,9 +73,8 @@ "@types/dotenv": "~8.2.0", | ||
"@types/puppeteer": "~2.0.0", | ||
"babel-polyfill": "~6.26.0", | ||
"chai": "~4.2.0", | ||
"codecov": "~3.6.1", | ||
"core-js": "~3.6.4", | ||
"dotenv": "~8.2.0", | ||
"eslint": "~6.8.0", | ||
"karma": "~4.4.0", | ||
"karma-cbt-launcher": "~0.4.6", | ||
"karma-chrome-launcher": "~3.1.0", | ||
@@ -85,14 +84,17 @@ "karma-cli": "~2.0.0", | ||
"karma-mocha": "~1.3.0", | ||
"karma-polyfill": "~1.0.0", | ||
"karma-sauce-launcher": "~1.2.0", | ||
"karma-typescript": "~4.1.1", | ||
"mocha": "~7.0.0", | ||
"nock": "~11.7.0", | ||
"nock": "~12.0.0", | ||
"prettier": "~1.19.1", | ||
"promise-polyfill": "~8.1.3", | ||
"puppeteer": "~2.1.1", | ||
"regenerator-runtime": "~0.13.3", | ||
"semantic-release": "~15.14.0", | ||
"sinon": "~8.1.0", | ||
"sinon": "~9.0.0", | ||
"ts-node": "~8.6.1", | ||
"typedoc": "~0.16.2", | ||
"typescript": "~3.7.2", | ||
"typedoc": "~0.16.2" | ||
"whatwg-fetch": "~3.0.0" | ||
} | ||
} |
@@ -12,2 +12,3 @@ <h1 align="center"> | ||
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/@ideal-postcodes/core-browser)](https://bundlephobia.com/result?p=@ideal-postcodes/core-browser) | ||
[![Release](https://github.com/ideal-postcodes/core-browser/workflows/Release/badge.svg)](https://github.com/ideal-postcodes/core-browser/actions) | ||
@@ -14,0 +15,0 @@ `@ideal-postcodes/core-browser` is the JavaScript browser client for api.ideal-postcodes.co.uk |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24994
165
35