This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

1
node_modules/form-data-encoder/lib/util/Headers.js generated vendored Normal file
View File

@@ -0,0 +1 @@
export {};

View File

@@ -0,0 +1,9 @@
const alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
export function createBoundary() {
let size = 16;
let res = "";
while (size--) {
res += alphabet[(Math.random() * alphabet.length) << 0];
}
return res;
}

View File

@@ -0,0 +1,4 @@
export const escapeName = (name) => String(name)
.replace(/\r/g, "%0D")
.replace(/\n/g, "%0A")
.replace(/"/g, "%22");

View File

@@ -0,0 +1,21 @@
import { isFunction } from "./isFunction.js";
const isAsyncIterable = (value) => (isFunction(value[Symbol.asyncIterator]));
async function* readStream(readable) {
const reader = readable.getReader();
while (true) {
const { done, value } = await reader.read();
if (done) {
break;
}
yield value;
}
}
export const getStreamIterator = (source) => {
if (isAsyncIterable(source)) {
return source;
}
if (isFunction(source.getReader)) {
return readStream(source);
}
throw new TypeError("Unsupported data source: Expected either ReadableStream or async iterable.");
};

8
node_modules/form-data-encoder/lib/util/isFile.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import { isFunction } from "./isFunction.js";
export const isFile = (value) => Boolean(value
&& typeof value === "object"
&& isFunction(value.constructor)
&& value[Symbol.toStringTag] === "File"
&& isFunction(value.stream)
&& value.name != null);
export const isFileLike = isFile;

View File

@@ -0,0 +1,8 @@
import { isFunction } from "./isFunction.js";
export const isFormData = (value) => Boolean(value
&& isFunction(value.constructor)
&& value[Symbol.toStringTag] === "FormData"
&& isFunction(value.append)
&& isFunction(value.getAll)
&& isFunction(value.entries)
&& isFunction(value[Symbol.iterator]));

View File

@@ -0,0 +1 @@
export const isFunction = (value) => (typeof value === "function");

View File

@@ -0,0 +1,12 @@
const getType = (value) => (Object.prototype.toString.call(value).slice(8, -1).toLowerCase());
export function isPlainObject(value) {
if (getType(value) !== "object") {
return false;
}
const pp = Object.getPrototypeOf(value);
if (pp === null || pp === undefined) {
return true;
}
const Ctor = pp.constructor && pp.constructor.toString();
return Ctor === Object.toString();
}

View File

@@ -0,0 +1,8 @@
export const normalizeValue = (value) => String(value)
.replace(/\r|\n/g, (match, i, str) => {
if ((match === "\r" && str[i + 1] !== "\n")
|| (match === "\n" && str[i - 1] !== "\r")) {
return "\r\n";
}
return match;
});

View File

@@ -0,0 +1,14 @@
function getProperty(target, prop) {
if (typeof prop === "string") {
for (const [name, value] of Object.entries(target)) {
if (prop.toLowerCase() === name.toLowerCase()) {
return value;
}
}
}
return undefined;
}
export const proxyHeaders = (object) => new Proxy(object, {
get: (target, prop) => getProperty(target, prop),
has: (target, prop) => getProperty(target, prop) !== undefined
});