# samualtnorman/lib architecture

> Architecture diagram of the GitHub repository samualtnorman/lib, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samualtnorman/lib
- Repository: https://github.com/samualtnorman/lib

## Overview

##### Main Components

a) Core Utility Categories:
- Data Structure Utilities (AutoMap)
- String Manipulation (spliceString, bufferToString)
- Mathematical Functions (average, lerp, sigmoid)
- File System Operations (findFiles, writeFilePersistent)
- Async Utilities (asyncReplace, createLock, queueTask)
- Encoding/Decoding (utf8Encoder, utf8Decoder, base128)
- Type Checking & Validation (is, isGenerator, isRecord)
- Performance Utilities (memoizeFunction, lazy)

b) Build System:
- Rollup bundler
- TypeScript compiler
- Package management (pnpm)

**[Build Pipeline]**

- [TypeScript Compilation]

- [Rollup Bundling]

**[Core Library]**

- [Data Structures]
- [String Utils]
- [Math Utils]
- [FS Operations]
- [Async Utils]
- [Encoders/Decoders]
- [Type Checking]
- [Performance Utils]

##### Important Elements to Highlight

- Node.js Version Requirements (18.20+, 20.10+, 22.0+)
- TypeScript Integration
- Module Dependencies
- Build Process Flow

##### Relationships

- Import/Export relationships between modules
- Build pipeline flow
- Module categorization
- Utility interdependencies

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Build
        TS[TypeScript Compiler]
        RB[Rollup Bundler]
        PM[Package Manager]
        TS --> RB
        RB --> PM
    end

    subgraph Core
        DS[Data Structures]
        STR[String Utils]
        MATH[Math Utils]
        FS[File System]
        ASYNC[Async Utils]
        ENC[Encoders/Decoders]
        TYPE[Type Checking]
        PERF[Performance Utils]
    end

    subgraph CI
        GHA[GitHub Actions]
        TEST[Testing]
        DEPLOY[Deployment]
        GHA --> TEST
        TEST --> DEPLOY
    end

    Build --> Core
    Core --> CI

    %% Data Structures
    DS --> AM[AutoMap]
    click AM "https://github.com/samualtnorman/lib/blob/main/src/AutoMap.ts"

    %% String Utils
    STR --> SS[spliceString]
    STR --> BTS[bufferToString]
    click SS "https://github.com/samualtnorman/lib/blob/main/src/spliceString.ts"
    click BTS "https://github.com/samualtnorman/lib/blob/main/src/bufferToString.ts"

    %% Math Utils
    MATH --> AVG[average]
    MATH --> LERP[lerp]
    MATH --> SIG[sigmoid]
    MATH --> SUM[sum]
    MATH --> CLAMP[clamp]
    click AVG "https://github.com/samualtnorman/lib/blob/main/src/average.ts"
    click LERP "https://github.com/samualtnorman/lib/blob/main/src/lerp.ts"
    click SIG "https://github.com/samualtnorman/lib/blob/main/src/sigmoid.ts"
    click SUM "https://github.com/samualtnorman/lib/blob/main/src/sum.ts"
    click CLAMP "https://github.com/samualtnorman/lib/blob/main/src/clamp.ts"

    %% File System
    FS --> FF[findFiles]
    FS --> WFP[writeFilePersistent]
    FS --> CFP[copyFilePersistent]
    FS --> RDS[readDirectoryWithStats]
    click FF "https://github.com/samualtnorman/lib/blob/main/src/findFiles.ts"
    click WFP "https://github.com/samualtnorman/lib/blob/main/src/writeFilePersistent.ts"
    click CFP "https://github.com/samualtnorman/lib/blob/main/src/copyFilePersistent.ts"
    click RDS "https://github.com/samualtnorman/lib/blob/main/src/readDirectoryWithStats.ts"

    %% Async Utils
    ASYNC --> AR[asyncReplace]
    ASYNC --> CL[createLock]
    ASYNC --> QT[queueTask]
    ASYNC --> WT[wait]
    ASYNC --> RAP[raceAllPromises]
    click AR "https://github.com/samualtnorman/lib/blob/main/src/asyncReplace.ts"
    click CL "https://github.com/samualtnorman/lib/blob/main/src/createLock.ts"
    click QT "https://github.com/samualtnorman/lib/blob/main/src/queueTask.ts"
    click WT "https://github.com/samualtnorman/lib/blob/main/src/wait.ts"
    click RAP "https://github.com/samualtnorman/lib/blob/main/src/raceAllPromises.ts"

    %% Encoders/Decoders
    ENC --> UE[utf8Encoder]
    ENC --> UD[utf8Decoder]
    ENC --> B128[base128]
    ENC --> AD[asciiDecoder]
    ENC --> LEB[leb128]
    click UE "https://github.com/samualtnorman/lib/blob/main/src/utf8Encoder.ts"
    click UD "https://github.com/samualtnorman/lib/blob/main/src/utf8Decoder.ts"
    click B128 "https://github.com/samualtnorman/lib/blob/main/src/base128.ts"
    click AD "https://github.com/samualtnorman/lib/blob/main/src/asciiDecoder.ts"
    click LEB "https://github.com/samualtnorman/lib/blob/main/src/leb128.ts"

    %% Type Checking
    TYPE --> IS[is]
    TYPE --> IG[isGenerator]
    TYPE --> IR[isRecord]
    TYPE --> AST[assert]
    click IS "https://github.com/samualtnorman/lib/blob/main/src/is.ts"
    click IG "https://github.com/samualtnorman/lib/blob/main/src/isGenerator.ts"
    click IR "https://github.com/samualtnorman/lib/blob/main/src/isRecord.ts"
    click AST "https://github.com/samualtnorman/lib/blob/main/src/assert.ts"

    %% Performance Utils
    PERF --> MF[memoizeFunction]
    PERF --> LZ[lazy]
    click MF "https://github.com/samualtnorman/lib/blob/main/src/memoizeFunction.ts"
    click LZ "https://github.com/samualtnorman/lib/blob/main/src/lazy.ts"

    %% Build System
    click RB "https://github.com/samualtnorman/lib/blob/main/rollup.config.js"
    click TS "https://github.com/samualtnorman/lib/blob/main/tsconfig.json"
    click PM "https://github.com/samualtnorman/lib/blob/main/package.json"

    %% CI/CD
    click DEPLOY "https://github.com/samualtnorman/lib/blob/main/.github/workflows/publish.yml"
    click TEST "https://github.com/samualtnorman/lib/blob/main/.github/workflows/test.yml"
    click GHA "https://github.com/samualtnorman/lib/blob/main/.github/workflows/codeql-analysis.yml"

    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px;
    classDef build fill:#ff9900,stroke:#333,stroke-width:2px;
    classDef core fill:#3498db,stroke:#333,stroke-width:2px;
    classDef fs fill:#2ecc71,stroke:#333,stroke-width:2px;
    classDef async fill:#9b59b6,stroke:#333,stroke-width:2px;
    classDef type fill:#f1c40f,stroke:#333,stroke-width:2px;
    classDef ci fill:#e74c3c,stroke:#333,stroke-width:2px;

    class TS,RB,PM build;
    class DS,STR,MATH,FS,ASYNC,ENC,TYPE,PERF core;
    class FF,WFP,CFP,RDS fs;
    class AR,CL,QT,WT,RAP async;
    class IS,IG,IR,AST type;
    class GHA,TEST,DEPLOY ci;
```
