# core/stores/check.store.ts

> 25 lines of code and 7 definitions.

Tree: GovLab Context
Language: typescript
Layer: application
Canonical: https://banes-lab.com/anatomy/context#file-context-core-stores-check-store-ts
Source text: https://banes-lab.com/source/context/core/stores/check.store.ts.txt

Listed in [core/stores](https://banes-lab.com/api/source/context/core/stores.md), after [core/stores/architecture.store.ts](https://banes-lab.com/source/context/core/stores/architecture.store.ts.md) and before [core/stores/lexicon.store.ts](https://banes-lab.com/source/context/core/stores/lexicon.store.ts.md).

## Definitions

- `checkOf` (method_definition, line 23, exported)
- `CheckTable` (class_declaration, line 5, exported)
- `#byKind` (public_field_definition, line 6, exported)
- `#byRecord` (public_field_definition, line 7, exported)
- `forKind` (method_definition, line 9, exported)
- `forRecord` (method_definition, line 16, exported)
- `facet` (lexical_declaration, line 17, exported)

## Contained in

- [core/stores](https://banes-lab.com/anatomy/context/folder-context-core-stores.md)

## Uses

- [core/converters/check.converter.ts](https://banes-lab.com/source/context/core/converters/check.converter.ts.md)

## Linked from

- [core/converters](https://banes-lab.com/anatomy/context/folder-context-core-converters.md)

## Source

```typescript
import { asCheck, mergeCheck } from "#core/converters/check.converter";
import type { CheckFacet } from "#types/check.types";
import { RECORD_KEY_SEPARATOR } from "#configuration/constants/check.constants";

export class CheckTable {
    readonly #byKind = new Map<string, CheckFacet>();
    readonly #byRecord = new Map<string, CheckFacet>();

    public forKind(kind: string, value: unknown): void {
        const facet = asCheck(value);
        if (facet !== null) {
            this.#byKind.set(kind, facet);
        }
    }

    public forRecord(kind: string, id: string, value: unknown): void {
        const facet = asCheck(value);
        if (facet !== null) {
            this.#byRecord.set(`${kind}${RECORD_KEY_SEPARATOR}${id}`, facet);
        }
    }

    public checkOf(kind: string, id: string): CheckFacet | null {
        return mergeCheck(
            this.#byKind.get(kind) ?? null,
            this.#byRecord.get(`${kind}${RECORD_KEY_SEPARATOR}${id}`) ?? null,
        );
    }
}
```
