Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/common/comp.ts

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
import * as rimbu from "https://deno.land/x/rimbu@0.13.0/common/comp.ts";

Functions

Returns a Comp instance that compares any value using default comparison functions. For Iterables and objects, their elements are compared recursively.

Returns a Comp instance that compares any value using default comparison functions, but never recursively compares Iterables or objects. In those cases, it will use the stringComp instance.

Returns a Comp instance that compares any value using default comparison functions. For Iterables and objects, their elements are compared only one level deep for performance and to avoid infinite recursion.

Returns a Comp instance converts values to string with JSON.stringify, and orders the resulting string naturally.

Returns a any Comp instance that orders any according to their toString values.

Returns a default bigint Comp instance that orders bigint numbers naturally.

Returns a default boolean Comp instance that orders booleans according to false < true.

Returns a Comp instance that orders objects with a valueOf method according to the given valueComp instance for the valueOf values.

Returns a Date Comp instance that orders Dates according to their .valueOf value.

Returns the default Comp instance, which is the Comp.anyDeepComp() instance.

Returns a Comp instance the reverses the order of the given comp instance.

Returns a Comp instance for Iterable objects that orders the Iterables by comparing the elements with the given itemComp Comp instance.

Returns a default number Comp instance that orders numbers naturally.

Returns a Comp instance for objects that orders the object keys according to the given keyComp, and then compares the corresponding values using the given valueComp. Objects are then compared as follows: starting with the smallest key of either object:

  • if only one of the objects has the key, the object with the key is considered to be larger than the other
  • if both objects have the key, the values are compared with valueComp. If the values are not equal, this result is returned.

Returns a Comp instance that compares strings in a case-insensitive way.

Returns a string Comp instance that orders strings according to their indexed char codes.

Returns a Comp instance that compares strings based on the string's localeCompare method.

Returns an Eq equality instance thet will return true when the given comp comparable instance returns 0.

Returns a Comp instance that extends the given comp instance with the capability to handle null values, where null is considered to be smaller than any other value, and equal to another null.

Returns a Comp instance that extends the given comp instance with the capability to handle undefined values, where undefined is considered to be smaller than any other value, and equal to another undefined.

Interfaces

An object providing methods to compare two values of type K.