How to use the monet.Either.Left function in monet

To help you get started, we’ve selected a few monet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github char0n / monad-t / test / FlutureTMonetEither / index.js View on Github external
it('tests rejected future', function(done) {
      FlutureTMonetEither
        .fromFuture(Future.reject('error1'))
        .and(FlutureTMonetEither.fromEither(Either.Left('error2')))
        .fork(
          (val) => {
            assert.strictEqual(val, 'error1');
            done();
          },
          noop
        );
    });
github char0n / monad-t / test / FlutureTMonetEither / index.js View on Github external
it('tests chainEither (left)', function(done) {
    const error = new Error();

    FlutureTMonetEither
      .fromEither(Either.Left(error))
      .chainEither(() => Either.Right(2))
      .fork(
        (val) => {
          assert.strictEqual(val, error);
          done();
        },
        noop
      );
  });
github char0n / monad-t / test / FlutureTMonetEither / index.js View on Github external
it('tests functor (left on Either)', function(done) {
    const add = a => b => a + b;
    const error = new Error();
    const fe = FlutureTMonetEither.of(Future.of(Either.Left(error))).map(add(1));

    fe.fork(
      (val) => {
        assert.strictEqual(val, error);
        done();
      },
      noop
    );
  });
github char0n / monad-t / test / FlutureTMonetEither / index.js View on Github external
it('tests parallel (left)', function(done) {
    FlutureTMonetEither
      .parallel(2, [
        FlutureTMonetEither.fromValue(1),
        FlutureTMonetEither.fromEither(Either.Left(2)),
        FlutureTMonetEither.fromValue(3),
      ])
      .fork(
        (val) => {
          assert.strictEqual(val, 2);
          done();
        },
        noop
      );
  });
github char0n / monad-t / test / FlutureTMonetEither / index.js View on Github external
it('tests both (left)', function(done) {
    FlutureTMonetEither
      .both(
        FlutureTMonetEither.fromEither(Either.Left(1)),
        FlutureTMonetEither.fromValue(2)
      )
      .map(sum)
      .fork(
        (val) => {
          assert.strictEqual(val, 1);
          done();
        },
        noop
      );
  });
github char0n / monad-t / test / FlutureTMonetEither / index.js View on Github external
    const add1 = a => FlutureTMonetEither.of(Future.of(Either.Left(a + 1)));
    const fe = FlutureTMonetEither.of(Future.of(Either.Left(error))).chain(add1);
github char0n / monad-t / src / FlutureTMonetEither / index.js View on Github external
return this[chain]((val) => {
    if (!predicate(val)) {
      if (isFunction(fnOrValue)) {
        return this.constructor.fromEither(Either.Left(fnOrValue(val)));
      }
      return this.constructor.fromEither(Either.Left(fnOrValue));
    }
    return this.constructor.fromValue(val);
  });
};
github char0n / monad-t / src / FlutureTMonetEither / index.js View on Github external
return this[chain]((val) => {
    if (!predicate(val)) {
      if (isFunction(fnOrValue)) {
        return this.constructor.fromEither(Either.Left(fnOrValue(val)));
      }
      return this.constructor.fromEither(Either.Left(fnOrValue));
    }
    return this.constructor.fromValue(val);
  });
};
github aappddeevv / dynamics-client-ui / packages / dynamics-client-ui / src / Data / interfaces.ts View on Github external
    error: (e: ErrorInfo): Result => Either.Left(e),
    errorNow: (error: Error, message?: string): Result => Either.Left({