@f/maybe-over

Maps a collection of things that may be functions over a value

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
00Feb 19, 2016Feb 19, 2016Minified + gzip package size for @f/maybe-over in KB

Readme

maybe-over

Build status Git tag NPM version Code style

Maps a collection of things that may be functions over a value. Like over, but allows for the possibility that some things in the collection are not functions.

Installation

$ npm install @f/maybe-over

Usage

Example, a hover component:

var maybeOver = require('@f/maybe-over')

function render ({children, state}) {
  children = maybeOver(state.hovering, children)

  return (
    <span>
      {
        maybeOver(state.hovering, children)
      }
    </span>
  )
}

API

maybeOver(value, maybeFns)

  • value - The value you want to call the functions in maybeFns with
  • maybeFns - A list of items. If the value in the list is a function, it will be executed with value as its first argument.

Returns: The result of executing all the functions in maybeFns on value, and just returning the other values in maybeFns.

License

MIT

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.