1.0.0 • Published 6 years ago

casette v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

casette

Casette is a tiny modular converter library. It's ridiculously simple, yet effective.

Installation

npm i casette

Example

const casette = require('casette')

// Built-in converters
var inch = 2
console.log(casette(inch, 'inch-cm'))

console.log(casette(-2, 'celsius-fahrenheit'))

// External converters
var some = casette(14, require('./some-converter'))

// Internal converters
var res = casette(25, a => a * 2 / 5)

Usage

You can use built-in, external or internal converters, that are simple, exported functions. Take a look at the built-in ones in the converters directory.

If you have an idea for a converter build it and PR, please. If required, write its test in the converters/converters.test.js. Tests are cool!

API

casette(value, converter)

Takes the value and the converter arguments. value can be anything, converter must be function. Returns anything.