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

@liting-yes/randomall

v1.2.1

Published

simple and elegant generation of random data

Downloads

11

Readme

randomall

Simple and elegant generation of random data.

Installtion

npm i @liting-yes/randomall

Hello Random

const random = require('@liting-yes/randomall')

random number

simple to use

random.number()
// output: 88
// return an integer between [0, 100)

random.number.DEFAULT
// default parameter value

use with args

Function random.number has 5 params as follows:

  • min number

mininum random number isn't less than it

  • max number

maxinum random number doesn't exceed it

  • radix number

base of return value (2-36)

notice: when radix != 10, the return value will be the string value of the corresponding random number

  • isInteger boolean

whether the return value is integer

  • decimal number

max number of decimal places returned

random.number(1, 10, 10, false, 5)
// output: 1.58
// return a float between [1, 10) with no more than 5 decimal places


// support object passing
random.number({ isInteger: false })
// output: 62.664065

random string

simple to use

random.string()
// output: Z1Qdvk
// return a random string whose characters are letters and numbers

random.string.DEFAULT
random.string.CHARACTAR
// default parameter value

use with args

Function random.stringhas 6 params as follows:

  • len number

    length of random string

  • banNum number

    random string without numbers*

  • banLowercase boolean

    random string without lowercase letters

  • banUppercase boolean

    random string without uppercase letters*

  • add array

    special characters that random string contains

  • remove array

    special characters that random string must never contain

random.string(10, true, false, true, ['@', '#', '?'], ['a', 'b', 'c'])
// output: #sr#u?ljsv
// return a random string that contain possibly the characters '@', '#', '? ' and no digits, uppercase letters, 'a', 'b', 'c'


// support object passing
random.string({ banNum: true, banLowercase: true })
// output: ODMZPO

random boolean

simple to use

random.boolean()
// output: true
// return a random boolean value

random array

simple to use

random.array()
// output: [45, 71,  8, 20, 79, 17, 73, 16, 85, 44]
// return an array of length 10 and each element has a value greater than 0 and less than 100

use with args

  • len number

    length of random array

  • fn function

    the function to generate random value

  • args remain parameters

    function arguments of fn

random.array(5, random.number, 1, 10)
// output: [ 9, 5, 2, 5, 5 ]
// return an array with 5 number element which is greater than 1 less than 10

random image

simple to use

random.image().then(imgUrl => console.log(imgUrl))
// returns a configurable random image address

random.image.DEFAULT_CONFIG
random.image.DEFAULT_LOCATION
// default parameter value

use with args

  • userConfig object

same as axios request configuration

  • userLocation array

nested position of target data

random.image({ baseURL:'https://api.ixiaowai.cn', url: '/mcapi/mcapi.php' }, ['imgurl']).then(imgUrl => console.log(imgUrl))
// return an random image url about the api

statement

the image API the repo is using is 小歪API

in order to avoid some unforeseen problems, it is recommended to configure the API yourself