edge-mock
Version:
types for testing an developer edge applications
74 lines • 1.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EdgeFormData = void 0;
const Blob_1 = require("./Blob");
class EdgeFormData {
map = new Map();
append(name, value, fileName) {
const value_ = asFormDataEntryValue(value);
const v = this.map.get(name);
if (v) {
v.push(value_);
}
else {
this.map.set(name, [value_]);
}
}
delete(name) {
this.map.delete(name);
}
get(name) {
const v = this.map.get(name);
return v ? v[0] : null;
}
getAll(name) {
return this.map.get(name) || [];
}
has(name) {
return this.map.has(name);
}
set(name, value, fileName) {
this.map.set(name, [asFormDataEntryValue(value)]);
}
forEach(callbackfn, thisArg) {
if (thisArg) {
callbackfn = callbackfn.bind(thisArg);
}
for (const [key, array] of this.map) {
for (const value of array) {
callbackfn(value, key, this);
}
}
}
*entries() {
for (const [key, array] of this.map) {
for (const value of array) {
yield [key, value];
}
}
}
keys() {
return this.map.keys();
}
*values() {
for (const array of this.map.values()) {
for (const value of array) {
yield value;
}
}
}
[Symbol.iterator]() {
return this.entries();
}
}
exports.EdgeFormData = EdgeFormData;
function asFormDataEntryValue(value) {
if (typeof value == 'string' || 'name' in value) {
return value;
}
else {
const parts = value._parts;
return new Blob_1.EdgeFile(parts, 'blob');
}
}
//# sourceMappingURL=FormData.js.map