@stu43005/defer
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

Defer

NPM

Install

Using npm:

npm install @stu43005/defer

Usage

import Defer from '@stu43005/defer';
import * as fs from 'fs';

async function main() {
    const defer = new Defer();
    try {
        const fd = await fs.open('someFile.txt');
        defer.defer(() => fs.close(fd));
        // ...
        // some actions with file
    } catch (error) {
        console.error(error);
    } finally {
        await defer;
    }
}
main();

License

MIT

/@stu43005/defer/

    Package Sidebar

    Install

    npm i @stu43005/defer

    Weekly Downloads

    0

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    5.39 kB

    Total Files

    6

    Last publish

    Collaborators

    • stu43005