Skip to content

Commit 4a46def

Browse files
committed
Maintenance update
Signed-off-by: Richie Bendall <[email protected]>
1 parent 9a458af commit 4a46def

File tree

6 files changed

+48
-33
lines changed

6 files changed

+48
-33
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
2-
fetch-blob
3-
==========
1+
# fetch-blob
42

53
[![npm version][npm-image]][npm-url]
64
[![build status][travis-image]][travis-url]
75
[![coverage status][codecov-image]][codecov-url]
86
[![install size][install-size-image]][install-size-url]
97

10-
A Blob implementation in Node.js, originally from node-fetch.
8+
A Blob implementation in Node.js, originally from [node-fetch](https://github.com/node-fetch/node-fetch).
119

12-
## Usage
10+
## Installation
1311

1412
```sh
1513
$ npm install fetch-blob
1614
```
1715

16+
## Usage
17+
1818
```js
1919
const Blob = require('fetch-blob');
2020
const fetch = require('node-fetch');
@@ -27,7 +27,7 @@ fetch('https://httpbin.org/post', {
2727
.then(json => console.log(json));
2828
```
2929

30-
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.
30+
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.
3131

3232
[npm-image]: https://flat.badgen.net/npm/v/fetch-blob
3333
[npm-url]: https://www.npmjs.com/package/fetch-blob

blob.d.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

index.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/// <reference lib="dom"/>
2+
3+
/** 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. */
4+
declare interface FetchBlob extends Blob {
5+
[Symbol.toStringTag]: 'Blob';
6+
stream(): ReadableStream;
7+
text(): Promise<string>;
8+
arrayBuffer(): Promise<ArrayBuffer>;
9+
toString(): '[object Blob]';
10+
11+
}
12+
13+
declare const FetchBlob: {
14+
prototype: FetchBlob;
15+
new(blobParts?: BlobPart[], options?: BlobPropertyBag): FetchBlob;
16+
};
17+
18+
export = FetchBlob;

blob.js renamed to index.js

File renamed without changes.

package.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
"name": "fetch-blob",
33
"version": "1.0.5",
44
"description": "A Blob implementation in Node.js, originally from node-fetch.",
5-
"main": "blob.js",
5+
"main": "index.js",
6+
"files": [
7+
"index.js",
8+
"index.d.ts"
9+
],
610
"scripts": {
711
"lint": "xo",
812
"test": "xo && ava",
@@ -24,11 +28,22 @@
2428
},
2529
"homepage": "https://github.com/node-fetch/fetch-blob#readme",
2630
"devDependencies": {
27-
"ava": "^3.3.0",
31+
"ava": "^3.7.0",
2832
"codecov": "^3.6.5",
2933
"get-stream": "^5.1.0",
3034
"node-fetch": "^2.6.0",
31-
"nyc": "^15.0.0",
32-
"xo": "^0.26.0"
35+
"nyc": "^15.0.1",
36+
"xo": "^0.29.1"
37+
},
38+
"xo": {
39+
"overrides": [
40+
{
41+
"files": "test.js",
42+
"rules": {
43+
"node/no-unsupported-features/es-syntax": 0,
44+
"node/no-unsupported-features/node-builtins": 0
45+
}
46+
}
47+
]
3348
}
3449
}

test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const test = require('ava');
2-
const Blob = require('./blob');
2+
const Blob = require('.');
33
const getStream = require('get-stream');
44
const {Response} = require('node-fetch');
55

@@ -66,16 +66,16 @@ test('Blob works with node-fetch Response.blob()', async t => {
6666
const data = 'a=1';
6767
const type = 'text/plain';
6868
const blob = new Blob([data], {type});
69-
const res = new Response(blob);
70-
const blob2 = await res.blob();
69+
const response = new Response(blob);
70+
const blob2 = await response.blob();
7171
t.is(await blob2.text(), data);
7272
});
7373

7474
test('Blob works with node-fetch Response.text()', async t => {
7575
const data = 'a=1';
7676
const type = 'text/plain';
7777
const blob = new Blob([data], {type});
78-
const res = new Response(blob);
79-
const text = await res.text();
78+
const response = new Response(blob);
79+
const text = await response.text();
8080
t.is(text, data);
8181
});

0 commit comments

Comments
 (0)