nnmap

1.0.0 • Public • Published

nnmap

nnmap is a function that takes a function and a value, then call the function with the value only if the value is not nil (undefined or null).

Usage

npm install --save nnmap
var nnmap = require('nnmap');
 
nnmap(function(a) {
  return a + 2;
}, 3);
// > 5
 
nnmap(function(a) {
  return a + 2;
}, undefined);
// > undefined
 
nnmap(function(a) {
  return a + 2;
}, null);
// > null

It also supports currying

var nnmap = require('nnmap');
 
[1,2,undefined, 4, 5].map(nnmap(function(a) {
  return a + 2;
}));
// > [3, 4, undefined, 6, 7]

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    106
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    106

Package Sidebar

Install

npm i nnmap

Weekly Downloads

16

Version

1.0.0

License

MIT

Last publish

Collaborators

  • zhangchiqing