Class: CancellableReadPromise

CancellableReadPromise()

new CancellableReadPromise()

Promise type returned by read, readTo, and readUntil for cancellable reads.

The returned promise will be an instance of ReadOptions.Promise, if set, which has the additional methods defined for this type.

Note that the method names were chosen to avoid conflict with the existing promise cancellation methods under consideration (e.g. abort, and cancel) since they may gain defined semantics which differ from the methods described here.

Any promises chained from the returned promise (e.g. returned from calling .then()) will not share the methods defined on this class, which prevents abort/cancel authority from being unintentionally conveyed to other consumers of the read data or its dependencies.

@ template ReturnType
Source:

Extends

  • Promise.<ReturnType>

Methods

abortRead()

Aborts a pending read operation, causing the Promise to be rejected. If the read operation is not currently pending, this does nothing.
Source:
See:
  • ReadOptions.cancellable

cancelRead() → {Buffer|string|Array}

Cancels a pending read operation, causing the Promise never to be resolved or rejected. If the read operation is not currently pending, this does nothing.
Source:
See:
  • ReadOptions.cancellable
Returns:
Any previously read data which could not be unshifted, or null if all data was unshifted.
Type
Buffer | string | Array