npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

randoscando

v1.0.1

Published

Predictable randomness library, all seed based

Downloads

13

Readme

Randoscando

A simple library for seed based predictable randomness.

The Randoest of the Scandoest

Randoscando follows a generator style setup for its randomness allowing it to describe how to generate a random value, you will be able to map random functions together via map, and manually move randomness forward using step like functions

Install

npm i randoscando

How To

Standard ESM module

import * as random from 'randoscando'
// or
import { int, step } from 'randoscando'

CommonJS

const random = require('randoscando')
// or
const { int, step } = require('randoscando')

CDN

Note: It is highly recommended to replace @latest with a strict version!

<!-- jsdelivr -->
<script src="https://cdn.jsdelivr.net/npm/randoscando@latest/dist/randoscando.iife.min.js"></script>
<!-- unpkg -->
<script src="https://unpkg.com/randoscando@latest/dist/randoscando.iife.min.js"></script>

Usage

The documentation will show you what each random function is capable of doing however in order to sequence these you need to use the step function

Using step allows you to move the randomness and its seed forward

In the example below the response is [90, 0.8986478650476784] where 90 is the random integer generated using the 'abc123' seed, and 0.8986478650476784 is the next seed in the sequence. Float numbers like this will always be the type of seeds returned from randoscando however when you call step, you can give it any kind of String or Number you'd like.

Example

import { step, int } from 'randoscando'

step(int(1, 100), 'abc123') // => [90, 0.8986478650476784]

Using Functions By Themselves

You can for sure use randoscandos functions without using step you just need to treat them as a simple generator

Example

import { int, initialSeed } from 'randoscando'

int(1, 100) // => { value: 100, step: function (seed) {} }

const seed = initialSeed('abc123')
const int = int(1, 100)

int.step(seed) // => [90, 0.8986478650476784]

The main thing step does is advance the randomness forward and help keep track of providing a new seed without the need of you creating a new alea seed everytime

Why?

I built RandoScando to mess around with seed based randomness and the algorithm behind it, just as a fun little project.

As for the name it came from a variable one of my good friends and coworkers used in one of our projects, so that it may live on forever.

Feedback

Please feel free to provide any and all feedback whether it involves better documentation, function ideas, or better ideas of how to handle functionality.