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.
Muthu Kumar
79125adb66
|
2 years ago | |
---|---|---|
.vscode | 2 years ago | |
.gitignore | 2 years ago | |
LICENSE | 2 years ago | |
README.md | 2 years ago | |
build_npm.ts | 2 years ago | |
index.ts | 2 years ago | |
package.json | 2 years ago | |
test.ts | 2 years ago |
README.md
📤 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!
import promiseObject from "@codefeathers/promise.object";
const resolved = await Promise.object(
Promise.resolve({
foo: Promise.resolve({
bar: Promise.resolve(5)
})
})
);
console.log(resolved);
//-> { foo: { bar: 5 } }
Deno
import promiseObject from "https://deno.land/x/promise_object@v0.10.0";
Credits
The original idea and challenge was from @TRGWII.