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 🙏

© 2024 – Pkg Stats / Ryan Hefner

plura

v0.7.0

Published

Super simple functional programming library

Downloads

27

Readme

Plura

npm version

Super simple functional programming library

Installation

npm install plura --save

Roadmap

  • monads...

Usage

Check tests for more usage information

Summary

always

Syntax

const getTen = always(10) // >> function
getTen() // >> 10

Parameters

  • value

Return value

Function and if executed get value

ap

Syntax

ap([addTwo, minusOne], [1, 2, 3]) // >> [3, 4, 5, 0, 1, 2]

Parameters

  • fns
    • array of functions
  • values
    • array of values

Return value

Array of applied functions to a array of values

chain

Aka: flatMap

Syntax

chain(duplicate, [1, 2]) // >> [1, 1, 2, 2]

Parameters

  • fn
    • function to change values
  • array
    • array to change

Return value

Array

compose

Syntax

const minusOneTimesTo = compose(timeTwo, minusOne)
minusOneTimesTo(2) // >> 2

Parameters

  • fns
    • as many functions you want
  • arguments
    • initial arguments

Return value

Composed functions

curry

Syntax

const addC = curry(add)
addC(1, 1, 1) // >> 3
addC(1)(1)(1) // >> 3
addC(1)(1, 1) // >> 3

Parameters

  • fn
    • function you want to curry
  • arguments
    • as many arguments needed to fulfill fn parameters

Return value

Curry:ed function

curryDestructed

Syntax

// add must have simple destruction! : no rest ... or nested destructions
const add = ({ a, b, c}) => a + b + c

const addC = curryDestructed(add)
addC({a: 1, b: 1, c: 1})     // >> 3
addC({a: 1})({b: 1})({c: 1}) // >> 3
addC({c: 1})({b: 1, a: 1})   // >> 3

Parameters

  • function you want to curry
  • arguments
    • as many arguments needed to fulfill fn parameters

Return value

Curry:ed function

curryObject

Syntax

// with object
const objectTemplate = {
  a: '',
  b: '',
  c: '',
}
const addC = curryObject(objectTemplate, add)
addC({a: 1, b: 1, c: 1})     // >> 3
addC({a: 1})({b: 1})({c: 1}) // >> 3
addC({c: 1})({b: 1, a: 1})   // >> 3

// with array
const arrayTemplate = [
  'a',
  'b',
  'c',
]
const addC = curryObject(arrayTemplate, add)
addC({a: 1, b: 1, c: 1})     // >> 3
addC({a: 1})({b: 1})({c: 1}) // >> 3
addC({c: 1})({b: 1, a: 1})   // >> 3

Parameters

  • template
    • template of object keys, object|array
  • fn
    • function you want to curry
  • arguments
    • as many arguments needed to fulfill fn parameters

Return value

Curry:ed function

filter

Syntax

filter(isEven, [2, 3, 6]) // >> [2]

Parameters

  • fn
    • function you want to apply to check array elements
  • array
    • array to filter over

Return value

Altred array

find

Syntax

find(hasIdOfOne, [{ id: 10 }, { id: 1 }]) // >> { id: 1 }

Parameters

  • fn
    • function to evaluate values
  • array
    • array to find value in
  • initailValue
    • optional
    • if find doesn't find anything initialValue will be returned, default: undefined

Return value

Any, found value

isArray

Syntax

isArray([1, 2]) // >> true

Parameters

  • any
    • checks if array or not

Return value

Boolean

isNumber

Syntax

isNumber(10) // >> true

Parameters

  • any
    • checks if number or not

Return value

Boolean

isObject

Syntax

isObject({ x: 1 }) // >> true

Parameters

  • any
    • checks if object or not

Return value

Boolean

isString

Syntax

isString('abc') // >> true

Parameters

  • any
    • checks if string or not

Return value

Boolean

map

Syntax

map(addOne, [1, 2, 3]) // >> [2, 3, 4]

Parameters

  • fn
    • function you want to apply to array elements
  • array
    • array to map over

Return value

Altred array

pipe

Syntax

const minusOneTimesTo = pipe(timeTwo, minusOne)
minusOneTimesTo(2) // >> 3

Parameters

  • fns
    • as many functions you want
  • arguments
    • initial arguments

Return value

Composed functions

reduce

Syntax

reduce(merge, 0, [2, 3, 6]) // >> 9

Parameters

  • fn
    • function you want to apply on array elements
  • initialValue
    • start value for your reduce
  • array || object
    • array || object to reduce over

Return value

Any

reduceobjindexed

Syntax

const addToArray = (a, [key, value]) => a.concat(key, value)

reduceObjIndexed(addToArray, [], {x: 2, y: 4}) // >> ['x', 2, 'y', 4]

Parameters

  • fn
    • function you want to apply on array elements
  • initialValue
    • start value for your reduce
  • object
    • object to reduce over

Return value

Any