npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

burtleprng

v1.0.0

Published

Fast, seeded, noncryptographic random numbers

Downloads

7

Readme

Bob Jenkins' small noncryptographic PRNG (pseudorandom number generator) ported to JavaScript.

Why not Math.random?

Sometimes you want repeatable results. With this lib, you can save the seed you used, and later initialize the PRNG with the same seed and get the same sequence of pseudorandom numbers.

Also, this PRNG beats the one built into V8 on ent's chi-square test, indicating that its output is, in a sense, "more random". (The results on ent's other tests are excellent for both.)

Is it fast?

Both BurtlePRNG and the native PRNG are incredibly fast and unlikely to be a bottleneck in your application.

You can use test.js, which prints 10MB of random bytes to the standard output using Node, to run your own benchmarks. On Node 0.10.28, there is no significant performance difference between generating 32-bit unsigned integers using test.js versus equivalent code using Math.random:

((1<<31) * 2 * Math.random()) >>> 0

Usage

If you're using Node.js, Browserify or Webpack, use the usual npm install burtleprng and require:

var BurtlePRNG = require('burtleprng');

Otherwise, simply include BurtlePRNG.js in a script tag. It will export a single class, BurtlePRNG.

API

new BurtlePRNG(seed)

Creates and returns a new PRNG instance. The seed argument is mandatory and should be an unsigned 32-bit integer. Reasonable ways to come up with a seed include:

Date.now() & 0x7fffffff

// or

((1<<31) * 2 * Math.random()) >>> 0

prng.next()

Returns a pseudorandom, unsigned 32-bit integer and advances the PRNG state.

prng.float()

Returns a pseudorandom floating-point number on the interval [0, 1), similar to Math.random(), and advances the PRNG state. Equivalent to prng.next() / 4294967296.0.

License

Bob Jenkins released his original C implementation of this PRNG as public domain. Similarly, burtleprng is released under the Creative Commons CC0 Public Domain Dedication. See COPYING.txt for details.