Guest User

Untitled

a guest
May 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. const async = require('async');
  2. const promiseFunction = function (x) {
  3. if (x) {
  4. return Promise.resolve(true);
  5. } else {
  6. return Promise.reject(false);
  7. }
  8. };
  9.  
  10. const asyncFunction = function (x, callback) {
  11. return promiseFunction(x)
  12. .then(result => callback(null, result))
  13. .catch(err => callback(err))
  14. };
  15.  
  16. async.map(
  17. [true, false, true],
  18. asyncCallback,
  19. (err, result) => console.log(err, result)
  20. );
Add Comment
Please, Sign In to add comment