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

fun-facts

v1.0.5

Published

NPM package for random facts, by Xilog.

Downloads

24

Readme

npm-randomfacts

The GitHub repo for my fun-facts npm package

How to use

First, you do the obvious, npm i fun-facts in terminal then const facts = require('randomfacts');
Next, you run the fact function: facts.get(options)
Now the options bit is detailed in the next section. It can be run without any options, just leave it blank (facts.get()).
The get function returns a fact as an object: { type: "success", fact: "example fact", desc: "extra details about example fact" }
If there's an error, it returns an error obj like this: { type: "error", msg: "you did something wrong mate" }
Note: The description may be blank since there are no extra details about the fact, read about the useDesc option below to avoid errors involving this.

Options

The options argument is an object, here's an example of how you might set it:

{
    category : "all",
    maxLength : 0,
    maxDLength : 0,
    useDesc: 0,
    safe : false
}

###Category: What category to choose a fact from, leave it blank for all or type a category (detailed in the Categories section)

###Max Length: Max length of the fact

###Max D Length: Max description length of the fact

###Use Desc: If 0, it will give a description unless description is blank (then it will not add a "desc" property)
If 1, it will give no description (the object does not have a "desc" property)
If 2, it will always give a fact that has a description (doesn't work yet)

###Safe: Safe output, currently doesn't do anything.

Categories

Current categories: (Lowercase when using of course!)

  • Animals
  • Brands
  • Countries
  • Fun
  • History
  • Language
  • Laws
  • Maths
  • Sports
  • Phobias

Functions

Currently all it can do is get() but more might be coming.

Contributions - Adding facts

Please make a pull request on GitHub to add facts or contribute, maybe also fix the hacky code if you want, greatly appreciated.
I'll try to accept ASAP.