Files
rea/tests/fixtures/artifactClassification.ts

17 lines
575 B
TypeScript
Raw Permalink Normal View History

import { createAsarHeaderSignatureProbe } from "../../src/artifacts/AsarHeader.js";
import { classifyArtifactContent } from "../../src/artifacts/inventory/ArtifactGraphConstruction.js";
/** Observe a supplied byte prefix before assigning an inventory path role. */
export const classifyArtifactBytesAtPath = (
path: string,
bytes: Buffer,
fileSize = bytes.length,
) => {
const probe = createAsarHeaderSignatureProbe();
probe.write(bytes);
return classifyArtifactContent(
path,
{ prefix: bytes, asarHeader: probe.finish(fileSize) },
fileSize,
);
};