# core/loaders/viewport.loader.ts

> 11 lines of code and 1 definition.

Tree: Project Scripts
Language: typescript
Layer: infrastructure
Canonical: https://banes-lab.com/anatomy/scripts#file-scripts-core-loaders-viewport-loader-ts
Source text: https://banes-lab.com/source/scripts/core/loaders/viewport.loader.ts.txt

Listed in [core/loaders](https://banes-lab.com/api/source/scripts/core/loaders.md), after [core/loaders/source.loader.ts](https://banes-lab.com/source/scripts/core/loaders/source.loader.ts.md).

## Definitions

- `builtRoutes` (lexical_declaration, line 4, exported)

## Contained in

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

## Uses

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

## Linked from

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

## Source

```typescript
import { existsSync, readdirSync } from "node:fs";
import { routeOfPage } from "#core/converters/viewport.converter";

export const builtRoutes = function builtRoutes(root: string): readonly string[] {
    if (!existsSync(root)) {
        return [];
    }
    return readdirSync(root, { recursive: true })
        .map((entry) => routeOfPage(String(entry)))
        .filter((route): route is string => route !== null)
        .toSorted((left, right) => left.localeCompare(right));
};
```
