Closed nigrosimone closed 6 days ago
@dimdenGD Maybe we can also cache accepts(this)
initialization, eg: ?
accepts(...types) {
if (!this.#accepts) {
this.#accepts = accepts(this);
}
return this.#accepts.types(...types);
}
acceptsCharsets(...charsets) {
if (!this.#accepts) {
this.#accepts = accepts(this);
}
return this.#accepts.charsets(...charsets);
}
acceptsEncodings(...encodings) {
if (!this.#accepts) {
this.#accepts = accepts(this);
}
return this.#accepts.encodings(...encodings);
}
acceptsLanguages(...languages) {
if (!this.#accepts) {
this.#accepts = accepts(this);
}
return this.#accepts.languages(...languages);
}
Probably no point in caching because calling that function just creates a class with no real work done until function is called
const accept = accepts({ headers: this.headers });
https://github.com/dimdenGD/ultimate-express/pull/56/commits/e8bb956a85535c2580a19acdcb0b9697c071909eobject accepts({ headers: this.headers })
https://github.com/dimdenGD/ultimate-express/pull/56/commits/6ff51e6b4d54f685845317873b9f30b3396e80c6Bonus Improvements:
accepts(this)
initialization, see https://github.com/dimdenGD/ultimate-express/pull/56#issuecomment-2480818321