promiser.js
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "promiser.js", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Creates a native ES6 Promise from a function which takes a node style Error-First callback.", | ||
@@ -5,0 +5,0 @@ "main": "promiser.js", |
@@ -7,7 +7,7 @@ const createPromise = (fttc, context) => { | ||
return new Promise((resolve, reject) => { | ||
fttc.apply(context, args.concat((err, res) => { | ||
fttc.apply(context, args.concat((err, ...res) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(res); | ||
resolve(...res); | ||
} | ||
@@ -14,0 +14,0 @@ })); |
# promiser.js | ||
Create native ES6 promises from functions which take node-style callbacks. | ||
## How to use | ||
## How to use | ||
@@ -12,3 +12,3 @@ ### require the library: | ||
const fs = require('fs'); | ||
createPromise(fs.readFile)('test.js', 'utf8'). | ||
@@ -40,3 +40,3 @@ then(() => console.log('SUCCESSFUL SUCCESS (function)')). | ||
} | ||
Instantiate the class, then create a promise from the method `a` by passing it to promiser, | ||
@@ -50,7 +50,7 @@ just don't forget to pass the context aswell! | ||
catch(console.error); | ||
const testClassFailure = new TestClass('FAILED FAILURE (method)', 'SUCCESSFUL FAILURE (method)', false); | ||
createPromise(testClassFailure.a, testClassFailure)(). | ||
then(console.log). | ||
catch(console.error); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13697