Skip to content

Instantly share code, notes, and snippets.

@rwaldron
Created March 6, 2016 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rwaldron/cf99b0bedb2e53c9a264 to your computer and use it in GitHub Desktop.
Save rwaldron/cf99b0bedb2e53c9a264 to your computer and use it in GitHub Desktop.
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