npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

fp-utils-types

v1.5.1

Published

FP utilities and types

Readme

Functional Programming utils and types

Hi! I am Takuya. Functional Programming utils and types provides you utilities and types that are well documented and easy to use.

Documentations

Compose

(functions) => composed function

import { compose } from 'fp-utils-types'

const composed = compose(smile, exclaim, toUpper)
composed('hello') // 'HELLO! :)'

CurryN

(number, function) => curried function

import { curryN } from 'fp-utils-types'

const obj = { name: 'foo' }
const prop = (key, obj, defaultValue) => (obj[key] ? obj[key] : defaultValue)

const curried1 = curryN(3, prop)('name', example)('hey')
const curried2 = curryN(3, prop)('name')(example)('hey')
curried1({ name: 'foo' }) // 'foo'
curried2({ name: 'foo' }) // 'foo'

FilterReducer

(a -> b) => ((a, b) -> c) => ((a, b) -> c)

import { filterReducer } from 'fp-utils-types'

const ns = [1, 2, 3]
const is1 = x => x === 1

ns.reduce(filterReducer(is1)(combinerByConcat), []) // [1]

MapReducer

(a -> b) => ((a, b) -> c) => ((a, b) -> c)

import { compose, curryN, mapReducer } from 'fp-utils-types'

const ns = [1, 2, 3]
const add = curryN(2, (x, y) => x + y)
const add1 = add(1)
const combinerByConcat = (acc, x) => acc.concat(x)

const transducer = compose(mapReducer(add1))

ns.reduce(transducer(combinerByConcat), []) // [2, 3, 4]
ns.reduce(transducer(add), 0) // 9

Pipe

(functions) => piped function

import { pipe } from 'fp-utils-types'

const piped = pipe(toUpper, exclaim, smile)
composed('hello') // 'HELLO! :)'

Either

(any) => Left(any) | Right(any)

| Methods | Argument | Return | | ------- | ------------- | ---------------------------------------------------------------------------------------------------------- | | map | unary | Left or Right | | chain | unary | Left or Right (chain itself returns the value of Left or Right so your unary needs to return Left or Right | | concat | Left or Right | Left or Right (concat if both of them are Right. Otherwise keep Left) | | fold | unary, unary | First unary is for when the value is Left. Second unary runs when the value is Right |

import { Either, id } from "fp-utils-types"
const { Left, Right } = Either

const isString = s => typeof(s) === 'string' ? Right(s) : Left(s)

const sayItNicely = s =>
  Either.fromNullable(s).map(toUpper).map(compose(smile, exclaim))

sayItNicely('hello').fold(() => "Left", id) // "HELLO! :)"
sayItNicely(null).fold(() => "Left", id) // "Left"

Identity

| Methods | Argument | Return | | ------- | -------- | ------------------------------------------------------------------------------------------- | | map | unary | Identity | | chain | unary | Identity (chain itself returns the value of Identity so your unary needs to return Identity | | concat | Identity | Identity | | fold | unary | value |

import { Identity } from "fp-utils-types"

Identity.of("hello")
      .map(toUpper)
      .map(exclaim)
      .map(smile)
      .fold(id) // "HELLO! :)"

Identity.of("hello")
      .map(toUpper)
      .concat(Identity(" world").map(exclaim).map(smile))
      .fold(id) // "HELLO world! :)"

Identity.of(["hello", "world"])
      .map(x => x.map(toUpper))
      .concat(Identity(["!"]).map(xs => xs.map(smile)))
      .fold(id) // ["HELLO", "WORLD", "! :)"]

IO

a -> IO a

| Methods | Signature | | --------------- | ------------------- | | map | (a -> b) -> IO a | | chain | (a -> IO b) -> IO c | | unsafePerformIO | _ -> a |

import { IO } from "fp-utils-types"

IO.of(2).map(add1).map(add1).unsafePerformIO()) // 4
IO.of(2)
  .map(x => x * 100)
  .chain(result =>
    IO.of([result, 25]).map(x => x.reduce((acc, y) => add(acc, y)))
   )
  .unsafePerformIO() // 225