Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 3.77 KB

nifty-tou.intrange.md

File metadata and controls

54 lines (40 loc) · 3.77 KB

Home > nifty-tou > IntRange

IntRange class

An immutable number range with min/max values.

Signature:

export default class IntRange implements Comparable<IntRange> 

Implements: Comparable<IntRange>

Remarks

The minimum and maximum values can use null to represent "none".

Constructors

Constructor Modifiers Description
(constructor)(min, max) Constructor.

Properties

Property Modifiers Type Description
isSingleton readonly boolean Test if this range represents a singleton value, where the minimum and maximum values in the range are equal.
length readonly number Get the number of values between min and max, inclusive.
max readonly number | null Get the minimum value.
min readonly number | null Get the minimum value.

Methods

Method Modifiers Description
adjacentTo(o) Test if this range is adjacent to (but not intersecting) a given range.
canMergeWith(o)

Test if this range could be merged with another range.

Two ranges can be merged if they are either adjacent to or intersect with each other.

compareTo(o)

Compares this object with the specified object for order.

Unbounded (null) values are ordered before bounded (non-null) values.

contains(value) Test if a value is within this range, inclusive.
containsAll(min, max) Test if another range is completely within this range, inclusive.
containsRange(o) Test if another range is completely within this range, inclusive.
delimiter(locale) static Get a locale-specific range delimiter to use.
description(bounds, r, options) static Generate a description of a range.
equals(obj)

Test for equality.

This method tests if obj is an instance of IntRange and compares the min and max values for strict equality.

intersects(o) Test if this range intersects with a given range.
mergeWith(o) Merge this range with a given range, returning the merged range.
of(value) static Create a singleton range, where the minimum and maximum values are equal.
parseRange(value, bounds, options) static Parse a range array of number strings into an IntRange.
rangeOf(min, max) static Create a range.
toString()

Get a string representation.

The format returned by this method is [min..max]. Any null value will be represented as an empty string.