Promise Initial only cata

https://github.com/eu81273/jsfiddle-console

by dimitrs_papadimitriou

HTML

<script src="https://rawgit.com/eu81273/jsfiddle-console/master/console.js"></script>
<script src="https://code.jquery.com/jquery-3.4.0.js"></script>

JavaScript

var EitherCoyoAsync = function(actions) {
  
    this.cata = alg => actions(alg.ok , alg.error); 
   }

  Promise.prototype.toEither = function() {
    var initialPromise = this;
    var either = new EitherCoyoAsync(function(resolve, reject) {
      initialPromise.then(resolve).catch(reject)
    } );
    return either;
  }
 
  Promise.resolve(5)
  .toEither()
   .cata({
      ok:  v => console.log(v),
      error: v => console.log("error:" + v)
    });