mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 19:53:50 +00:00
19 lines
615 B
TypeScript
19 lines
615 B
TypeScript
import { classifyArtifactContent } from "../../src/artifacts/inventory/ArtifactGraphConstruction.js";
|
|
import { createAsarHeaderSignatureProbe } from "../../src/resources/index.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);
|
|
const { kind, format } = classifyArtifactContent(
|
|
path,
|
|
{ prefix: bytes, asarHeader: probe.finish(fileSize) },
|
|
fileSize,
|
|
);
|
|
return { kind, format };
|
|
};
|