Created
April 15, 2018 22:55
-
-
Save tabrindle/95be427e518918621aea5d63a6820e36 to your computer and use it in GitHub Desktop.
Resolve promises in place - first library attempt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pProps = require('p-props'); | |
const sleep = (message) => new Promise(resolve => setTimeout(() => resolve(message), Math.floor(Math.random() * 2500))); | |
const get = message => sleep(message).then(res => res); | |
const data = { | |
Amit: get('Amit'), | |
vitae: get('vitae'), | |
Lorem: { | |
Tellus: get('Tellus'), | |
Ipsum: get('Ipsum'), | |
Sit: { | |
Dolor: get('Dolor'), | |
mattis: get('mattis'), | |
ornare: get('ornare'), | |
}, | |
}, | |
}; | |
pProps(data).then(result => { | |
console.log(JSON.stringify(result)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment