Compare commits

...
14 Commits
Author SHA1 Message Date
Antoni Kepinski 960f7e528d Merge branch 'master' of https://github.com/node-fetch/fetch-blob 2020-05-21 11:08:12 +02:00
Antoni Kepinski 582880a297 bump version number 2020-05-21 11:08:09 +02:00
Antoni Kepinski c1dd0851d8 Update CHANGELOG.md 2020-05-21 11:07:56 +02:00
Linus Unnebäck bec5a3dceb Use upstream Blob directly in typings (#38) 2020-05-21 09:12:04 +01:00
Richie Bendall 6fabfce52f Update dependencies
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
2020-05-19 21:59:02 +12:00
Richie Bendall 4a46def452 Maintenance update
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
2020-04-14 21:52:25 +12:00
Richie Bendall 9a458af871 Remove lockfiles
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
2020-04-14 21:47:17 +12:00
Richie Bendall f7e60156a4 docs: Fix grammar
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
2020-03-22 16:14:38 +13:00
Richie Bendall af2edbd01c Merge branch 'master' of https://github.com/node-fetch/fetch-blob 2020-03-22 15:45:43 +13:00
Richie Bendall f4ddd159a4 docs: Update meta
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
2020-03-22 15:45:40 +13:00
dependabot-preview[bot]anddependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> 83559d1144 [Security] Bump acorn from 7.1.0 to 7.1.1 (#23)
Bumps [acorn](https://github.com/acornjs/acorn) from 7.1.0 to 7.1.1. **This update includes a security fix.**
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/7.1.0...7.1.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
2020-03-22 15:43:12 +13:00
dependabot-preview[bot] 8bf6441343 Bump codecov from 3.6.1 to 3.6.5 (#14)
Bumps [codecov](https://github.com/codecov/codecov-node) from 3.6.1 to 3.6.5.
- [Release notes](https://github.com/codecov/codecov-node/releases)
- [Commits](https://github.com/codecov/codecov-node/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-25 11:13:37 +13:00
Richie Bendall 1f5258cd79 chore: Update dependencies
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
2020-02-13 21:48:24 +13:00
Richie Bendall f336a8d182 feat: Add typings (#6)
Signed-off-by: Richie Bendall <richiebendall@gmail.com>
2019-12-15 19:35:42 +08:00
10 changed files with 108 additions and 5441 deletions
+5
View File
@@ -1,3 +1,8 @@
# Lock files
package-lock.json
yarn.lock
# Logs
logs
*.log
+1
View File
@@ -0,0 +1 @@
package-lock=false
+5 -3
View File
@@ -1,11 +1,13 @@
language: node_js
node_js:
- "8"
- "10"
- "12"
- "lts/*"
- "node"
script:
- npm run lint
- npm run coverage
cache:
directories:
- node_modules
+6 -2
View File
@@ -1,14 +1,18 @@
Changelog
=========
## v1.0.6
- Enhance: use upstream Blob directly in typings (#38)
- Other: update dependencies
## v1.0.5
- Other: no change to code, update dev dependency to address vulnerability reports
## v1.0.4
- Other: general code revwrite to pass linting, prepare for `node-fetch` release v3
- Other: general code rewrite to pass linting, prepare for `node-fetch` release v3
## v1.0.3
+15 -14
View File
@@ -1,38 +1,39 @@
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 on 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');
fetch('https://httpbin.org/post', {
method: 'POST',
body: new Blob(['hello'], { type: 'text/plain' })
})
.then(res => res.json()) // expecting a json response
method: 'POST',
body: new Blob(['hello'], { type: 'text/plain' })
})
.then(res => res.json());
.then(json => console.log(json));
```
See [MDN doc](https://developer.mozilla.org/en-US/docs/Web/API/Blob) and [Tests](https://github.com/bitinn/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
[travis-image]: https://flat.badgen.net/travis/bitinn/fetch-blob
[travis-url]: https://travis-ci.org/bitinn/fetch-blob
[codecov-image]: https://flat.badgen.net/codecov/c/github/bitinn/fetch-blob/master
[codecov-url]: https://codecov.io/gh/bitinn/fetch-blob
[travis-image]: https://flat.badgen.net/travis/node-fetch/fetch-blob
[travis-url]: https://travis-ci.org/node-fetch/fetch-blob
[codecov-image]: https://flat.badgen.net/codecov/c/github/node-fetch/fetch-blob/master
[codecov-url]: https://codecov.io/gh/node-fetch/fetch-blob
[install-size-image]: https://flat.badgen.net/packagephobia/install/fetch-blob
[install-size-url]: https://packagephobia.now.sh/result?p=fetch-blob
Vendored
+4
View File
@@ -0,0 +1,4 @@
/// <reference lib="dom"/>
/* global Blob */
export = Blob;
+2 -5
View File
@@ -1,10 +1,7 @@
// Based on https://github.com/tmpvar/jsdom/blob/aa85b2abf07766ff7bf5c1f6daafb3726f2f2db5/lib/jsdom/living/blob.js
// (MIT licensed)
const Stream = require('stream');
// Fix for "Readable" isn't a named export issue
const {Readable} = Stream;
const {Readable: ReadableStream} = require('stream');
const BUFFER = Symbol('buffer');
const TYPE = Symbol('type');
@@ -71,7 +68,7 @@ class Blob {
}
stream() {
const readable = new Readable();
const readable = new ReadableStream();
readable._read = () => { };
readable.push(this[BUFFER]);
readable.push(null);
-5358
View File
File diff suppressed because it is too large Load Diff
+30 -13
View File
@@ -1,32 +1,49 @@
{
"name": "fetch-blob",
"version": "1.0.5",
"description": "A Blob implementation on node.js, originally from node-fetch",
"main": "blob.js",
"version": "1.0.6",
"description": "A Blob implementation in Node.js, originally from node-fetch.",
"main": "index.js",
"files": [
"index.js",
"index.d.ts"
],
"scripts": {
"test": "ava",
"lint": "xo",
"test": "xo && ava",
"report": "nyc ava",
"coverage": "nyc --reporter json --reporter text ava && codecov -f coverage/coverage-final.json"
},
"repository": {
"type": "git",
"url": "git+https://github.com/bitinn/fetch-blob.git"
},
"repository": "https://github.com/node-fetch/fetch-blob.git",
"keywords": [
"blob",
"node-fetch"
],
"engines": {
"node": ">=6"
},
"author": "David Frank",
"license": "MIT",
"bugs": {
"url": "https://github.com/bitinn/fetch-blob/issues"
"url": "https://github.com/node-fetch/fetch-blob/issues"
},
"homepage": "https://github.com/bitinn/fetch-blob#readme",
"homepage": "https://github.com/node-fetch/fetch-blob#readme",
"devDependencies": {
"ava": "^1.4.1",
"codecov": "^3.6.1",
"ava": "^3.8.2",
"codecov": "^3.7.0",
"get-stream": "^5.1.0",
"node-fetch": "^2.6.0",
"nyc": "^14.1.1"
"nyc": "^15.0.1",
"xo": "^0.30.0"
},
"xo": {
"overrides": [
{
"files": "test.js",
"rules": {
"node/no-unsupported-features/es-syntax": 0,
"node/no-unsupported-features/node-builtins": 0
}
}
]
}
}
+40 -46
View File
@@ -1,87 +1,81 @@
import test from 'ava';
import Blob from './blob';
import util from 'util';
import stream from 'stream';
import getStream from 'get-stream';
import { Response } from 'node-fetch';
const TextDecoder = util.TextDecoder;
const Readable = stream.Readable;
const test = require('ava');
const Blob = require('.');
const getStream = require('get-stream');
const {Response} = require('node-fetch');
test('Blob ctor', t => {
let data = 'a=1';
let blob = new Blob([data]);
const data = 'a=1';
const blob = new Blob([data]); // eslint-disable-line no-unused-vars
t.pass();
});
test('Blob size', t => {
let data = 'a=1';
let blob = new Blob([data]);
const data = 'a=1';
const blob = new Blob([data]);
t.is(blob.size, data.length);
});
test('Blob type', t => {
let data = 'a=1';
let type = 'text/plain';
let blob = new Blob([data], { type });
const data = 'a=1';
const type = 'text/plain';
const blob = new Blob([data], {type});
t.is(blob.type, type);
});
test('Blob text()', async t => {
let data = 'a=1';
let type = 'text/plain';
let blob = new Blob([data], { type });
const data = 'a=1';
const type = 'text/plain';
const blob = new Blob([data], {type});
t.is(await blob.text(), data);
});
test('Blob arrayBuffer()', async t => {
let data = 'a=1';
let type = 'text/plain';
let blob = new Blob([data], { type });
const data = 'a=1';
const type = 'text/plain';
const blob = new Blob([data], {type});
let decoder = new TextDecoder('utf-8');
let buffer = await blob.arrayBuffer();
const decoder = new TextDecoder('utf-8');
const buffer = await blob.arrayBuffer();
t.is(decoder.decode(buffer), data);
});
test('Blob stream()', async t => {
let data = 'a=1';
let type = 'text/plain';
let blob = new Blob([data], { type });
let result = await getStream(blob.stream());
const data = 'a=1';
const type = 'text/plain';
const blob = new Blob([data], {type});
const result = await getStream(blob.stream());
t.is(result, data);
});
test('Blob toString()', t => {
let data = 'a=1';
let type = 'text/plain';
let blob = new Blob([data], { type });
const data = 'a=1';
const type = 'text/plain';
const blob = new Blob([data], {type});
t.is(blob.toString(), '[object Blob]');
});
test('Blob slice()', async t => {
let data = 'a=1';
let type = 'text/plain';
let blob = new Blob([data], { type });
let blob2 = blob.slice(0, 1);
const data = 'a=1';
const type = 'text/plain';
const blob = new Blob([data], {type});
const blob2 = blob.slice(0, 1);
t.is(await blob2.text(), data.slice(0, 1));
});
test('Blob works with node-fetch Response.blob()', async t => {
let data = 'a=1';
let type = 'text/plain';
let blob = new Blob([data], { type });
let res = new Response(blob);
let blob2 = await res.blob();
const data = 'a=1';
const type = 'text/plain';
const blob = new Blob([data], {type});
const response = new Response(blob);
const blob2 = await response.blob();
t.is(await blob2.text(), data);
});
test('Blob works with node-fetch Response.text()', async t => {
let data = 'a=1';
let type = 'text/plain';
let blob = new Blob([data], { type });
let res = new Response(blob);
let text = await res.text();
const data = 'a=1';
const type = 'text/plain';
const blob = new Blob([data], {type});
const response = new Response(blob);
const text = await response.text();
t.is(text, data);
});