New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@esm2cjs/form-data-encoder

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@esm2cjs/form-data-encoder - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

25

build/cjs/FormDataEncoder.js

@@ -88,7 +88,11 @@ "use strict";

__classPrivateFieldSet(this, _FormDataEncoder_footer, __classPrivateFieldGet(this, _FormDataEncoder_encoder, "f").encode(`${__classPrivateFieldGet(this, _FormDataEncoder_DASHES, "f")}${this.boundary}${__classPrivateFieldGet(this, _FormDataEncoder_DASHES, "f")}${__classPrivateFieldGet(this, _FormDataEncoder_CRLF, "f").repeat(2)}`), "f");
this.contentLength = __classPrivateFieldGet(this, _FormDataEncoder_instances, "m", _FormDataEncoder_getContentLength).call(this);
this.headers = (0, import_proxyHeaders.proxyHeaders)(Object.freeze({
"Content-Type": this.contentType,
"Content-Length": this.contentLength
}));
const headers = {
"Content-Type": this.contentType
};
const contentLength = __classPrivateFieldGet(this, _FormDataEncoder_instances, "m", _FormDataEncoder_getContentLength).call(this);
if (contentLength) {
this.contentLength = contentLength;
headers["Content-Length"] = contentLength;
}
this.headers = (0, import_proxyHeaders.proxyHeaders)(Object.freeze(headers));
Object.defineProperties(this, {

@@ -102,3 +106,3 @@ boundary: readonlyProp,

getContentLength() {
return Number(this.contentLength);
return this.contentLength == null ? void 0 : Number(this.contentLength);
}

@@ -131,3 +135,4 @@ *values() {

}
if (__classPrivateFieldGet(this, _FormDataEncoder_options, "f").enableAdditionalHeaders === true) {
const size = (0, import_isFile.isFile)(value) ? value.size : value.byteLength;
if (__classPrivateFieldGet(this, _FormDataEncoder_options, "f").enableAdditionalHeaders === true && size != null && !isNaN(size)) {
header += `${__classPrivateFieldGet(this, _FormDataEncoder_CRLF, "f")}Content-Length: ${(0, import_isFile.isFile)(value) ? value.size : value.byteLength}`;

@@ -140,4 +145,8 @@ }

const value = (0, import_isFile.isFile)(raw) ? raw : __classPrivateFieldGet(this, _FormDataEncoder_encoder, "f").encode((0, import_normalizeValue.normalizeValue)(raw));
const size = (0, import_isFile.isFile)(value) ? value.size : value.byteLength;
if (size == null || isNaN(size)) {
return void 0;
}
length += __classPrivateFieldGet(this, _FormDataEncoder_instances, "m", _FormDataEncoder_getFieldHeader).call(this, name, value).byteLength;
length += (0, import_isFile.isFile)(value) ? value.size : value.byteLength;
length += size;
length += __classPrivateFieldGet(this, _FormDataEncoder_CRLF_BYTES_LENGTH, "f");

@@ -144,0 +153,0 @@ }

@@ -26,3 +26,3 @@ "use strict";

var import_isFunction = require("./isFunction.js");
const isFile = (value) => Boolean(value && typeof value === "object" && (0, import_isFunction.isFunction)(value.constructor) && value[Symbol.toStringTag] === "File" && (0, import_isFunction.isFunction)(value.stream) && value.name != null && value.size != null && value.lastModified != null);
const isFile = (value) => Boolean(value && typeof value === "object" && (0, import_isFunction.isFunction)(value.constructor) && value[Symbol.toStringTag] === "File" && (0, import_isFunction.isFunction)(value.stream) && value.name != null);
const isFileLike = isFile;

@@ -29,0 +29,0 @@ // Annotate the CommonJS export names for ESM import in node:

@@ -35,5 +35,5 @@ "use strict";

}
const proxyHeaders = (target) => new Proxy(target, {
get: (target2, prop) => getProperty(target2, prop),
has: (target2, prop) => getProperty(target2, prop) !== void 0
const proxyHeaders = (object) => new Proxy(object, {
get: (target, prop) => getProperty(target, prop),
has: (target, prop) => getProperty(target, prop) !== void 0
});

@@ -40,0 +40,0 @@ // Annotate the CommonJS export names for ESM import in node:

import type { LowercaseObjectKeys } from "./util/LowercaseObjectKeys.js";
import type { FormDataLike } from "./FormDataLike.js";
import type { FileLike } from "./FileLike.js";
declare type RawHeaders = Readonly<{
interface RawHeaders {
"Content-Type": string;
"Content-Length": string;
}>;
export declare type FormDataEncoderHeaders = RawHeaders & LowercaseObjectKeys<RawHeaders>;
"Content-Length"?: string;
}
export declare type FormDataEncoderHeaders = Readonly<RawHeaders> & Readonly<LowercaseObjectKeys<RawHeaders>>;
export interface FormDataEncoderOptions {

@@ -36,3 +36,3 @@ /**

*/
readonly contentLength: string;
readonly contentLength: string | undefined;
/**

@@ -84,3 +84,3 @@ * Returns headers object with Content-Type and Content-Length header

*/
getContentLength(): number;
getContentLength(): number | undefined;
/**

@@ -87,0 +87,0 @@ * Creates an iterator allowing to go through form-data parts (with metadata).

@@ -61,7 +61,11 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {

__classPrivateFieldSet(this, _FormDataEncoder_footer, __classPrivateFieldGet(this, _FormDataEncoder_encoder, "f").encode(`${__classPrivateFieldGet(this, _FormDataEncoder_DASHES, "f")}${this.boundary}${__classPrivateFieldGet(this, _FormDataEncoder_DASHES, "f")}${__classPrivateFieldGet(this, _FormDataEncoder_CRLF, "f").repeat(2)}`), "f");
this.contentLength = __classPrivateFieldGet(this, _FormDataEncoder_instances, "m", _FormDataEncoder_getContentLength).call(this);
this.headers = proxyHeaders(Object.freeze({
"Content-Type": this.contentType,
"Content-Length": this.contentLength
}));
const headers = {
"Content-Type": this.contentType
};
const contentLength = __classPrivateFieldGet(this, _FormDataEncoder_instances, "m", _FormDataEncoder_getContentLength).call(this);
if (contentLength) {
this.contentLength = contentLength;
headers["Content-Length"] = contentLength;
}
this.headers = proxyHeaders(Object.freeze(headers));
Object.defineProperties(this, {

@@ -75,3 +79,3 @@ boundary: readonlyProp,

getContentLength() {
return Number(this.contentLength);
return this.contentLength == null ? undefined : Number(this.contentLength);
}

@@ -105,3 +109,6 @@ *values() {

}
if (__classPrivateFieldGet(this, _FormDataEncoder_options, "f").enableAdditionalHeaders === true) {
const size = isFile(value) ? value.size : value.byteLength;
if (__classPrivateFieldGet(this, _FormDataEncoder_options, "f").enableAdditionalHeaders === true
&& size != null
&& !isNaN(size)) {
header += `${__classPrivateFieldGet(this, _FormDataEncoder_CRLF, "f")}Content-Length: ${isFile(value) ? value.size : value.byteLength}`;

@@ -114,4 +121,8 @@ }

const value = isFile(raw) ? raw : __classPrivateFieldGet(this, _FormDataEncoder_encoder, "f").encode(normalizeValue(raw));
const size = isFile(value) ? value.size : value.byteLength;
if (size == null || isNaN(size)) {
return undefined;
}
length += __classPrivateFieldGet(this, _FormDataEncoder_instances, "m", _FormDataEncoder_getFieldHeader).call(this, name, value).byteLength;
length += isFile(value) ? value.size : value.byteLength;
length += size;
length += __classPrivateFieldGet(this, _FormDataEncoder_CRLF_BYTES_LENGTH, "f");

@@ -118,0 +129,0 @@ }

@@ -7,5 +7,3 @@ import { isFunction } from "./isFunction.js";

&& isFunction(value.stream)
&& value.name != null
&& value.size != null
&& value.lastModified != null);
&& value.name != null);
export const isFileLike = isFile;
import type { LowercaseObjectKeys } from "./LowercaseObjectKeys.js";
declare type AnyObject = Record<string | symbol, string>;
export declare const proxyHeaders: <T extends AnyObject>(target: T) => T & LowercaseObjectKeys<T>;
export declare const proxyHeaders: <T extends AnyObject>(object: T) => T & LowercaseObjectKeys<T>;
export {};

@@ -12,5 +12,5 @@ function getProperty(target, prop) {

}
export const proxyHeaders = (target) => new Proxy(target, {
export const proxyHeaders = (object) => new Proxy(object, {
get: (target, prop) => getProperty(target, prop),
has: (target, prop) => getProperty(target, prop) !== undefined
});
{
"name": "@esm2cjs/form-data-encoder",
"version": "2.0.1",
"version": "2.1.0",
"description": "Encode FormData content into the multipart/form-data format. This is a fork of octet-stream/form-data-encoder, but with CommonJS support.",

@@ -45,23 +45,24 @@ "repository": "esm2cjs/form-data-encoder",

"devDependencies": {
"@octetstream/eslint-config": "5.0.0",
"@octetstream/eslint-config": "6.2.2",
"@types/mime-types": "2.1.1",
"@types/node": "17.0.35",
"@typescript-eslint/eslint-plugin": "5.18.0",
"@typescript-eslint/parser": "5.18.0",
"ava": "4.2.0",
"c8": "7.11.3",
"del-cli": "4.0.1",
"eslint": "7.32.0",
"eslint-config-airbnb-typescript": "12.3.1",
"eslint-import-resolver-typescript": "2.7.1",
"@types/node": "18.7.6",
"@typescript-eslint/eslint-plugin": "5.33.1",
"@typescript-eslint/parser": "5.33.1",
"ava": "4.3.1",
"c8": "7.12.0",
"del-cli": "5.0.0",
"eslint": "8.22.0",
"eslint-config-airbnb-typescript": "17.0.0",
"eslint-import-resolver-typescript": "3.4.2",
"eslint-plugin-ava": "13.2.0",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-react": "7.26.1",
"formdata-node": "4.3.2",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "6.6.1",
"eslint-plugin-react": "7.30.1",
"formdata-node": "4.4.0",
"husky": "8.0.1",
"lint-staged": "12.4.1",
"lint-staged": "13.0.3",
"pinst": "3.0.0",
"ts-node": "10.7.0",
"ts-node": "10.9.1",
"ttypescript": "1.5.13",
"typescript": "4.6.4"
"typescript": "4.7.4"
},

@@ -68,0 +69,0 @@ "publishConfig": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc