dzucconi / map-cursor-to-max

A simple function to map some cursor to its position within a maximum

Home Page:https://www.npmjs.com/package/map-cursor-to-max

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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;

About

A simple function to map some cursor to its position within a maximum

https://www.npmjs.com/package/map-cursor-to-max


Languages

Language:TypeScript 94.3%Language:JavaScript 5.7%