# core/factories/reference.factory.ts

> 8 lines of code and 2 definitions.

Tree: Bane's Lab Build Scripts
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-factories-reference-factory-ts
Source text: https://banes-lab.com/source/build-scripts/core/factories/reference.factory.ts.txt

Listed in [core/factories](https://banes-lab.com/api/source/build-scripts/core/factories.md), after [core/factories/producer.factory.ts](https://banes-lab.com/source/build-scripts/core/factories/producer.factory.ts.md) and before [core/factories/server.factory.ts](https://banes-lab.com/source/build-scripts/core/factories/server.factory.ts.md).

## Definitions

- `singleRelation` (lexical_declaration, line 8, exported)
- `relationOf` (lexical_declaration, line 4, exported)

## Contained in

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

## Used by

- [core/converters/layer.reference.converter.ts](https://banes-lab.com/source/build-scripts/core/converters/layer.reference.converter.ts.md)
- [core/converters/reference.converter.ts](https://banes-lab.com/source/build-scripts/core/converters/reference.converter.ts.md)

## Linked from

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

## Source

```typescript
import type { EdgeRef } from "@banes-lab/web/types/link.types.js";
import type { ReferenceRelation } from "@banes-lab/web/types/reference.types.js";

export const relationOf = function relationOf(id: string, edges: readonly EdgeRef[]): readonly ReferenceRelation[] {
    return edges.length === 0 ? [] : [{ edges, relation: id }];
};

export const singleRelation = function singleRelation(id: string, edge: EdgeRef | null): readonly ReferenceRelation[] {
    return edge === null ? [] : [{ edges: [edge], relation: id }];
};
```
