Hyperlinkv0.8.0-beta.28

Order

Order.minconsteffect/Order.ts:800
<A>(O: Order<A>): { (that: A): (self: A) => A; (self: A, that: A): A }

Returns the minimum of two values according to the given order. If they are equal, returns the first argument.

When to use

Use when you need to select the smaller of two values according to an Order.

Details

Returns the value that compares as less than or equal to the other value. If values are equal, the first argument is returned.

Example (Selecting the minimum value)

import { Order } from "effect"

const minNumber = Order.min(Order.Number)

console.log(minNumber(1, 2)) // 1
console.log(minNumber(2, 1)) // 1
console.log(minNumber(1, 1)) // 1
comparisonsmaxclamp
Source effect/Order.ts:8004 lines
export const min = <A>(O: Order<A>): {
  (that: A): (self: A) => A
  (self: A, that: A): A
} => dual(2, (self: A, that: A) => self === that || O(self, that) < 1 ? self : that)
Referenced by 6 symbols