@esfx/disposable
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@esfx/disposable

The @esfx/disposable package provides a low-level API for defining explicit resource management that third-party libraries can use to interoperate.

Overview

Installation

npm i @esfx/disposable

Usage

import { Disposable } from "@esfx/disposable";

class MyFileResouce {
    constructor() {
        this.handle = fs.openSync("path/to/file");
    }

    close() {
        fs.closeSync(this.handle);
        this.handle = undefined;
    }

    // provide low-level 'dispose' primitive for interop
    [Disposable.dispose]() {
        this.close();
    }
}

API

You can read more about the API here.

Readme

Keywords

none

Package Sidebar

Install

npm i @esfx/disposable

Weekly Downloads

13,216

Version

1.0.0

License

Apache-2.0

Unpacked Size

239 kB

Total Files

34

Last publish

Collaborators

  • rbuckton