Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CheckedNumber

A number primitive that will always stay within a certain range

example

Create with a milliseconds instance

const number = new CheckedNumber(16, { min: 10, max: 20});
number = -5;  // throw NumberRangeError

Hierarchy

Implements

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

Properties

max

max: number

min

min: number

Accessors

value

  • get value(): number
  • set value(value: number): void

Methods

__@toPrimitive

  • __@toPrimitive(hint: "string" | "number" | "default"): string | number

__@toStringTag

  • __@toStringTag(): string

get

  • get(): number

set

toJSON

  • toJSON(_?: string): any | number | string | boolean | null
  • Converts the primitive into it's JSON representation

    Parameters

    • Default value _: string = ""

    Returns any | number | string | boolean | null

    the object to serialize with JSON.stringify

toString

  • toString(): string

valueOf

  • valueOf(): number