Created
November 3, 2017 10:49
-
-
Save aichholzer/e44452d0e9614cb3d14de10f15ad64a2 to your computer and use it in GitHub Desktop.
Promise maps
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 heartbeats = [1, 2, 3].map((value) => Promise.resolve({ id: value, date: +new Date() })); | |
Promise.all(heartbeats).then((values) => { | |
console.log(values.map((value) => !value.date ? null : { | |
id: value.id, | |
name: 'location', | |
heartbeat: value.date | |
}).filter(v => v).sort() | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment