1.0.0 • Published 4 years ago

map-cursor-to-max v1.0.0

Weekly downloads
986
License
MIT
Repository
github
Last release
4 years ago

map-cursor-to-max

semantic-release npm Build Status

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;