bingo-functional-js
Version:
A port of the PHP bingo-functional library
17 lines (14 loc) • 306 B
JavaScript
const firstVal = (list) => list[0]
/**
* head function
*
* head :: [a, b] -> a
* @param {(array|object)} list
* @returns {*}
* @example
*
* head(['foo', 'bar'])
* // => 'foo'
*/
const head = (list) => (Array.isArray(list) ? firstVal(list) : firstVal(Object.values(list)))
module.exports = head