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

@radically-straightforward/examples

v1.0.0

Published

🥸 Example data for testing

Downloads

11

Readme

Radically Straightforward · Examples

🥸 Example data for testing

Installation

$ npm install @radically-straightforward/examples

Usage

import * as examples from "./index.mjs";

name()

export function name(): string;

Examples of names of people.

Sources

  • First names: https://www.ssa.gov/oact/babynames/decades/century.html
  • Last names: https://www.thoughtco.com/most-common-us-surnames-1422656

text()

export function text({
  model = textModel,
  length = 10,
}: {
  model?: {
    [predecessor: string]: {
      [successor: string]: {
        count: number;
        percentile: number;
      };
    };
  };
  length?: number;
} = {}): string;

Example text.

If the length is 0, then the text is short and may not contain punctuation, which is suitable, for example, for the title of a conversation.

The default model mostly talks about food. You may train your own model on other subjects by following these steps:

  1. Create a file called urls.json with a list of Wikipedia articles on subjects that the model should talk about, for example:

    urls.json

    [
      "https://en.wikipedia.org/wiki/Maple_syrup",
      "https://en.wikipedia.org/wiki/Chocolate_chip"
    ]
  2. Run the binary that comes with @radically-straightforward/examples to collect those Wikipedia articles:

    $ npx examples collect
  3. A file called corpus.json is created with the collected Wikipedia articles, and the urls.json file is updated with more Wikipedia articles.

    Select the articles that you consider relevant in urls.json, return to step 1, and repeat until enough enough Wikipedia articles have been collected. A bigger corpus yields a richer model with more diverse example texts, but it also produces bigger files and risks going off-topic.

  4. Train the model with the binary that comes with @radically-straightforward/examples:

    $ npx examples train

    This produces a file called model.json which includes the model, and its contents can be provided to text() as the model.

    At this point you may delete the files urls.json and corpus.json if you wish.

References

  • https://healeycodes.com/generating-text-with-markov-chains
  • https://www.youtube.com/watch?v=eGFJ8vugIWA

Avatars

The folder avatars/ contains 263 examples of faces.

These people don’t exist, the faces were collected from https://github.com/NVlabs/stylegan2 / https://drive.google.com/drive/folders/1mTeo3J3Jo6aYImBshLM6XRl_Ua8fqgVW and resized to 256×256px with avatars/index.mjs.

Related Work

Faker, casual, and so forth

These other libraries don’t include text that can be trained on arbitrary topics and avatars.