Giter Site home page Giter Site logo

randomcontentgenerator's Introduction

Random Content Generator (RCG)

Simple but customizable random content generator. From simple and basic random content to advanced and complex.
RCG gives you full control on how you want your content to be generated.

0.3 Update

0.3 update has some breaking changes. make sure the read the changes before updating.

See it in action

Test the library on code sandbox

Usage

Install the package on NPM
npm i randomcontentgenerator

Create a schema to tell RCG how to generate the content. Here's an example of a very basic schema.

{
    "fields": [
        {
            "name": "Project Topic",
            "data": ["Cooking", "Travel", "Job Search"]
        },
        {
            "name": "Type",
            "data": ["Microservice", "Website", "Backend server"]
        },
        {
            "name": "Language",
            "data": ["Typescript", "C#", "Python"]
        }
    ]
}

The generator will pick one of each at random and generate a random result, for example:

    { "projectTopic": "Travel", "Type": "Website", "Language": "C#" }

In your code define a new ContentGenerator and pass the schema in the constructor. Calling the build() method will return the result as a string in JSON format.

    let generator = new ContentGenerator(schema);
    let json = generator.build();

The schema above is simple and often not enough. Here we have an example of more advanced schema.

{
    "fields": [
        {
            "name": "Card Name",
            "data": {
                "text": [
                    "@{0} @g{0} Spell",
                    "@{0} @g{0} Spell",
                    "@{0} @g{0} Card"
                ],
                "properties": [
                    [
                        "Awesome",
                        "Weak"
                    ]
                ]
            }
        },
        {
            "name": "Description",
            "data": {
                "text": [
                    "Deal @{0} @g{0} damage to the opponent",
                    "Draw @{1} Cards",
                    "Heal @{0} health"
                ],
                "properties": [
                    {
                        "min": 20,
                        "max": 51
                    },
                    {
                        "min": 1,
                        "max": 6
                    }
                ]
            }
        },
        {
            "name": "Cost",
            "data": {
                "min": 0,
                "max": 11
            }
        }
    ],
    "globalProperties": [
        [
            "Fire",
            "Frost",
            "Earth"
        ]
    ]
}

This may seems like a lot but actually really simple when you take 5 minutes to understand it. More information is found at the wiki section.

Docs

We offer full documentation over everything in the library to make using and contributing to the library easy.
You can access the docs in the wiki section where we explain how to use the library to its full potential and explaining how each system work.

Contributing

Everyone is welcome to help in any way possible (even minor).
If you modify the code, we do have a simple style guide to follow which can be found in the contributing section.
If you make a pull request that modifies the code you must request a pull request into the development branch first.

Work In Progress

This is a very early version of the package and may contain bugs and heavy changes in the future. use at your own risk.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.