@tsdotnet/disposable - v2.0.1
    Preparing search index...

    Function dispose

    • Disposes multiple disposable objects, throwing any exceptions that occur during disposal.

      This is the main disposal function that takes a variable number of disposable objects and calls their dispose methods. Any exceptions thrown during disposal will propagate to the caller.

      Parameters

      • ...disposables: DisposableItem[]

        The objects to dispose of. Can accept any type and will safely ignore objects that don't have a dispose() method or are null/undefined.

      Returns void

      Any exception thrown by the dispose() methods of the objects.

      const resource1 = new DatabaseConnection();
      const resource2 = new FileStream();

      // Dispose multiple resources at once
      dispose(resource1, resource2, null); // null is safely ignored