Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fast, documented generator instead of slow, undocumented generator #6

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ var fileSlug = uniqueSlug('/etc/passwd')
If *str* is passed in then the return value will be its murmur hash in
hex.

If *str* is not passed in, it will be 4 bytes coverted into 8 hex
characters, generated by `crypto.pseudoRandomBytes`.

If *str* is not passed in, it will be 4 randomly generated bytes
converted into 8 hexadecimal characters.
9 changes: 1 addition & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ module.exports = function (uniq) {
var hash = new MurmurHash3(uniq)
return ('00000000' + hash.result().toString(16)).substr(-8)
} else {
// Called without a callback, because this interface should neither block
// nor error (by contrast with randomBytes which will throw an exception
// without enough entropy).
//
// However, due to a change in Node 0.10.27+, pseudoRandomBytes is now the
// same as randomBytes, and may in fact block in situations where
// insufficent entropy is available.
return crypto.pseudoRandomBytes(4).toString('hex')
return (Math.random().toString(16) + '0000000').substr(2, 8)
}
}