Ordering
Combining
Signature
declare const combine: { (that: Ordering): (self: Ordering) => Ordering; (self: Ordering, that: Ordering): Ordering;}combineAll
Added in v2.0.0
Source
Signature
declare function combineAll(collection: Iterable<Ordering>): OrderingcombineMany
Added in v2.0.0
Source
Signature
declare const combineMany: { (collection: Iterable<Ordering>): (self: Ordering) => Ordering; (self: Ordering, collection: Iterable<Ordering>): Ordering;}Model
Other
Inverts the ordering of the input Ordering.
Signature
declare function reverse(o: Ordering): OrderingExample
import * as assert from "node:assert"import { reverse } from "effect/Ordering"
assert.deepStrictEqual(reverse(1), -1)assert.deepStrictEqual(reverse(-1), 1)assert.deepStrictEqual(reverse(0), 0)Pattern Matching
Depending on the Ordering parameter given to it, returns a value produced by one of the 3 functions provided as parameters.
Signature
declare const match: { <A, B, C = B>(options: { readonly onEqual: LazyArg<B>; readonly onGreaterThan: LazyArg<C>; readonly onLessThan: LazyArg<A>; }): (self: Ordering) => A | B | C; <A, B, C = B>(o: Ordering, options: { readonly onEqual: LazyArg<B>; readonly onGreaterThan: LazyArg<C>; readonly onLessThan: LazyArg<A>; }): A | B | C;}Example
import * as assert from "node:assert"import { Ordering } from "effect"import { constant } from "effect/Function"
const toMessage = Ordering.match({ onLessThan: constant('less than'), onEqual: constant('equal'), onGreaterThan: constant('greater than')})
assert.deepStrictEqual(toMessage(-1), "less than")assert.deepStrictEqual(toMessage(0), "equal")assert.deepStrictEqual(toMessage(1), "greater than")