From 0d9c0ed041a9f6f36e468dd251bcb6e54834d7f0 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Tue, 19 Dec 2023 02:49:25 -0800 Subject: [PATCH 1/4] Turn of biome linter/complexity/useLiteralKeys linter rule --- biome.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/biome.json b/biome.json index 63919df3..807b9013 100644 --- a/biome.json +++ b/biome.json @@ -17,15 +17,16 @@ "useMediaCaption": "off", "noSvgWithoutTitle": "off" }, + "complexity": { + "useLiteralKeys": "off", + "useOptionalChain": "off" + }, "performance": { "noAccumulatingSpread": "off" }, "suspicious": { "noArrayIndexKey": "off", "noExplicitAny": "off" - }, - "complexity": { - "useOptionalChain": "off" } } } From 8dc2ac39163c4984ba908edd024f2c75ddfa5aa4 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Tue, 19 Dec 2023 02:49:56 -0800 Subject: [PATCH 2/4] Replace use of Headers with Object --- index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index a3ed7f8f..ce407f91 100644 --- a/index.js +++ b/index.js @@ -191,15 +191,15 @@ class Replicate { url.searchParams.append(key, value); } - const headers = new Headers(); + const headers = {}; if (auth) { - headers.append("Authorization", `Token ${auth}`); + headers["Authorization"] = `Token ${auth}`; } - headers.append("Content-Type", "application/json"); - headers.append("User-Agent", userAgent); + headers["Content-Type"] = "application/json"; + headers["User-Agent"] = userAgent; if (options.headers) { - for (const [key, value] of options.headers.entries()) { - headers.append(key, value); + for (const [key, value] of Object.entries(options.headers)) { + headers[key] = value; } } From 0e9e0371fbd5a12775ed47e351991631bfaf2bb8 Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Tue, 19 Dec 2023 02:50:01 -0800 Subject: [PATCH 3/4] Update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0afa9c5a..4d6e7280 100644 --- a/README.md +++ b/README.md @@ -132,8 +132,8 @@ such as injecting headers or adding log statements. ```js replicate.fetch = (url, options) => { - const headers = new Headers(options && options.headers); - headers.append("X-Custom-Header", "some value"); + const headers = options && options.headers ? { ...options.headers } : {}; + headers["X-Custom-Header"] = "some value"; console.log("fetch", { url, ...options, headers }); From 0f8e3557bc0ddacb2052c3efc8f3b096fbf76a6a Mon Sep 17 00:00:00 2001 From: Mattt Zmuda Date: Tue, 19 Dec 2023 02:53:30 -0800 Subject: [PATCH 4/4] Add Node 20 to CI matrix --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e41e8aef..155ea01f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,8 @@ jobs: strategy: matrix: - node-version: [18.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + node-version: [18.x, 20.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/previous-releases steps: - uses: actions/checkout@v3