Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "compare"

file

Several useful things for doing comparisons and sorting data.

author

Nathan Pennie kb1rd@kb1rd.net

Index

Type aliases

BoundSelector

BoundSelector: "max" | "min"

Specifies a bound of a range.

CompareFunction

CompareFunction<T>: (other: T) => CompareResult

A function type that takes T and returns a CompareResult.

Type parameters

  • T

Type declaration

CompareResult

CompareResult: -1 | 0 | 1

One of zero, one, or negative one.

DualCompareFunction

DualCompareFunction<T>: (a: T, b: T) => CompareResult

A function type that takes two of a type T and returns a CompareResult.

Type parameters

  • T

Type declaration

Functions

cmpResult

  • Turns a number into a CompareResult. If it is greater than 0, it will become 1. If it is less then 0, it will become -1. If the input is violating type constraints and is not a number, an error will be thrown.

    throws

    {TypeError} If n is not a number

    Parameters

    • n: number

      The number to transform

    Returns CompareResult

    -1 if n<0, 0 if n==0, 1 if n>0

Generated using TypeDoc