Example #1
0
 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));
 });
Example #2
0
 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));
 });
Example #3
0
 it('should work correctly', (done) => {
   const value = 1;
   Just(value).toPromise().then((resolvedValue) => {
     expect(resolvedValue).to.equal(value);
     done();
   });
 });
Example #4
0
 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;
 });
Example #5
0
 [ { option: Just(2).orElse(() => Just(3)).get(),
Example #6
0
 .bind((n) => Just(n * 2))
Example #7
0
 it('should work correctly', () => {
   expect(Just(1).fold({
     just: () => true,
     nothing: () => false,
   })).to.be.true;
 });
Example #8
0
 it('should be instance of Maybe', () => {
   expect(Just(1)).to.be.an.instanceof(Maybe);
 });
Example #9
0
 const value = Nothing.orElse(() => Just(3)).get();
Example #10
0
 .bind(() => Just(2))