All files array.js

87.88% Statements 29/33
100% Branches 0/0
81.82% Functions 18/22
100% Lines 11/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49            10x         9x         2x         2x       3x       2x       2x       2x       2x       2x   2x  
// requires [spread](spread.html)
import { spread, } from './spread';
 
// **map** `:: Iterable<a>  -> (a->b) -> [b]`
// returns an Iterable<a> of the return values of a
// function called on each element of an iterable
export const map = coll => fn => spread(coll).map(fn);
 
// **mapTo** `:: (a->b) -> Iterable<a>  -> [b]`
// returns an Iterable<a> of the return values of a
// function called on each element of an iterable
export const mapTo = fn => coll => map(coll)(fn);
 
// **reduce** `:: Iterable<a>  -> ((a->b), b) -> b`
// returns the accumulated value of a function
// called on each element of an iterable
export const reduce = coll => (fn, init) => spread(coll).reduce(fn, init);
 
// **reduceBy** `:: ((a->b), b) -> Iterable<a>  -> b`
// returns the accumulated value of a function
// called on each element of an iterable
export const reduceBy = (fn, init) => coll => spread(coll).reduce(fn, init);
 
// **filter** `:: Iterable<a>  -> (a->bool) -> [a]`
// returns the iterable's values which return true for a given function
export const filter = coll => fn => spread(coll).filter(fn);
 
// **filtBy** `:: (a->bool) -> Iterable<a>  -> [a]`
// returns the iterable's values which return true for a given function
export const filtBy = fn => coll => filter(coll)(fn);
 
// **every** `:: Iterable<a>  -> (a->bool) -> bool`
// checks if every element of an iterable returns true for a given function
export const every = coll => fn => spread(coll).every(fn);
 
// **everyPass** `:: (a->bool) -> Iterable<a>  -> bool`
// checks if every element of an iterable returns true for a given function
export const everyPass = fn => coll => every(coll)(fn);
 
// **some** `:: Iterable<a>  -> (a->b) -> [b]`
// checks if any element of an iterable returns true for a given function
export const some = coll => fn => spread(coll).some(fn);
 
// **somePass** `:: (a->b) -> Iterable<a>  -> [b]`
// checks if any element of an iterable returns true for a given function
export const somePass = fn => coll => some(coll)(fn);
 
export const findBy = matchFunc => coll => spread(coll).find(matchFunc);