@namely/underly
Advanced tools
Comparing version 0.0.0 to 0.1.0
@@ -227,3 +227,3 @@ var isNumber = function isNumber(value) { | ||
return function (input) { | ||
return input.reduce(function (a, b) { | ||
return input.length === 0 ? undefined : input.reduce(function (a, b) { | ||
return compare(b, a) > 0 ? b : a; | ||
@@ -316,3 +316,3 @@ }); | ||
return function (input) { | ||
return input.reduce(function (a, b) { | ||
return input.length === 0 ? undefined : input.reduce(function (a, b) { | ||
return negCompare(b, a) > 0 ? b : a; | ||
@@ -319,0 +319,0 @@ }); |
@@ -231,3 +231,3 @@ 'use strict'; | ||
return function (input) { | ||
return input.reduce(function (a, b) { | ||
return input.length === 0 ? undefined : input.reduce(function (a, b) { | ||
return compare(b, a) > 0 ? b : a; | ||
@@ -320,3 +320,3 @@ }); | ||
return function (input) { | ||
return input.reduce(function (a, b) { | ||
return input.length === 0 ? undefined : input.reduce(function (a, b) { | ||
return negCompare(b, a) > 0 ? b : a; | ||
@@ -323,0 +323,0 @@ }); |
{ | ||
"name": "@namely/underly", | ||
"version": "0.0.0", | ||
"version": "0.1.0", | ||
"description": "Lightweight functional helpers", | ||
@@ -5,0 +5,0 @@ "author": "Vince Malone <vince.malone@namely.com>", |
@@ -89,1 +89,5 @@ import test, { Macro } from 'ava'; | ||
); | ||
test('empty', t => { | ||
t.deepEqual(max()([]), undefined); | ||
}); |
@@ -33,3 +33,5 @@ interface Compare<T> { | ||
*/ | ||
export const max = <T = number>(compare: Compare<T> = defaultCompare) => (input: T[]) => | ||
input.reduce((a: T, b: T) => (compare(b, a) > 0 ? b : a)); | ||
export const max = <T = number>(compare: Compare<T> = defaultCompare) => ( | ||
input: T[], | ||
): T | undefined => | ||
input.length === 0 ? undefined : input.reduce((a: T, b: T) => (compare(b, a) > 0 ? b : a)); |
@@ -89,1 +89,5 @@ import test, { Macro } from 'ava'; | ||
); | ||
test('empty', t => { | ||
t.deepEqual(min()([]), undefined); | ||
}); |
@@ -37,3 +37,4 @@ import { neg } from './neg'; | ||
const negCompare = neg(compare); | ||
return (input: T[]) => input.reduce((a, b) => (negCompare(b, a) > 0 ? b : a)); | ||
return (input: T[]) => | ||
input.length === 0 ? undefined : input.reduce((a, b) => (negCompare(b, a) > 0 ? b : a)); | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138957
2835