Skip to content

Instantly share code, notes, and snippets.

@aichholzer
Created November 3, 2017 10:49
Show Gist options
  • Save aichholzer/e44452d0e9614cb3d14de10f15ad64a2 to your computer and use it in GitHub Desktop.
Save aichholzer/e44452d0e9614cb3d14de10f15ad64a2 to your computer and use it in GitHub Desktop.
Promise maps
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