MCPcopy
hub / github.com/gildas-lormeau/zip.js / seekSignature

Function seekSignature

index-native.cjs:4271–4291  ·  view source on GitHub ↗
(reader, signature, startOffset, minimumBytes, maximumLength)

Source from the content-addressed store, hash-verified

4269}
4270
4271async function seekSignature(reader, signature, startOffset, minimumBytes, maximumLength) {
4272 const signatureArray = new Uint8Array(4);
4273 const signatureView = getDataView$1(signatureArray);
4274 setUint32$1(signatureView, 0, signature);
4275 const maximumBytes = minimumBytes + maximumLength;
4276 return (await seek(minimumBytes)) || await seek(Math.min(maximumBytes, startOffset));
4277
4278 async function seek(length) {
4279 const offset = startOffset - length;
4280 const bytes = await readUint8Array(reader, offset, length);
4281 for (let indexByte = bytes.length - minimumBytes; indexByte >= 0; indexByte--) {
4282 if (bytes[indexByte] == signatureArray[0] && bytes[indexByte + 1] == signatureArray[1] &&
4283 bytes[indexByte + 2] == signatureArray[2] && bytes[indexByte + 3] == signatureArray[3]) {
4284 return {
4285 offset: offset + indexByte,
4286 buffer: bytes.slice(indexByte, indexByte + minimumBytes).buffer
4287 };
4288 }
4289 }
4290 }
4291}
4292
4293function getOptionValue$1(zipReader, options, name) {
4294 return options[name] === UNDEFINED_VALUE ? zipReader.options[name] : options[name];

Callers 1

getEntriesGeneratorMethod · 0.70

Calls 3

getDataView$1Function · 0.70
setUint32$1Function · 0.70
seekFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…