Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

maeby

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maeby

The maybe monad in JS

  • 2.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-20%
Maintainers
1
Weekly downloads
 
Created
Source

maeby

Build Status Coverage Status

the maybe monad - in JS - with some adornments

about

This is mostly just a fun project to learn more about monads. The exposed interface tries to stick closely to a textbook monad interface, but adds a bit of convenience to accommodate the syntax and semantics of JS.

installation

$ npm add maeby
# or
$ yarn add maeby

example

import { maybe, just, nothing } from 'maeby'

const flakyCaps = name =>
  Math.random() > 0.5 ? name.toUpperCase() : null

maybe(flakyCaps('hey'))
  .bind(curtGreeting => `${curtGreeting}! how's it goin?`)
  // ^ equivalent to:
  // .bind(curtGreeting => just(`${curtGreeting}! how's it goin?`))
  .unwrap()
  // ^ convert back to the plain unwrapped JS value

api

maybe (value: T): Maybe<T>

just (value: T): Maybe<T>

nothing (): Maybe<T>

bind<T, U> (instance: Maybe<T>, transform: (value: T) => (Maybe<U> | U)): Maybe<U>

js <T> (m: Maybe<T>): ?T

FAQs

Package last updated on 03 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc