Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

super-maker

AndrewShedov5.3kMIT1.0.13

Data generator designed specifically for turboMaker.

synthetic-data, data-generator, lorem, random, crypto, randomBytes, content, hashtags

readme

Discord MIT License

superMaker

Data generator designed specifically for turboMaker.
Generates random text, hashtags, words, dates, emails, id, url, arrays, booleans, etc.

Suitable for

  • Populating databases and creating synthetic content (posts, users, products, etc.)
  • Rapid prototyping

Features

  1. Ability to create a fully custom data storage to be used during generation.
  2. Uses Fisher-Yates shuffle - a reliable shuffling algorithm.
  3. Text generation with hashtags.
  4. Automatic hashtag extraction.
  5. Generation of unique email, id, etc., using randomBytes().
  6. Work with arrays and objects.

Installation & Usage

  1. Install the package:
npm i super-maker
  1. In the root of the project, create a file super-maker-storage.json.

Fill it with data, for example:

{
  "words": [
    "zorvian",
    "velthara",
    "quarnex"
  ],
  "hashtags": [
    "#Mercury",
    "#Venus",
    "#Moon"
  ],
  "fullName": [
    "James Smith",
    "John Johnson",
    "Robert Brown"
  ],
  "fullNames": {
    "name": [
      "James",
      "Emily",
      "Michael"
    ],
    "surname": [
      "Smith",
      "Johnson",
      "Williams"
    ]
  },
  "images": {
    "avatar": [
      "https://raw.githubusercontent.com/AndrewShedov/superMaker/refs/heads/main/storage/images/1.webp",
      "https://raw.githubusercontent.com/AndrewShedov/superMaker/refs/heads/main/storage/images/2.webp"
    ],
    "banner": [
      "https://raw.githubusercontent.com/AndrewShedov/superMaker/refs/heads/main/storage/images/1.webp",
      "https://raw.githubusercontent.com/AndrewShedov/superMaker/refs/heads/main/storage/images/2.webp"
    ]
  },
  "users": [
    "683a6251661f8f39765a75cc",
    "683a6220c57fe3aba56e3745",
    "683a622042fd1cb967541fb5",
    "683a62208355f4708ed7ed81"
  ]
}
  1. Generate data in turboMaker.

Example: posts generation:

import { superMaker } from 'super-maker';
import { ObjectId } from 'mongodb';

export const config = {
    uri: 'mongodb://127.0.0.1:27017',
    db: 'crystalTest',
    collection: 'posts',
    numberThreads: 'max',
    numberDocuments: 1_000_000,
    batchSize: 10_000,
    timeStepMs: 20
};

export async function generatingData({
    createdAt,
    updatedAt
}) {

    const user = superMaker.take.value({
        key: 'users'
    });

    const {
        title,
        text,
        hashtagsFromFullText
    } = superMaker.lorem.fullText.generate({

        titleOptions: {
            sentenceMin: 0,
            sentenceMax: 1,
            wordMin: 4,
            wordMax: 7,
            hashtagMin: 0,
            hashtagMax: 1
        },

        textOptions: {
            sentenceMin: 1,
            sentenceMax: 12,
            wordMin: 4,
            wordMax: 10,
            hashtagMin: 0,
            hashtagMax: 2
        }
    });

    return {

        title,
        text,
        hashtags: hashtagsFromFullText,

        views: superMaker.randomNumber({
            min: 120,
            max: 3125
        }),

        mainImage: superMaker.take.value({
            key: 'images.avatar'
        }),

        liked: superMaker.take.values({
            key: 'users',
            min: 3,
            max: 25
        }),

        user: new ObjectId(user),
        createdAt,
        updatedAt
    };
}

Examples of generations

Available methods

lorem: {
    words,
    sentences,
    fullText
  },

words

Takes words from the storage and outputs them in random order, uses - Fisher-Yates shuffle.

sentences

Takes words from the store and turns them into sentences with or without hashtags and outputs them randomly, uses Fisher-Yates shuffle. You can specify different output variations.

fullText

Extracts words from the storage, converts them into sentences with or without hashtags, and outputs them randomly using the Fisher-Yates shuffle. You can split a sentence into parts: title, text, hashtagsFromFullText and output each part in a separate document field, as well as specify different output variations.

 take: {
    value,
    values
  },

value

Returns a single value from storage, by key.

values

Outputs an array of values from storage by key, with various variations and output settings.

randomNumber,
randomDate,
randomBoolean,
randomCrypto,
randomEmailCrypto

randomNumber

Outputs a random number in a configurable range.

randomDate

Displays a random date within a configurable range.
Time format - 24 hour.

randomBoolean

Outputs a random boolean within a configurable percentage range.

randomCrypto

Outputs generated cryptographically strong pseudo-random data with the given length superMaker.randomCrypto(16). Uses - randomBytes().

randomEmailCrypto

Outputs generated cryptographically strong pseudo-random data with a given length superMaker.randomEmailCrypto(5) and frames it in '06e675b854@gmail.com'. Uses - randomBytes().

Full description of methods

Simulation of CRYSTAL v2.0 operation using synthetic data generated with turboMaker and superMaker:

CRYSTAL v1.0 features

SHEDOV.TOP | CRYSTAL | Discord | Telegram | X | VK | VK Video | YouTube