{
  "definitions": [
    {
      "callable": true,
      "callees": [
        {
          "file": "core/persistence/folder.persistence.ts",
          "name": "inBatches",
          "source": {
            "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-folder-persistence-ts",
            "json": "https://banes-lab.com/json/source/build-scripts/core/persistence/folder.persistence.ts",
            "label": "core/persistence/folder.persistence.ts",
            "markdown": "https://banes-lab.com/source/build-scripts/core/persistence/folder.persistence.ts.md",
            "ref": "anatomy:file-build-scripts-core-persistence-folder-persistence-ts"
          }
        },
        {
          "file": "core/persistence/folder.persistence.ts",
          "name": "pruneEmptyFolders",
          "source": {
            "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-folder-persistence-ts",
            "json": "https://banes-lab.com/json/source/build-scripts/core/persistence/folder.persistence.ts",
            "label": "core/persistence/folder.persistence.ts",
            "markdown": "https://banes-lab.com/source/build-scripts/core/persistence/folder.persistence.ts.md",
            "ref": "anatomy:file-build-scripts-core-persistence-folder-persistence-ts"
          }
        }
      ],
      "callers": [
        {
          "file": "core/persistence/coordination.persistence.ts",
          "name": "supplyCoordination",
          "source": {
            "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-coordination-persistence-ts",
            "json": "https://banes-lab.com/json/source/build-scripts/core/persistence/coordination.persistence.ts",
            "label": "core/persistence/coordination.persistence.ts",
            "markdown": "https://banes-lab.com/source/build-scripts/core/persistence/coordination.persistence.ts.md",
            "ref": "anatomy:file-build-scripts-core-persistence-coordination-persistence-ts"
          }
        }
      ],
      "exported": true,
      "flow": "relay",
      "kind": "lexical_declaration",
      "line": 69,
      "name": "syncFolder",
      "signature": "export const syncFolder = async function syncFolder("
    },
    {
      "callable": true,
      "callees": [],
      "callers": [
        {
          "file": "core/persistence/folder.persistence.ts",
          "name": "syncFolder",
          "source": {
            "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-folder-persistence-ts",
            "json": "https://banes-lab.com/json/source/build-scripts/core/persistence/folder.persistence.ts",
            "label": "core/persistence/folder.persistence.ts",
            "markdown": "https://banes-lab.com/source/build-scripts/core/persistence/folder.persistence.ts.md",
            "ref": "anatomy:file-build-scripts-core-persistence-folder-persistence-ts"
          }
        }
      ],
      "exported": false,
      "flow": "leaf",
      "kind": "lexical_declaration",
      "line": 42,
      "name": "inBatches",
      "signature": "const inBatches = async function inBatches<T>("
    },
    {
      "callable": true,
      "callees": [],
      "callers": [
        {
          "file": "core/persistence/folder.persistence.ts",
          "name": "syncFolder",
          "source": {
            "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-folder-persistence-ts",
            "json": "https://banes-lab.com/json/source/build-scripts/core/persistence/folder.persistence.ts",
            "label": "core/persistence/folder.persistence.ts",
            "markdown": "https://banes-lab.com/source/build-scripts/core/persistence/folder.persistence.ts.md",
            "ref": "anatomy:file-build-scripts-core-persistence-folder-persistence-ts"
          }
        }
      ],
      "exported": false,
      "flow": "leaf",
      "kind": "lexical_declaration",
      "line": 56,
      "name": "pruneEmptyFolders",
      "signature": "const pruneEmptyFolders = async function pruneEmptyFolders(dir: string): Promise<boolean> {"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 7,
      "name": "BATCH",
      "signature": "const BATCH = 64;"
    },
    {
      "callable": true,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 9,
      "name": "admitAll",
      "signature": "const admitAll = function admitAll(): boolean {"
    },
    {
      "callable": true,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 13,
      "name": "filesUnder",
      "signature": "const filesUnder = async function filesUnder("
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 19,
      "name": "nested",
      "signature": "const nested = await Promise.all("
    },
    {
      "callable": true,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 30,
      "name": "differs",
      "signature": "const differs = async function differs(source: string, target: string): Promise<boolean> {"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 34,
      "name": "[from, to]",
      "signature": "const [from, to] = await Promise.all([stat(source), stat(target)]);"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 38,
      "name": "[left, right]",
      "signature": "const [left, right] = await Promise.all([readFile(source), readFile(target)]);"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 46,
      "name": "batches",
      "signature": "const batches = Array.from({ length: Math.ceil(items.length / BATCH) }, (_, index) =>"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 50,
      "name": "done",
      "signature": "const done = await previous;"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 51,
      "name": "results",
      "signature": "const results = await Promise.all(batch.map(each));"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 57,
      "name": "entries",
      "signature": "const entries = await readdir(dir, { withFileTypes: true });"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 58,
      "name": "emptied",
      "signature": "const emptied = await Promise.all("
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 61,
      "name": "left",
      "signature": "const left = entries.length - emptied.filter(Boolean).length;"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 74,
      "name": "wanted",
      "signature": "const wanted = await filesUnder(from, from, admit);"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 75,
      "name": "kept",
      "signature": "const kept = new Set(wanted);"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 76,
      "name": "present",
      "signature": "const present = existsSync(to) ? await filesUnder(to, to, admitAll) : [];"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 77,
      "name": "copied",
      "signature": "const copied = await inBatches(wanted, async (file) => {"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 78,
      "name": "source",
      "signature": "const source = join(from, file);"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 79,
      "name": "target",
      "signature": "const target = join(to, file);"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 87,
      "name": "stale",
      "signature": "const stale = present.filter((file) => !kept.has(file));"
    }
  ],
  "document": null,
  "findings": [],
  "generated": false,
  "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-folder-persistence-ts",
  "language": "typescript",
  "layer": "infrastructure",
  "name": "folder.persistence.ts",
  "path": "core/persistence/folder.persistence.ts",
  "ref": "anatomy:file-build-scripts-core-persistence-folder-persistence-ts",
  "relations": [
    {
      "links": [
        {
          "href": "https://banes-lab.com/anatomy/build-scripts#folder-build-scripts-core-persistence",
          "json": "https://banes-lab.com/json/anatomy/build-scripts/folder-build-scripts-core-persistence",
          "label": "core/persistence",
          "markdown": "https://banes-lab.com/anatomy/build-scripts/folder-build-scripts-core-persistence.md",
          "ref": "chapter:/anatomy/build-scripts#folder-build-scripts-core-persistence"
        }
      ],
      "relation": "contained-in"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-coordination-persistence-ts",
          "json": "https://banes-lab.com/json/source/build-scripts/core/persistence/coordination.persistence.ts",
          "label": "core/persistence/coordination.persistence.ts",
          "markdown": "https://banes-lab.com/source/build-scripts/core/persistence/coordination.persistence.ts.md",
          "ref": "anatomy:file-build-scripts-core-persistence-coordination-persistence-ts"
        }
      ],
      "relation": "used-by"
    },
    {
      "links": [
        {
          "href": "https://banes-lab.com/anatomy/build-scripts#folder-build-scripts-core-persistence",
          "json": "https://banes-lab.com/json/anatomy/build-scripts/folder-build-scripts-core-persistence",
          "label": "core/persistence",
          "markdown": "https://banes-lab.com/anatomy/build-scripts/folder-build-scripts-core-persistence.md",
          "ref": "chapter:/anatomy/build-scripts#folder-build-scripts-core-persistence"
        }
      ],
      "relation": "linked-from"
    }
  ],
  "slots": {
    "concern": "persistence",
    "subject": "folder",
    "variant": null
  },
  "stats": {
    "bytes": 3355,
    "callable": 6,
    "definitions": 23,
    "edges": 2,
    "exported": 8,
    "files": 1,
    "findings": {},
    "flows": {
      "relay": 1,
      "leaf": 2,
      "isolated": 20
    },
    "lines": {
      "blank": 7,
      "code": 89,
      "total": 96
    }
  },
  "summary": "89 lines of code and 23 definitions.",
  "text": "https://banes-lab.com/source/build-scripts/core/persistence/folder.persistence.ts.txt",
  "tree": "build-scripts",
  "siblings": {
    "next": {
      "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-graph-persistence-ts",
      "json": "https://banes-lab.com/json/source/build-scripts/core/persistence/graph.persistence.ts",
      "label": "core/persistence/graph.persistence.ts",
      "markdown": "https://banes-lab.com/source/build-scripts/core/persistence/graph.persistence.ts.md",
      "ref": "anatomy:file-build-scripts-core-persistence-graph-persistence-ts"
    },
    "previous": {
      "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-diagram-persistence-ts",
      "json": "https://banes-lab.com/json/source/build-scripts/core/persistence/diagram.persistence.ts",
      "label": "core/persistence/diagram.persistence.ts",
      "markdown": "https://banes-lab.com/source/build-scripts/core/persistence/diagram.persistence.ts.md",
      "ref": "anatomy:file-build-scripts-core-persistence-diagram-persistence-ts"
    }
  },
  "up": {
    "href": null,
    "json": "https://banes-lab.com/json/api/source/build-scripts/core/persistence",
    "label": "core/persistence",
    "markdown": "https://banes-lab.com/api/source/build-scripts/core/persistence.md",
    "ref": "api:source/build-scripts/core/persistence"
  }
}
