feat: export Blob, File and FormData + utilities (#1463)
* feat: export FormData, Blob and Files * use import from index instead * sort a-z * explicit export * bump version * xo lint
This commit is contained in:
parent
b2f5d8d3fa
commit
81b1378bb3
|
@ -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": {
|
||||
|
|
12
src/index.js
12
src/index.js
|
@ -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';
|
||||
import {
|
||||
Blob,
|
||||
File,
|
||||
fileFromSync,
|
||||
fileFrom,
|
||||
blobFromSync,
|
||||
blobFrom
|
||||
} from 'fetch-blob/from.js';
|
||||
|
||||
export {Headers, Request, Response, FetchError, AbortError, isRedirect};
|
||||
export {FormData, Headers, Request, Response, FetchError, AbortError, isRedirect};
|
||||
export {Blob, File, fileFromSync, fileFrom, blobFromSync, blobFrom};
|
||||
|
||||
const supportedSchemas = new Set(['data:', 'http:', 'https:']);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
33
test/main.js
33
test/main.js
|
@ -1,28 +1,27 @@
|
|||
// Test tools
|
||||
import zlib from 'node:zlib';
|
||||
import crypto from 'node:crypto';
|
||||
import http from 'node:http';
|
||||
import fs from 'node:fs';
|
||||
import stream from 'node:stream';
|
||||
import path from 'node:path';
|
||||
import {lookup} from 'node:dns';
|
||||
import crypto from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import http from 'node:http';
|
||||
import path from 'node:path';
|
||||
import stream from 'node:stream';
|
||||
import vm from 'node:vm';
|
||||
import chai from 'chai';
|
||||
import chaiPromised from 'chai-as-promised';
|
||||
import chaiIterator from 'chai-iterator';
|
||||
import chaiString from 'chai-string';
|
||||
import FormData from 'form-data';
|
||||
import {FormData as FormDataNode} from 'formdata-polyfill/esm.min.js';
|
||||
import zlib from 'node:zlib';
|
||||
|
||||
import {text} from 'stream-consumers';
|
||||
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 chai from 'chai';
|
||||
import chaiIterator from 'chai-iterator';
|
||||
import chaiPromised from 'chai-as-promised';
|
||||
import chaiString from 'chai-string';
|
||||
import FormData from 'form-data';
|
||||
|
||||
import fetch, {
|
||||
Blob,
|
||||
FetchError,
|
||||
fileFromSync,
|
||||
FormData as FormDataNode,
|
||||
Headers,
|
||||
Request,
|
||||
Response
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue