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

    1.0.0-pre.30 • 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.

    Keywords

    none

    Install

    npm i @esfx/disposable

    DownloadsWeekly Downloads

    2,538

    Version

    1.0.0-pre.30

    License

    Apache-2.0

    Unpacked Size

    183 kB

    Total Files

    40

    Last publish

    Collaborators

    • rbuckton