Skip to content

filipdanic/execute-if-function

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
/**
 * execute-if-function
 * --------------
 *
 * Execute passed argument if it is a function.
 *
 * `npm install execute-if-function`
 *  or
 * `yarn add execute-if-function`
 *
 * Example:
 * executeIfFunction(someFunction); // will execute function and return result
 * executeIfFunction(someNonFunction); // will just return back someNonFunction
 *
 */

/**
 * @param {*} fn
 * @returns {*}
 */
var executeIfFunction = function executeIfFunction(fn) {
  return typeof fn === 'function' ? fn() : fn;
};

module.exports = executeIfFunction;

About

Execute passed argument if it is a function.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published