You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
868 B
868 B
📤 Promise.object
Promise.object
is Promise.all
for objects, and it traverses deeply! It's also fully typed.
Installation
npm install --save @codefeathers/promise.object
Usage
import { promiseObject } from "@codefeathers/promise.object";
// --
const resolved = await Promise.object({
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!
Promise.object = require('@codefeathers/promise.object');
const { log } = console;
// --
const resolved = await Promise.object(
Promise.resolve({
foo: Promise.resolve({
bar: Promise.resolve(5)
})
})
);
console.log(resolved);
//-> { foo: { bar: 5 } }
Credits
The original idea and challenge was from @TRGWII.