mirror of
https://github.com/xfarrow/blink
synced 2025-06-27 09:03:02 +02:00
npx eslint --fix
This commit is contained in:
@ -3,29 +3,21 @@
|
||||
// .then() returns a new Promise when you do "return",
|
||||
// internally calling resolve().
|
||||
|
||||
new Promise(function(resolve, reject) {
|
||||
|
||||
setTimeout(() => resolve(1), 1);
|
||||
|
||||
}).then(function(result) {
|
||||
|
||||
console.log(result);
|
||||
return result * 2;
|
||||
|
||||
}).then(function(result) {
|
||||
|
||||
console.log(result);
|
||||
return result * 2;
|
||||
|
||||
}).then(function(result) {
|
||||
|
||||
console.log(result);
|
||||
return result * 2;
|
||||
|
||||
});
|
||||
new Promise(function (resolve, reject) {
|
||||
setTimeout(() => resolve(1), 1);
|
||||
}).then(function (result) {
|
||||
console.log(result);
|
||||
return result * 2;
|
||||
}).then(function (result) {
|
||||
console.log(result);
|
||||
return result * 2;
|
||||
}).then(function (result) {
|
||||
console.log(result);
|
||||
return result * 2;
|
||||
});
|
||||
|
||||
/*
|
||||
It will print
|
||||
It will print
|
||||
1
|
||||
2
|
||||
4
|
||||
@ -33,7 +25,7 @@ new Promise(function(resolve, reject) {
|
||||
|
||||
/*
|
||||
It means that "then" is internally implemented roughly as follows:
|
||||
|
||||
|
||||
function then(f){
|
||||
return new Promise(function(resolve, reject) {
|
||||
resolve(f());
|
||||
@ -45,12 +37,12 @@ new Promise(function(resolve, reject) {
|
||||
|
||||
fetch('http://www.fsf.org')
|
||||
// .then below runs when the remote server responds
|
||||
.then(function(response) {
|
||||
.then(function (response) {
|
||||
// response.text() returns a new promise that resolves with the full response text
|
||||
// when it loads
|
||||
return response.text();
|
||||
})
|
||||
.then(function(text) {
|
||||
.then(function (text) {
|
||||
// ...and here's the content of the remote file
|
||||
console.log(text);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user