Tsentials these

From senrecep/tsentials · View interactive version

Tsentials these is an AI agent skill from the GitHub repository senrecep/tsentials. Use when a computation can produce both a value and errors (partial success).

How to use this skill

Skill file

tsentials/these — Skill

Use when a computation can produce both a value and errors (partial success).

API

import { These } from 'tsentials/these';

// Constructors
These.left(err);           // failure only
These.right(42);           // success only
These.both(err, 42);       // partial success

// Pipeline
These.map(these, n => n * 2);
These.mapLeft(these, e => wrap(e));
These.flatMap(these, n => validate(n)); // from Both: f's Left wins, else Both(original left, new value)

// Type guards
These.isLeft(these);       // boolean
These.isRight(these);      // boolean
These.isBoth(these);       // boolean

// Pipeline
These.tap(these, v => console.log(v));     // side effect on success value
These.tapLeft(these, e => console.log(e)); // side effect on error value

// Extraction
These.match(these, onLeft, onRight, onBoth);
These.getRight(these);     // A | undefined
These.getLeft(these);      // E | undefined

// Convert to/from Result
These.toResult(these);       // Both → failure
These.toResultLenient(these); // Both → success (discards errors)
These.fromResult(result);

// Partition an array
These.partition([These.right(1), These.left(err)]);

Patterns

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.