diff --git a/.gitignore b/.gitignore index b8c3d51..246b15d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules/ package-lock.json logs/ *.log +.DS_Store diff --git a/.npmignore b/.npmignore index 2cd1ac8..cf9b323 100644 --- a/.npmignore +++ b/.npmignore @@ -6,3 +6,4 @@ logs/ .gitignore .gitattributes .travis.yml +.DS_Store diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 7900fef..0000000 --- a/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -sudo: false -language: node_js -node_js: - - '8' - - '10' - - '12' -install: npm i -g eslint && npm i eslint-config-amber eslint-plugin-json diff --git a/LICENSE.md b/LICENSE.md index 3a6f590..04fb520 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,7 @@ Internet Systems Consortium license =================================== -Copyright (c) 2017-2018, dragonfire535 +Copyright (c) 2017-2022, dragonfire535 Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice diff --git a/README.md b/README.md index 9128618..03d6827 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ look like you are using [superagent](https://www.npmjs.com/package/superagent). const request = require('node-superfetch'); try { - const { body } = await request.get('https://registry.npmjs.com/node-fetch'); + const { body } = await request.get('https://registry.npmjs.com/node-superfetch'); console.log(body); } catch (err) { console.error(err); @@ -24,9 +24,9 @@ FormData), `redirects` (for setting the allowed number of redirects), and Additionally, you can also use the `noResultData` option to get everything except the actual result data of the request. This is essentially doing the -request without calling any of `node-fetch`'s methods to parse the result data. +request without calling any methods to parse the result data. ```js -const { headers, url } = await request.get('https://registry.npmjs.com/node-fetch', { noResultData: true }); -console.log(url); // should log https://registry.npmjs.com/node-fetch +const { headers, url } = await request.get('https://registry.npmjs.com/node-superfetch', { noResultData: true }); +console.log(url); // should log https://registry.npmjs.com/node-superfetch ``` diff --git a/index.js b/index.js index 60c9e6d..7a49a79 100644 --- a/index.js +++ b/index.js @@ -26,10 +26,7 @@ class Request { agent: this.agent }); let raw = null; - if (!this.noResultData) { - raw = await response.arrayBuffer(); - raw = arrayBufferToBuffer(raw); - } + if (!this.noResultData) raw = arrayBufferToBuffer(await response.arrayBuffer()); const headers = {}; for (const [header, value] of response.headers.entries()) headers[header] = value; const res = { diff --git a/package.json b/package.json index 5436521..4e531ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-superfetch", - "version": "0.3.2", + "version": "0.3.3", "description": "A wrapper for Node.js' fetch API that makes it appear like superagent.", "main": "index.js", "typings": "typings/index.d.ts", @@ -31,11 +31,11 @@ "node": ">=18" }, "dependencies": { + "arraybuffer-to-buffer": "^0.0.7", "form-data": "^4.0.0" }, "devDependencies": { "@types/node": "^18.7.18", - "arraybuffer-to-buffer": "^0.0.7", "eslint": "^8.23.1", "eslint-config-amber": "^2.0.4", "eslint-plugin-json": "^3.1.0",