Socket
Socket
Sign inDemoInstall

gnrng

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gnrng

A minimal seeded random number generator.


Version published
Weekly downloads
5
increased by66.67%
Maintainers
1
Install size
6.59 kB
Created
Weekly downloads
 

Readme

Source

gnrng

A minimal seeded random number generator that generates numbers between -1 and 1. Adapted from the more full-featured seedrandom (and using xorshift), though chances are this is all you need.

Pronounced "grrrngg".

Installation

npm i gnrgn

or

yarn add gnrng

Usage

Call rng with a string as the generator's seed and receive a new function in return. Call this function to produce a random number between -1 and 1. Calling rng again with the same seed will produce the same random numbers.

import { rng } from "gnrng"

const getRandom1 = rng("abc")
const a = getRandom1() // Random number between -1 and 1
const b = getRandom1() // Random number between -1 and 1

const getRandom2 = rng("abc") // same seed
getRandom2() === a // true
getRandom2() === b // true

const getRandom3 = rng("xyz") // different seed
getRandom3() === a // false
getRandom3() === b // false

Keywords

FAQs

Last updated on 09 Jun 2022

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