Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xorshift

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xorshift

Random number generator using xorshift128+

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created

What is xorshift?

The xorshift npm package is a JavaScript implementation of the xorshift family of pseudorandom number generators (PRNGs). It is designed to provide fast and high-quality random number generation suitable for various applications such as simulations, games, and procedural content generation.

What are xorshift's main functionalities?

Basic Random Number Generation

This feature allows you to generate a basic random number using the xorshift algorithm. The `random` method returns a floating-point number between 0 and 1.

const xorshift = require('xorshift');
const rng = xorshift.create();
console.log(rng.random());

Seeded Random Number Generation

This feature allows you to initialize the random number generator with a specific seed. This is useful for reproducible results in simulations or tests.

const xorshift = require('xorshift');
const seed = [1, 2, 3, 4];
const rng = xorshift.create(seed);
console.log(rng.random());

Random Integer Generation

This feature allows you to generate a random integer. The `randomint` method returns a 32-bit integer.

const xorshift = require('xorshift');
const rng = xorshift.create();
console.log(rng.randomint());

Random Number Generation in a Range

This feature allows you to generate a random number within a specified range. The `randomInRange` function demonstrates how to use the `random` method to achieve this.

const xorshift = require('xorshift');
const rng = xorshift.create();
function randomInRange(min, max) {
  return min + Math.floor(rng.random() * (max - min + 1));
}
console.log(randomInRange(1, 100));

Other packages similar to xorshift

Keywords

FAQs

Package last updated on 13 Aug 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc