npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mandolin

v0.0.0

Published

This is an attempt to make Monadic types practical in JavaScript. This is heavily inspired by Scala.

Readme

Mandolin

This is a library of Monads in JavaScript. The intent of this library is to provide Monads, as well as a great way to interop between Monadic types and vanilla JS types.

In this library, the monadic bind is called flatMap, in order to not conflict with Function.prototype.bind. The monadic return is called unit, to not cause any confusion with the return keyword.

What is a monad?

In brief, a Monad is a wrapper around a value that allows you to make safe, composable operations. It eliminates the need to throw errors, as well as the need for things like null values. A JavaScript Array is a monad-like data type, but doesn't fully satisfy the rules of being a monad, given that it doesn't have a bind (or flatMap) function.

Monads are common in functional programming languages.

Here are some great resources that discuss monads:

Available monads

Option

An Option is a type comprising of Some and None. A value of type Option can either be a Some, in which it holds a value, or a None, in which it holds no value. This is used in lieu of null and undefined.

Example:

const bobsEmail = new Some("[email protected]");
// We have Bob's email
const sandrasEmail = new None();
// we do not have Sandra's email

The way to get a reference to the actual value is through either map, flatMap or match.

bobsEmail.map((email) => doThingWithEmail(email));

This is similar to writing a null check:

if (email !== null || email !== undefined) {
  doThingWithEmail(email)
}

Either

A disjoint union of Left and Right, and is right-biased. map and flatMap are only called if it is a Right. This is similar to an Option, in that Left : None :: Right : Some. The difference is that a Left can also hold values.

Types

This library makes no assumptions about type safety. The approach, rather, is to use Reads combinators to serialize monads that follow certain sets of rules. For example, in Scala, an Option of a String is notated as such:

Option[String]

The seemingly equivalent example in our library is this:

Option.as(M.string)

The difference is, Option.as(M.String) is not a type, but a rule for reading in values. Essentially, this is the same thing as types, but I think makes more sense in a world that doesn't perform any compile-time type checking.

Pattern Matching

JavaScript doesn't have pattern matching built into the language. However, each algebraic data type in this library comes with a match function that behaves like pattern matching.

new Left("foo").match({
  Left (str) { ... },
  Right (str) { ... }
});

The return value of match is the return value of whichever function ends up being called.