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

std-fns

v0.2.3

Published

Functional JavaScript Library

Downloads

25

Readme

std-fns

Standard Functions is a library aimed to fill in the gaps in the JS standard library. The library follows, or aims to follow, functional programming methodologies. Even though stable it is not very useful at the moment, so use at your own risk.

Documentation

Functions

bimap(leftFn, rightFn, p) ⇒ Promise.<(R|never)>

Map over the success or error of a promise.

Kind: global function

| Param | Type | | --- | --- | | leftFn | function | | rightFn | function | | p | Promise.<(T|never)> |

fmap(fn, p) ⇒ Promise.<(T|never)>

Map over the value of a promise. The function provided should return another Promise.

Kind: global function

| Param | Type | | --- | --- | | fn | function | | p | Promise.<(T|never)> |

lmap(fn, p) ⇒ Promise.<(T|never)>

Short for left map, map over the error, or catch, of a promise. The function will only be called if the promise provided has fail.

Kind: global function

| Param | Type | | --- | --- | | fn | function | | p | Promise.<(T|never)> |

map(fn, p) ⇒ Promise.<(T|never)>

Map over the value of a promise. The map function will only be called if the promise is resolved.

Kind: global function

| Param | Type | | --- | --- | | fn | function | | p | Promise.<(T|never)> |

tap(fn, p) ⇒ Promise.<T>

Create a side effect from the value of a promise. The tap function is only called if the promise is resolved.

Kind: global function

| Param | Type | | --- | --- | | fn | function | | p | Promise.<T> |

always(val) ⇒ function

Creates a function which always returns the same value.

Kind: global function

| Param | Type | | --- | --- | | val | * |

and(...args) ⇒ *

Evaluates all arguments passed and returns the first falsey or last truthy value. It works like && operator.

Kind: global function

| Param | Type | | --- | --- | | ...args | Array.<mixed> |

compose(...fns) ⇒ function

Compose a function from all functions passed as arguments from left to right.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | ...fns | function | Comma separated list of functions |

composeRight(...fns) ⇒ function

Compose a function from all functions passed as arguments from right to left.

Kind: global function

| Param | Type | | --- | --- | | ...fns | function |

curry(fn, ...initialArgs) ⇒ function

Curry a function taking arguments from left to right. The constructor function accepts multiple value arguments. Returned functions also accept multiple arguments.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | fn | function | | | ...initialArgs | Array.<mixed> | Comma separated list of arguments. Can be undefined. |

curryRight(fn, ...initialArgs) ⇒ function

Curry a function taking arguments from right to left. The constructor function accepts multiple value arguments. Returned functions also accept multiple arguments.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | fn | function | | | ...initialArgs | $ReadOnlyArray.<mixed> | Comma separated list of arguments. Can be undefined. |

identity(val) ⇒ T

Pass a value to a function which returns said value.

Kind: global function

| Param | Type | | --- | --- | | val | T |

inst(methodName, val) ⇒ any | null

Call instance method of an object.

Kind: global function

| Param | Type | | --- | --- | | methodName | String | | val | Object |

negate(fn) ⇒ function

Creates a function which negates the value of the result. Works like the ! operator on the result of the function provided

Kind: global function

| Param | Type | | --- | --- | | fn | function |

not(val) ⇒ boolean

Negates a argument to a boolean value like the ! operator.

Kind: global function

| Param | Type | | --- | --- | | val | * |

or(...args) ⇒ *

Evaluates all arguments passed and returns the first truthy or last falsey value. It works like || operator.

Kind: global function

| Param | Type | | --- | --- | | ...args | $ReadOnlyArray.<mixed> |

partial(fn, ...args) ⇒ function

Partially apply arguments to a function from left to right.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | fn | function | | | ...args | $ReadOnlyArray.<mixed> | Comma separated list of values. |

partialRight(fn, ...outerArgs) ⇒ function

Partially apply arguments to a function from right to left.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | fn | function | | | ...outerArgs | $ReadOnlyArray.<mixed> | Comma separated list of values. |

trim(val) ⇒ string

Trims a string. Works like the string trim method.

Kind: global function

| Param | | --- | | val |

dec(num) ⇒ number

Decrement a number by one.

Kind: global function

| Param | Type | | --- | --- | | num | number |

inc(num) ⇒ number

Increment a number by one.

Kind: global function

| Param | Type | | --- | --- | | num | number |

subtract(...numbers) ⇒ number

Subtract all numbers passed into the function. It will subtract from left to right, first argument minus the second and then the product minus the next argument and so on.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | ...numbers | Array.<number> | Comma separated list of values. |

sum(...numbers) ⇒ number

Sum all numbers passed into the function. It will sum from left to right, first argument plus the second and then the product plus the next argument and so on.

Kind: global function

| Param | Type | Description | | --- | --- | --- | | ...numbers | Array.<number> | Comma separated list of values. |

Todo

  • Add more function.
  • Add data structures.
  • Add algebraic types.
  • Add Flow library definition to the flow-typed project.