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

blarney

v0.1.5

Published

Create repeatable random information

Downloads

2

Readme

Blarney

Generate repeatable random data in JS

Inspired by Faker.js Uses slightly modified Alea PRNG

Getting started

For the server, install Blarney via npm.

npm install Blarney

For the browser, download Blarney.js, and include it as a script tag.

<script src="Blarney.js"></script>
<script>
  var ns = new Blarney();
  ns.integer(); // Random integer between 0 and 2^32
</script>

Usage

Instantiation

To create a new Blarney instance, do var ns = new Blarney();. You can pass any number of arbitrary arguments to the Blarney() constructor to be used as seed data. If you don't pass anything, it will just use the default.

Seeding

If you want to reset the seed of an instance you already have, call ns.sow() and pass in the seed data you want to use. The constructor calls sow() internally on instantiation.

Numbers

  • integer() - returns a random integer between 0 and 2^32
  • frac() - returns a random real number between 0 and 1
  • real() - returns a random real number between 0 and 2^32
  • integerInRange(min, max) - returns a random integer between min and max
  • realInRange(min, max) - returns a random real number between min and max
  • normal() - returns a random real number between -1 and 1

Utilities

  • uuid() - returns a valid v4 UUID hex string
  • pick(array) - returns a random member of array
  • weightedPick(array) - returns a random member of array, favoring the earlier entries
  • timestamp(min, max) - returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified

Language

  • word() - returns a random word of lipsum
  • words(n) - returns n random words of lipsum, 3 if not specified
  • sentence() - returns a random lipsum sentence
  • sentences(n) - returns n random lipsum sentences, 3 if not specified

People

  • gender() - returns 'male' or 'female'
  • firstName(gender) - returns a random common first name, gender is optional
  • lastName() - returns a random common last name
  • name(gender) - returns a random first and last name, gender is optional
  • portrait(gender) - returns an object containing Flickr short URLs for four images. Keys are smallSquare, largeSquare, thumbnail, and small. The photos are from GregPC's 1000faces1 set on Flickr. Special thanks to him for doing all the hard work and allowing us to benefit from it!
  • jobTitle() - returns a random job title
  • email() - returns a random email address

Miscellaneous

  • buzzPhrase() - returns a random web 2.0 business plan...
  • domain() - returns a random domain name

License

Do whatever you want with this code. The consequences of your actions are your own responsibility.