Skip to content

javiercejudo/unary-with-optional-callback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unary-with-optional-callback

Build Status Coverage Status Code Climate

Creates a unary function with an optional transformer callback from a callable and a transformer fallback

Install

npm i unary-with-optional-callback

Usage

var unaryWithOptionalCallback = require('unary-with-optional-callback');

function transformableSqrt(transformer, x) {
  return transformer(Math.sqrt(x));
}

var integerSqrt = unaryWithOptionalCallback(transformableSqrt, Math.floor);

integerSqrt(8); // => 2
integerSqrt(8, Math.ceil); // => 3

About

Creates a unary function with an optional transformer callback from a callable and a transformer fallback

Resources

License

Stars

Watchers

Forks

Packages

No packages published