Skip to content

Instantly share code, notes, and snippets.

@joepie91
Created July 2, 2015 06:31
Show Gist options
  • Save joepie91/3610c6e41bc654ccaadf to your computer and use it in GitHub Desktop.
Save joepie91/3610c6e41bc654ccaadf to your computer and use it in GitHub Desktop.
Promisifying an EventEmitter
function scanForThing() {
return new Promise(function(resolve, reject){
var emitter = scanLibrary.scan();
emitter.on("discover", function(peripheral){
resolve(peripheral);
});
emitter.on("error", function(err){
reject(err);
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment