Skip to content

Instantly share code, notes, and snippets.

View patrixr's full-sized avatar
🌱
Slow growth

Patrick R patrixr

🌱
Slow growth
View GitHub Profile
@patrixr
patrixr / promisify.js
Created February 5, 2016 03:15
Promisify: from callback to promise
function promisify(func, scope) {
return function () {
var args = [].slice.call(arguments);
var deferred = Promise.defer();
args.push(function () {
if (arguments[0]) {
// There was an error
deferred.reject(arguments[0]);