formdata-node
Advanced tools
Comparing version 3.6.4 to 3.7.0
export declare const FormData: { | ||
new (form?: HTMLFormElement | undefined): FormData; | ||
prototype: FormData; | ||
}; | ||
export declare const Blob: { | ||
}, Blob: { | ||
new (blobParts?: BlobPart[] | undefined, options?: BlobPropertyBag | undefined): Blob; | ||
prototype: Blob; | ||
}; | ||
export declare const File: { | ||
}, File: { | ||
new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag | undefined): File; | ||
prototype: File; | ||
}; |
@@ -6,2 +6,7 @@ /// <reference types="node" /> | ||
export declare type FormDataFieldValue = string | File; | ||
/** | ||
* Additional field options. | ||
* | ||
* @deprecated The options argument is non-standard and will be removed from this package in the next major release (4.x). | ||
*/ | ||
export interface FormDataFieldOptions { | ||
@@ -30,2 +35,8 @@ /** | ||
}>; | ||
/** | ||
* Provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using fetch(). | ||
* | ||
* Note that this object is not a part of Node.js, so you might need to check is an HTTP client of your choice support spec-compliant FormData. | ||
* However, if your HTTP client does not support FormData, you can use [`form-data-encoder`](https://npmjs.com/package/form-data-encoder) package to handle "multipart/form-data" encoding. | ||
*/ | ||
export declare class FormData { | ||
@@ -40,2 +51,3 @@ #private; | ||
"Content-Type": string; | ||
"Content-Length": string; | ||
}; | ||
@@ -48,2 +60,5 @@ /** | ||
get stream(): Readable; | ||
/** | ||
* @deprecated FormData#boundary property is non-standard and will be removed from this package in the next major release (4.x). Use https://npmjs.com/form-data-encoder package to serilize FormData. | ||
*/ | ||
get boundary(): string; | ||
@@ -50,0 +65,0 @@ constructor(entries?: FormDataConstructorEntries); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.File = exports.Blob = exports.FormData = void 0; | ||
function accessValue(name) { | ||
const globalObject = (function () { | ||
if (typeof globalThis !== "undefined") { | ||
return globalThis[name]; | ||
return globalThis; | ||
} | ||
if (typeof self !== "undefined") { | ||
return self[name]; | ||
return self; | ||
} | ||
return window[name]; | ||
} | ||
exports.FormData = accessValue("FormData"); | ||
exports.Blob = accessValue("Blob"); | ||
exports.File = accessValue("File"); | ||
return window; | ||
}()); | ||
exports.FormData = globalObject.FormData, exports.Blob = globalObject.Blob, exports.File = globalObject.File; |
"use strict"; | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
@@ -23,3 +17,2 @@ if (kind === "m") throw new TypeError("Private method is not writable"); | ||
var _FormData_instances, _FormData_stream, _FormData_encoder, _FormData_content, _FormData_setField; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -33,8 +26,3 @@ exports.FormData = void 0; | ||
const fileFromPath_1 = require("./fileFromPath"); | ||
const deprecateHeaders_1 = __importDefault(require("./util/deprecateHeaders")); | ||
const deprecateReadStream_1 = __importDefault(require("./util/deprecateReadStream")); | ||
const deprecateGetComputedLength_1 = __importDefault(require("./util/deprecateGetComputedLength")); | ||
const deprecateSymbolAsyncIterator_1 = __importDefault(require("./util/deprecateSymbolAsyncIterator")); | ||
const deprecateBuffer_1 = __importDefault(require("./util/deprecateBuffer")); | ||
const deprecateStream_1 = __importDefault(require("./util/deprecateStream")); | ||
const deprecations_1 = require("./util/deprecations"); | ||
const isFile_1 = __importDefault(require("./util/isFile")); | ||
@@ -57,7 +45,7 @@ const isPlainObject_1 = __importDefault(require("./util/isPlainObject")); | ||
get headers() { | ||
return { | ||
"Content-Type": `multipart/form-data; boundary=${this.boundary}` | ||
}; | ||
deprecations_1.deprecateHeaders(); | ||
return __classPrivateFieldGet(this, _FormData_encoder, "f").headers; | ||
} | ||
get stream() { | ||
deprecations_1.deprecateStream(); | ||
if (!__classPrivateFieldGet(this, _FormData_stream, "f")) { | ||
@@ -69,5 +57,7 @@ __classPrivateFieldSet(this, _FormData_stream, stream_1.Readable.from(this), "f"); | ||
get boundary() { | ||
deprecations_1.deprecateBoundary(); | ||
return __classPrivateFieldGet(this, _FormData_encoder, "f").boundary; | ||
} | ||
getComputedLength() { | ||
deprecations_1.deprecateGetComputedLength(); | ||
return __classPrivateFieldGet(this, _FormData_encoder, "f").getContentLength(); | ||
@@ -136,2 +126,8 @@ } | ||
name = String(name); | ||
if (Buffer.isBuffer(value)) { | ||
deprecations_1.deprecateBuffer(); | ||
} | ||
if (isReadStream_1.default(value)) { | ||
deprecations_1.deprecateReadStream(); | ||
} | ||
let filename; | ||
@@ -144,2 +140,5 @@ if (isPlainObject_1.default(filenameOrOptions)) { | ||
} | ||
if (isPlainObject_1.default(options)) { | ||
deprecations_1.deprecateOptions(); | ||
} | ||
if (argsLength < 2) { | ||
@@ -196,26 +195,7 @@ throw new TypeError(`Failed to execute '${methodName}' on 'FormData': ` | ||
} | ||
async *[_a = Symbol.asyncIterator]() { | ||
async *[Symbol.asyncIterator]() { | ||
deprecations_1.deprecateSymbolAsyncIterator(); | ||
yield* __classPrivateFieldGet(this, _FormData_encoder, "f").encode(); | ||
} | ||
} | ||
__decorate([ | ||
deprecateHeaders_1.default | ||
], FormData.prototype, "headers", null); | ||
__decorate([ | ||
deprecateStream_1.default | ||
], FormData.prototype, "stream", null); | ||
__decorate([ | ||
deprecateGetComputedLength_1.default | ||
], FormData.prototype, "getComputedLength", null); | ||
__decorate([ | ||
deprecateBuffer_1.default, | ||
deprecateReadStream_1.default | ||
], FormData.prototype, "append", null); | ||
__decorate([ | ||
deprecateBuffer_1.default, | ||
deprecateReadStream_1.default | ||
], FormData.prototype, "set", null); | ||
__decorate([ | ||
deprecateSymbolAsyncIterator_1.default | ||
], FormData.prototype, _a, null); | ||
exports.FormData = FormData; |
@@ -1,12 +0,10 @@ | ||
function accessValue(name) { | ||
const globalObject = (function () { | ||
if (typeof globalThis !== "undefined") { | ||
return globalThis[name]; | ||
return globalThis; | ||
} | ||
if (typeof self !== "undefined") { | ||
return self[name]; | ||
return self; | ||
} | ||
return window[name]; | ||
} | ||
export const FormData = accessValue("FormData"); | ||
export const Blob = accessValue("Blob"); | ||
export const File = accessValue("File"); | ||
return window; | ||
}()); | ||
export const { FormData, Blob, File } = globalObject; |
@@ -1,7 +0,1 @@ | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
@@ -19,3 +13,2 @@ if (kind === "m") throw new TypeError("Private method is not writable"); | ||
var _FormData_instances, _FormData_stream, _FormData_encoder, _FormData_content, _FormData_setField; | ||
var _a; | ||
import { Readable } from "stream"; | ||
@@ -27,8 +20,3 @@ import { basename } from "path"; | ||
import { fileFromPathSync } from "./fileFromPath.js"; | ||
import deprecateHeaders from "./util/deprecateHeaders.js"; | ||
import deprecateReadStream from "./util/deprecateReadStream.js"; | ||
import deprecateGetComputedLength from "./util/deprecateGetComputedLength.js"; | ||
import deprecateSymbolAsyncIterator from "./util/deprecateSymbolAsyncIterator.js"; | ||
import deprecateBuffer from "./util/deprecateBuffer.js"; | ||
import deprecateStream from "./util/deprecateStream.js"; | ||
import { deprecateBoundary, deprecateHeaders, deprecateStream, deprecateBuffer, deprecateReadStream, deprecateOptions, deprecateGetComputedLength, deprecateSymbolAsyncIterator } from "./util/deprecations.js"; | ||
import isFile from "./util/isFile.js"; | ||
@@ -51,7 +39,7 @@ import isPlainObject from "./util/isPlainObject.js"; | ||
get headers() { | ||
return { | ||
"Content-Type": `multipart/form-data; boundary=${this.boundary}` | ||
}; | ||
deprecateHeaders(); | ||
return __classPrivateFieldGet(this, _FormData_encoder, "f").headers; | ||
} | ||
get stream() { | ||
deprecateStream(); | ||
if (!__classPrivateFieldGet(this, _FormData_stream, "f")) { | ||
@@ -63,5 +51,7 @@ __classPrivateFieldSet(this, _FormData_stream, Readable.from(this), "f"); | ||
get boundary() { | ||
deprecateBoundary(); | ||
return __classPrivateFieldGet(this, _FormData_encoder, "f").boundary; | ||
} | ||
getComputedLength() { | ||
deprecateGetComputedLength(); | ||
return __classPrivateFieldGet(this, _FormData_encoder, "f").getContentLength(); | ||
@@ -130,2 +120,8 @@ } | ||
name = String(name); | ||
if (Buffer.isBuffer(value)) { | ||
deprecateBuffer(); | ||
} | ||
if (isReadStream(value)) { | ||
deprecateReadStream(); | ||
} | ||
let filename; | ||
@@ -138,2 +134,5 @@ if (isPlainObject(filenameOrOptions)) { | ||
} | ||
if (isPlainObject(options)) { | ||
deprecateOptions(); | ||
} | ||
if (argsLength < 2) { | ||
@@ -190,25 +189,6 @@ throw new TypeError(`Failed to execute '${methodName}' on 'FormData': ` | ||
} | ||
async *[_a = Symbol.asyncIterator]() { | ||
async *[Symbol.asyncIterator]() { | ||
deprecateSymbolAsyncIterator(); | ||
yield* __classPrivateFieldGet(this, _FormData_encoder, "f").encode(); | ||
} | ||
} | ||
__decorate([ | ||
deprecateHeaders | ||
], FormData.prototype, "headers", null); | ||
__decorate([ | ||
deprecateStream | ||
], FormData.prototype, "stream", null); | ||
__decorate([ | ||
deprecateGetComputedLength | ||
], FormData.prototype, "getComputedLength", null); | ||
__decorate([ | ||
deprecateBuffer, | ||
deprecateReadStream | ||
], FormData.prototype, "append", null); | ||
__decorate([ | ||
deprecateBuffer, | ||
deprecateReadStream | ||
], FormData.prototype, "set", null); | ||
__decorate([ | ||
deprecateSymbolAsyncIterator | ||
], FormData.prototype, _a, null); |
{ | ||
"name": "formdata-node", | ||
"version": "3.6.4", | ||
"version": "3.7.0", | ||
"description": "FormData implementation for Node.js", | ||
@@ -54,3 +54,3 @@ "repository": "octet-stream/form-data", | ||
"@octetstream/eslint-config": "5.0.0", | ||
"@types/node": "16.4.14", | ||
"@types/node": "16.6.1", | ||
"@types/sinon": "10.0.2", | ||
@@ -57,0 +57,0 @@ "@typescript-eslint/eslint-plugin": "4.29.1", |
69681
47
1084