Socket
Socket
Sign inDemoInstall

hash-int

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    hash-int

Hashes integers


Version published
Weekly downloads
550
increased by5.57%
Maintainers
1
Install size
4.34 kB
Created
Weekly downloads
 

Readme

Source

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

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 Wang

JS Port (c) 2013 Mikola Lysenko. MIT License

Keywords

FAQs

Last updated on 29 Apr 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc