disposable.d.ts 624 B

1234567891011121314151617
  1. /**
  2. * A type which requires manual disposal to free unmanaged resources. In the
  3. * context of this library, this usually means freeing memory from WebAssembly
  4. * code.
  5. */
  6. export interface IDisposable {
  7. /**
  8. * Frees unmanaged resources of the object. This method is idempotent;
  9. * calling it multiple times will have no ill effects.
  10. */
  11. dispose(): void;
  12. }
  13. /**
  14. * A helper function that calls `.dispose()` on the {@link IDisposable} when
  15. * the given function (or promise returned by the function) returns.
  16. */
  17. export declare const using: <T, D extends IDisposable>(disposable: D, fn: (d: D) => T) => T;