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

clique-seeds

v0.0.8

Published

A utility for creating seed data for both the server and client.

Downloads

2

Readme

clique-seeds

Install

yarn add clique-seeds

Overview

Use the Seeds() constructor to instantiate a generator for creating seed data. The Seeds constructor takes two optional arguments:

  • instance<?number|?string>: See the Chance.js Seed documentation. The instance value essentially guarantees repeatable results given the same instance value and options arguments.
  • options<?object>: See default options below.
Default options

Most of the following default options apply to the init() method which generates a graph of relational data.

{
  customerCount: 2,
  maxFolderDepth: 6,
  maxAssets: 30,
  maxProjects: 10,
  maxFolders: 10,
  maxCollections: 10,
  quiet: true,        // Quiet mode prevents the init method from printing record counts
}

NOTE: Modifying these options can exponentially increase the number of records generated

Usage

const Seeds = require('clique-seeds');

// Instantiate the seeds with an instance value of 1
const seeds = new Seeds(1);

// Creates an individual asset.
const asset = seeds.asset();

// An "overrides" object can be passed while creating records which will automatically override the seed
// generated object. Also note, this folder object is pushed into the seeds.records.folders array.
const folder = seeds.folder({ id: '123123' });

// Create 10 customers. Note, this will not create an "hasMany" data for the generated customers. Use the
// seeds.init() method for generating a graph of data.
const customers = seeds.generate(10, this.customer)

// Initialize a graph of data stored on the object this.records. Note, calling seeds.init() twice will duplicate
// the amount of data generated. Also note, any records created prior to seeds.init() will exist within the records
// arrays.
seeds.init()

// Will return objects in the shape the json-api expects for seeding the db
seeds.serialize('projects')

/* =========== String Generators =========== */
seeds.title()                  // Generates a random human readable title (titles can have multiple words)
seeds.companyName()            // String suitable for a company name
seeds.titleWord()              // Individual title word
seeds.buzzWord()               // Individual buzzword
seeds.randomCount(10, 100)     // Generate a random number between 10 - 100

/* =========== Numeric Generators =========== */
seeds.smallCount(10)        // Generates a number between 0 - 10 that is more likely to be small
seeds.largeCount(10)        // Opposite of seeds.smallCount()
seeds.randomCount(10, 100)  // Generate a random number between 10 - 100

/* =========== Use Once Generator =========== */
// Use once will return a random value from an array, then mutate the array to
// remove the value which has been returned. Thus, guaranteeing that values can only
// be "used once." Note, you may add arrays to the seeds.data map for this purpose. However,
// be careful to not override any of the existing data arrays.
seeds.useOnce(['foo', 'bar'], 'baz') // returns some item from array (e.g. 'bar')
seeds.useOnce(['foo', 'bar'], 'baz') // returns some different from array (e.g. 'foo')
seeds.useOnce(['foo', 'bar'], 'baz') // returns default value from array (e.g. 'baz')
seeds.useOnce(['foo', 'bar'], 'baz') // returns default value from array (e.g. 'baz')