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

manatki

v0.2.0

Published

Function programming in Typescript/Javascript

Readme

manatki

Build status

Dependency-free library for functional programming in Typescript/Javascript

In functional programming, a monad is a structure that combines program fragments (functions) and wraps their return values in a type with additional computation. In addition to defining a wrapping monadic type, monads define two operators: one to wrap a value in the monad type, and another to compose together functions that output values of the monad type.

The library implements Scala approach of monad classes: Option[T], Some[T], None

Get started

To install the library you should use npm:

npm i --save manatki

Then you are able to import it in your project:

import {Option, Some, None} from 'manatki';

Optionally turn on implicit constructors of Option and Either

String and Number classes are Optionative and Validative, so they can be converted to Option, Either<void, string> etc (see further).

To add this possibility you should import implicits from manatki:

import 'manatki/implicits'; // All implicits
import 'manatki/implicits/String'; // implicits for strings
import 'manatki/implicits/Number'; // implicits for number

Features

  1. Option[T]
const name: Option[String] = Some("name") // here we can get some optional value from outside
const upper = name
  .map(String.prototype.trim)
  .filter(e => e.length !== 0)
  .map(String.prototype.toUpperCase);
console.log(upper.getOrElse(""))
  1. Either[K, T]
  1. Try[T]
const a = (n: number) => (d: number) => {
  if (d === 0) throw new Error("division by zero");
  return n / d;
};

const status1 = Try<number>(() => a(5)(1)).fold<string>((n: number) => "Success", (e: Error) => e.message);
console.log(status1); // Success

const status2 = Try<number>(() => a(5)(0)).fold<string>((n: number) => "Success", (e: Error) => e.message);
console.log(status2); // division by zero

You can make your class Optionative by inheriting from Optionative:

class MyClass extends Optionative<MyClass> {
  // ...
}
const a = new MyClass();
a.some(); // returns Option<MyClass>

You can make your class Validative by inheriting from Validative:

class MyClass extends Validative<MyClass> {
  // ...
}
const a = new MyClass();
a.asLeft(); // returns Either<MyClass, void>
a.asRight(); // returns Either<void, MyClass>
  1. Algebra

Monoid, Semigroup interfaces. Implicitly, String and Number are Monoidal in manatki.

Functional programming

  1. lFold
lFold ((f: string) => (g: string) => f + g) ("") (["2","3","4","5","6"]); // 23456

lFold ((e: number) => (f: number) => e + f) (0) ([1,2,3]); // 6
  1. rFold
rFold ((f: string) => (g: string) => f + g)("") (["2","3","4","5","6"]); // "65432"

License

MIT