it('should work correctly', () => { [ { option: Just(2).orElse(() => Just(3)).get(), value: 2, }, { option: Just(false).orElse(() => Nothing).get(), value: false, }, ].forEach(({option, value}) => expect(option).to.equal(value)); });
it('should work correctly', () => { [ { option: Just(2).getOrElse(() => 3), value: 2, }, { option: Just(false).getOrElse(() => true), value: false, }, ].forEach(({option, value}) => expect(option).to.equal(value)); });
it('should work correctly', (done) => { const value = 1; Just(value).toPromise().then((resolvedValue) => { expect(resolvedValue).to.equal(value); done(); }); });
it('should work correctly', () => { expect(Just(2) .lift((n) => n * 2) .lift((n) => n * 2) .fold({ just: (n) => n === 8, nothing: () => false, })).to.be.true; });
[ { option: Just(2).orElse(() => Just(3)).get(),
.bind((n) => Just(n * 2))
it('should work correctly', () => { expect(Just(1).fold({ just: () => true, nothing: () => false, })).to.be.true; });
it('should be instance of Maybe', () => { expect(Just(1)).to.be.an.instanceof(Maybe); });
const value = Nothing.orElse(() => Just(3)).get();
.bind(() => Just(2))