Skip to content
/ defer Public

A package that allows you to defer the execution of a particular instruction at the end of the function's execution.

Notifications You must be signed in to change notification settings

j4ndrw/defer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Defer

A package that allows you to defer the execution of a particular instruction at the end of the function's execution.

Example usage

import { deferred } from '@j4ndrw/defer';

const file = ...; // imagine this is a file object with read, write, open and close methods

async function main() {
    const content = await deferred(async ({ defer }) => {
        await file.open();
        defer(async () => file.close());

        file.write("This is some text");
        return file.read();
    })
}

main();

About

A package that allows you to defer the execution of a particular instruction at the end of the function's execution.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published