Using this function you can easily promisify a function. Supply the function you want to promisify as first argument and when you call the function that is returned from this function using the arguments you would have normally used, it'll return a promise. When the function is finished it'll resolve the promise, but when the first parameter in the callback function is an error it'll throw an error.
Click me for the documentation about the promise class.