Skip to content

Commit

Permalink
Use ES private fields.
Browse files Browse the repository at this point in the history
  • Loading branch information
RillingDev committed Mar 13, 2022
1 parent 4467882 commit ad2a9e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Ok.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ValidatableElement } from "./dom/ValidatableElement";
* Wraps a dictionary of validators and allows binding/applying it to DOM elements.
*/
export class Ok {
private readonly map: Map<string, Validator>;
readonly #map: Map<string, Validator>;

/**
* Creates a new instance.
Expand All @@ -15,7 +15,7 @@ export class Ok {
* The value contains the validator to apply. See {@link Validator} for details.
*/
public constructor(validators: Record<string, Validator>) {
this.map = new Map(Object.entries(validators));
this.#map = new Map(Object.entries(validators));
}

/**
Expand Down Expand Up @@ -66,12 +66,12 @@ export class Ok {
.split(",")
.map((str) => str.trim())
.map((validatorName) => {
if (!this.map.has(validatorName)) {
if (!this.#map.has(validatorName)) {
throw new Error(
`Validator for name '${validatorName}' is not registered.`
);
}
return this.map.get(validatorName)!;
return this.#map.get(validatorName)!;
});
}
}
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"moduleResolution": "node",
"esModuleInterop": true,
"strict": true,
"useDefineForClassFields": true,
// Per-project
"target": "ES2020",
"lib": ["ES2020", "DOM"]
Expand Down

0 comments on commit ad2a9e4

Please sign in to comment.