Socket
Socket
Sign inDemoInstall

@no-day/fp-ts-lcg

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @no-day/fp-ts-lcg

A seeded pseudorandom number generator based on the linear congruential generator algorithm.


Version published
Weekly downloads
92
decreased by-32.85%
Maintainers
1
Install size
19.1 kB
Created
Weekly downloads
 

Readme

Source

fp-ts-lcg

A seeded pseudorandom number generator based on the linear congruential generator algorithm.

A port of purescript-lcg.

Install

Uses fp-ts as a peer dependency.

npm install fp-ts @no-day/fp-ts-lcg

JavaScript Example

// index.js

const lcg = require("@no-day/lcg");

let seed = lcg.mkSeed(3532);

for (let i = 0; i < 10; i++) {
  console.log(lcg.unSeed(seed));
  seed = lcg.lcgNext(seed);
}

Result:

node index.js
3533
170541443
901176102
1242866010
134522471
1691132760
373584549
879580920
351404483
1819954887

The generated seeds are pseudo random. Meaning, that whenever the same initial seed is chosen (here it's 3532), the results of the next seeds will be always the same. The generated seeds will be equally distributed in the range of lcg.seedMin and lcg.seedMax.

Dcoumentation

  • API

FAQs

Last updated on 01 Oct 2021

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