Skip to content

Commit e36595b

Browse files
authored
chore: reuse fetch method (#97)
* chore: reuse fetch method By creating the fetch function in the constructor, we allocate a new function every time the mocker is instantiated. We can avoid this by using a field (to bind `this`) which itself delegates to a method on the prototype. * chore: run format
1 parent 7515e1e commit e36595b

File tree

4 files changed

+795
-734
lines changed

4 files changed

+795
-734
lines changed

src/custom-request.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ export function createCustomRequest(RequestClass) {
6161
writable: false,
6262
});
6363
}
64-
64+
6565
/*
6666
* Default setting for `redirect` is "follow" in the fetch API.
6767
* Not all runtimes follow the spec, so we need to ensure
6868
* that the `redirect` property is set correctly.
6969
*/
7070
const expectedRedirect = init?.redirect ?? "follow";
71-
71+
7272
if (expectedRedirect !== this.redirect) {
7373
Object.defineProperty(this, "redirect", {
7474
configurable: true,

0 commit comments

Comments
 (0)