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 🙏

© 2026 – Pkg Stats / Ryan Hefner

fpu

v0.3.8

Published

Functional programming utilities

Readme

FPU

Functional programming utilities

Changelog

0.3.8 (latest)

Upgrade babel, webpack and co, remove browser build

0.3.7

Fix Factories::reduce and Immutables

0.3.0

Add Factories

0.2.0

Add Immutables

0.1.0

Initial release : Curries, Functions, Helpers, Predicates & Types

Requirement

node >= 6

Installation

npm install fpu

Documentation

Usage

// ES6-
const {
  Curries,
  Factories,
  Functions,
  Helpers,
  Immutables,
  Predicates,
  Types
} = require('fpu')

// ES6+
import {
  Curries,
  Factories,
  Functions,
  Helpers,
  Immutables,
  Predicates,
  Types
} from 'fpu'

Helpers

apply

Partial application

import { Functions, Helpers } from 'fpu'

const inc = Helpers.apply( Functions.add, 1 )

inc( 4 )
// 5

compose

Right to left function composition

import { Functions, Helpers } from 'fpu'

const { add, multiply } = Functions,
      dbl = Helpers.apply( multiply, 2 ),
      inc = Helpers.apply( add, 1 )

const addIncThenDbl = Helpers.compose( dbl, inc, add )

addIncThenDbl( 1, 2 )
// 8

curry

Function currying

import { Functions, Helpers } from 'fpu'

const curriedAdd = Helpers.curry( Functions.add ),
      add5 = curriedAdd( 5 )

curriedAdd( 1, 2 )
// 3

add5( 3 )
// 8

pipe

Left to right function composition

import { Functions, Helpers } from 'fpu'

const { add, multiply } = Functions,
      dbl = Helpers.apply( multiply, 2 ),
      inc = Helpers.apply( add, 1 )

const addIncThenDbl = Helpers.pipe( add, inc, dbl )

addIncThenDbl( 1, 2 )
// 8

Immutables

Immutables always return an immutable.

array

import { Immutables } from 'fpu'

const a = Immutables( [] )

// or

const a = Immutables()
append

Append items

import { Immutables } from 'fpu'

const a = Immutables([ 'foo', 'bar', 'qnx' ])

a.append( 'doh', 'woo' )
// [ 'foo', 'bar', 'qnx', 'doh', 'woo' ]
insert

Insert item(s) at a position

import { Immutables } from 'fpu'

const a = Immutables([ 'foo', 'bar', 'qnx' ])

a.insert( 2, 'doh', 'woo' )
// [ 'foo','bar', 'doh', 'woo', 'qnx' ]
length

Length of the array

import { Immutables } from 'fpu'

const a = Immutables([ 'foo', 'bar', 'qnx' ])

a.length
// 3
prepend

Prepend item(s)

import { Immutables } from 'fpu'

const a = Immutables([ 'foo', 'bar', 'qnx' ])

a.prepend( 'doh', 'woo' )
// [ 'doh', 'woo', 'foo', 'bar', 'qnx' ]
remove

Remove item(s) with position(s) and/or value(s)

import { Immutables } from 'fpu'

const a = Immutables([ 'foo', 'bar', 'qnx', 'woo' ])

a.remove( 1 )
// [ 'foo', 'qnx', woo' ]

a.remove( 1, 2 )
// [ 'foo', woo' ]

a.remove( 'bar' )
// [ 'foo', 'qnx', woo' ]

a.remove( 'bar', 'qnx' )
// [ 'foo', 'woo' ]

a.remove( 'bar', 3 )
// [ 'foo', 'qnx' ]
replace

Replace item(s) from a position

import { Immutables } from 'fpu'

const a = Immutables([ 'foo', 'bar', 'qnx', 'woo' ])

a.replace( 1, null, null )
// [ 'foo', null, null, 'qnx', 'woo' ]
sort

Aka quick sort

import { Immutables } from 'fpu'

const a = Immutables([ 'woo', 'foo', 'doh', 'qnx', 'bar' ])

a.sort()
// [ 'bar', 'doh', 'foo', 'qnx', 'woo' ]

a.sort( true )
// [ 'woo', 'qnx', 'foo', 'doh', 'bar' ]
unique

Only unique values

import { Immutables } from 'fpu'

const a = Immutables([ 17, 43, 10, 51, 10, 43, 28 ])

a.unique()
// [ 17, 43, 10, 51, 28 ]
value

Return array's value

import { Immutables } from 'fpu'

const a = Immutables([ 'foo', 'bar', 'qnx' ])

a.value
// [ 'foo', 'bar', 'qnx' ]

object

import { Immutables } from 'fpu'

const a = Immutables( {} )
keys

Keys of the object

import { Immutables } from 'fpu'

const o = Immutables({ foo: 'bar', qnx: null, hello: 'world' })

o.keys
// [ 'foo', 'qnx', 'hello' ]
set

Add and/or update property's values

import { Immutables } from 'fpu'

const o = Immutables({ foo: 'bar', qnx: null, hello: 'world' })

o.set({ pid: 0 })
// { foo: 'bar', qnx: null, hello: 'world', pid: 0 }

o.set({ qnx: 'doh' })
// { foo: 'bar', qnx: 'doh', hello: 'world' }

o.set({ qnx: 'doh', pid: 0 })
// { foo: 'bar', qnx: 'doh', hello: 'world', pid: 0 }
unset

Unset properties

import { Immutables } from 'fpu'

const o = Immutables({ foo: 'bar', qnx: null, hello: 'world' })

o.unset( 'qnx', 'hello' )
// { foo: 'bar' }
value

Return object's value

import { Immutables } from 'fpu'

const a = Immutables({ foo: 'bar', qnx: null, hello: 'world' })

a.value
// { foo: 'bar', qnx: null, hello: 'world' }

Factories

filter

Array.filter factory

import { Factories } from 'fpu'

const a = [ 0, 1, 2, 3, 4, 5 ]
const oddOnly = (v) => v % 2 === 1
const oddFilter = Factories.filter( oddOnly )

oddFilter( a )
// [ 1, 3, 5 ]

map

Array.map factory

import { Factories } from 'fpu'

const a = [ 0, 1, 2, 3, 4, 5 ]
const dbl = (v) => v * 2
const dblMap = Factories.map( dbl )

dblMap( a )
// [ 0, 2, 4, 6, 8, 10 ]

reduce

Array.reduce factory

import { Factories } from 'fpu'

const items = [
  { foo: 'bar', woo: null },
  { qnx: true },
  { woo: false }
]

const merge = (a, b) => ({ ...a, ...b })
const mergeObj = Factories.reduce( merge )

mergeObj( items )
// { foo: 'bar', woo: false, qnx: true }

Functions

All this functions have an arity of 2.

add, and, divide, multiply, or, substract

Predicates

All this functions have an arity of 2.

eq, gt, gte, lt, lte, not

Curries

Curried functions and predicates, with an arity of 1.

add, and, divide, eq, gt, gte, lt, lte, multiply, not, or, substract

Types

Types detection's functions, with and arity of 1.

isArray, isboolean, isNull, isNumber, isObject, isString, isUndefined