How to use the strtok3.fromFile 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 / test / test-id3v2.3.ts View on Github external
it('should parse a raw ID3v2.3 header', () => {

    const filePath = path.join(samplePath, 'MusicBrainz - Beth Hart - Sinner\'s Prayer.id3v23');

    const metadata = new MetadataCollector({});

    return strtok.fromFile(filePath).then(tokenizer => {
      return new ID3v2Parser().parse(metadata, tokenizer, {}).then(() => {

        assert.strictEqual(33, metadata.native['ID3v2.3'].length);

        const id3v23 = mm.orderTags(metadata.native['ID3v2.3']);
        assert.isDefined(id3v23.UFID, 'check if ID3v2.3-UFID is set');
      });
    });
  });
github Borewit / music-metadata / lib / index.ts View on Github external
export async function parseFile(filePath: string, options: IOptions = {}): Promise {

  debug(`parseFile: ${filePath}`);

  const fileTokenizer = await strtok3.fromFile(filePath);

  const fileReader = new RandomFileReader(filePath, fileTokenizer.fileSize);
  try {
    await Core.scanAppendingHeaders(fileReader, options);
  } finally {
    fileReader.close();
  }

  try {
    const parserName = ParserFactory.getParserIdForExtension(filePath);
    if (!parserName)
      debug(' Parser could not be determined by file extension');

    return await ParserFactory.parse(fileTokenizer, parserName, options);
  } finally {
    await fileTokenizer.close();

strtok3

A promise based streaming tokenizer

MIT
Latest version published 1 month ago

Package Health Score

80 / 100
Full package analysis