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

2.0.2 • Public • Published

unfun-ts

Maintainability Test Coverage CircleCI

Practical helpers to unfunctionalize fp-ts types

Description

Functional programming is powerful, but not always the most practical. This package encourages using functional programming in Typescript using fp-ts by providing a very practical way to interact with the broader, imperative codebase.

Install

unfun-ts is a utility library for fp-ts. Therefore fp-ts is a peer dependency of unfun-ts.

yarn add unfun-ts
yarn add fp-ts@^2.0.0

Usage

import * as UE from "unfun-ts/lib/Either";
import * as E from "fp-ts/lib/Either";
import { pipe } from "fp-ts/lib/pipeable";
 
// const nullyValue: undefined | number;
try {
  const value = pipe(
    nullyValue,
    E.fromNullable("nully"),
    UE.getOrThrow(),
  );
} catch (bad) {
  console.error(`The value was ${bad}`);
}

Package Sidebar

Install

npm i unfun-ts

Weekly Downloads

1

Version

2.0.2

License

MIT

Unpacked Size

22.8 kB

Total Files

39

Last publish

Collaborators

  • jdolle