static createFrom()
Creates the `Range` instance from the given random numbers and the step
Range.createFrom()
Range.createFrom()
Creates the Range
instance from the given random numbers
and the step
.
public static createFrom<Step extends number = 1>(
numbers: number[],
step: Step = 1 as Step
): Range<number, number, Step> {
return Range.create(
Math.min.apply(0, numbers),
Math.max.apply(0, numbers),
step
);
}
Generic type variables
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
An Array
of numbers to find a range and create a new instance.
step:
Step
step:
Step
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 Step
.
Returns
The return value is the Range
instance created from the given required random numbers and the optional step.
Example usage
// Example usage.
import { Range } from '@angular-package/range';
// Returns Range {min: 4, max: 27} of type Range<number, number, 1>.
Range.createFrom([12, 14, 5, 23, 14, 27, 17, 4, 11, 12]);
// Returns Range {min: 4, max: 27} of type Range<number, number, 1.5>.
Range.createFrom([12, 14, 5, 23, 14, 27, 17, 4, 11, 12]);
Last updated