Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jdolle/unfun-ts
Practical helpers to unfunctionalize fp-ts types
https://github.com/jdolle/unfun-ts
fp-ts functional-programming typescript
Last synced: 7 days ago
JSON representation
Practical helpers to unfunctionalize fp-ts types
- Host: GitHub
- URL: https://github.com/jdolle/unfun-ts
- Owner: jdolle
- License: mit
- Created: 2020-02-15T09:31:14.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-11T17:07:32.000Z (21 days ago)
- Last Synced: 2024-12-22T23:30:07.112Z (10 days ago)
- Topics: fp-ts, functional-programming, typescript
- Language: TypeScript
- Homepage: https://jdolle.github.io/unfun-ts/
- Size: 368 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# unfun-ts
[![Maintainability](https://api.codeclimate.com/v1/badges/8f9c1a0cb3f5c1857bd1/maintainability)](https://codeclimate.com/github/jdolle/unfun-ts/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/8f9c1a0cb3f5c1857bd1/test_coverage)](https://codeclimate.com/github/jdolle/unfun-ts/test_coverage) [![CircleCI](https://circleci.com/gh/jdolle/unfun-ts.svg?style=shield&circle-token=8a84ce64e98e1931fcfaea27b0ad3ba13f147c92)](https://circleci.com/gh/jdolle/unfun-ts)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`](https://github.com/gcanti/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
```ts
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}`);
}
```