1.0.1 • Published 2 years ago

deasync-obj v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

deasync-obj

transforms object with promises values to object with resolved values.

Installation

npm install deasync-obj

(typescript ready, no need for @types/deasync-obj :))

Example

import { deasyncObj } from 'deasync-obj';

async function main() {
    const obj = {
        foo: {
            bar: Promise.resolve(5),
            baz: [6, Promise.resolve(7)]
        }
    };

    deasyncObj(obj).then(() => {
        console.log(obj);
    });


}

main();

This will print:

{ foo: { bar: 5, baz: [6, 7] } }