Created
March 6, 2016 19:05
-
-
Save rwaldron/cf99b0bedb2e53c9a264 to your computer and use it in GitHub Desktop.
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
var tags = require("common-tags"); // npm install common-tags | |
var Proximity = { | |
read: function(which) { | |
var distance = [Math.round(Math.random() * 20)]; | |
return Promise.resolve( | |
Object.assign({}, which, { distance }) | |
); | |
} | |
}; | |
Promise.all([ | |
Proximity.read({ position: "bottom-left", direction: "rear" }), | |
Proximity.read({ position: "top-middle", direction: "front" }), | |
]).then(proximities => { | |
proximities.forEach(prox => { | |
console.log( | |
tags.stripIndent` | |
Position: ${prox.position} | |
Direction: ${prox.direction} | |
Distance: ${prox.distance}cm | |
---------------------------- | |
` | |
); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment