Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/junosuarez/resolved
npm module: a promises/a compliant `when`, but for objects instead of arrays
https://github.com/junosuarez/resolved
Last synced: 8 days ago
JSON representation
npm module: a promises/a compliant `when`, but for objects instead of arrays
- Host: GitHub
- URL: https://github.com/junosuarez/resolved
- Owner: junosuarez
- Created: 2012-12-14T12:15:45.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-04-28T23:22:26.000Z (over 9 years ago)
- Last Synced: 2024-04-23T10:35:13.123Z (7 months ago)
- Language: JavaScript
- Size: 180 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# resolved
Like Promise.all but for ObjectsIf your friends ask, this is why Promises are cool: they're objects that you can pass around and do things to while you're waiting for their promised values. With `resolved`, you can embed promises in other objects and then get the aggregate resolved value.
This is similar to the function `when`, which takes an array of promises and returns a promise for an array of all of the resolved values. `resolved` does the same, but for objects instead of arrays.
## installation
```console
$ npm install resolved
```## usage
```js
var resolved = require('resolved')var obj = {
a: 'a regular value',
b: promiseOfTrue,
c: [
promiseOfFalse,
promiseOf1
]
}resolved(obj).then(function(resolvedObj) {
// resolvedObj => {
// a: 'a regular value',
// b: true,
// c: [
// promiseOfFalse,
// promiseOf1
// ]
// }
})resolved.deep(obj).then(function(resolvedObj) {
// resolvedObj => {
// a: 'a regular value',
// b: true,
// c: [
// false,
// 1
// ]
// }
})
```## license
MIT
(c) 2015 jden - Jason Denizac - http://jden.mit-license.org/2015