# @mikuroxina/mini-fn

> The minimal functional programming library.

Latest version **7.4.0** (published 2026-07-17) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @mikuroxina/mini-fn
pnpm add @mikuroxina/mini-fn
yarn add @mikuroxina/mini-fn
bun add @mikuroxina/mini-fn
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 7.4.0 |
| Published | 2026-07-17 |
| First published | 2022-08-14 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 972.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 17 |
| Maintainers | mikuroxina |

## Links

- npm: https://www.npmjs.com/package/@mikuroxina/mini-fn
- Repository: https://github.com/MikuroXina/mini-fn
- Homepage: https://mikuroxina.github.io/mini-fn/
- Issues: https://github.com/MikuroXina/mini-fn/issues
- npm.io page: https://npm.io/package/@mikuroxina/mini-fn

## Recent versions

- 7.4.0 (latest) — 2026-07-17
- 7.3.0 — 2026-07-05
- 7.2.0 — 2026-01-31
- 7.1.0 — 2026-01-24
- 7.0.0 — 2025-03-04
- 6.8.0 — 2025-02-14
- 6.7.0 — 2024-10-30
- 6.6.0 — 2024-08-13
- 6.5.0 — 2024-07-24
- 6.4.0 — 2024-07-15
- 6.3.1 — 2024-05-26
- 6.3.0 — 2024-05-26
- 6.2.1 — 2024-05-12
- 6.2.0 — 2024-05-12
- 6.1.1 — 2024-04-28
- … 23 more at https://npm.io/package/@mikuroxina/mini-fn/versions

## README

# mini-fn

The minimal functional programming library.

[![codecov](https://codecov.io/github/MikuroXina/mini-fn/branch/main/graph/badge.svg?token=3HZ2Y5T1A2)](https://codecov.io/github/MikuroXina/mini-fn)

---

mini-fn provides simple, tiny library having functional features and its type
declarations without dependencies.

## Examples

You can pipe your functions with `Cat<T>`'s `feed<U>(f: (t: T) => U): Cat<U>`
method like this:

```ts
import { Cat } from "@mikuroxina/mini-fn";

const result = Cat.cat(-3)
    .feed((x) => x ** 2)
    .feed((x) => x.toString());
console.log(result.value); // "9"
```

And there are some useful types such as `Option<T>`, `Result<E, T>`, and so on.

```ts
import { Option } from "@mikuroxina/mini-fn";
const sqrtThenToString = (num: number): Option.Option<string> => {
    if (num < 0) {
        return Option.none();
    }
    return Option.some(Math.sqrt(num).toString());
};

const applied = Option.andThen(sqrtThenToString);
applied(Option.some(4)); // some("2")
applied(Option.some(-1)); // none
applied(Option.none()); // none
```

Some of them also provides its monad implementation, so you can combine and
transform them like this:

```ts
import { Cat, Option } from "@mikuroxina/mini-fn";

const half = (x: number): Option.Option<number> => {
    if (x % 2 != 0) {
        return Option.none();
    }
    return Option.some(x / 2);
};
const liftedHalf = Option.monad.flatMap(half);

Cat.cat(20)
    .feed(Option.monad.pure)
    .feed(liftedHalf)
    .feed(Cat.log) // some(10)
    .feed(liftedHalf)
    .feed(Cat.log) // some(5)
    .feed(liftedHalf)
    .feed(Cat.log); // none
```

Also `CatT` allows you to compute with a `Monad` environment as:

```ts
import { Cat, List } from "@mikuroxina/mini-fn";

// Find patterns where `x + y + z == 5` for all natural number `x`, `y`, and `z`.
const patterns = Cat.doT(List.monad)
    .addM("x", List.range(0, 6))
    .addMWith("y", ({ x }) => List.range(0, 6 - x))
    .addWith("z", ({ x, y }) => 5 - (x + y))
    .finish(({ x, y, z }) => [x, y, z] as const);

console.dir(List.toArray(patterns));
/* [
    [0, 0, 5],
    [0, 1, 4],
    [0, 2, 3],
    [0, 3, 2],
    [0, 4, 1],
    [0, 5, 0],
    [1, 0, 4],
    [1, 1, 3],
    [1, 2, 2],
    [1, 3, 1],
    [1, 4, 0],
    [2, 0, 3],
    [2, 1, 2],
    [2, 2, 1],
    [2, 3, 0],
    [3, 0, 2],
    [3, 1, 1],
    [3, 2, 0],
    [4, 0, 1],
    [4, 1, 0],
    [5, 0, 0],
] */
```

---
_Source: https://npm.io/package/@mikuroxina/mini-fn · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
