Giter Site home page Giter Site logo

config-randomizer's Introduction

config-randomizer

Config randomizer used to generate configuration from a set of input parameters.

Recurses through your input configuration object, and checks for two scenarios:

  1. If the sub-object matches RandomizableCount interface, it calculates a concrete length based off of the count, and fills the array with mimics of the itemDetails interface.

  2. If the sub-object matches RandomizableRange interface, it calculates a concrete value within the minValIncl and maxValIncl range according to the weight function.

    • The potential values to chose from are found by starting at the minValIncl, and stepping by the stepper amount until the maxValIncl is reached

    Note: if the maxValIncl is not an even amount of steps from the minValIncl (NOT recommended), the last value before going over the max value, as well as the max value, will both be included. For example:

    1->5 by 1.5 = 1, 2.5, 4, 5
    

Note: As you will see in the example, these two interfaces can be used together. You can leverage a RandomizableCount whose itemDetails contains a RandomizableRange.

Example Usage

The following input configuration

{
    a: {
        b: {
            minValIncl: 1,
            maxValIncl: 4,
            weightFnKey: "EVEN",
            stepper: 1
        },
        c: {
            d: {
                minValIncl: 0.1,
                maxValIncl: 0.5,
                stepper: 0.1,
                weightFnKey: "EVEN"
            }
        },
        e: {
            count: {
                minValIncl: 1,
                maxValIncl: 4,
                stepper: 1,
                weightFnKey: "EVEN"
            },
            itemDetails: {
                e_1: "hello",
                e_2: {
                    minValIncl: 0.6,
                    maxValIncl: 0.9,
                    stepper: 0.1,
                    weightFnKey: "EVEN"
                }
            }
        }
    }
}

Could produce the following when run through deRandomize.

{
    a: {
        b: 2
        c: {
            d: 0.1
        },
        e: [{
            e_1: "hello",
            e_2: 0.7
        }, {
            e_1: "hello",
            e_2: 0.6
        }]
    }
}

Supported Weight Functions

  1. EVEN
    • Gives every step value an even weight, so each value is equally likely.

config-randomizer's People

Contributors

pasquej avatar jpasquers avatar

Watchers

James Cloos avatar  avatar

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.