A library of utility functions, written in ES6 and transpiled using babel and uglify.
Taken from a handful of utility functions I found myself using all over the place in my fork of RanvierMUD.
Install using npm install fnk --save
Use cases:
const _ = require('fnk');
_.has('potatoes', 'toes')
_.has([true, false], false)
_.hasNot([true, false], 'toes')
_.arrayDiff(['a', 'b', 'c'], ['a'])
_.cache(fn);
fn(x)
fn(x)
_.fillArray(4, 'bazinga')
const quadruple = _.createIterator(x => x + x, 2);
quadruple('f')
_.values({1: 'a', 2: 'b'})
_.reduceValues({1: 'a', 2: 'b'}, (x, acc) => acc + x, '')
_.hasKeys({})
_.haskeys({'potato': undefined})
const doStupidMath = _.compose(x => x + 1, x => x * 2, x => x + 100);
doStupidMath(2)
_.leftPad(10, 'potatoes', '*')
_.leftPad(5, 'potatos', '*')
const isPlayer = (thing) => _.is(Player, thing);
isPlayer(potato)
isPlayer(new Player())
const mustBePositive = _.setBounds(1, Infinity);
mustBePositive(-100)
mustBePositive(52)