getValueOfStep()
Returns the range value of the given `step`
Range.prototype.getValueOfStep()
Range.prototype.getValueOfStep()
The getValueOfStep()
method returns the range value of the given step
.
public getValueOfStep(step: number): number | undefined {
return step > 0 && step <= this.steps ? this.range[step - 1] : undefined;
}
Parameters
Step parameter of number
type to retrieve the range value.
Return type
Returns
The return value is the range value of the given step
within a range otherwise undefined
.
Example usage
// Example usage.
import { Method } from '@angular-package/range';
// Create new instance.
// Returns Range {min: -27, max: 27, value: 10} of Range<-27, 27, 3>.
const range = new Range(-27, 27, 10, 3);
// Maximum steps is 19.
range.steps;
// Get value of step 3. Returns -21.
range.getValueOfStep(3);
// Get range to step 20. Returns undefined.
range.getValueOfStep(20);
// Get range to step 1. Returns -27.
range.getValueOfStep(1);
Last updated