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.
const resource1 = new DatabaseConnection();
const resource2 = new FileStream();
// Dispose multiple resources at once
dispose(resource1, resource2, null); // null is safely ignored
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.