How to use the strtok3/lib/core.fromBuffer function in strtok3

To help you get started, we’ve selected a few strtok3 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Borewit / music-metadata / lib / apev2 / APEv2Parser.ts View on Github external
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);
  }
github Borewit / music-metadata / lib / apev2 / APEv2Parser.ts View on Github external
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);
  }
github sindresorhus / file-type / core.js View on Github external
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);
}
github Borewit / music-metadata / lib / core.ts View on Github external
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);
}

strtok3

A promise based streaming tokenizer

MIT
Latest version published 1 month ago

Package Health Score

80 / 100
Full package analysis