Advertisement
Guest User

Untitled

a guest
May 25th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. "use strict";
  2.  
  3. var send = function send(param) {
  4. return new Promise(function (resolve, reject) {
  5. console.log("ici send");
  6. find(function () {
  7. console.log("ici callback");
  8. });
  9.  
  10. if (true) {
  11. resolve("resolve " + param);
  12. } else {
  13. reject("reject " + param);
  14. }
  15. });
  16. };
  17.  
  18. function find(callback) {
  19. console.log("ici find :");
  20. setTimeout(callback, 2000);
  21. };
  22.  
  23. console.log("start");
  24.  
  25. send("toto").then(function (res) {
  26. console.log("ici then :", res);
  27. });
  28.  
  29. console.log("end");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement