tar
    Preparing search index...

    Class Pack

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    "[ABORTED]": boolean
    "[ASYNC]": boolean
    "[BUFFER]": Buffer<ArrayBufferLike>[]
    "[BUFFERLENGTH]": number
    "[CLOSED]": boolean
    "[DATALISTENERS]": number
    "[DECODER]": SD | null
    "[DESTROYED]": boolean
    "[DISCARDED]": boolean
    "[EMITTED_END]": boolean
    "[EMITTED_ERROR]": unknown
    "[EMITTING_END]": boolean
    "[ENCODING]": BufferEncoding | null
    "[ENDED]": boolean = false
    "[EOF]": boolean
    "[FLOWING]": boolean
    "[JOBS]": number = 0
    "[OBJECTMODE]": boolean
    "[PAUSED]": boolean
    "[PIPES]": Pipe<Buffer<ArrayBufferLike>>[]
    "[PROCESSING]": boolean = false
    "[QUEUE]": Yallist<PackJob>
    "[SIGNAL]"?: AbortSignal
    "[WRITEENTRYCLASS]": typeof WriteEntry | typeof WriteEntrySync
    cwd: string
    file: string
    filter: (path: string, entry: ReadEntry | Stats) => boolean
    follow: boolean
    jobs: number
    linkCache: Map<`${number}:${number}`, string>
    maxReadSize?: number
    mtime?: Date
    noDirRecurse: boolean
    noMtime: boolean
    noPax: boolean
    onWriteEntry?: (entry: WriteEntry) => void
    portable: boolean
    prefix: string
    preservePaths: boolean
    readable: boolean

    true if the stream can be read

    readdirCache: Map<string, string[]>
    statCache: Map<string, Stats>
    strict: boolean
    sync: boolean = false
    writable: boolean

    true if the stream can be written

    zip?: BrotliCompress | Gzip | ZstdCompress

    Accessors

    • get aborted(): boolean

      True if the stream has been aborted.

      Returns boolean

    • set aborted(_: boolean): void

      No-op setter. Stream aborted status is set via the AbortSignal provided in the constructor options.

      Parameters

      • _: boolean

      Returns void

    • get async(): boolean

      true if this is an async stream

      Returns boolean

    • set async(a: boolean): void

      Set to true to make this stream async.

      Once set, it cannot be unset, as this would potentially cause incorrect behavior. Ie, a sync stream can be made async, but an async stream cannot be safely made sync.

      Parameters

      • a: boolean

      Returns void

    • get bufferLength(): number

      The amount of data stored in the buffer waiting to be read.

      For Buffer strings, this will be the total byte length. For string encoding streams, this will be the string character length, according to JavaScript's string.length logic. For objectMode streams, this is a count of the items waiting to be emitted.

      Returns number

    • get destroyed(): boolean

      true if the stream has been forcibly destroyed

      Returns boolean

    • get emittedEnd(): boolean

      true if the 'end' event has been emitted

      Returns boolean

    • get encoding(): BufferEncoding | null

      The BufferEncoding currently in use, or null

      Returns BufferEncoding | null

    • set encoding(_enc: BufferEncoding | null): void

      Parameters

      • _enc: BufferEncoding | null

      Returns void

      • This is a read only property
    • get flowing(): boolean

      true if the stream is currently in a flowing state, meaning that any writes will be immediately emitted.

      Returns boolean

    • get objectMode(): boolean

      True if this is an objectMode stream

      Returns boolean

    • set objectMode(_om: boolean): void

      Parameters

      • _om: boolean

      Returns void

      • This is a read-only property
    • get paused(): boolean

      true if the stream is currently in a paused state

      Returns boolean

    • get isStream(): (
          s: any,
      ) => s is
          | Minipass<any, any, any>
          | WriteStream
          | ReadStream
          | ReadStream & { fd: number }
          | EventEmitter<any> & {
              pause(): any;
              pipe(...destArgs: any[]): any;
              resume(): any;
          }
          | WriteStream & { fd: number }
          | EventEmitter<any> & {
              end(): any;
              write(chunk: any, ...args: any[]): any;
          }

      Alias for isStream

      Former export location, maintained for backwards compatibility.

      Returns (
          s: any,
      ) => s is
          | Minipass<any, any, any>
          | WriteStream
          | ReadStream
          | ReadStream & { fd: number }
          | EventEmitter<any> & {
              pause(): any;
              pipe(...destArgs: any[]): any;
              resume(): any;
          }
          | WriteStream & { fd: number }
          | EventEmitter<any> & {
              end(): any;
              write(chunk: any, ...args: any[]): any;
          }

    Methods

    • Returns void

    • Parameters

      • p: string

      Returns void

    • Asynchronous for await of iteration.

      This will continue emitting all chunks until the stream terminates.

      Returns AsyncGenerator<Buffer<ArrayBufferLike>, void, void>

    • Parameters

      • chunk: Buffer

      Returns void

    • Returns Buffer

    • The Symbol.for('nodejs.rejection') method is called in case a promise rejection happens when emitting an event and captureRejections is enabled on the emitter. It is possible to use events.captureRejectionSymbol in place of Symbol.for('nodejs.rejection').

      import { EventEmitter, captureRejectionSymbol } from 'node:events';

      class MyClass extends EventEmitter {
      constructor() {
      super({ captureRejections: true });
      }

      [captureRejectionSymbol](err, event, ...args) {
      console.log('rejection happened for', event, 'with', err, ...args);
      this.destroy(err);
      }

      destroy(err) {
      // Tear the resource down here.
      }
      }

      Parameters

      • error: Error
      • event: string | symbol
      • ...args: any[]

      Returns void

      v13.4.0, v12.16.0

    • Parameters

      • data: Buffer

      Returns boolean

    • Returns boolean

    • Returns boolean

    [ENTRY]

    • Parameters

      • OptionalnoDrain: boolean

      Returns void

    • Parameters

      • chunk: Buffer

      Returns boolean

    • Synchronous for of iteration.

      The iteration will terminate when the internal buffer runs out, even if the stream has not yet terminated.

      Returns Generator<Buffer<ArrayBufferLike>, void, void>

    • Returns void

    • Parameters

      • n: number | null
      • chunk: Buffer

      Returns Buffer

    • Returns void

    • Parameters

      • chunk: Buffer

      Returns boolean

    • Alias for Minipass#on

      Type Parameters

      • Event extends keyof Events<Buffer<ArrayBufferLike>>

      Parameters

      Returns this

    • Return a Promise that resolves to an array of all emitted data once the stream ends.

      Returns Promise<Buffer<ArrayBufferLike>[] & { dataLength: number }>

    • Return a Promise that resolves to the concatenation of all emitted data once the stream ends.

      Not allowed on objectMode streams.

      Returns Promise<Buffer<ArrayBufferLike>>

    • Destroy a stream, preventing it from being used for any further purpose.

      If the stream has a close() method, then it will be called on destruction.

      After destruction, any attempt to write data, read data, or emit most events will be ignored.

      If an error argument is provided, then it will be emitted in an 'error' event.

      Parameters

      • Optionaler: unknown

      Returns this

    • Mostly identical to EventEmitter.emit, with the following behavior differences to prevent data loss and unnecessary hangs:

      If the stream has been destroyed, and the event is something other than 'close' or 'error', then false is returned and no handlers are called.

      If the event is 'end', and has already been emitted, then the event is ignored. If the stream is in a paused or non-flowing state, then the event will be deferred until data flow resumes. If the stream is async, then handlers will be called on the next tick rather than immediately.

      If the event is 'close', and 'end' has not yet been emitted, then the event will be deferred until after 'end' is emitted.

      If the event is 'error', and an AbortSignal was provided for the stream, and there are no listeners, then the event is ignored, matching the behavior of node core streams in the presense of an AbortSignal.

      If the event is 'finish' or 'prefinish', then all listeners will be removed after emitting the event, to prevent double-firing.

      Type Parameters

      • Event extends keyof Events<Buffer<ArrayBufferLike>>

      Parameters

      Returns boolean

    • End the stream, optionally providing a final write.

      See Minipass#write for argument descriptions

      Parameters

      • Optionalcb: () => void

      Returns this

    • Parameters

      • path: string | ReadEntry
      • Optionalcb: () => void

      Returns this

    • Parameters

      • path: string | ReadEntry
      • Optionalencoding: Encoding
      • Optionalcb: () => void

      Returns this

    • Returns an array listing the events for which the emitter has registered listeners.

      import { EventEmitter } from 'node:events';

      const myEE = new EventEmitter();
      myEE.on('foo', () => {});
      myEE.on('bar', () => {});

      const sym = Symbol('symbol');
      myEE.on(sym, () => {});

      console.log(myEE.eventNames());
      // Prints: [ 'foo', 'bar', Symbol(symbol) ]

      Returns (string | symbol)[]

      v6.0.0

    • Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to events.defaultMaxListeners.

      Returns number

      v1.0.0

    • Returns the number of listeners listening for the event named eventName. If listener is provided, it will return how many times the listener is found in the list of the listeners of the event.

      Type Parameters

      • E extends string | symbol

      Parameters

      • eventName: string | symbol

        The name of the event being listened for

      • Optionallistener: (...args: any[]) => void

        The event handler function

      Returns number

      v3.2.0

    • Returns a copy of the array of listeners for the event named eventName.

      server.on('connection', (stream) => {
      console.log('someone connected!');
      });
      console.log(util.inspect(server.listeners('connection')));
      // Prints: [ [Function] ]

      Type Parameters

      • E extends string | symbol

      Parameters

      • eventName: string | symbol

      Returns ((...args: any[]) => void)[]

      v0.1.26

    • Mostly identical to EventEmitter.off

      If a 'data' event handler is removed, and it was the last consumer (ie, there are no pipe destinations or other 'data' event listeners), then the flow of data will stop until there is another consumer or Minipass#resume is explicitly called.

      Type Parameters

      • Event extends keyof Events<Buffer<ArrayBufferLike>>

      Parameters

      Returns this

    • Mostly identical to EventEmitter.on, with the following behavior differences to prevent data loss and unnecessary hangs:

      • Adding a 'data' event handler will trigger the flow of data

      • Adding a 'readable' event handler when there is data waiting to be read will cause 'readable' to be emitted immediately.

      • Adding an 'endish' event handler ('end', 'finish', etc.) which has already passed will cause the event to be emitted immediately and all handlers removed.

      • Adding an 'error' event handler after an error has been emitted will cause the event to be re-emitted immediately with the error previously raised.

      Type Parameters

      • Event extends keyof Events<Buffer<ArrayBufferLike>>

      Parameters

      Returns this

    • Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

      server.once('connection', (stream) => {
      console.log('Ah, we have our first user!');
      });

      Returns a reference to the EventEmitter, so that calls can be chained.

      By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

      import { EventEmitter } from 'node:events';
      const myEE = new EventEmitter();
      myEE.once('foo', () => console.log('a'));
      myEE.prependOnceListener('foo', () => console.log('b'));
      myEE.emit('foo');
      // Prints:
      // b
      // a

      Type Parameters

      • E extends string | symbol

      Parameters

      • eventName: string | symbol

        The name of the event.

      • listener: (...args: any[]) => void

        The callback function

      Returns this

      v0.3.0

    • Pause the stream

      Returns void

    • Pipe all data emitted by this stream into the destination provided.

      Triggers the flow of data.

      Type Parameters

      • W extends Writable

      Parameters

      • dest: W
      • Optionalopts: PipeOptions

      Returns W

    • Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

      server.prependListener('connection', (stream) => {
      console.log('someone connected!');
      });

      Returns a reference to the EventEmitter, so that calls can be chained.

      Type Parameters

      • E extends string | symbol

      Parameters

      • eventName: string | symbol

        The name of the event.

      • listener: (...args: any[]) => void

        The callback function

      Returns this

      v6.0.0

    • Adds a one-time listener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.

      server.prependOnceListener('connection', (stream) => {
      console.log('Ah, we have our first user!');
      });

      Returns a reference to the EventEmitter, so that calls can be chained.

      Type Parameters

      • E extends string | symbol

      Parameters

      • eventName: string | symbol

        The name of the event.

      • listener: (...args: any[]) => void

        The callback function

      Returns this

      v6.0.0

    • Return a void Promise that resolves once the stream ends.

      Returns Promise<void>

    • Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).

      import { EventEmitter } from 'node:events';
      const emitter = new EventEmitter();
      emitter.once('log', () => console.log('log once'));

      // Returns a new Array with a function `onceWrapper` which has a property
      // `listener` which contains the original listener bound above
      const listeners = emitter.rawListeners('log');
      const logFnWrapper = listeners[0];

      // Logs "log once" to the console and does not unbind the `once` event
      logFnWrapper.listener();

      // Logs "log once" to the console and removes the listener
      logFnWrapper();

      emitter.on('log', () => console.log('log persistently'));
      // Will return a new Array with a single function bound by `.on()` above
      const newListeners = emitter.rawListeners('log');

      // Logs "log persistently" twice
      newListeners[0]();
      emitter.emit('log');

      Type Parameters

      • E extends string | symbol

      Parameters

      • eventName: string | symbol

      Returns ((...args: any[]) => void)[]

      v9.4.0

    • Low-level explicit read method.

      In objectMode, the argument is ignored, and one item is returned if available.

      n is the number of bytes (or in the case of encoding streams, characters) to consume. If n is not provided, then the entire buffer is returned, or null is returned if no data is available.

      If n is greater that the amount of data in the internal buffer, then null is returned.

      Parameters

      • Optionaln: number | null

      Returns Buffer<ArrayBufferLike> | null

    • Mostly identical to EventEmitter.removeAllListeners

      If all 'data' event handlers are removed, and they were the last consumer (ie, there are no pipe destinations), then the flow of data will stop until there is another consumer or Minipass#resume is explicitly called.

      Type Parameters

      • Event extends keyof Events<Buffer<ArrayBufferLike>>

      Parameters

      Returns this

    • Alias for Minipass#off

      Type Parameters

      • Event extends keyof Events<Buffer<ArrayBufferLike>>

      Parameters

      Returns this

    • Resume the stream if it is currently in a paused state

      If called when there are no pipe destinations or data event listeners, this will place the stream in a "discarded" state, where all data will be thrown away. The discarded state is removed if a pipe destination or data handler is added, if pause() is called, or if any synchronous or asynchronous iteration is started.

      Returns void

    • Parameters

      • _enc: Encoding

      Returns void

      • Encoding may only be set at instantiation time
    • By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.

      Returns a reference to the EventEmitter, so that calls can be chained.

      Parameters

      • n: number

      Returns this

      v0.3.5

    • Fully unhook a piped destination stream.

      If the destination stream was the only consumer of this stream (ie, there are no other piped destinations or 'data' event listeners) then the flow of data will stop until there is another consumer or Minipass#resume is explicitly called.

      Type Parameters

      • W extends Writable

      Parameters

      • dest: W

      Returns void

    • Parameters

      • code: string
      • message: string | Error
      • data: WarnData = {}

      Returns void

    • Write data into the stream

      If the chunk written is a string, and encoding is not specified, then utf8 will be assumed. If the stream encoding matches the encoding of a written string, and the state of the string decoder allows it, then the string will be passed through to either the output or the internal buffer without any processing. Otherwise, it will be turned into a Buffer object for processing into the desired encoding.

      If provided, cb function is called immediately before return for sync streams, or on next tick for async streams, because for this base class, a chunk is considered "processed" once it is accepted and either emitted or buffered. That is, the callback does not indicate that the chunk has been eventually emitted, though of course child classes can override this function to do whatever processing is required and call super.write(...) only once processing is completed.

      Parameters

      Returns boolean