1.0.2 • Published 9 years ago

scale-buckets v1.0.2

Weekly downloads
194
License
MIT
Repository
github
Last release
9 years ago

Scale Buckets

A little utility for sorting a range of values into little histogram-like bins.

So, let's say you have a range of 1024 values. (Maybe it's a potentiometer for some Nodebot you're working on.) Depending on the value, you want to get one of four elements from the range. If it's from 0-255, you want the first element. But, if the value is 1000, you want the fourth element.

If you've every felt this pain, then Scale Buckets if for you.

const scaleBuckets = require('scale-buckets');

const scale = scaleBuckets(['a', 'b', 'c', 'd'], 1, 1024);

scale(200); // returns 'a'
scale(1000); // returns 'd'
1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago