Created
April 21, 2015 19:05
-
-
Save nolanamy/5b40a5a236be2c0157cd to your computer and use it in GitHub Desktop.
Check for hat() collisions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var hat = require('hat'); | |
var _ = require('lodash'); | |
var rack = {}; | |
for(var i = 0; i < 1000000; i++) { | |
var id = hat(); | |
rack[id] = rack[id] ? rack[id] + 1 : 1; | |
} | |
var dupes = _.filter(rack, function(a) { return a > 1 }); | |
console.log(dupes); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consistently 0 collisions. Collisions only seem to happen after server reboots or something like that.