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.
-
Note that after you implement a method, it's allowed to use it in other methods (e.g.
Promise.resolve
). -
Methods behavior should match the TC39 specification, so pay attention to the requirements described in the comments.
-
Some inputs specify an iterable, but for simplicity we'll be accounting for arrays only.
-
Be sure to validate inputs — throw a
TypeError
if the input is invalid!
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