OshinKaramian / maybe-callback

Maybe call a callback if its a function

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

maybe-callback NPM Version Build Status

Maybe call a callback if it really is who it says it is.

Installation

Node.js is required. To install, type this at the command line:

npm install maybe-callback

Usage

var maybeCallback = require('maybe-callback');
 
function callback(arg) {
    return arg + 1;
}

maybeCallback(callback)(1);  //=> 2
maybeCallback(null)(1);  //=> undefined

var once = maybeCallback.once(callback);
once(1); //=> 2
once(1); //=> undefined

About

Maybe call a callback if its a function

License:MIT License


Languages

Language:JavaScript 100.0%