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
const durations = [1000, 2000, 3000] | |
promises = durations.map((duration) => { | |
return timeOut(duration).catch(e => e) // Handling the error for each promise. | |
}) | |
Promise.all(promises) | |
.then(response => console.log(response)) // ["Completed in 1000", "Rejected in 2000", "Completed in 3000"] | |
.catch(error => console.log(`Error in executing ${error}`)) |
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
// A simple promise that resolves after a given time | |
const timeOut = (t) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
if (t === 2000) { | |
reject(`Rejected in ${t}`) | |
} else { | |
resolve(`Completed in ${t}`) | |
} | |
}, t) |
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
// A simple promise that resolves after a given time | |
const timeOut = (t) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(`Completed in ${t}`) | |
}, t) | |
}) | |
} | |
const durations = [1000, 2000, 3000] |
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
// A simple promise that resolves after a given time | |
const timeOut = (t) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(`Completed in ${t}`) | |
}, t) | |
}) | |
} | |
// Resolving a normal promise. |
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
pry-rescue | |
pry-nav | |
pry-rails | |
pry-stack_explorer | |
pry-theme |
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
set number | |
set noet ci pi sts=0 sw=4 ts=4 | |
set cursorline | |
set showcmd | |
filetype indent on | |
set wildmenu | |
set lazyredraw | |
set showmatch | |
set incsearch | |
set hlsearch |
NewerOlder