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

x/rimbu/common/index.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@1.2.0/common/index.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>