{
  "definitions": [
    {
      "callable": false,
      "callees": [],
      "callers": [
        {
          "file": "core/persistence/text.persistence.ts",
          "name": "brotliOf",
          "source": {
            "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-text-persistence-ts",
            "json": "https://banes-lab.com/json/source/build-scripts/core/persistence/text.persistence.ts",
            "label": "core/persistence/text.persistence.ts",
            "markdown": "https://banes-lab.com/source/build-scripts/core/persistence/text.persistence.ts.md",
            "ref": "anatomy:file-build-scripts-core-persistence-text-persistence-ts"
          }
        }
      ],
      "exported": false,
      "flow": "leaf",
      "kind": "lexical_declaration",
      "line": 17,
      "name": "compress",
      "signature": "const compress = promisify(brotliCompress);"
    },
    {
      "callable": true,
      "callees": [],
      "callers": [
        {
          "file": "core/steps/text.step.ts",
          "name": "run",
          "source": {
            "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-steps-text-step-ts",
            "json": "https://banes-lab.com/json/source/build-scripts/core/steps/text.step.ts",
            "label": "core/steps/text.step.ts",
            "markdown": "https://banes-lab.com/source/build-scripts/core/steps/text.step.ts.md",
            "ref": "anatomy:file-build-scripts-core-steps-text-step-ts"
          }
        }
      ],
      "exported": true,
      "flow": "leaf",
      "kind": "lexical_declaration",
      "line": 72,
      "name": "precompressText",
      "signature": "export const precompressText = async function precompressText(outDir: string, cache: string): Promise<TextCompression> {"
    },
    {
      "callable": true,
      "callees": [
        {
          "file": "core/persistence/text.persistence.ts",
          "name": "compress",
          "source": {
            "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-text-persistence-ts",
            "json": "https://banes-lab.com/json/source/build-scripts/core/persistence/text.persistence.ts",
            "label": "core/persistence/text.persistence.ts",
            "markdown": "https://banes-lab.com/source/build-scripts/core/persistence/text.persistence.ts.md",
            "ref": "anatomy:file-build-scripts-core-persistence-text-persistence-ts"
          }
        }
      ],
      "callers": [],
      "exported": false,
      "flow": "entry",
      "kind": "lexical_declaration",
      "line": 24,
      "name": "brotliOf",
      "signature": "const brotliOf = async function brotliOf(bytes: Buffer): Promise<Buffer> {"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 16,
      "name": "BATCH",
      "signature": "const BATCH = 32;"
    },
    {
      "callable": true,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 19,
      "name": "isPrecompressible",
      "signature": "export const isPrecompressible = function isPrecompressible(file: string, present: ReadonlySet<string>): boolean {"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 20,
      "name": "extension",
      "signature": "const extension = extensionOf(file);"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "type_alias_declaration",
      "line": 34,
      "name": "Outcome",
      "signature": "type Outcome = \"compressed\" | \"reused\" | \"skipped\";"
    },
    {
      "callable": true,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 36,
      "name": "ensureCached",
      "signature": "const ensureCached = async function ensureCached("
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 41,
      "name": "held",
      "signature": "const held = prepared.get(cached);"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 46,
      "name": "job",
      "signature": "const job = existsSync(cached)"
    },
    {
      "callable": true,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 56,
      "name": "siblingOf",
      "signature": "const siblingOf = async function siblingOf("
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 62,
      "name": "bytes",
      "signature": "const bytes = await readFile(join(outDir, file));"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 66,
      "name": "cached",
      "signature": "const cached = join(cache, digestOf(bytes) + BROTLI_EXTENSION);"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": false,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 67,
      "name": "fresh",
      "signature": "const fresh = await ensureCached(cached, bytes, prepared);"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 74,
      "name": "files",
      "signature": "const files = walk(outDir, outDir);"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 75,
      "name": "present",
      "signature": "const present = new Set(files);"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 76,
      "name": "targets",
      "signature": "const targets = files.filter((file) => isPrecompressible(file, present));"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 77,
      "name": "prepared",
      "signature": "const prepared = new Map<string, Promise<boolean>>();"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 78,
      "name": "batches",
      "signature": "const batches = Array.from({ length: Math.ceil(targets.length / BATCH) }, (_, index) =>"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 81,
      "name": "counts",
      "signature": "const counts = await batches.reduce<Promise<TextCompression>>("
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 83,
      "name": "done",
      "signature": "const done = await previous;"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 84,
      "name": "outcomes",
      "signature": "const outcomes = await Promise.all(batch.map(async (file) => siblingOf(outDir, file, cache, prepared)));"
    },
    {
      "callable": false,
      "callees": [],
      "callers": [],
      "exported": true,
      "flow": "isolated",
      "kind": "lexical_declaration",
      "line": 92,
      "name": "stale",
      "signature": "const stale = (await readdir(cache)).map((name) => join(cache, name)).filter((path) => !prepared.has(path));"
    }
  ],
  "document": null,
  "findings": [],
  "generated": false,
  "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-text-persistence-ts",
  "language": "typescript",
  "layer": "infrastructure",
  "name": "text.persistence.ts",
  "path": "core/persistence/text.persistence.ts",
  "ref": "anatomy:file-build-scripts-core-persistence-text-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-steps-text-step-ts",
          "json": "https://banes-lab.com/json/source/build-scripts/core/steps/text.step.ts",
          "label": "core/steps/text.step.ts",
          "markdown": "https://banes-lab.com/source/build-scripts/core/steps/text.step.ts.md",
          "ref": "anatomy:file-build-scripts-core-steps-text-step-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"
        },
        {
          "href": "https://banes-lab.com/anatomy/build-scripts#folder-build-scripts-core-steps",
          "json": "https://banes-lab.com/json/anatomy/build-scripts/folder-build-scripts-core-steps",
          "label": "core/steps",
          "markdown": "https://banes-lab.com/anatomy/build-scripts/folder-build-scripts-core-steps.md",
          "ref": "chapter:/anatomy/build-scripts#folder-build-scripts-core-steps"
        }
      ],
      "relation": "linked-from"
    }
  ],
  "slots": {
    "concern": "persistence",
    "subject": "text",
    "variant": null
  },
  "stats": {
    "bytes": 3732,
    "callable": 5,
    "definitions": 23,
    "edges": 1,
    "exported": 12,
    "files": 1,
    "findings": {},
    "flows": {
      "leaf": 2,
      "entry": 1,
      "isolated": 20
    },
    "lines": {
      "blank": 7,
      "code": 88,
      "total": 95
    }
  },
  "summary": "88 lines of code and 23 definitions.",
  "text": "https://banes-lab.com/source/build-scripts/core/persistence/text.persistence.ts.txt",
  "tree": "build-scripts",
  "siblings": {
    "next": {
      "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-tree-persistence-ts",
      "json": "https://banes-lab.com/json/source/build-scripts/core/persistence/tree.persistence.ts",
      "label": "core/persistence/tree.persistence.ts",
      "markdown": "https://banes-lab.com/source/build-scripts/core/persistence/tree.persistence.ts.md",
      "ref": "anatomy:file-build-scripts-core-persistence-tree-persistence-ts"
    },
    "previous": {
      "href": "https://banes-lab.com/anatomy/build-scripts#file-build-scripts-core-persistence-tab-persistence-ts",
      "json": "https://banes-lab.com/json/source/build-scripts/core/persistence/tab.persistence.ts",
      "label": "core/persistence/tab.persistence.ts",
      "markdown": "https://banes-lab.com/source/build-scripts/core/persistence/tab.persistence.ts.md",
      "ref": "anatomy:file-build-scripts-core-persistence-tab-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"
  }
}
