UNPKG

@eagleoutice/flowr-dev

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

28 lines 1.4 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.encodeIndex = encodeIndex; exports.decodeIndex = decodeIndex; exports.readSigDbIndex = readSigDbIndex; /** * The sidecar `.idx` index format: the byte ranges a reader seeks to (dictionary + per-package blob) plus the * package routing/metadata, and its compact on-disk (wire) form. Split out of `../sigdb` so the reader/writer * there does not carry the index encoding. */ const fs_1 = __importDefault(require("fs")); /** encode an index to its compact on-disk form; omit `meta` when it is hoisted elsewhere (a manifest) */ function encodeIndex(i, withMeta = true) { return { n: i.byteCount, d: i.dict, b: i.blobs, p: i.pkgs, ...(withMeta ? { m: i.meta } : {}) }; } /** decode a compact index; `meta` falls back to a hoisted map, and `dict` to empty (a blob-only shard) */ function decodeIndex(w, meta) { const full = w; return { byteCount: w.n, dict: full.d ?? [0, 0], blobs: w.b, pkgs: w.p, meta: full.m ?? meta ?? {} }; } /** read a plain bundle's sidecar `.idx` file and decode it */ function readSigDbIndex(plainFile) { return decodeIndex(JSON.parse(fs_1.default.readFileSync(`${plainFile}.idx`, 'utf8'))); } //# sourceMappingURL=index-format.js.map