# domain/registries/base.registry.ts

> 11 lines of code and 2 definitions.

Tree: Site tree
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/tree#file-domain-registries-base-registry-ts
Source text: https://banes-lab.com/assets/sources/source.0c126045858b0976128f0bd73f876b6aa032146991dc0562a9e59321d1db4d01.generated.txt

## Definitions

- `createRegistry` (lexical_declaration, line 3, exported)
- `entries` (lexical_declaration, line 4, exported)

## Source

```typescript
import type { Identified, Registry } from "#types/registry.types";

export const createRegistry = function createRegistry<T extends Identified>(): Registry<T> {
    const entries = new Map<string, T>();
    return {
        all: () => [...entries.values()],
        byId: (id) => entries.get(id),
        register: (entry) => {
            entries.set(entry.id, entry);
        },
    };
};
```
