Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/hash-int
Hash integers
https://github.com/mikolalysenko/hash-int
Last synced: about 2 months ago
JSON representation
Hash integers
- Host: GitHub
- URL: https://github.com/mikolalysenko/hash-int
- Owner: mikolalysenko
- License: mit
- Created: 2013-04-09T01:03:50.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-04-29T01:07:45.000Z (over 10 years ago)
- Last Synced: 2024-10-20T14:28:19.578Z (2 months ago)
- Language: JavaScript
- Size: 125 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hash-int
Given an integer, deterministically computes a psuedorandom unsigned 32 bit integer. Based on Thomas Wang's 7-shift integer hash algorithm. For more discussion and experiments, see the following references:* Thomas Wang's Original Homepage (now down): http://www.cris.com/~Ttwang/tech/inthash.htm
* Bob Jenkins' Write Up: http://burtleburtle.net/bob/hash/integer.html## Install
npm install hash-int
## Example```javascript
var hashInt = require("hash-int")for(var i=-10; i<=10; ++i) {
console.log(hashInt(i))
}
```### `require("hash-int")(x)`
Given an integer `x` as a seed, computes a psuedorandom integer.* `x` the seed value
**Returns**: A signed 32 bit integer representing the value of `x`
# Credits
Algorithm by Thomas WangJS Port (c) 2013 Mikola Lysenko. MIT License