
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
sutor-random
Advanced tools
A naïve seeded pseudo-random number generator for JS. This is mainly meant for testing purposes: the method used is reportedly ~2-3 times slower than Math.random()
.
reduce
)npm install
into project.
// import all functions under the `Random` namespace:
import Random from 'sutor-random'
// use like:
Random.seeded()
Random.intBetween(10, 20)
// import specific functions
import { seeded, intBetween} from 'sutor-random'
// use like:
seeded()
intBetween(10, 20)
Random.seeded([seed])
Returns a random value between zero and one inclusive. Functionally identical to Math.random()
. If the optional seed is passed, values become predictable.
> Random.seeded(1)
0.7098480789645691
Random.intBetween(min, max[, seed])
Returns a random integer between min and max inclusive. If the optional seed is passed, values become predictable.
> Random.intBetween(10, 20, 1)
17
Random.intUpTo(max[, seed])
Returns a random integer between zero and max inclusive. If the optional seed is passed, values become predictable.
> Random.intBetween(20, 1)
14
Random.shuffle(array[, seed])
Shuffles an array randomly, using Random.seeded()
+ a privately-defined shuffle function. If the optional seed is passed, values become predictable.
> Random.shuffle([1,2,3,4,5,6], 20)
[2,4,6,3,1,5]
FAQs
A naïve seeded PRNG implementation.
We found that sutor-random demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.