proback.js
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -7,3 +7,3 @@ module.exports = { | ||
}, | ||
embracer: async function (promise, callback) { | ||
embracer: function (promise, callback) { | ||
return new Promise( (resolve, reject) => { | ||
@@ -15,5 +15,4 @@ promise | ||
}, | ||
dummy: async function ( res, callback ) { | ||
quicker: function ( res, callback ) { | ||
return new Promise( (resolve, reject) => { | ||
console.log( res ) | ||
if (callback) callback( null, res ) | ||
@@ -23,9 +22,9 @@ resolve(res) | ||
}, | ||
quicker: async function ( res, callback ) { | ||
thrower: function ( err, callback ) { | ||
return new Promise( (resolve, reject) => { | ||
if (callback) callback( null, res ) | ||
resolve(res) | ||
if (callback) callback( err ) | ||
reject(err) | ||
} ) | ||
}, | ||
syncAll: async function (promises) { | ||
syncAll: function (promises) { | ||
if (!Array.isArray(promises)) { | ||
@@ -59,3 +58,3 @@ throw new Error('First argument need to be an array of Promises') | ||
}, | ||
forAll: async function ( promises, callback, defaultRes ) { | ||
forAll: function ( promises, callback, defaultRes ) { | ||
return new Promise( (resolve, reject) => { | ||
@@ -62,0 +61,0 @@ Promise.all( promises ) |
{ | ||
"name": "proback.js", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Tiny libary to aid Promise/Callback dual API design", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -9,3 +9,3 @@ proback.js - dependency-free very minimal helper for APIs with Promise/callback dual design | ||
[proback.js](https://github.com/imrefazekas/proback.js) is an extremely tiny helper library to help the creation of APIs where functions are aimed to enable Promise-based and callback-based usage as well. | ||
[proback.js](https://github.com/imrefazekas/proback.js) is an extremely tiny helper library to help the creation of APIs where functions are aimed to enable Promise-based and callback-based design as well. | ||
@@ -57,1 +57,28 @@ [Usage](#usage) | ||
``` | ||
## Rules | ||
- quicker ( res, callback ) | ||
Defines a simple promise to send a result through the optional callback as well | ||
- thrower ( err, callback ) | ||
Defines a simple promise to throw an error through the optional callback as well | ||
- syncAll (promises) | ||
Performes all promises in order | ||
- forAll ( promises, callback, defaultRes ) | ||
Performes all promises and channel the result to the given callback | ||
- handler ( callback, resolve, reject ) | ||
Defines a callback function, which will use the passed opional callback and promise functions to channel the results | ||
- returner ( err, res, callback, resolve, reject ) | ||
Error mades it mark the error through the optional callback and the optional reject function or send the result back to the optional callback or the optional resolve function | ||
- resolver (res, callback, resolve) | ||
Sends a result through the optional callback and the optional reject function | ||
- rejecter (err, callback, reject) | ||
Marks an error through the optional callback and the optional reject function |
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
13940
82
317