
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A practical randomness toolkit. Sample/shuffle arrays, generate strings, create UUIDs, and more, with a unified API for Math.random(), crypto, or custom/transformed PRNGs.
Alea is a utility wrapper for turning random numbers into useful values. Give it any source of randomness, get a toolkit for dice, samples, strings, and more.
Install: npm i @xtia/alea
import { alea } from "@xtia/alea";
// default alea draws from Math.random()
// game development
const damage = alea.between(10, 20);
const crit = alea.chance(0.1);
const loot = alea.sample(['sword', 'potion', 'gold']);
const enemySpawner = alea.createWeightedSampler([
["goblin", 10],
["orc", 5],
["dragon", 0.1] // rare but possible!
]);
const enemy = enemySpawner.sample();
// data generation
const userId = alea.string(8, 'abcdef0123456789');
const fakeName = alea.phrase(nameTables, '{firstName} {lastName}');
// statistics
const [z1, z2] = alea.normal(0, 1);
For convenience, common character sets for string can be imported: import { charsets } from "@xtia/alea".
Use the same API layer, whatever the source of randomness:
import { cryptoAlea } from "@xtia/alea";
// cryptoAlea draws from runtime's crypto
const id = cryptoAlea.uuid();
const unpredictableDeck = cryptoAlea.shuffle(cards);
Use any randomness provider:
import {
aleaFromFunc,
aleaFromSeed,
aleaFromByteSource,
aleaFromSequence
} from "@xtia/alea";
// deterministic, with seed (uses Mulberry32 PRNG):
const seededRng = aleaFromSeed("abc123");
// custom source of randomness:
const xkcdRng = aleaFromFunc(() => 4/6); // https://xkcd.com/221/
// from third-party PRNGs
import { MersenneTwister } from "acme-math";
const mt = new MersenneTwister(mySeed);
const mtAlea = aleaFromFunc(() => mt.random());
// from random byte providers:
const secureRng = aleaFromByteSource(
buf => hardwareRng.fillRandomBytes(buf)
);
// preset sequence for debugging/testing
const presetRng = aleaFromSequence([.1, .4, .8], "loop");
Or use a provided PRNG algorithm:
import {
mulberry32,
sfc32,
xoshiro128pp,
} from "@xtia/alea/prng";
// each returns an Alea instance:
const fast = mulberry32("my-seed");
const varied = sfc32(1, 2, 3, 4);
const strong = xoshiro128pp(5, 6, 7, 8);
const reproducibleId = varied.string(12, hexadecimal);
Transform randomness for different probability curves:
// exponential distribution
const expSampler = alea.transform(x => -Math.log(1 - x));
const waitTime = expSampler.between(0, 10);
// quadratic ease
const leftSkewed = alea.transform(x => x * x)
.sample(items);
// square root ease
const rightSkewed = alea.transform(x => Math.sqrt(x))
.sample(items);
bytes() queries the RNG provider once per 4 bytes; transform curves are applied at the 32-bit level.FAQs
A practical randomness toolkit. Sample/shuffle arrays, generate strings, create UUIDs, and more, with a unified API for Math.random(), crypto, or custom/transformed PRNGs.
We found that @xtia/alea demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.