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

randomcrap

v1.3.0

Published

Returns random crap

Downloads

4

Readme

randomcrap

This is a dependency free random crap generator. Currently it handles getting random simple random ints, but I will be adding stuff to it as I need it for my other projects.

This has more entropy than Math.random() but isn't going to be adequate for crypto. For that I suggest GRC javascript peudo-random number generator or Web Cryptography API.

Planned additions

  • [x] random int
  • [x] random from set
  • [x] random float
  • [x] random alpha
  • [x] random alpha numeric
  • [ ] random emoji

API

This is meant to be a flexible yet not cryptography sound random number generator. The numbers should look good, and the bias is adjustable. A high bias will yield higher random numbers from sets. This bias can be set through the constructor or through a setter function.

Classes

Constants

RandomCrap

Class for generation of RandomCrap.

Please do not complain about these numbers not being "true" random. The point behind doing this isn't to have correct math, but instead to generate numbers that are fun. This is why the bais exists and can be adjusted. This way the developer can influence the result to adjust the fun.

Kind: global class

new RandomCrap([biasAdjuster])

| Param | Type | Default | Description | | --- | --- | --- | --- | | [biasAdjuster] | Float | "NORMAL_BIAS" | Allows setting a high or low bias for random generation. |

randomCrap.setBias([bias])

Sets the current random bias.

Kind: instance method of RandomCrap

| Param | Type | Default | Description | | --- | --- | --- | --- | | [bias] | Float | "NORMAL_BIAS" | Allows setting a high or low bias for random generation. Setting nothing will reset to neutral bias. |

randomCrap.getBias() ⇒ Boolean

Returns the current bias.

Kind: instance method of RandomCrap

randomCrap.randomFrom(set, [name], [loop])

Gets a random element from a supplied set.

Kind: instance method of RandomCrap

| Param | Type | Default | Description | | --- | --- | --- | --- | | set | Array | | The set from which to pull a random element. | | [name] | String | "__default" | The name of the set, if this is set then the random element will be removed as a possible element in future calls. | | [loop] | Boolean | "false" | Append the original set back onto the end if the set is empty. |

randomCrap.simpleRandomAlpha(options) ⇒ String

Returns a random alpha character.

Kind: instance method of RandomCrap

| Param | Type | Default | Description | | --- | --- | --- | --- | | options | Object | | Optional arguments. | | [options.allCaps] | Boolean | "false" | Only return Capitalized letters. | | [options.noCaps] | Boolean | "false" | Never return Capitalized letters. | | [options._set] | Array | "[a, b, c, ... z]" | Inject set, useful for testing, or localization. |

randomCrap.simpleRandomFloat(wholePrecision, floatPrecision) ⇒ Float

Returns a simple random floating point Number.

Kind: instance method of RandomCrap

| Param | Type | Description | | --- | --- | --- | | wholePrecision | Integer | The number of precision to the left of the decimal point. | | floatPrecision | Integer | The number of precision to the right of the decimal point. |

randomCrap.simpleRandomInt(min, max) ⇒ Integer

Returns a random integer from min (inclusive) to max (inclusive).

Kind: instance method of RandomCrap

| Param | Type | Description | | --- | --- | --- | | min | Integer | The lowest number to return. | | max | Integer | The highest number to return. |

NORMAL_BIAS : Number

The Normal Bias needed to create centered Random Number Generation.

Kind: global constant

HIGH_ADJUSTER : Number

The High end on which the random number will be adjusted for randomness.

Kind: global constant

LOW_ADJUSTER : Number

The High end on which the random number will be adjusted for randomness.

Kind: global constant