moneo-ts
TypeScript icon, indicating that this package has built-in type declarations

1.6.0 • Public • Published

moneo-ts

A small, simple, but powerful library for functional programming written in TypeScript. It was designed to be extremely lightweight, easy to learn and use.

This library includes a set of powerful tools to write predictable, immutable, and safe code that is easy to reason about. This is especially useful when dealing with complex data structures, async code, or error handling.

Contents

Installation

To use moneo-ts, install the package via npm.

npm install moneo-ts

# or install a specific version
npm install moneo-ts@x.x.x

Examples

Option

import { Option, Some, None } from 'moneo-ts';

Option(0); // Some<number>
Option(''); // Some<string>
Option({}); // Some<{}>
Option(null); // None
Option(undefined); // None

Either

import { Either, Right, Left } from 'moneo-ts';

Right(0); // Right<number>
Right(''); // Right<string>
Right({}); // Right<{}>
Right(null); // Right<null>
Right(undefined); // Right<undefined>

Left(0); // Left<number>
Left(''); // Left<string>
Left({}); // Left<{}>
Left(null); // Left<null>
Left(undefined); // Left<undefined>

IO

import { IO, IOAsync } from 'moneo-ts';

IO(() => 1); // IO<void, number>
IO((env: { a: 1 }) => env.a + 1); // IO<{ a: number }, number>
IOAsync(async () => 1); // IOAsync<void, number>
IOAsync(async (env: { a: 1 }) => env.a + 1); // IOAsync<{ a: number }, number>

Package Sidebar

Install

npm i moneo-ts

Weekly Downloads

6

Version

1.6.0

License

MIT

Unpacked Size

1.06 MB

Total Files

93

Last publish

Collaborators

  • patrickap