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

somerandchar

v1.0.3

Published

somerandchar lets you generate random characters for your applications. You can generate some random characters of customizable length. You can also choose from the character set to generate these desired random characters from. The best part, somerandcha

Downloads

8

Readme

somerandchar

somerandchar lets you generate random characters for your applications. You can generate some random characters of customizable length. You can also choose from the character set to generate these desired random characters from. The best part, somerandchar has no dependencies thus flexibly customizable.

Install

clone

git clone https://github.com/Otumian-empire/somerandchar.git

npm

npm i somerandchar

Usage

Generate X numbers for token

// Need 6 numbers for token - Alnum

const { Alnum, RandomCharGenerator } = require("somerandchar");

// Extend the Alnum class and override the size attribute
class Size6Alnum extends Alnum {
  constructor(size) {
    super().size = size; // could be passed directly
  }
}

// create an instance of the Extended class - Size6Alnum
const size = 6;
const size6 = new Size6Alnum(size);

// create instance of RandomCharGenerator and call it's generateRandomChar()
const result = new RandomCharGenerator(size6);
console.log(result.generateRandomChar());

// 895208
// 650209
// 888880
// 070770
// 499237

Generate long random alphabetic string for email verication

// Need long random alphabetic string for email verication,
// as part of url - Alpha returns 128 characters

const { Alpha, RandomCharGenerator } = require("somerandchar");

const longRandStr = new RandomCharGenerator(new Alpha());
console.log(longRandStr.generateRandomChar());

// -ILcOUfDzqzLzFtjWfgupdilsCTgHfhsBxckWokekH-LeAOoAiwmTgfjbLVaGzILEgVFQpTwivuJVaVOadKuQLwIJwPdUFiAKnQgkqXpASEIlzJhP_UL-jOuvmkCOtGj

Generate long random alphanumeric string for email verication

// Need long alphanumeric characters as token for email verication,
// as part of url - AlphaNum returns 64 characters

const { AlphaNum, RandomCharGenerator } = require("somerandchar");

const result = new RandomCharGenerator(new AlphaNum());

console.log(result.generateRandomChar());

// tUwmZE7PU8UImjEtwHRGF5mG30F7c9jmHL_TnCOQ956Usw_FALQihABC0F9V11-T
// DK3PCLtBEKS625KsONF064BRMxKCP-Qc7gMqRbH10dzITb5wtfT-_iW6qqEoqZTM
// xoHkrxF7x1UHtK30bxZRI88oNouJnRzfq_Kj-shGbb8ffmxc5ls3IpvAUeRerLVm

Modify the internals of somerandchar

Override a sample class

super().char_set = "some string character set of your choice"

class CustomAlnum extends Alnum {
  constructor(size) {
    super().size = size;
  }
}

const size = 128;

const customAlnum = new CustomAlnum(size);
const randCharGen = new RandomCharGenerator(customAlnum);

const result = randCharGen.generateRandomChar();

console.log(result);

// 71008276754097452371346850771953727143571590264375932186817824239670462309173275913598287285550337958838560274112638134932579800

Pass an obejct of size and char_set instead of extending a class

const size = 16;
const char_set =
  "johnDOEu997uwt0tq5--z_(hz5m)un(7jp68(3)htuwlh__-psq5w1pDAnceMoney";

const option = { size, char_set };
const randCharGen = new RandomCharGenerator(option);

const result = randCharGen.generateRandomChar();

console.log(result);

// qt(mD(Mm_5chAt8D
// psyA9_qEn7p756on
// q__39h5no-j_6t7M