Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function delay(t, v) {
- return new Promise(function (resolve) {
- setTimeout(resolve.bind(null, v), t)
- });
- }
- Promise.prototype.delay = function (t) {
- return this.then(function (v) {
- return delay(t, v);
- });
- }
- function solve (time) {
- Promise.resolve("hello1").delay(time).then(function (v) {
- console.log("111111");
- }).then(function (v) {
- setTimeout(() => {
- console.log("222222");
- }, time);
- }).delay(time).then(function (v) {
- setTimeout(() => {
- console.log("333333");
- }, time);
- }).delay(time).then(function (v) {
- setTimeout(() => {
- console.log("444444");
- }, time);
- })
- }
- solve(2000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement