All files accessors.js

100% Statements 20/20
0% Branches 0/7
100% Functions 11/11
100% Lines 9/9
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            6x       6x       6x       6x       6x       6x       6x       6x   6x  
// requires [cast](cast.html), and [spread](spread.html)
import { asMap, } from './cast';
import { spread, spreadK, spreadV, } from './spread';
 
// **get** `:: Iterable<{k:v}> -> k -> v`  
// retrieves a value stored at a key from a collection
export const get = c => k => asMap(c).get(k);
 
// **fromIndex** `:: Iterable<a> -> number -> a`  
// returns the value stored at an Iterable<a> position
export const fromIndex = (c = new Set) => i => spread(c).slice(i, i + 1).shift();
 
// **first** `:: Iterable<a> -> a`  
// returns the first element of an iterable
export const first = (c = []) => spread(c).shift();
 
// **last** `:: Iterable<a> -> a`  
// returns the last element of an iterable
export const last = (c = []) => spread(c).pop();
 
// **firstK** `:: Iterable<{k:v}>  -> k`  
// returns the first key of an iterable
export const firstK = (c = []) => first(spreadK(c));
 
// **lastK** `:: Iterable<{k:v}>  -> k`  
// returns the last key of an iterable
export const lastK = (c = []) => last(spreadK(c));
 
// **firstV** `:: Iterable<a> -> a`  
// returns the first value of an iterable
export const firstV = (c = []) => first(spreadV(c));
 
// **lastV** `:: Iterable<a> -> a -> [a]`  
// returns the last value of an iterable
export const lastV = (c = []) => last(spreadV(c));
 
export const rest = coll => spread(coll).slice(1);