rescale-util

3.0.0 • Public • Published

rescale-util

Build Status Coverage Status Code Climate

Rescale utilities

Install

npm i rescale-util

Usage

var rescaleUtil = require('rescale-util');
 
rescaleUtil.isValidScale([-3, 5]); // => true
rescaleUtil.isValidScale([0, 0]); // => false
rescaleUtil.getLastError(); // => the extremes cannot be the same. Eg. [0, 1]
 
rescaleUtil.resetLastError();
rescaleUtil.getLastError(); // => '' (empty string)
 
rescaleUtil.isValidPreset([[-3, 5], [1, 0]]); // => true
rescaleUtil.isValidPreset(10); // => false
rescaleUtil.getLastError(); // => a preset must be an Array with two scales. Eg. [[0, 100], [32, 212]]
 
rescaleUtil.areValidPresets([[[Math.PI, 0], [Math.E, 5]], [[0, 100], [32, 212]]]); // => true
rescaleUtil.areValidPresets(10); // => false
rescaleUtil.getLastError(); // => presets must be an Array with presets. Eg. [[[0, 100], [32, 212]], [[0, 100], [-273.15, -173.15]]]

Rescale-util also provides a specific error:

var rescaleUtil = require('rescale-util');
var RescaleError = rescaleUtil.RescaleError;
 
if (!rescaleUtil.isValidScale(someScale)) {
  throw new RescaleError(rescaleUtil.getLastError());
}

See spec.

Related projects

  • linear-converter: flexible linear converter with built in conversions for common units.
  • rescale: rescales a point given two scales.
  • scale: scales normalised data.
  • normalise: normalise data to [0, 1].

Package Sidebar

Install

npm i rescale-util

Weekly Downloads

1

Version

3.0.0

License

MIT

Last publish

Collaborators

  • javiercejudo