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()
  • Parameters
  • Example usage
Edit on GitHub
  1. Range {}

★ Constructor

Creates the `Range` instance with a range of the given required `min`, `max` and optional current `value`, `step`

PreviousGeneric type variablesNextAccessors

Last updated 3 years ago

Range()

Creates the instance with a range of the given required , and optional current , .

range.class.ts
constructor(min: Min, max: Max, value?: number, step: Step = 1 as Step) {
  this.#maximum = new Maximum(max);
  this.#minimum = new Minimum(min);
  this.#step = step;
  // Sets the range value between the given `min` and `max`.
  this.value = value;
  // Define the `min` and `max` property.
  Object.defineProperties(this, {
    min: {
      value: min,
      enumerable: true,
      writable: false,
    },
    max: {
      value: max,
      enumerable: true,
      writable: false,
    },
  });
}

Parameters

Example usage

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

// Returns Range {min: 4, max: 27} of Range<4, 27, 1>
new Range(4, 27);

// Returns Range {min: 4, max: 27, value: 27} of Range<4, 27, 1>
new Range(4, 27, 27);

// Returns Range {min: 4, max: 27, value: 5} of Range<4, 27, 1.5>
new Range(4, 27, 5, 1.5);

min:

The minimum range of generic type variable to set with a new instance.

max:

The maximum range of generic type variable to set with a new instance.

value?:

The optional value of the type between the given and specifies the default value of a new instance.

step:=1 as

Optional step of generic type variable to set with a new instance, by default 1.

The step is used by the accessor, , and methods to return the entire range and also by the , methods to respectively decrement, increment range value.

number
range
getRange()
getRangeOfStep()
stepByStep()
valueDown()
valueUp()
Range
min
max
value
step
number
Range
min
max
Range
Range
Range
Min
Min
Max
Max
Step
Step
Step