Back to rankings

true-myth/true-myth

TypeScripttrue-myth.dev

Safe and idiomatic TypeScript types to handle null, error, and async code handling: Maybe, Result, and Task types that are really nice.

typescripttypescript-librarytypescript-definitionsfunctional-programmingjavascriptmonadsfunctorsapplicatives
Star Growth
Stars
1.4k
Forks
36
Weekly Growth
Issues
6
5001k
Sep 2017Aug 2020Aug 2023Jul 2026
Artifactsnpmnpm install true-myth
README

True Myth

True Myth provides safe, idiomatic null, error, and async code handling in TypeScript, with Maybe, Result, and Task types that are really nice.

Test coverage: 100% npm supported TypeScript versions Nightly TypeScript Run Stability: Active DNS by JS.org docs built with Typedoc

READMEAPI docsSourceIntro blog post

Overview

True Myth provides standard, type-safe wrappers and helper functions to help you with three extremely common cases in programming:

  • not having a value
  • having a result where you need to deal with either success or failure
  • having an asynchronous operation which may fail

You could implement all of these yourself – it's not hard! – but it's much easier to just have one extremely well-tested library you can use everywhere to solve this problem once and for all.

See the docs for setup, guides, and API docs!

Contents

Requirements

  • TS 5.3+
  • tsconfig.json:
    • moduleResolution: use "Node16" or later
    • strict: true
  • package.json
    • type: "module" (or else use import() to import True Myth into a commonJS build)

For details on using a pure ES modules package in TypeScript, see the TypeScript handbook's guide.

Compatibility

This project follows the current draft of the Semantic Versioning for TypeScript Types specification.

  • Currently supported TypeScript versions: 5.3–6.0
  • Compiler support policy: simple majors
  • Public API: all published, documented types not in a -private module and not marked as @internal or @private are public

Basic bundle size info

Size of the ESM build without tree-shaking (yes, these are in bytes: this is a pretty small library!):

file size (B) terser[^terser] (B) terser and brotli[^brotli] (B)
-private/utils.js 942 358 175
index.js 644 352 122
maybe.js 23052 3838 943
result.js 21376 4257 1034
standard-schema.js 5984 758 318
task/delay.js 3901 649 259
task.js 59937 7629 2036
test-support.js 473 142 89
toolbelt.js 3739 886 278
unit.js 656 58 57
total[^total] 120704 18927 5311

Notes:

  • The unmodified size includes comments.

  • Thus, running through Terser gets us a much more realistic size: about 18.1KB to parse.

  • The total size across the wire of the whole library will be ~5.2KB.

  • This is all tree-shakeable to a significant degree: you should only have to “pay for” the types and functions you actually use, directly or indirectly. If your production bundle does not import or use anything from true-myth/test-support, you will not pay for it, for example. However, some parts of the library do depend directly on other parts: for example, toolbelt uses exports from result and maybe, and Task makes extensive use of Result under the hood.

    In detail, here are the dependencies of each module:

    Module Depends on
    index.js All, but as tree-shakeable as possible
    maybe.js unit.js, -private/utils.js
    result.js unit.js, -private/utils.js
    standard-schema.js task.js, result.js
    task.js result.js, unit.js, task/delay.js, -private/utils.js
    task/delay.js None
    test-support.js maybe.js, result.js
    toolbelt.js maybe.js, result.js, -private/utils.js
  • This intentionally excludes the ESLint plugin contents, which should not be part of an production bundle.

[^terser]: Using terser 5.46.2 with --compress --mangle --mangle-props.

[^brotli]: Generated by running gzip -kq11 on the result of the terser invocation.

[^total]: This is just the sum of the previous lines. Real-world bundle size is a function of what you actually use, how your bundler handles tree-shaking, and how the results of bundling compresses. Notice that sufficiently small files can end up larger after compression; this stops being an issue once part of a bundle.

Inspiration

The design of True Myth draws heavily on prior art; essentially nothing of this is original – perhaps excepting the choice to make Maybe.of handle null and undefined in constructing the types. In particular, however, True Myth draws particular inspiration from:

Related repositories
n8n-io/n8n

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

TypeScriptnpmOtherautomationipaas
n8n.io
197.4k59.5k
microsoft/vscode

Visual Studio Code

TypeScriptnpmMIT Licenseeditorelectron
code.visualstudio.com
187.8k41.3k
f/prompts.chat

f.k.a. Awesome ChatGPT Prompts. Share, discover, and collect prompts from the community. Free and open source — self-host for your organization with complete privacy.

HTMLOtherchatgptai
prompts.chat
166.2k21.5k
langchain-ai/langchain

The agent engineering platform.

PythonPyPIMIT Licenseaianthropic
docs.langchain.com/langchain/
142.3k23.7k
farion1231/cc-switch

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

Rustcrates.ioMIT Licenseai-toolsclaude-code
ccswitch.io
119.8k8k
microsoft/TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

TypeScriptnpmApache License 2.0typescriptjavascript
typescriptlang.org
109.9k13.6k
immich-app/immich

High performance self-hosted photo and video management solution.

TypeScriptnpmGNU Affero General Public License v3.0backup-toolmobile-app
immich.app
108.4k6.3k
denoland/deno

A modern runtime for JavaScript and TypeScript.

Rustcrates.ioMIT Licensedenotypescript
deno.com
107.8k6.2k
angular/angular

Deliver web apps with confidence 🚀

TypeScriptnpmMIT Licenseangulartypescript
angular.dev
100.6k27.5k
ant-design/ant-design

An enterprise-class UI design language and React UI library

TypeScriptnpmMIT Licensereactui-kit
ant.design
98.8k54.7k
oven-sh/bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one

Rustcrates.ioOtherbunbundler
bun.com
95k4.9k
storybookjs/storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation

TypeScriptnpmMIT Licensestorybookstyleguide
storybook.js.org
90.6k10.2k