normalize-to-range

2.0.0 • Public • Published

normalize-to-range

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

Build 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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.0.020latest

Version History

VersionDownloads (Last 7 Days)Published
2.0.020
1.4.00
1.3.70
1.3.63
1.3.20
1.3.10
1.3.00
1.2.30
1.2.20
1.2.10
1.2.00
1.1.130
1.1.120
1.1.110
1.1.100
1.1.90
1.1.80
1.1.70
1.1.60
1.1.50
1.1.40
1.1.30
1.1.20
1.1.10
1.0.01

Package Sidebar

Install

npm i normalize-to-range

Weekly Downloads

24

Version

2.0.0

License

MIT

Last publish

Collaborators

  • zakangelle