@larskoelpin/maybe.js
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

Maybe

Simple Maybe Monad

Check spec for more examples

    it('Does not propagate null', () => {
        function getUser() {
            return new Maybe({
                getAvatar: function() {
                    return new Maybe(null); // no avatar
                }
            });
        }
        const url = getUser()
            .chain(user => user.getAvatar())
            .chain(avatar => avatar.url)
        expect(url.isNothing()).toBe(true);
    })

Package Sidebar

Install

npm i @larskoelpin/maybe.js

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • larskoelpin