λ

JFP: Javascript Function Processor

##Array Functions

compact

####Example

j.compact(['my string', false, 0, 52, undefined]);

// [ 'my string', 52 ]

concat

####Example

j.concat([1, 2, 3], [4, 5, 6]);

// [ 1, 2, 3, 4, 5, 6 ]

conj

####Example

j.conj(4, [1, 2, 3]);

// [ 1, 2, 3, 4 ]

cons

####Example

j.cons(4, [1, 2, 3]);

// [ 4, 1, 2, 3 ]

contains

####Example

j.contains(5, [1, 2, 3, 4, 5, 6]);

// true

difference

####Example

j.difference([1, 2, 3, 4, 5], [2, 4, 5]);

// [1, 3]

drop

####Example

j.drop(0, [1, 2, 3, 4, 5]);

// [ 2, 3, 4, 5 ]

j.drop(4, [1, 2, 3, 4, 5]);

// [ 1, 2, 3, 4 ]

j.drop(2, [1, 2, 3, 4, 5]);

// [ 1, 2, 4, 5 ]

dropFirst

####Example

j.dropFirst([1, 2, 3, 4, 5]);

// [ 2, 3, 4, 5 ]

dropLast

####Example

j.dropLast([1, 2, 3, 4, 5]);

// [ 1, 2, 3, 4 ]

each

####Example

j.each(function(value){ console.log(value); }, [1, 2, 3, 4, 5]);

// 1
// 2
// 3
// 4
// 5

every

####Example

j.every(j.odd, [1, 3, 5, 6, 7]);

// false

filter

####Example

j.filter(function(value){ return value % 2 === 0; }, [1, 2, 3, 4, 5, 6]);

// [ 2, 4, 6 ]

find

####Example

j.find(function(value){ return value % 2 === 0; }, [1, 2, 3, 4, 5, 6]);

// 2

first

####Example

j.first([1, 2, 3, 4, 5, 6]);

// 1

hasFirst

####Example

j.hasFirst([1, 2, 3]); // true
j.hasFirst([]); // false
j.hasFirst(null); // false

intersect

####Example

j.intersect([1, 2, 3], [2, 3, 4]);

// [2, 3]

last

####Example

j.first([1, 2, 3, 4, 5, 6]);

// 6

lastIndex

####Example

j.first([1, 2, 3, 4, 5, 6]);

// 5

map

####Example

j.map(function(value){ return value * 3; }, [1, 2, 3, 4, 5, 6]);

// [ 3, 6, 9, 12, 15, 18 ]

multiPartition

###Example

var recordset = [
    { id: 1, foreignId: 1 },
    { id: 2, foreignId: 2 },
    { id: 3, foreignId: 1 },
    { id: 4, foreignId: 3 },
    { id: 5, foreignId: 4 }
];

function foreignIdMatch (id, record) {
    return record.foreignId === id;
}

j.multipartition(foreignIdMatch, [1, 2], recordset);

/*
[
    [ { id: 1, foreignId: 1 }, { id: 3, foreignId: 1 } ],
    [ { id: 2, foreignId: 2 } ],
    [ { id: 4, foreignId: 3 }, { id: 5, foreignId: 4 } ]
];
*/

nth

####Example

j.nth(0, [1, 2, 3, 4, 5, 6]);

// 1

j.nth(5, [1, 2, 3, 4, 5, 6]);

// 6

j.nth(3, [1, 2, 3, 4, 5, 6]);

// 4

numberOf

####Example

j.numberOf(j.even, [1, 2, 3, 4, 5, 6]);

// 3

partition

###Example

j.partition(j.even, [1, 2, 3, 4, 5]);

// [ [2, 4], [1, 3, 5] ]

reduce

####Example

j.reduce(function(a, b){ return a + b; }, [1, 2, 3, 4, 5]); // 15
j.reduce([1, 2, 3, 4], j.add, 10); // 20

rest

####Example

j.rest([1, 2, 3, 4, 5]);

// [ 2, 3, 4, 5 ]

slice

####Example

j.slice(0, [1, 2, 3, 4, 5]);

// [ 1, 2, 3, 4, 5 ]

j.slice(2, [1, 2, 3, 4, 5]);

// [ 4, 5 ]

j.slice(2, [1, 2, 3, 4, 5], 3);

// [ 4 ]

some

####Example

j.some(j.even, [1, 2, 3, 4, 5]);

// true

sort

####Example

j.sort([1, 3, 2, 5, 4]);

// [1, 2, 3, 4, 5]

function comparator(a, b){
    var b - a; 
}

j.sort(comparator, [1, 3, 2, 5, 4]);

// [5, 4, 3, 2, 1]

symmetricDifference

####Example

j.symmetricDifference([1, 2, 3, 4], [2, 3, 4, 5]);

// [1, 5]

take

####Example

j.take(3, [1, 2, 3, 4, 5]);

// [ 1, 2, 3 ]

union

####Example

j.union([1, 2, 3], [2, 3, 4]);

// [1, 2, 3, 4]

unique

####Example

j.unique([2, 5, 2, 3, 2, 4, 3, 1]);

// [ 1, 2, 3, 4, 5 ]