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 🙏

© 2025 – Pkg Stats / Ryan Hefner

xoshiro-js

v0.3.0

Published

[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg)](https://github.com/RichardLitt/standard-readme) [![license](https://img.shields.io/github/license/joeltg/xoshiro-js)](https://opensource.org/licenses/MIT)

Readme

xoshiro-js

standard-readme compliant license NPM version TypeScript types

Modern pure-JavaScript implementation of the XoShiRo family of pseudo-random number generators. This library is TypeScript-native, ESM-only, and has zero dependencies.

The implementation and interfaces here are ported directly from the Zig standard library. The unit tests assert identical behavior to Zig's Random interface for generating values, ranges, etc.

Table of Contents

Install

npm i xoshiro-js

Usage

import PRNG from "xoshiro-js" // default export is XoShiRo256PlusPlus

const prng = new PRNG(0n)

console.log(prng.range(5, 25)) // 11
console.log(prng.range(5, 25)) // 13
console.log(prng.range(5, 25)) // 12
console.log(prng.range(5, 25)) // 5

API

interface PRNG {
  fill(buffer: Uint8Array): void

  /** random integer 0 <= x < 2^8 */
  getUint8(): number

  /** random integer 0 <= x < 2^16 */
  getUint16(): number

  /** random integer 0 <= x < 2^32 */
  getUint32(): number

  /** random integer 0 <= x < 2^64 */
  getBigUint64(): bigint

  /** Generate a uniformly distributed f32 value in the range [0, 1) */
  getFloat32(): number

  /** Generate a uniformly distributed f64 value in the range [0, 1) */
  getFloat64(): number

  /** random integer min <= x <= max */
  range(min: number, max: number): number
  rangeBigInt(min: bigint, max: bigint): bigint

  /** select a random element of the provided array */
  select<T>(array: readonly T[]): T

  /** shuffle the provided array in-place */
  shuffle<T>(array: T[]): void
}

declare class XoShiRo128Plus implements PRNG {
  constructor(seed?: bigint | number[])
}

declare class XoShiRo128PlusPlus implements PRNG {
  constructor(seed?: bigint | number[])
}

declare class XoShiRo128StarStar implements PRNG {
  constructor(seed?: bigint | number[])
}

declare class XoShiRo256Plus implements PRNG {
  constructor(seed?: bigint | bigint[])
}

declare class XoShiRo256PlusPlus implements PRNG {
  constructor(seed?: bigint | bigint[])
}

declare class XoShiRo256StarStar implements PRNG {
  constructor(seed?: bigint | bigint[])
}

Testing

Tests use AVA and live in the test directory.

npm run test

Contributing

If you have suggestions for additional PRNG interface methods, find a bug, or would like to add more tests, please open an issue to discuss it!

License

MIT © 2025 Joel Gustafson