Promise.object
is Promise.all
for objects, and it traverses deeply! It's also fully typed.
npm install --save @codefeathers/promise.object
import promiseObject from "@codefeathers/promise.object";
const resolved = await promiseObject({
foo: Promise.resolve(5),
bar: {
baz: Promise.resolve([ 1, 2, 3 ])
}
});
console.log(resolved);
//-> { foo: 5, bar: { baz: [ 1, 2, 3 ] } }
We need to go deeper!
import promiseObject from "@codefeathers/promise.object";
const resolved = await promiseObject(
Promise.resolve({
foo: Promise.resolve({
bar: Promise.resolve(5)
})
})
);
console.log(resolved);
//-> { foo: { bar: 5 } }
import promiseObject from "https://deno.land/x/promise_object@v0.10.0";
The original idea and challenge was from @TRGWII.