1.0.0 • Published 7 years ago
nnmap v1.0.0
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]
1.0.0
7 years ago