Maintenance update
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/// <reference lib="dom"/>
|
||||
|
||||
// /** 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<string>
|
||||
arrayBuffer(): Promise<ArrayBuffer>
|
||||
toString(): "[object Blob]"
|
||||
[Symbol.toStringTag]: "Blob"
|
||||
|
||||
}
|
||||
|
||||
declare const FetchBlob: {
|
||||
prototype: FetchBlob
|
||||
new(blobParts?: BlobPart[], options?: BlobPropertyBag): FetchBlob
|
||||
};
|
||||
|
||||
export = FetchBlob
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
/// <reference lib="dom"/>
|
||||
|
||||
/** 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<string>;
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
toString(): '[object Blob]';
|
||||
|
||||
}
|
||||
|
||||
declare const FetchBlob: {
|
||||
prototype: FetchBlob;
|
||||
new(blobParts?: BlobPart[], options?: BlobPropertyBag): FetchBlob;
|
||||
};
|
||||
|
||||
export = FetchBlob;
|
||||
+19
-4
@@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user