greaterThan
greaterThan
(right: number) => (left: number) => number
Test whether a number is greater than another
const gt1 = greaterThan(1) gt1(1) // is false gt1(2) // is true
const gt1 = greaterThan(1) gt1(1) // is false gt1(2) // is true
const gt1 = greaterThan(1) gt1(1) // is false gt1(2) // is true
const gt1 = greaterThan(1) gt1(1) // is false gt1(2) // is true
Sometimes we want to test for thesholds. Below, we want to display boots which have sold over 70 in the last week. Let's find our hot sellers.
const bootsSoldInLastWeek = { columbia: 82, timberland: 65, nortiv: 58, keen: 79, } const soldOver70 = greaterThan(70) const getHotSellers = compose([keepWhen(soldOver70), Object.keys]) const hotSellers = getHotSellers(bootsSoldInLastWeek) console.log(hotSellers) // is [ // columbia, // keen, // ]
type BootSales = Record<string, number> const bootsSoldInLastWeek = { columbia: 82, timberland: 65, nortiv: 58, keen: 79, } const soldOver70 = greaterThan(70) const keepHotSellers = keepWhen(soldOver70)<BootSales> const getHotSellers = compose([keepHotSellers, Object.keys]) const hotSellers = getHotSellers(bootsSoldInLastWeek) console.log(hotSellers) // is [ // columbia, // keen, // ]
const bootsSoldInLastWeek = { columbia: 82, timberland: 65, nortiv: 58, keen: 79, } const soldOver70 = greaterThan(70) const getHotSellers = compose([ keepWhen(soldOver70), Object.keys, ]) const hotSellers = getHotSellers( bootsSoldInLastWeek ) console.log(hotSellers) // is [ // columbia, // keen, // ]
type BootSales = Record<string, number> const bootsSoldInLastWeek = { columbia: 82, timberland: 65, nortiv: 58, keen: 79, } const soldOver70 = greaterThan(70) const keepHotSellers = keepWhen( soldOver70 )<BootSales> const getHotSellers = compose([ keepHotSellers, Object.keys, ]) const hotSellers = getHotSellers( bootsSoldInLastWeek ) console.log(hotSellers) // is [ // columbia, // keen, // ]