Have ideas to improve npm?Join in the discussion! ¬Ľ

    one-wise
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.0¬†‚Äʬ†Public¬†‚Äʬ†Published

    one-wise

    One-wise combinatorial testing generator

    npm version Build Status Coverage Status

    A 1-wise (a.k.a. 1-way) testing generator guarantees that at least one value of each group appears in the generated tests. The produced array has exactly the length of the largest input array.

    About

    This is a fast and simple implementation of a 1-wise testing generator. No external dependencies. Uses semantic versioning.

    Install

    npm install one-wise

    Example

    oneWise( {
        "foo": [ "x", "y" ],
        "bar": [ "a", "b", "c", "d" ],
        "baz": [ "f", "g" ]
    } )

    will return

    [
       { "foo": "x", "bar": "a", "baz": "f" },
       { "foo": "y", "bar": "b", "baz": "g" },
       { "foo": "x", "bar": "c", "baz": "f" },
       { "foo": "y", "bar": "d", "baz": "g" }
    ]

    Note: the values of foo and bar in the last two lines are picked randomly.

    It uses JavaScript's Math.random(), but a predictive pseudo-random generator function (e.g., seedrandom) can be passed as a second argument. Such function must work like Math.random() and return a number >= 0 and < 1.

    oneWise( /* your object */, myPseudoRandomNumberGenerator );

    Declaration

    Browser

    <script crossorigin src="https://unpkg.com/one-wise" ></script>
    <script>
    console.log(
        oneWise( {
            "foo": [ "x", "y" ],
            "bar": [ 1, 2, 3 ]
        } )
    );
    </script> 

    Option 2: Using unpkg and ESM:

    <script crossorigin src="https://unpkg.com/one-wise/index.esm.js" ></script>
    <script>
    import oneWise from 'one-wise';
    </script> 

    CommonJS (NodeJS)

    const oneWise = require('one-wise');

    ESM/TypeScript

    import oneWise from 'one-wise';

    API

    oneWise( obj [, prngFunc ] )

    • obj {object} - The given object.
    • prngFunc {function} - Pseudo-random number generator function used to pick array elements to repeat. Defaults to Math.random.

    See also

    License

    MIT © Thiago Delgado Pinto

    Install

    npm i one-wise

    DownloadsWeekly Downloads

    27

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    14.2 kB

    Total Files

    12

    Last publish

    Collaborators

    • avatar