Range
PackagesGitHub
v1.0
v1.0
  • 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.create()
  • Generic type variables
  • Parameters
  • Return type
  • Returns
  • Example usage
  1. Range {}
  2. Methods

static create()

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

Range.create()

The static create() method returns a new instance of Range with a range of the given required min, max and optional current value, step.

range.class.ts
public static create<
  Min extends number,
  Max extends number,
  Step extends number = 1
>(min: Min, max: Max, value?: number, step?: Step): Range<Min, Max, Step> {
  return new this(min, max, value, step);
}

Generic type variables

Minextendsnumber

A generic type variable constrained by the number, by default of the value captured from the supplied min indicates the minimum range type of a new Range instance.

Maxextendsnumber

A generic type variable constrained by the number, by default of the value captured from the supplied max indicates the maximum range type of a new Range instance.

Stepextendsnumber= 1

A generic type variable constrained by the number, by default of the value equal to 1, optionally captured from the supplied step indicates the range step type of a new Range instance.

Parameters

min:Min

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

max:Max

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

value?:number

The optional value of the number type between the given min and max specifies the default value of a new Range instance.

step:Step=1 asStep

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

Return type

Range<Min,Max,Step>

The return type is the Range object that takes generic type variable Min, Max and Step.

Returns

The return value is the Range instance with a range of the given required min, max and optional current value, step.

Example usage

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

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

// Returns Range {min: 4, max: 27} of Range<4, 27, 1.5>
Range.create(4, 27, undefined, 1.5);

// Returns Range {min: 4, max: 27, value: 4} of Range<4, 27, 1.5>
Range.create(4, 27, 4, 1.5);
Previous↓ StaticNextstatic createFrom()

Last updated 1 year ago