-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
184eb60
commit f805c84
Showing
17 changed files
with
307 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
description: 'tracks effects when awaiting thenables' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
(async function () { | ||
return { | ||
then() { | ||
console.log(1); | ||
} | ||
}; | ||
})(); | ||
|
||
(async function () { | ||
await { | ||
then: function () { | ||
console.log(2); | ||
} | ||
}; | ||
return { then() {} }; | ||
})(); | ||
|
||
(async function () { | ||
await { | ||
get then() { | ||
console.log(3); | ||
return () => {}; | ||
} | ||
}; | ||
return { then() {} }; | ||
})(); | ||
|
||
(async function () { | ||
await { | ||
get then() { | ||
return () => console.log(4); | ||
} | ||
}; | ||
return { then() {} }; | ||
})(); | ||
|
||
(async function () { | ||
await await { | ||
then(resolve) { | ||
resolve({ | ||
then() { | ||
console.log(5); | ||
} | ||
}); | ||
} | ||
}; | ||
return { then() {} }; | ||
})(); | ||
|
||
async function asyncIdentity(x) { | ||
return x; | ||
} | ||
|
||
asyncIdentity({}); // no side effects - may be dropped | ||
|
||
const promise = asyncIdentity(6); | ||
|
||
promise.then(x => console.log(x)); | ||
|
||
asyncIdentity({ | ||
then(success, fail) { | ||
success(console.log(7)); | ||
} | ||
}); | ||
|
||
asyncIdentity({ | ||
then(resolve) { | ||
resolve({ | ||
then() { | ||
console.log(8); | ||
} | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
(async function () { | ||
return { | ||
then() { | ||
console.log(1); | ||
} | ||
}; | ||
})(); | ||
|
||
// removed | ||
(async function () { | ||
return { then() {} }; | ||
})(); | ||
|
||
(async function () { | ||
await { | ||
then: function () { | ||
console.log(2); | ||
} | ||
}; | ||
return { then() {} }; | ||
})(); | ||
|
||
// removed | ||
(async function () { | ||
await { | ||
then: function () {} | ||
}; | ||
return { then() {} }; | ||
})(); | ||
|
||
(async function () { | ||
await { | ||
get then() { | ||
console.log(3); | ||
return () => {}; | ||
} | ||
}; | ||
return { then() {} }; | ||
})(); | ||
|
||
(async function () { | ||
await { | ||
get then() { | ||
return () => console.log(4); | ||
} | ||
}; | ||
return { then() {} }; | ||
})(); | ||
|
||
// removed | ||
(async function () { | ||
await { | ||
get then() { | ||
return () => {}; | ||
} | ||
}; | ||
return { then() {} }; | ||
})(); | ||
|
||
(async function () { | ||
await await { | ||
then(resolve) { | ||
resolve({ | ||
then() { | ||
console.log(5); | ||
} | ||
}); | ||
} | ||
}; | ||
return { then() {} }; | ||
})(); | ||
|
||
async function asyncIdentity(x) { | ||
return x; | ||
} | ||
|
||
asyncIdentity({}); // no side effects - may be dropped | ||
|
||
const promise = asyncIdentity(6); | ||
|
||
promise.then(x => console.log(x)); | ||
|
||
asyncIdentity({ | ||
then(success, fail) { | ||
success(console.log(7)); | ||
} | ||
}); | ||
|
||
asyncIdentity({ | ||
then(resolve) { | ||
resolve({ | ||
then() { | ||
console.log(8); | ||
} | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
module.exports = { | ||
description: 'do not remove promise creations', | ||
options: { output: { name: 'bundle' } } | ||
description: 'do not remove promise creations' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
Promise.resolve({ | ||
then() { | ||
console.log(1); | ||
} | ||
}); | ||
|
||
Promise.resolve({ | ||
get then() { | ||
return () => console.log(2); | ||
} | ||
}); | ||
|
||
Promise.reject('should be kept for uncaught rejections'); | ||
|
||
Promise.all([ | ||
{ | ||
then() { | ||
console.log(3); | ||
} | ||
}, | ||
null | ||
]); | ||
|
||
Promise.all([ | ||
null, | ||
{ | ||
get then() { | ||
return () => console.log(4); | ||
} | ||
} | ||
]); | ||
|
||
Promise.race([ | ||
{ | ||
then() { | ||
console.log(5); | ||
} | ||
}, | ||
null | ||
]); | ||
|
||
Promise.race([ | ||
null, | ||
{ | ||
get then() { | ||
return () => console.log(6); | ||
} | ||
} | ||
]); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.