# core/factories/representation.factory.ts

> 18 lines of code and 4 definitions.

Tree: GovLab Patterns
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/patterns#file-patterns-core-factories-representation-factory-ts
Source text: https://banes-lab.com/source/patterns/core/factories/representation.factory.ts.txt

Listed in [core/factories](https://banes-lab.com/api/source/patterns/core/factories.md), after [core/factories/record.factory.ts](https://banes-lab.com/source/patterns/core/factories/record.factory.ts.md) and before [core/factories/seed.factory.ts](https://banes-lab.com/source/patterns/core/factories/seed.factory.ts.md).

## Definitions

- `runtimeOf` (lexical_declaration, line 4, exported)
- `findings` (method_definition, line 9, exported)
- `sample` (method_definition, line 12, exported)
- `update` (method_definition, line 15, exported)

## Contained in

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

## Used by

- [core/plugins/representation.distribution.plugin.ts](https://banes-lab.com/source/patterns/core/plugins/representation.distribution.plugin.ts.md)
- [core/plugins/representation.graph.plugin.ts](https://banes-lab.com/source/patterns/core/plugins/representation.graph.plugin.ts.md)
- [core/plugins/representation.grid.plugin.ts](https://banes-lab.com/source/patterns/core/plugins/representation.grid.plugin.ts.md)
- [core/plugins/representation.sequence.plugin.ts](https://banes-lab.com/source/patterns/core/plugins/representation.sequence.plugin.ts.md)
- [core/plugins/representation.tree.plugin.ts](https://banes-lab.com/source/patterns/core/plugins/representation.tree.plugin.ts.md)
- [core/plugins/representation.vector.plugin.ts](https://banes-lab.com/source/patterns/core/plugins/representation.vector.plugin.ts.md)

## Linked from

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

## Source

```typescript
import type { Accumulator, RepresentationRuntime } from "#types/representation.types";
import type { Finding } from "#types/finding.types";

export const runtimeOf = function runtimeOf<S>(
    accumulator: Accumulator<S>,
    findingsOf: (summary: S) => Finding[],
): RepresentationRuntime {
    return {
        findings(): Finding[] {
            return findingsOf(accumulator.result());
        },
        sample(rng): unknown {
            return accumulator.sample(rng);
        },
        update(chunk): void {
            accumulator.update(chunk);
        },
    };
};
```
