Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

hash-int

mikolalysenko5.6kMIT1.0.0

Hashes integers

integer, hash, psuedo, random, number, integer, table, thomas, wang

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:

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