Version 2.0

This commit is contained in:
Randall
2021-06-12 19:26:05 -04:00
committed by GitHub
parent dea019c42c
commit b8da556091
16 changed files with 3071 additions and 76 deletions

33
classes/headers.js Normal file
View File

@ -0,0 +1,33 @@
class Headers {
constructor(rawHeaders) {
this.rawHeaders = rawHeaders;
}
entries() {
return Object.entries(this.rawHeaders)
.sort((e1, e2) => e1[0].localeCompare(e2[0]))
.map(([key, val]) => [key, val[0]]);
}
keys() {
return this.entries().map((e) => e[0]);
}
values() {
return this.entries().map((e) => e[1]);
}
get(name) {
return (this.rawHeaders[name.toLowerCase()] || [])[0] || null;
}
has(name) {
return !!this.get(name);
}
raw() {
return this.rawHeaders;
}
}
module.exports = Headers;