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

randomizer-package

v1.2.3

Published

A package to *easily* get random elements from arrays or strings, and a full wrapper for ez-math.js, a package that makes math very easy.

Downloads

6

Readme

Randomizer Package:

A new package that allows you to easily call random elements of an array, or from a string, AND also functions as a full wrapper for ez-math.js

how to use

const Random = require('randomizer-package');
console.log(Random.random('first possibility, 'second possibility')) //returns one of the possibilities that are split by commas, randomly chosen
console.log(Random.random(['first possibility', 'second possibility'])) // does the same as above

console.log(Random.add('1, 2, 3, 4')); //returns 10
console.log(Random.add([1, 2, 3 , 4])); //same thing as above
console.log(Random.subtr([1, 2, 3, 4])) //same as: ((1 - 2) - 3) - 4; returns 8
console.log(Random.div([1, 2, 3])) //divides the first 2 parameters(1 and 2), and gets 0.5; divides that by next param and returns what it has when there are no more params to loop through. this returns 0.1666.
console.log(Random.multi('1, 2, 3, 4, 5')) //The same as 1(2)(3)(4)(5)
console.log(Random.pow('10, 2, 4')) //The same as (10^2)^4

Methods:

random - returns a random response from an array or string

Parameters - array(required)

type: string or array

example: math.random(['hi', 'hello', 'ok']) - returns a pseudo-randomly chosen response; other ways to do the same thing: var responses = ['hi', 'hello', 'ok'] math.random(responses); or: math.random('hi, hello, ok') //all in ONE string

randomInt - returns a random integer within the min and max

Parameters - min,max(both default to 0, so without any params, you will get 0, and with only min, you will get min)

type: string or number

example: math.randomInt(1, 100) - returns a random Integer between 1 and 100

add - adds all of the numbers specified

Parameters - array(required)

type: string or array

example: math.add([1, 2, 3, 4]) OR math.add('1, 2, 3 ,4') 1 STRING, the commas are inside the string, not representing new strings.

subtr - subtracts all of the numbers specified in the same order

Parameters - array(required)

type: string or array

example: math.subtr([1, 2, 3, 4]) - returns -8 (executes [(1-2)-3]-4)

multi - multiplies all numbers specified

Parameters - array(required)

type: string or array

example: math.multi([1, 2, 3, 4]) returns 24 (executes [(1 * 2) * 3] * 4)

div - divides all numbers specified in the same order

Parameters - array(required)

type: string or array

example: math.div([1, 2, 3, 4]) - returns 0.041666666666666664 (executes [(1 / 2) / 3] / 4)

pow - raises array[0] to array[1] and raises that to the next parameter. - continues until there is nothing else to loop through(see example for better understanding)

Parameters - array(required)

type: string or array

example: math.pow([5, 2, 3]) - returns 15625 (executes [5 ^ 2] ^ 3)(the same as: math.pow([5, math.multi([2, 3])])), which multiplies 2 and 3, getting 6, and raises 5 to that(5^6)

avg - takes the average value of numbers in an array.

Parameters - array(required)

type: string or array

example math.avg('1, 2, 3, 4, 5') - returns 3, because the average value of the numbers is 3.

Example