stepLimitfunction
The next limit up or down the steps (10, 50, 100, 500, 1,000, then all). From all a step down is 1,000; from 10 a step down stays at 10; a limit between two steps goes to the nearer step in that direction.
Import it
import { stepLimit } from "@johnmorrisdotca/hoshi-stars/distance";
Definition
function stepLimit(limit: number, direction: 1 | -1): number
Parameters
| Name | Type | Description |
|---|---|---|
limit | number | The limit now, in light-years ( |
direction | 1 | -1 | 1 for farther, -1 for nearer. |
Returns
number
The new limit.
Examples
import { stepLimit } from "@johnmorrisdotca/hoshi-stars/distance";
console.log(stepLimit(10, 1), stepLimit(1000, 1), stepLimit(Infinity, -1), stepLimit(70, 1), stepLimit(70, -1));50 Infinity 1000 100 50What it prints (run when this page was built)