Skip to content
This repository has been archived by the owner on Mar 16, 2020. It is now read-only.

skyrpex/cast-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cast-function

Casts value as a function if it's not one.

Install

$ npm install cast-function

Usage

const castFunction = require('cast-function');

const unicorn = '🦄';
const rainbow = () => '🌈';

console.log(castFunction(unicorn)()); // 🦄
console.log(castFunction(rainbow)()); // 🌈

API

castFunction(value)

Casts value as a function that returns value if it's not one.

License

MIT © Cristian Pallarés