How to use the strtok3.fromStream 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 / src / ogg.ts View on Github external
public parse(tokenizer: strtok3.ITokenizer, options: IOptions): Promise {

    this.tokenizer = tokenizer;
    this.vorbisParser = new VorbisParser();

    this.vorbisStream = new VorbisStream();
    return strtok3.fromStream(this.vorbisStream).then((vorbisTokenizer) => {
      // ToDo: should be provided with level-2 tokenizer
      const vorbis = this.vorbisParser.parse(vorbisTokenizer, options).then((metadata) => {

        if (metadata.format.sampleRate) {
          // Calculate duration
          metadata.format.duration = this.header.absoluteGranulePosition / metadata.format.sampleRate;
        }

        return metadata;
      });

      const ogg = this.parsePage().catch((err) => {
        if (err === StreamReader.EndOfStream) {
          // console.log("EndOfStream: ogg");
          this.vorbisStream.append(null);
        } else throw err;
github Borewit / music-metadata / lib / index.ts View on Github external
export async function parseStream(stream: Stream.Readable, mimeType?: string, options: IOptions = {}): Promise {
  const tokenizer = await strtok3.fromStream(stream);
  return Core.parseFromTokenizer(tokenizer, mimeType, options);
}

strtok3

A promise based streaming tokenizer

MIT
Latest version published 21 days ago

Package Health Score

80 / 100
Full package analysis