We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
IncomingMessage.headersDistinct
IncomingMessage.trailersDistinct
1 parent 1eec581 commit 08e36ccCopy full SHA for 08e36cc
src/runtime/node/http/_request.ts
@@ -41,4 +41,24 @@ export class IncomingMessage extends Readable implements http.IncomingMessage {
41
setTimeout(_msecs: number, _callback?: () => void) {
42
return this;
43
}
44
+
45
+ get headersDistinct() {
46
+ return _distinct(this.headers);
47
+ }
48
49
+ get trailersDistinct() {
50
+ return _distinct(this.trailers);
51
52
+}
53
54
+function _distinct(obj: Record<string, any>) {
55
+ const d: Record<string, string[]> = {};
56
+ for (const [key, value] of Object.entries(obj)) {
57
+ if (key) {
58
+ d[key as string] = (Array.isArray(value) ? value : [value]).filter(
59
+ Boolean
60
+ );
61
62
63
+ return d;
64
0 commit comments