Skip to content

Commit

Permalink
feat: export Blob, File and FormData + utilities (#1463)
Browse files Browse the repository at this point in the history
* feat: export FormData, Blob and Files

* use import from index instead

* sort a-z

* explicit export

* bump version

* xo lint
  • Loading branch information
jimmywarting authored Jan 20, 2022
1 parent b2f5d8d commit 81b1378
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
},
"dependencies": {
"data-uri-to-buffer": "^4.0.0",
"fetch-blob": "^3.1.3",
"fetch-blob": "^3.1.4",
"formdata-polyfill": "^4.0.10"
},
"tsd": {
Expand Down
14 changes: 12 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,20 @@ import Request, {getNodeRequestOptions} from './request.js';
import {FetchError} from './errors/fetch-error.js';
import {AbortError} from './errors/abort-error.js';
import {isRedirect} from './utils/is-redirect.js';
import {FormData} from 'formdata-polyfill/esm.min.js';
import {isDomainOrSubdomain} from './utils/is.js';
import {parseReferrerPolicyFromHeader} from './utils/referrer.js';

export {Headers, Request, Response, FetchError, AbortError, isRedirect};
import {
Blob,
File,
fileFromSync,
fileFrom,
blobFromSync,
blobFrom
} from 'fetch-blob/from.js';

export {FormData, Headers, Request, Response, FetchError, AbortError, isRedirect};
export {Blob, File, fileFromSync, fileFrom, blobFromSync, blobFrom};

const supportedSchemas = new Set(['data:', 'http:', 'https:']);

Expand Down
4 changes: 1 addition & 3 deletions test/form-data.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {FormData as FormDataNode} from 'formdata-node';
import {FormData} from 'formdata-polyfill/esm.min.js';
import {Blob} from 'fetch-blob/from.js';
import chai from 'chai';
import {Request, Response} from '../src/index.js';
import {Request, Response, FormData, Blob} from '../src/index.js';

const {expect} = chai;

Expand Down
25 changes: 12 additions & 13 deletions test/main.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
// Test tools
import zlib from 'node:zlib';
import {lookup} from 'node:dns';
import crypto from 'node:crypto';
import http from 'node:http';
import fs from 'node:fs';
import stream from 'node:stream';
import http from 'node:http';
import path from 'node:path';
import {lookup} from 'node:dns';
import stream from 'node:stream';
import vm from 'node:vm';
import zlib from 'node:zlib';

import {text} from 'stream-consumers';
import AbortControllerMysticatea from 'abort-controller';
import abortControllerPolyfill from 'abortcontroller-polyfill/dist/abortcontroller.js';
import chai from 'chai';
import chaiPromised from 'chai-as-promised';
import chaiIterator from 'chai-iterator';
import chaiPromised from 'chai-as-promised';
import chaiString from 'chai-string';
import FormData from 'form-data';
import {FormData as FormDataNode} from 'formdata-polyfill/esm.min.js';
import AbortControllerMysticatea from 'abort-controller';
import abortControllerPolyfill from 'abortcontroller-polyfill/dist/abortcontroller.js';
import {text} from 'stream-consumers';

// Test subjects
import Blob from 'fetch-blob';
import {fileFromSync} from 'fetch-blob/from.js';

import fetch, {
Blob,
FetchError,
fileFromSync,
FormData as FormDataNode,
Headers,
Request,
Response
Expand Down
3 changes: 1 addition & 2 deletions test/response.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as stream from 'node:stream';
import chai from 'chai';
import Blob from 'fetch-blob';
import {Response} from '../src/index.js';
import {Response, Blob} from '../src/index.js';
import TestServer from './utils/server.js';

const {expect} = chai;
Expand Down

0 comments on commit 81b1378

Please sign in to comment.