Hang on...
Promises
The two objectives of this exercise are :
- Implement a
promisify
function that turns a function using the "callback pattern" into a function that returns aPromise
. See the example below.
function fetchProduct(productId, function(error, data) { if (error) { // Handle the error } else { // Make something with your data } }) const fetchProductAsPromise = promisify(fetchProduct); // Now you got a function `fetchProductAsPromise` // that returns a promise fetchProductAsPromise(productId) .then((data) => {}) .catch((error) => {});
- Re-implement the following built-ins
Promise
methods (without using them)
all
: takes an array of promises and resolves when all of them are resolved, or rejects when one of them rejects.allSettled
: takes an array of promises and resolves when all of them either resolve or reject.race
: takes an array of promises and resolves or rejects with the value of the first promise that resolves or rejects.any
: takes an array of promises and resolves when one of them resolves, or rejects when all of them reject.
Adding your container request
Getting your dedicated container
Connecting to your container
Setting up your editor
Finalizing your playground
TerminalEditorBrowser