@n7e/transpose
v0.1.0
Published
A simple little library making transposing values between different ranges a breeze.
Readme
Transpose
A simple little library making transposing values between different ranges a breeze.
For further insights, read on.
Installation
To install this library use your favorite package manager. No additional steps are required to start using the library.
npm install @n7e/transposeThis library is implemented in TypeScript but can be used with JavaScript without any additional steps.
Transpose
Let's start with an example and transpose the value 50 from one range to
another.
import { transpose } from "@n7e/transpose";
transpose(50).from([0, 100]).to([0, 10]); // -> 5
transpose(50).from([0, 100]).to([-5, 5]); // -> 0
transpose(50).from([0, 100]).to([-12, -2]); // -> -7Value Proxy
To reuse the same value for different transpositions the transpose() function
produces a value proxy object that can be reused.
import { transpose } from "@n7e/transpose";
const valueProxy = transpose(50);
valueProxy.from([0, 100]).to([0, 10]); // -> 5
valueProxy.from([0, 100]).to([-5, 5]); // -> 0Range Proxy
To reuse the same value and origin range for different transpositions the value proxy object produces a range proxy object that can be reused.
import { transpose } from "@n7e/transpose";
const rangeProxy = transpose(50).from([0, 100]);
rangeProxy.to([0, 10]); // -> 5
rangeProxy.to([-5, 5]); // -> 0