-
<inner> creator() → {Array}
-
Returns an array with two values : the promise and the callback to call
- Deprecated:
-
- Prefer use of S.promiseCallback()
- Source:
-
Returns:
-
Type
-
Array
Example
var [promise, doneCallback] = promises.creator();
fs.readFile('./myFile.txt', doneCallback);
promise.then((txtContentBuffer) => {
console.log(txtContentBuffer.toString());
});
-
<inner> done() → {function}
-
Returns a callback that resolve or reject the created promise that you can get with {promises}
- Deprecated:
-
- Prefer use of S.promiseCallback()
- Source:
-
Returns:
callback(err, result)
-
Type
-
function
-
<inner> forEach(iterable, callback) → {Promise}
-
Execute promises in parallel
Parameters:
Name |
Type |
Description |
iterable |
Array
|
Object
|
Map
|
Set
|
an iterable with .map method (like Array), or an key/value object |
callback |
function
|
callback(value, index) called for each values |
- Source:
-
Returns:
-
Type
-
Promise
-
<inner> forEachSeries(iterable, callback) → {Promise}
-
Execute promises in series
Parameters:
Name |
Type |
Description |
iterable |
Array
|
Object
|
an iterable with .map method (like Array), or an key/value object |
callback |
function
|
callback(value, index) called for each values |
- Source:
-
Returns:
-
Type
-
Promise
-
<inner> promise() → {Promise}
-
Returns the Promise created by the previously called method done()
- Deprecated:
-
- Prefer use of S.promiseCallback()
- Source:
-
Returns:
-
Type
-
Promise
Example
promises.promise(callback(promises.done()));
-
<inner> promiseCallback(callback) → {Promise}
-
Returns a promise
The first argument is a callback with a done function
Parameters:
Name |
Type |
Description |
callback |
function
|
callback((done) => {}) |
- Source:
-
Returns:
-
Type
-
Promise
Example
S.promiseCallback((done) => {
fs.readFile('./myFile.txt', done);
}).then((txtContentBuffer) => {
console.log(txtContentBuffer.toString());
});
-
<inner> resolveFromCallback(resolve, reject) → {function}
-
Creates a callback that resolve or reject a promise
according to the default callback convention in node: (err, result)
Parameters:
Name |
Type |
Description |
resolve |
function
|
resolve function of the promise |
reject |
function
|
reject function of the promise |
- Source:
-
Returns:
-
Type
-
function
-
<inner> whileTrue(iterable, callback) → {Promise}
-
Execute the second callback wile the first callback is true
Parameters:
Name |
Type |
Description |
iterable |
function
|
an iterable with .map method (like Array), or an key/value object |
callback |
function
|
callback(value, index) called for each values |
- Source:
-
Returns:
-
Type
-
Promise