hash a value to a consistent number within a specified range. in goes key out goes number that's it.
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
.gitignore
.travis.yml
README.md
chash.js
distributiontest.js
example.js
package.json

README.md

Build Status

node-chash

hash a value to a consistent number within a specified range. in goes key out goes number that's it.

example

var chash = require('chash');

var colors = ['red','blue','green','purple']
, bobscolor = chash('bob',colors.length)
, ryanscolor = chash('ryan',colors.length)
, suescolor = chash('sue',colors.length)
;

console.log('bob will always be',colors[bobscolor]);
console.log('ryan will always be',colors[ryanscolor]);
console.log('sue will always be',colors[suescolor]);

notes

random distribution

?_?