DEV Community

Christopher Cavalea
Christopher Cavalea

Posted on

Aimless.js - The Missing JS Randomness Library

Hello Dev Community!

My name is Chris and I released v1.0.0 of Aimless.js on Github this week. I think it's a pretty cool utility library for generating random numbers, and I wanted to share some of the things it could do!

Check out my demo page.

My goal with this project was to create a library that made no assumptions regarding the PRNG that a user might use, and instead focus on the applications of PRNGs inside of frontend applications. For example:

import { bool, boolWithEngine } from 'aimless.js'

bool() // true/false

const customBool = boolWithEngine(() => 0)
customBool() // always false
Enter fullscreen mode Exit fullscreen mode

Aimless.js provides a large variety of utilities, all of which accept custom PRNGs and create a minuscule import weight via code bundlers.

import { normalDist } from 'aimless.js'

const results = []
const mean = 0
const std = 1

for (let i = 0; i < 100000; i++) {
  results.push(
    normalDist(mean, std)
  )
}

// You can expect that the mean of results will equal 0 +/- .001,
// with a standard deviation of 1
Enter fullscreen mode Exit fullscreen mode

This is v1.0.0 of a project I plan to maintain indefinitely, and I'm looking for community feedback around ways to improve it or additional utilities that the community would find useful! I will be compiling any feedback and preparing a v1.1.0 minor release in the near future.

If you like the project, share the <3 with a star on GitHub. Thank you!

Top comments (0)