Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
);
});
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
);
});
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
);
});
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
);
});
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
);
});
const add1 = a => FlutureTMonetEither.of(Future.of(Either.Left(a + 1)));
const fe = FlutureTMonetEither.of(Future.of(Either.Left(error))).chain(add1);
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);
});
};
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);
});
};
error: (e: ErrorInfo): Result => Either.Left(e),
errorNow: (error: Error, message?: string): Result => Either.Left({