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

understory

v2.0.3

Published

Composable utility functions based on lodash fp.

Downloads

48

Readme

Understory

Version 2 is ESM.

Importing all of lodash/fp.js #4296

Composable utility functions based on or inspired by lodash. For best results learn about _.flow() and read the Lodash FP Guide.

Install ESLint rules for lodash/fp by extending eslint with plugin:lodash-fp/recommended and including the lodash-fp plugin.

There are also promise enabled varients of _.flow as flowP and _.forEach as forEachP.

We call it "understory" because it's close to "underscore" and the understory is the layer of vegetation below the forest canopy.

branch

Curried function form of a conditional ternary expression

Parameters

  • trueVal any The value returned when true.
  • falseVal any The value returned when false.
  • bool any The value to check truthiness against.

Returns any The trueVal or falseVal depending on bool.

overBranch

Passes argument to boolCheck function. If true sends same argument to getTrue function.

Parameters

  • boolCheck (Function | any) Function that check if value is true.
  • getTrue (Function | any) Get the value when true.
  • getFalse (Function | any) Optional. Get value when false. (optional, default identity)

Examples

overBranch(boolCheck, getTrue)

Returns any Function that accepts a value and returns result of getTrue or getFalse.

onTrue

Passes argument to boolCheck function. If true sends same argument to getTrue function. Similar to overBranch but no getFalse option.

Parameters

  • boolCheck (Function | any) Function that check if value is true.
  • getValue (Function | any) Get the value when true.
  • item (Function | any) The value sent to boolCheck.

Examples

onTrue(_.isString, _.toUpper)('foo') // => 'FOO'
onTrue(_.isString, _.toUpper)(45) // => 45

Returns any Result of getValue when true or the untouched item.

callWith

[callWith description]

Parameters

  • args [type] [description]

Returns [type] [description]

condId

  • See: onTrue if you have one condition.

Accepts many [boolCheck, onTrue] arguments. See _.cond() for more info. The function or exact match to check item against. If onTrue is a function it is sent the the value like _.cond() If onTrue is not a function the value of onTrue is returned.

Parameters

  • conditions array one or more condition arrays [boolCheck, thenFunc]

Returns any Result of found thenFunc or if no conditions found return original.

isFalse

Returns true if sent a value that is exactly false.

Parameters

  • value any Send it anything

Examples

isFalse(1) // => false
isFalse(false) // => true

Returns bool Tells you if it is exactly false.

isZero

Returns true if sent a value that is exactly 0.

Parameters

  • value any Send it anything

Examples

isZero(0.1) // => false
isZero(0) // => true

Returns bool Tells you if it is exactly zero.

isTrue

Returns true if sent a value that is exactly false.

Parameters

  • value any Send it anything

Examples

isTrue(1) // => false
isTrue(true) // => true

Returns bool Tells you if it is exactly false.

isWorthless

[isWorthless description]

Parameters

  • value any

Examples

isWorthless({}) // => true
isWorthless([' ', null]) // => true
isWorthless(' ') // => true
isWorthless({ foo: null, bar: 0 }) // => true

Returns bool Tells you if value is empty.

isValue

If value is truthy, null, zero, or false.

Parameters

  • value any

Returns bool Tells you if arg is a value probably worth keeping.

hasSize

Opposite of _.isEmpty.

Type: Function

oneOf

A curried version of _.includes without a rearg.

Type: Function

Examples

oneOf([2,3,4])(3) // => true

isGt

Checks to see if second arg is greater than first. See _.lt

Type: Function

Examples

isGt(1)(2) // => true

isLt

Checks to see if second arg is less than first. See _.gt

Type: Function

Examples

isLt(2)(1) // => true

subtrahend

Subtract two numbers.

Parameters

  • subtrahend number A quantity/number to be subtracted from another.
  • minuend number A quantity/number from which another is to be subtracted.

Examples

_.subtrahend(6)(8);
// => 2
_.subtrahend(6, 8);
// => 2

Returns number Returns the difference.

addend

Add two numbers or strings.

Parameters

  • addend (number | string) A quantity/number to be added to the end of another.
  • augend (number | string) A quantity/number from to another is added.

Examples

_.addend('c')('ab');
// => 'abc'

Returns number Returns the sum.

roundTo

Round number with precision.

Parameters

  • precision number The precision to round to.
  • number number The number to round.

Examples

round(1)(14.23);
// => 14.2

Returns number Returns the rounded number.

arrayToIndex

Create an index with keys of arr and all values of val.

Parameters

  • arr array [description]
  • val Boolean [description] (optional, default true)

Returns Object [description]

forEachP

Like _.forEach but can handle a promise generator as the iteratee. Iterates over elements of collection and invokes iteratee for each element. The iteratee is invoked with one argument: (value). Iteratee functions may NOT exit iteration early.

Parameters

  • iteratee Function The function that should process each item.
  • collection Array The iterable. Each val send to func after previous resolves.

Returns Promise The value return value of the last promise.

mapP

map for Promises. Invokes iteratee in serial sequence instead of all at once.

Parameters

  • iteratee Function The function that should process each item.
  • collection Array The iterable. Each val send to func after previous resolves.

Returns Promise The value return value of the last promise.