nullify

Wrap a function to only run on non-null values

Usage no npm install needed!

<script type="module">
  import nullify from 'https://cdn.skypack.dev/nullify';
</script>

README

nullify Build Status

Wrap a function to only run on non-null values

Install

$ npm install --save nullify

Usage

var nullify = require('nullify')

nullify(reverse)('foo')
//=> oof

nullify(reverse)(null)
//=> null

function reverse (string) {
  return string.split('').reverse().join('')
}

API

nullify(fn) -> function

Returns a function that passes through to fn when the outer function receives a non-null value.

fn

Required
Type: function

License

MIT © Ben Drucker