Skip to main content
Module

x/rimbu/mod.ts>Comp.withUndefined

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
function Comp.withUndefined
import { Comp } from "https://deno.land/x/rimbu@0.13.1/mod.ts";
const { withUndefined } = Comp;

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.

Examples

Example 1

const c = Comp.withUndefined(Comp.numberComp())
console.log(c.compare(undefined, 5) < 0)
// => true
console.log(c.compare(undefined, undefined))
// => 0

Parameters

comp: Comp<T>
  • the Comp instance to wrap

Returns

Comp<T | undefined>