Skip to content

@alex.garcia/libfec / coverEnd

Function: coverEnd() ​

coverEnd(prefix): number | null

Defined in: header.ts:101

How many bytes at the start of prefix settle the filing's header and cover, or null while they could still depend on bytes after prefix. For streaming: download until this isn't null, then open that much. Bytes after it can't change the header, cover or cover record, or the error opening the filing raises; an F99's [BEGINTEXT] block counts as part of its cover.

ts
let buf = new Uint8Array(0);
for await (const chunk of response.body) {
  buf = concat(buf, chunk);
  const n = coverEnd(buf);
  if (n !== null) return new Filing(buf.subarray(0, n)); // and cancel the download
}
return new Filing(buf); // the whole file: whatever it has

A Filing opened on the prefix is an ordinary Filing over those bytes: its sourceLength is n, and its itemizations are just the complete rows before n, if any.

Parameters ​

prefix ​

ArrayBuffer | Uint8Array<ArrayBufferLike>

Returns ​

number | null