Guest User

Untitled

a guest
Dec 15th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. /**
  2. * @param { Promise } promise
  3. * @param { Object= } errorExt - Additional Information you can pass to the err object
  4. * @return { Promise }
  5. */
  6. function to(promise, errorExt) {
  7. return promise
  8. .then(function (data) { return [null, data]; })
  9. .catch(function (err) {
  10. if (errorExt) {
  11. Object.assign(err, errorExt);
  12. }
  13. return [err, undefined];
  14. });
  15. }
  16.  
  17. export { to };
  18. export default to;
Add Comment
Please, Sign In to add comment