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

1.2.10 • Public • Published

FP utils

A bunch of useful utility functions

Examples

Either

import { either, Either, Right, Left } from 'fputils';

// define fetch function, this function does not throw, but returns Either data or error instead
const get = <T>(url: string): Either<Error, T> => new Promise(async resolve => {
    try {
        return resolve(Right(await fetch(url)))
    } catch (error) {
        return resolve(Left(error))
    }
});

// either usage
either((error) => {
    console.error({ error })
}, (result) => {
    console.log({ result })
}, await get<string[]>('https://api'));

Readme

Keywords

Package Sidebar

Install

npm i fputils

Weekly Downloads

27

Version

1.2.10

License

ISC

Unpacked Size

94.9 kB

Total Files

122

Last publish

Collaborators

  • dejvovo
  • smidhonza
  • kolebjak
  • dtourek