Skip to content

suvelocity/PromiseBoilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Promise Challenge

Promise=>declare

Story

  • The client comes from a religious background and isn't comfortable with the word "promise" being part of their software
  • The client wants a new class to replace the Promise, called... Declare
  • clone this Repo.
  • run npm i to install jest test library in order for the tests to run.
  • Edit index.js to implement the Declare class.
  • run npm run test in the terminal to run the tests.

Requirements from the Declare class

  1. is not implemented using the built-in Promise Class.
  2. can create an instance with an executor function using the new keyword
  3. has a then method, which returns a Declare instance
  4. can use the return value of the executor with then method
  5. can use multiple thens chained one after the other
  6. can use an asynchronous executor
  • NOTE - there's no need to handle errors in this implementation.

HOT TIP

add .skip to the end of a test in test.js to skip it in a run, and only test what you want to.

test.skip("Is not an instance of Promise", () => {
    const declare = new Declare(()=>{});
    return expect(declare instanceof Promise).toBe(false);
  });

Recommended prior Knowledge

try to pass this challange using only the resources below: (don't look for other implementations)

HINTS

your stuck? click here!

Moses-Promise

Releases

No releases published

Packages

No packages published