UNPKG

@eluvio/elv-js-helpers

Version:

A collection of Javascript helper functions used by several Eluvio libraries.

17 lines (14 loc) 494 B
'use strict' const _max = require('@eluvio/ramda-fork/src/max') const reduce = require('crocks/pointfree/reduce') // return max element of array (note that an undefined element in first position will wind up being evaluated as max) const max = arr => arr.length === 0 ? undefined : arr.length === 1 ? arr[0] : reduce(_max, arr[0], arr.slice(1)) module.exports = max // // console.log(max([undefined, 1])) // console.log(max([1, undefined])) // console.log(max([1, 2, undefined]))