Skip to content

Fallback when a value is not Function.

License

Notifications You must be signed in to change notification settings

value-fallback/FNVL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FNVL

license npm npm Travis ESLint Gluons

Fallback when a value is not Function.

Installation

Via NPM:

NPM

npm install fnvl

Via Yarn:

yarn add fnvl

Usage

const fnvl = require('fnvl');

function someFn() {
	// ...
}

// When a value is not Function, it will return fallback value.
let a = fnvl(10, 'x'); // a = 'x'
let b = fnvl([1, 2, 3], console.log); // b = console.log

// When a value is Function, it will return that value.
let c = fnvl(console.error, 1); // c = console.error
let d = fnvl(someFn, () => {}); // d = someFn

API

fnvl(value, fallbackValue)

value

A main value.

fallbackValue

A fallback value.