λ

JFP: Javascript Function Processor

##Core Functions

j

####Example

j('conj')(1)([2, 3, 4]); // [1, 2, 3, 4]
j('pick', 'key')({ key: 'foo' }); // 'foo'

always

####Example

var alwaysTrue = j.always(true),
    alwaysFoo = j.always('foo');

alwaysTrue(); // true
alwaysFoo('bar'); // 'foo'

j.filter(alwaysTrue, [1, 2, 3, 4]); // [1, 2, 3, 4] -- identity filter

apply

####Example

function add(a, b){
    return a + b;
}

j.apply(add, [1, 2]);

//3

compose

####Example

function isUndefined(value){
    return typeof value === 'undefined';
}

function not(value){
    return !value;
}

var notUndefined = j.compose(not, isUndefined);

notUndefined(null);

//true

notUndefined(undefined);

//false

countArguments

####Example

j.countArguments(function(arg1, arg2, arg3){});

//3

curry

####Example

function add(a, b);

j.curry(add)(1)(2);

//3

j.curry(add, 1)(2);

//3

j.curry(add, 1, 2);

//3

deref

####Example

var myObj = {
    data: {
        aList: [
            'foo',
            'bar',
            'baz'
        ]
    }
};

j.deref('data.aList.1', myObj); // bar
j.deref('data.aList.baz', myObj); // null

empty

####Example

j.empty('object'); // {}
j.empty('array'); // []
j.empty('boolean'); // false

execute

####Example

j.execute(j.add); // 0
j.execute(j.add, 5); // 5
j.execute(j.add, 5, 7); // 12

getType

####Example

j.getType('foo'); // string
j.getType({}); // object
j.getType([]); // array

identity

####Example

j.identity('my value');

//my value

partial

####Example

function divide(a, b){
    return a / b;
}

j.partial(divide, 6)(2);

//3

partialReverse

####Example

function concatThree(astr, bstr, cstr){
    return astr + bstr + cstr;
}

j.partialReverse(concatThree, 'foo')('bar', 'baz'); // foobazbar

pipeline

####Example

j.pipeline([1, 2, 3, 4],
           j('reduce', j.add, 0),
           j('multiply', 3));
// 30

recur

####Example

function factorial(recur, base, result){
    var sanitizedResult = j.either(1, result);
    return (base >= 0) ? recur(base - 1, sanitizedResult * base) : sanitizedResult;
}

j.recur(factorial, 5);

//120

reverseArgs

####Example

function strConcat(astr, bstr){
    return astr + bstr;
}

j.reverseArgs(strConcat)('foo', 'bar'); // barfoo

rpartial

####Example

function divide(a, b){
return a / b;
}

j.rpartial(divide, 4)(2);

//0.5

splitPartial

####Example

function addToFakeSet (obj, value) {
    obj[key] = true;
    return obj;
}

var reduceToSet = j.splitPartial(j.reduce, [addToFakeSet], [{}]);

reduceToSet([1, 2, 3, 4, 2, 5, 1, 1, 3]); // { 1: true, 2: true, 3: true, 4: true, 5: true }

shortCircuit

####Example

j.shortCircuit(0, j('apply', j.add), [1, 2]); // 3
j.shortCircuit(0, j('apply', j.add), null); // 0