static create()
Returns a new instance of `Range` with a range of the given required `min`, `max` and optional current `value`, `step`
Range.create()
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
.
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
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.
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.
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
The minimum range of generic type variable Min
to set with a new Range
instance.
The maximum range of generic type variable Max
to set with a new Range
instance.
The optional value of the number
type between the given min
and max
specifies the default value of a new Range
instance.
Optional step of generic type variable Step
to set with a new Range
instance, by default 1
.
Return type
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);
Last updated