@cto.af/pcap-ng-parser
    Preparing search index...

    Class PCAPNGParser

    Parse a PCAPng or old-style PCAP file from a stream.

    import fs from 'node:fs/promises';
    import {PCAPNGParser} from '@cto.af/pcap-ng-parser';

    const parser = new PCAPNGParser();
    parser.on('data', pkt => console.log(pkt.data)); // Uint8Array
    const file = await fs.open('examples/res/myfile.pcapng');
    file.readableWebStream().pipeTo(parser);

    Hierarchy

    • WritableStream<Uint8Array>
      • PCAPNGParser

    Implements

    • EventTarget
    Index

    Constructors

    Properties

    interfaces: Interface[] = []

    Interface information receieved for the current section, in order of reception.

    locked: boolean

    The locked read-only property of the WritableStream interface returns a boolean indicating whether the WritableStream is locked to a writer.

    MDN Reference

    Accessors

    • get ng(): boolean

      Is this file in the pcap-ng format?

      Returns boolean

    Methods

    • The abort() method of the WritableStream interface aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.

      MDN Reference

      Parameters

      • Optionalreason: any

      Returns Promise<void>

    • The close() method of the WritableStream interface closes the associated stream.

      MDN Reference

      Returns Promise<void>

    • The getWriter() method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance.

      MDN Reference

      Returns WritableStreamDefaultWriter<Uint8Array<ArrayBufferLike>>

    • Listen for an event, unwrapping the detailor error in the event so that it is easier to process.

      Type Parameters

      Parameters

      Returns this

      This, for chaining.

    • Listen for the first occurence of a given event. Does the same unwrapping as on.

      Type Parameters

      Parameters

      Returns this

      This, for chaining.