Skip to content

kottans/promise-api-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Promise API workshop

Your task is to implement Promise static methods (.resolve, .reject, .all, .race, .allSettled, .any) from scratch via a Promise constructor. For this, you will create a custom class called CustomPromise, that will extend the native Promise.

Open index.js to begin.

Requirements

  1. Note that after you implement a method, it's allowed to use it in other methods (e.g. Promise.resolve).

  2. Methods behavior should match the TC39 specification, so pay attention to the requirements described in the comments.

  3. Some inputs specify an iterable, but for simplicity we'll be accounting for arrays only.

  4. Be sure to validate inputs — throw a TypeError if the input is invalid!

Test it!

After you're done, check your implementation by running npm run test in the console.

If you'd like to run tests separately for individual methods, try:

npm run test [nameOfTheMethod].js

For example, to run CustomPromise.resolve tests only:

npm run test resolve.js

About

🧰 DIY Promise static methods

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •