# core/loaders/location.loader.ts

> 16 lines of code and 4 definitions.

Tree: GovLab Paths
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/paths#file-paths-core-loaders-location-loader-ts
Source text: https://banes-lab.com/source/paths/core/loaders/location.loader.ts.txt

Listed in [core/loaders](https://banes-lab.com/api/source/paths/core/loaders.md).

## Definitions

- `loadTree` (lexical_declaration, line 11)
- `MEMBER_DIR` (lexical_declaration, line 9)
- `parsed` (lexical_declaration, line 12)
- `LOCATION_TREE` (lexical_declaration, line 19, exported)

## Contained in

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

## Uses

- [core/predicates/location.predicate.ts](https://banes-lab.com/source/paths/core/predicates/location.predicate.ts.md)

## Linked from

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

## Source

```typescript
import { INVALID_TREE } from "#configuration/strings/location.strings";
import type { PathTree } from "#types/location.types";
import { TREE_FILE } from "#configuration/constants/location.constants";
import { isPathTree } from "#core/predicates/location.predicate";
import { join } from "node:path";
import { parse } from "yaml";
import { readFileSync } from "node:fs";

const MEMBER_DIR = join(import.meta.dirname, "..", "..");

const loadTree = function loadTree(): PathTree {
    const parsed: unknown = parse(readFileSync(join(MEMBER_DIR, TREE_FILE), "utf8"));
    if (!isPathTree(parsed)) {
        throw new Error(INVALID_TREE);
    }
    return parsed;
};

export const LOCATION_TREE: PathTree = loadTree();
```
