Skip to content
Normalize an array of numbers or object property values to a specified range.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
README.md
circle.yml
index.js
package.json

README.md

normalize-to-range

Normalize an array of numbers or object property values to a specified range.

Circle CI Coverage Status

Installation

$ npm install normalize-to-range

Usage

import normalize from 'normalize-to-range';

Array of numbers:

normalize([0, 1, 7, 9, 10], 0, 300);
// [0, 30, 210, 270, 300]

Array of objects:

normalize([{ height: 12 }, { height: 40 }], 0, 1000, 'height');
// [{ height: 300 }, { height: 1000 }]

By default normalizes between 0 and 1:

normalize([0, 1, 6, 10]);
// [0, 0.1, 0.6, 1]

Standalone

Generate a standalone build in dist (for use with <script> tags and AMD module loaders):

$ npm run build:standalone

Test

Tests are done with tape by running:

$ npm test

License

MIT

You can’t perform that action at this time.