Claire's Utility JavaScript functions. 🔩🔧
Inspired by 1-liners - even though they aren't 1-liners.
From the command line, on a computer with node installed:
npm i clairity
The package is made up of the following four functions. You can use them one-by-one as shown below:
var ifThen = require('clairity').ifThen;
ifThen('3 > 4', 'foo');
// 'foo'
var howMany = require('clairity').howMany;
howMany(['a', 'b', 'a'], 'a');
// 2
var itContains = require('clairity').itContains;
itContains('foobar' 'oo');
// true
var replaceWhitespace = require('clairity').replaceWhitespace;
replaceWhitespace('foo bar', '-');
// 'foo-bar'
Or you can pull in the entire module and use functions when required.
var c = require('clairity');
c.ifThen('4 > 2', 'wah');
Clone the repo, install the dependencies and then from the command line:
npm test
Here. 🌟👫☀️