sensible-maybe
TypeScript icon, indicating that this package has built-in type declarations

2.3.0 • Public • Published

sensible-maybe

A pretty barebones Maybe implementation in TypeScript. Let's try to stay practical. You don't need to build your entire application with this thing.

View the documentation

Installing

$ yarn add sensible-maybe

Examples

Maybe.of(getUser())
  .map((user) => user.name)
  .getOrElse("Not signed in");

Maybe.of(getUser()).either(
  (user) => <a href="/account">{user.name}</a>,
  () => <a href="/login">Login</a>
);

Maybe.of(getUser())
  .filter((user) => user.isAdmin)
  .map((user) => `Admin: ${user.name}`)
  .getOrElse("Unauthorized!");

Maybe.of(getUser())
  .map((user) => user.name)
  .forEach((name) => console.log(name));

Readme

Keywords

none

Package Sidebar

Install

npm i sensible-maybe

Weekly Downloads

9

Version

2.3.0

License

MIT

Unpacked Size

33.7 kB

Total Files

15

Last publish

Collaborators

  • rzane