maybe-callback

Maybe call a callback if it's a function

MIT 2 个版本
安装
npm install maybe-callback
yarn add maybe-callback
pnpm add maybe-callback
bun add maybe-callback
README

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
版本列表
2.1.0 2016-01-26
1.0.0 2014-09-30