From 4a46def45247e7e1fac18b9e399e0969b2c4a962 Mon Sep 17 00:00:00 2001 From: Richie Bendall Date: Tue, 14 Apr 2020 21:52:25 +1200 Subject: [PATCH] Maintenance update Signed-off-by: Richie Bendall --- README.md | 12 ++++++------ blob.d.ts | 18 ------------------ index.d.ts | 18 ++++++++++++++++++ blob.js => index.js | 0 package.json | 23 +++++++++++++++++++---- test.js | 10 +++++----- 6 files changed, 48 insertions(+), 33 deletions(-) delete mode 100644 blob.d.ts create mode 100644 index.d.ts rename blob.js => index.js (100%) diff --git a/README.md b/README.md index 1755e4a..8885473 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,20 @@ - -fetch-blob -========== +# fetch-blob [![npm version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![coverage status][codecov-image]][codecov-url] [![install size][install-size-image]][install-size-url] -A Blob implementation in Node.js, originally from node-fetch. +A Blob implementation in Node.js, originally from [node-fetch](https://github.com/node-fetch/node-fetch). -## Usage +## Installation ```sh $ npm install fetch-blob ``` +## Usage + ```js const Blob = require('fetch-blob'); const fetch = require('node-fetch'); @@ -27,7 +27,7 @@ fetch('https://httpbin.org/post', { .then(json => console.log(json)); ``` -See [MDN doc](https://developer.mozilla.org/en-US/docs/Web/API/Blob) and [Tests](https://github.com/node-fetch/fetch-blob/blob/master/test.js) for more details. +See the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/Blob) and [tests](https://github.com/node-fetch/fetch-blob/blob/master/test.js) for more details. [npm-image]: https://flat.badgen.net/npm/v/fetch-blob [npm-url]: https://www.npmjs.com/package/fetch-blob diff --git a/blob.d.ts b/blob.d.ts deleted file mode 100644 index 1ee6713..0000000 --- a/blob.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -// /** A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. */ -declare interface FetchBlob extends Blob { - stream(): ReadableStream - text(): Promise - arrayBuffer(): Promise - toString(): "[object Blob]" - [Symbol.toStringTag]: "Blob" - -} - -declare const FetchBlob: { - prototype: FetchBlob - new(blobParts?: BlobPart[], options?: BlobPropertyBag): FetchBlob -}; - -export = FetchBlob diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..08c7413 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,18 @@ +/// + +/** A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The File interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. */ +declare interface FetchBlob extends Blob { + [Symbol.toStringTag]: 'Blob'; + stream(): ReadableStream; + text(): Promise; + arrayBuffer(): Promise; + toString(): '[object Blob]'; + +} + +declare const FetchBlob: { + prototype: FetchBlob; + new(blobParts?: BlobPart[], options?: BlobPropertyBag): FetchBlob; +}; + +export = FetchBlob; diff --git a/blob.js b/index.js similarity index 100% rename from blob.js rename to index.js diff --git a/package.json b/package.json index 68a3961..32276b2 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,11 @@ "name": "fetch-blob", "version": "1.0.5", "description": "A Blob implementation in Node.js, originally from node-fetch.", - "main": "blob.js", + "main": "index.js", + "files": [ + "index.js", + "index.d.ts" + ], "scripts": { "lint": "xo", "test": "xo && ava", @@ -24,11 +28,22 @@ }, "homepage": "https://github.com/node-fetch/fetch-blob#readme", "devDependencies": { - "ava": "^3.3.0", + "ava": "^3.7.0", "codecov": "^3.6.5", "get-stream": "^5.1.0", "node-fetch": "^2.6.0", - "nyc": "^15.0.0", - "xo": "^0.26.0" + "nyc": "^15.0.1", + "xo": "^0.29.1" + }, + "xo": { + "overrides": [ + { + "files": "test.js", + "rules": { + "node/no-unsupported-features/es-syntax": 0, + "node/no-unsupported-features/node-builtins": 0 + } + } + ] } } diff --git a/test.js b/test.js index 241b516..a25be73 100644 --- a/test.js +++ b/test.js @@ -1,5 +1,5 @@ const test = require('ava'); -const Blob = require('./blob'); +const Blob = require('.'); const getStream = require('get-stream'); const {Response} = require('node-fetch'); @@ -66,8 +66,8 @@ test('Blob works with node-fetch Response.blob()', async t => { const data = 'a=1'; const type = 'text/plain'; const blob = new Blob([data], {type}); - const res = new Response(blob); - const blob2 = await res.blob(); + const response = new Response(blob); + const blob2 = await response.blob(); t.is(await blob2.text(), data); }); @@ -75,7 +75,7 @@ test('Blob works with node-fetch Response.text()', async t => { const data = 'a=1'; const type = 'text/plain'; const blob = new Blob([data], {type}); - const res = new Response(blob); - const text = await res.text(); + const response = new Response(blob); + const text = await response.text(); t.is(text, data); });