Skip to content

Commit 139a6cc

Browse files
committed
Deduplicate readonly props declarations in constructor
1 parent b2e6a94 commit 139a6cc

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/FormDataEncoder.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const defaultOptions: FormDataEncoderOptions = {
3636
enableAdditionalHeaders: false
3737
}
3838

39+
const readonlyProp: PropertyDescriptor = {writable: false, configurable: false}
40+
3941
/**
4042
* Implements [`multipart/form-data` encoding algorithm](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#multipart/form-data-encoding-algorithm),
4143
* allowing to add support for spec-comliant [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) to an HTTP client.
@@ -182,10 +184,10 @@ export class FormDataEncoder {
182184

183185
// Make sure following properties read-only in runtime.
184186
Object.defineProperties(this, {
185-
boundary: {writable: false, configurable: false},
186-
contentType: {writable: false, configurable: false},
187-
contentLength: {writable: false, configurable: false},
188-
headers: {writable: false, configurable: false}
187+
boundary: readonlyProp,
188+
contentType: readonlyProp,
189+
contentLength: readonlyProp,
190+
headers: readonlyProp
189191
})
190192
}
191193

0 commit comments

Comments
 (0)