javascript - Does my Promise implementation agree with specifications? -


I'm trying to create a TypeScript promise implementation (actually a polyfil) which agrees with the current specifications (I I use these).

It should be done, the code is here, but I can not understand 2.2.7 subpoints of glasses.

Please someone can explain 2.2.7 sub-points and tell me that I have implemented them correctly?

Thanks for the attention and time, Matia.

Let's talk to the code say that we are called promise 1 . According to the tip:

By device

Then a promise will be returned

Self explanatory: Promise 2 = Promise 1.then (Completed, Calculated); By device

If either a completed or calculated value returns x, run the promise resolution process [[Resolution ]] (Promise 2, x).

If we have

  promise 2 = promise 1 Then ((=) => 123, () => 123);   

Then you can do this

  Promise 2 Then ((x) => <* * 123 * /, (x) = & gt; / * will not be called * /);              
  Promise 2 = Promise 1 Then ((=) = {new error ('message');}, () = & gt; {new error ('message');});   

Then you can do

  promise2.then ((x) => = * to * /, (x) = & gt ; / * X will be equal to "new error ('message')" * /);  

Spec

If the fullfill is not a function and the promise 1 is complete, then the promise 2 must be completed with the same value.

If we have

  promise 1 = new promise (work (solution, reject) {solution (123)}); Promise 2 = Promise 1 Then (tap, zero);   

Then we can do this

  Promise 2.then ((x) => / * x 123 * /, (x) = & Gt; / * should not be called * /);  

Spec

If there is no function given on it and Promise 1 has declined, then Promise 2 rejected for the same reason should go.

If we have

  promise 1 = new promise (work (solution, reject) {reject (123)}); Promise 2 = Promise 1 Then (tap, zero);   

Then we can do this

  Promise 2.then ((x) => = * to * /, (x) = & Gt; / * x 123 * /);   

To verify that you have been shown to write the execution, I recommend using Chai with Mocha.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -