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

faketastic

v0.0.23

Published

A library to help you with modelling data entities and generate them as mock data.

Downloads

14

Readme

Faketastic

Installation

$ npm install faketastic

What is faketastic?

Faketastic is a library giving you tools to model your entities and generate randomized data from it. This way you get any number of random data, while still respecting your data restrictions specified in your model. The main difference to well-known mock data generators out there is that faketastic don't want to feed you with just some random data, but it lets you define what data to use and in what shape to deliver. It also strives to let you add semantics to it. The vision is to allow users to design data models of arbitrary complexity and instantly generate valid and meaningful data.

Thus the main purpose of faketastic (yet) is the combination of defining data models and generating valid sample data from it.

API is in Concept State

Please note: faketastic's API is currently in concept state and may be subject to changes in the future. If you like the idea of this project, please feel free to get in touch and/or contribute :)

Quick Example

import { template, use, oneOf, range, quantity, build } from 'faketastic';

// simple array we can define with a bunch of made-up street names
import { StreetNames } from './resources.ts';
// same here for Names, could be possibly split up into any
// category of names (first-names, surnames, male, female, ...)
import { Names } from './resources.ts';

const Address = template({
  // gives you one value of the given street names
  street: oneOf(StreetNames),
  // gives you a random number within the defined range
  zip: range(100000, 999999),
});

const Person = template({
  name: oneOf(Names),
  age: range(1, 99),
  // gives you 3 (built) instances of the Address template
  address: use(Address, quantity(3)),
});

// simple string transform function for use in Employee
const toMailName = (name: string) => name.replace(' ', '.').toLowerCase();

const Employee = extend(Person, {
  age: range(16, 62),
  email: combine(
    {
      name: ref(Employee, 'name', map(toMailName)),
      domain: oneOf(Domains),
    },
    values => `${values.name}@${values.domain}.de`,
  ),
});

const output = build(Employee, 3);
/*
  "output" will be something like:
  [
    {
      "name": "Daniel Banuelos",
      "age": 54,
      "email": "[email protected]",
      "address": [
        {
          "street": "Eldow Street",
          "zip": 221996
        },
        // 2 more addresses ...
      ]
    },
    // 2 more employees ...
  ]
*/