1.0.0 • Published 4 years ago
map-cursor-to-max v1.0.0
map-cursor-to-max
What is this?
A simple function to map some cursor to its position within a maximum.
Installation
yarn add map-cursor-to-max
Usage
import { mapCursorToMax } from "map-cursor-to-max";
mapCursorToMax(0, 10); // => 0
mapCursorToMax(1, 10); // => 1
mapCursorToMax(9, 10); // => 9
mapCursorToMax(10, 10); // => 0
mapCursorToMax(11, 10); // => 1
mapCursorToMax(-1, 10); // => 9
Interface
const mapCursorToMax: (cursor: number, max: number) => number;
1.0.0
4 years ago