Skip to content

Commit

Permalink
Simplify headersArr init
Browse files Browse the repository at this point in the history
  • Loading branch information
PaperStrike committed Sep 19, 2021
1 parent 2836bd3 commit 45e563c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/InterceptRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,17 @@ export default class InterceptRule {

init: RequestInit;

headersArr: [string, string][];
headersArr: [string, string][] = [];

constructor(input: RequestInfo | RegExp, init: RequestInit = {}) {
this.input = input;
this.init = init;

let headers: Iterable<[string, string]>;
if (init.headers) {
headers = new Headers(init.headers);
this.headersArr.push(...new Headers(init.headers));
} else if (input instanceof Request) {
headers = input.headers;
} else {
headers = [];
this.headersArr.push(...input.headers);
}
this.headersArr = [...headers];
}

private delayDuration = 0;
Expand Down

0 comments on commit 45e563c

Please sign in to comment.