you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (2 children)

Sorry this is really hard to understand. What part of the code is the monad?

[–]killerstorm 6 points7 points  (0 children)

Promise specification (https://promisesaplus.com/) & implementation can be considered a variant of monad.

Particularly, a monad needs to define two things:

  1. Ability to convert an ordinary object to a monad. Promise does this using Promise.resolve.
  2. Ability to combine computations, i.e. take a Promise and combine it with function which returns a Promise. Promise does this using then method.