Skip to content

Instantly share code, notes, and snippets.

@joepie91
Created July 2, 2015 06:31
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 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