Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
map-number
Advanced tools
processing/p5.js map like function, including floating point numbers support
processing/p5.js map like function, including floating point numbers support
:warning: this
map
function has nothing to do withArray.prototype.map
method.
npm install map-number
const { map } = require("map-number");
const y = map(Math.sin(angle), -1, 1, 100, 0);
<script src="https://cdn.jsdelivr.net/npm/map-number/dist/map.umd.min.js"></script>
const y = mapNum.map(Math.sin(angle), -1, 1, 100, 0);
maps a number in a range to a different range, returning a floting point number, including number outside the given output range.
all other map function variants depend on this one.
function map(num: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
maps a number in a range to a different range, returning a number truncated to the inmediate previous integer number, including number outside the given output range.
function floor(num: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
maps a number in a range to a different range, returning a number rounded to the closest integer number, including number outside the given output range.
function round(num: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
maps a number in a range to a different range, returning a floting point number, limiting the result to the given output range.
function limit(num: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
creates a single argument function implementing the given map
, floor
, round
or limit
function, useful when you need to map values multiple times within the same range, see example
function create(func: MapFunction, inMin: number, inMax: number, outMin: number, outMax: number): (num: number) => number;
const myMap = create(map, -1, 1, 100, 0);
myMap(Math.sin(angle));
// ... is equivalent to...
map(Math.sin(angle), -1, 1, 100, 0);
an alias for create method
MIT :copyright: Manuel Fernández
1.0.6 (2019-05-24)
FAQs
processing/p5.js map like function, including floating point numbers support
The npm package map-number receives a total of 608 weekly downloads. As such, map-number popularity was classified as not popular.
We found that map-number demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.