fn-safe-run

1.0.6 • Public • Published

Purposes

Safe run functions with params (or not).

Installation

$ npm install fn-safe-run

Usage

Method Description
checkAndRun Checking and run first param if it is a function. Other parameters are arguments to the passed function.
checkAndRunLog Same as checkAndRun but logging if the first param is not a function (Use for debugging).

Example

import { checkAndRun, checkAndRunLog } from 'fn-safe-run';
... 
{ 
  const func = console.log;
  const obj = {hello: 'world'};
 
  checkAndRun(func, 12345); // Call console.log with param 12345
  checkAndRun(obj); // Nothing will happen :)
  checkAndRunLog(obj, 12345); // Return in console: 'Argument [object Object] is not a function'
}

Package Sidebar

Install

npm i fn-safe-run

Weekly Downloads

8

Version

1.0.6

License

ISC

Unpacked Size

1.85 kB

Total Files

3

Last publish

Collaborators

  • ocaxapprivet