Range
PackagesGitHub
Draft
Draft
  • Introduction
  • ❤ Benefits
  • General concepts
  • Getting started
    • Skeleton
    • Installation
      • npm
    • Public API
    • Basic concepts
  • Greater {}
    • Overview
    • Generic type variables
    • ★ Constructor
    • Accessors
      • get [Symbol.toStringTag]()
    • Methods
      • static create()
      • static isGreater()
      • than()
      • thanEvery()
      • thanSome()
      • valueOf()
  • Inequality {}
    • Overview
    • Generic type variables
    • Constructor
    • Accessors
      • get greater()
      • get less()
    • Properties
      • #greater
      • #less
    • Methods
      • greaterThan()
      • greaterThanEvery()
      • greaterThanSome()
      • lessThan()
      • lessThanEvery()
      • lessThanSome()
  • Less {}
    • Overview
    • Generic type variables
    • ★ Constructor
    • Accessors
      • get [Symbol.toStringTag]()
    • Methods
      • static create()
      • static isLess()
      • than()
      • thanEvery()
      • thanSome()
      • valueOf()
    • Example usage
  • Maximum {}
    • Overview
    • Generic type variables
    • ★ Constructor
    • Accessors
      • get [Symbol.toStringTag]()
    • Methods
      • static create()
      • static isMaximum()
      • valueOf()
  • Minimum {}
    • Overview
    • Generic type variables
    • ★ Constructor
    • Accessors
      • get [Symbol.toStringTag]()
    • Methods
      • static create()
      • static isMinimum()
      • valueOf()
  • Number {}
    • Overview
    • Generic type variables
    • ★ Constructor
    • Methods
      • static create()
      • static isNumber()
      • valueOf()
  • Range {}
    • Overview
    • Generic type variables
    • ★ Constructor
    • Accessors
      • get range()
      • get step()
      • get steps()
      • value()?
      • get [Symbol.toStringTag]()
    • Properties
      • max!
      • min!
      • #maximum
      • #minimum
      • #step
      • #value?
    • Methods
      • ↓ Static
      • static create()
      • static createFrom()
      • static createMaximum()
      • static createMinimum()
      • static isRange()
      • ↓ Instance
      • forEachStep()
      • getCurrentRange()
      • getCurrentStep()
      • ⚠ getMax()
      • ⚠ getMin()
      • getRange()
      • getRangeOfStep()
      • getValueOfStep()
      • has()
      • hasEvery()
      • hasSome()
      • isBetween()
      • isBetweenEvery()
      • isBetweenSome()
      • maxGreaterThan()
      • maxLessThan()
      • minGreaterThan()
      • minLessThan()
      • setValue()
      • setValueToStep()
      • stepByStep()
      • ⚠ toArray()
      • valueDown()
      • ⚠ valueOf()
      • valueUp()
  • Change log
    • Keep a changelog
    • CHANGELOG.md
    • v1.0.0-rc.0
    • v1.0.0-rc
    • v1.0.0-beta.0
  • GIT
    • Commit
    • Semantic Versioning
  • License
    • MIT
  • Social
    • Gettr
    • Twitter
    • YouTube
  • Contact
    • ⋯ Chat
    • @ Email
    • ✆ Phone
  • Donate
    • ฿ Cryptocurrency
    • $ Fiat
Powered by GitBook
On this page
  • Range.isRange()
  • Generic type variables
  • Parameters
  • Return type
  • Returns
  • Example usage
Edit on GitHub
  1. Range {}
  2. Methods

static isRange()

Checks whether the value is an instance of `Range` of any or the given minimum, maximum, and step

Previousstatic createMinimum()Next↓ Instance

Last updated 3 years ago

Range.isRange()

The static isRange() method checks whether the is an instance of of any or the given , range and .

range.class.ts
public static isRange<
  Min extends number,
  Max extends number,
  Step extends number
>(
  value: any,
  min?: Min,
  max?: Max,
  step?: Step
): value is Range<Min, Max, Step> {
  return typeof value === 'object' && value instanceof this
    ? (typeof min === 'number' ? value.min === min : true) &&
        (typeof max === 'number' ? value.max === max : true) &&
        (typeof step === 'number' ? value.step === step : true)
    : false;
}

Generic type variables

Parameters

Return type

Returns

Example usage

// Example usage.
import { Range } from '@angular-package/range';

// Create new instance.
const range = new Range(4, 27, 1.5);

// Returns true of type value is Range<number, number, number>
Range.isRange(range);

// Returns true of type value is Range<4, number, number>
Range.isRange(range, 4);

// Returns true of type value is Range<4, 27, number>
Range.isRange(range, 4, 27);

// Returns true of type value is Range<4, 27, 1.5>
Range.isRange(range, 4, 27, 1.5);

// Returns false of type value is Range<3, number, number>
Range.isRange(range, 3);

// Returns false of type value is Range<3, 26, number>
Range.isRange(range, 3, 26);

// Returns false of type value is Range<3, 26, 1.0>
Range.isRange(range, 3, 26, 1.0);

// Returns true of type value is Range<number, 27, number>
Range.isRange(range, undefined, 27);

// Returns true of type value is Range<number, number, 1.5>
Range.isRange(range, undefined, undefined, 1.5);

Minextends

A generic type variable constrained by the , by default of the value captured from the supplied indicates the minimum range type via the .

Maxextends

A generic type variable constrained by the , by default of the value captured from the supplied indicates the maximum range type via the .

Stepextends

A generic type variable constrained by the , by default of the value equal to 1, optionally captured from the supplied indicates the range step type via .

value:

The value of type to test against the instance.

min?:

The optional minimum range of generic type variable to check whether it's equal to a minimum of the given .

max?:

The optional maximum range of generic type variable to check whether it's equal to a maximum of the given .

step?:

Optional step of generic type variable to check whether it's equal to the step of the given .

value is<,,>

The return type is a resulting from its statement indicating the is the object that takes the generic type variable , and .

The return value is a indicating whether the provided is an instance of of any or the given , range and .

number
number
number
any
any
Range
Range
value
minimum
maximum
step
number
min
return type
number
max
return type
number
step
return type
Min
Min
value
Max
Max
value
Step
Step
value
Range
Min
Max
Step
boolean
Range
value
Min
Max
Step
boolean
Range
value
minimum
maximum
step