Skip to content

Commit b306c28

Browse files
committed
Make Encoder#headers to be the actual property instead of a getter. Put Encoder#headers initialization into Encoder constructor.
1 parent 84119a1 commit b306c28

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/Encoder.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ export class Encoder {
2222
*/
2323
readonly contentType: string
2424

25+
/**
26+
* Returns headers object with Content-Type and Content-Length header
27+
*/
28+
readonly headers: {
29+
"Content-Type": string
30+
"Content-Length": number
31+
}
32+
2533
/**
2634
* Returns field's footer
2735
*/
@@ -65,16 +73,11 @@ export class Encoder {
6573
this.#footer = new TextEncoder().encode(
6674
`${DASHES}${this.boundary}${DASHES}${CRLF.repeat(2)}`
6775
)
68-
}
6976

70-
/**
71-
* Returns headers object with Content-Type and Content-Length header
72-
*/
73-
get headers() {
74-
return {
77+
this.headers = Object.freeze({
7578
"Content-Type": this.contentType,
76-
"Content-Length": this.getContentLength(),
77-
}
79+
"Content-Length": this.getContentLength()
80+
})
7881
}
7982

8083
private _getFieldHeader(name: string, value: unknown): Uint8Array {

0 commit comments

Comments
 (0)