Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private static parseTagFooter(metadata: INativeMetadataCollector, buffer: Buffer, options: IOptions): Promise {
const footer = TagFooter.get(buffer, buffer.length - TagFooter.len);
assert.strictEqual(footer.ID, preamble, 'APEv2 Footer preamble');
strtok3.fromBuffer(buffer);
const apeParser = new APEv2Parser();
apeParser.init(metadata, strtok3.fromBuffer(buffer), options);
return apeParser.parseTags(footer);
}
private static parseTagFooter(metadata: INativeMetadataCollector, buffer: Buffer, options: IOptions): Promise {
const footer = TagFooter.get(buffer, buffer.length - TagFooter.len);
assert.strictEqual(footer.ID, preamble, 'APEv2 Footer preamble');
strtok3.fromBuffer(buffer);
const apeParser = new APEv2Parser();
apeParser.init(metadata, strtok3.fromBuffer(buffer), options);
return apeParser.parseTags(footer);
}
function fromBuffer(input) {
if (!(input instanceof Uint8Array || input instanceof ArrayBuffer || Buffer.isBuffer(input))) {
throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`Buffer\` or \`ArrayBuffer\`, got \`${typeof input}\``);
}
const buffer = input instanceof Buffer ? input : Buffer.from(input);
if (!(buffer && buffer.length > 1)) {
return;
}
const tokenizer = strtok3.fromBuffer(buffer);
return fromTokenizer(tokenizer);
}
export async function parseBuffer(buf: Buffer, mimeType?: string, options: IOptions = {}): Promise {
const bufferReader = new RandomBufferReader(buf);
await scanAppendingHeaders(bufferReader, options);
const tokenizer = strtok3.fromBuffer(buf);
return parseFromTokenizer(tokenizer, mimeType, options);
}