-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
2 changed files
with
52 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
let myPromise = new Promise.resolve("ok") | ||
const doSomething = () => console.log("ok") | ||
const catchErrors = () => console.log("ok") | ||
myPromise.then(doSomething) | ||
myPromise.then(doSomething, catchErrors) // catch() may be a little better | ||
function doSomethingElse() { | ||
return myPromise.then(doSomething) | ||
} | ||
|
||
myPromise.then(function (val: number) { | ||
return Promise.resolve(val * 2) | ||
}) | ||
myPromise.then(function (val: number) { | ||
return Promise.reject('bad thing') | ||
}) | ||
|
||
|
||
myPromise.finally(function (val) { | ||
return val | ||
}) | ||
|
||
|
||
new Promise(function (reject, resolve) { console.log("ok") }) // incorrect order | ||
new Promise(function (ok, fail) { console.log("ok")}) // non-standard parameter names | ||
new Promise(function (_, reject) { console.log("ok")}) // a simple underscore is not allowed |