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

@abhinavkrin/meteor-random

v1.2.4

Published

NPM version of Meteor's Random

Downloads

22

Readme

@abhinavkrin/meteor-random

Welcome to the @abhinavkrin/meteor-random package! This is a direct TypeScript port of Meteor's random package, tailored for server-side usage outside of Meteor code.

Overview

The @abhinavkrin/meteor-random package provides a suite of functions for generating random numbers and strings. Utilizing a cryptographically strong pseudorandom number generator (when available), this package ensures robust randomness for your applications. On older browsers or servers lacking sufficient entropy, it gracefully degrades to a weaker random number generator.

Features

Random.id([n])

Generate a unique identifier, perfect for ensuring uniqueness across your application.

  • Usage: Random.id([n])
  • Example: Random.id() might return "Jjwjg6gouWLXhMGKW"
  • Parameter: n (optional) specifies the length of the identifier. Defaults to 17 characters.

Random.secret([n])

Create a random string of printable characters, offering 6 bits of entropy per character. Ideal for security-critical secrets intended for machine consumption.

  • Usage: Random.secret([n])
  • Example: Random.secret() might return a 43-character string.
  • Parameter: n (optional) specifies the length of the secret string. Defaults to 43 characters, providing 256 bits of entropy.

Random.fraction()

Obtain a random number between 0 and 1, similar to Math.random.

  • Usage: Random.fraction()
  • Example: Random.fraction() might return 0.735432843

Random.choice(arrayOrString)

Select a random element from the given array or string.

  • Usage: Random.choice(arrayOrString)
  • Example: Random.choice(['apple', 'banana', 'cherry']) might return "banana"

Random.hexString(n)

Generate a random string of n hexadecimal digits.

  • Usage: Random.hexString(n)
  • Example: Random.hexString(8) might return "4f5a1c3b"
  • Parameter: n specifies the length of the hex string.

Links

Unleash the power of randomness in your TypeScript projects with @abhinavkrin/meteor-random! Whether you need unique identifiers, secure secrets, or simple random numbers, this package has got you covered. Dive into the documentation to learn more and start integrating it into your projects today!