Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/feathers-studio/promise.object

📤 Deep resolve promises in objects.
https://github.com/feathers-studio/promise.object

deep-resolve object promise promise-a-plus

Last synced: about 16 hours ago
JSON representation

📤 Deep resolve promises in objects.

Awesome Lists containing this project

README

        

# 📤 Promise.object

`Promise.object` is `Promise.all` for objects, and it traverses deeply! It's also fully typed.

## Installation

```shell
npm install --save @codefeathers/promise.object
```

## Usage

```TS
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_!

```JavaScript
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 } }
```

## Deno

```TS
import promiseObject from "https://deno.land/x/[email protected]";
```

## Credits

The original idea and challenge was from [@TRGWII](https://github.com/TRGWII).