1.0.6 • Published 5 years ago

fn-safe-run v1.0.6

Weekly downloads
83
License
ISC
Repository
github
Last release
5 years ago

Purposes

Safe run functions with params (or not).

Installation

$ npm install fn-safe-run

Usage

MethodDescription
checkAndRunChecking and run first param if it is a function. Other parameters are arguments to the passed function.
checkAndRunLogSame 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'
}
1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago