Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@types/seedrandom
Advanced tools
@types/seedrandom is a TypeScript type definition package for the seedrandom library, which is used to create seeded random number generators. This allows for reproducible random number sequences, which can be useful in simulations, games, and other applications where predictable randomness is needed.
Creating a Seeded Random Number Generator
This feature allows you to create a random number generator that produces the same sequence of numbers each time it is initialized with the same seed. This is useful for reproducibility in tests and simulations.
const seedrandom = require('seedrandom');
const rng = seedrandom('my-seed');
console.log(rng());
Using Different Algorithms
Seedrandom supports different algorithms for generating random numbers. This example shows how to use the 'alea' algorithm.
const seedrandom = require('seedrandom');
const rng = seedrandom('my-seed', { algorithm: 'alea' });
console.log(rng());
Generating Random Numbers in a Range
This feature demonstrates how to generate random numbers within a specific range using a seeded random number generator.
const seedrandom = require('seedrandom');
const rng = seedrandom('my-seed');
const randomInRange = (min, max) => min + rng() * (max - min);
console.log(randomInRange(1, 10));
random-seed is another library that provides seeded random number generation. It is simpler and has fewer features compared to seedrandom, but it is still useful for basic seeded random number generation.
chance is a library that provides a wide range of random data generators, including seeded random number generation. It offers more functionality than seedrandom, such as generating random names, addresses, and other data types.
random-js is a library that provides a variety of random number generators, including seeded generators. It offers more control over the random number generation process and supports multiple algorithms.
npm install --save @types/seedrandom
This package contains type definitions for seedrandom (https://github.com/davidbau/seedrandom).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/seedrandom.
// Type definitions for seedrandom 3.0
// Project: https://github.com/davidbau/seedrandom
// Definitions by: Kern Handa <https://github.com/kernhanda>
// Eugene Zaretskiy <https://github.com/EugeneZ>
// Martin Badin <https://github.com/martin-badin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace seedrandom {
type State = object;
interface Callback {
(prng?: PRNG, shortseed?: string, global?: boolean, state?: State): PRNG;
}
interface Options {
entropy?: boolean | undefined;
global?: boolean | undefined;
pass?: Callback | undefined;
state?: boolean | State | undefined;
}
interface PRNG {
(): number;
double(): number;
int32(): number;
quick(): number;
state(): State;
}
}
interface seedrandom {
(seed?: string, options?: seedrandom.Options, callback?: seedrandom.Callback): seedrandom.PRNG;
alea(seed?: string, options?: seedrandom.Options): seedrandom.PRNG;
Alea: new (seed?: string) => seedrandom.PRNG;
tychei(seed?: string, options?: seedrandom.Options): seedrandom.PRNG;
Tychei: new (seed?: string) => seedrandom.PRNG;
xor128(seed?: string, options?: seedrandom.Options): seedrandom.PRNG;
Xor128: new (seed?: string) => seedrandom.PRNG;
xor4096(seed?: string, options?: seedrandom.Options): seedrandom.PRNG;
Xor4096: new (seed?: string) => seedrandom.PRNG;
xorshift7(seed?: string, options?: seedrandom.Options): seedrandom.PRNG;
XorShift7: new (seed?: string) => seedrandom.PRNG;
xorwow(seed?: string, options?: seedrandom.Options): seedrandom.PRNG;
XorWow: new (seed?: string) => seedrandom.PRNG;
}
declare const seedrandom: seedrandom;
export = seedrandom;
These definitions were written by Kern Handa, Eugene Zaretskiy, and Martin Badin.
FAQs
TypeScript definitions for seedrandom
The npm package @types/seedrandom receives a total of 509,088 weekly downloads. As such, @types/seedrandom popularity was classified as popular.
We found that @types/seedrandom 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.