How to use the chance.natural function in chance

To help you get started, we’ve selected a few chance examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gobwas / dm.js / test / unit / dm.js View on Github external
function makeRandomObj(recursive, obj) {
                    return _.reduce(new Array(chance.natural({min: 3, max: 7})), function(result, value, index) {
                        var val;

                        if (obj) {
                            result[chance.word()] = chance.word();
                        } else {
                            switch (index) {
                                case 1: {
                                    val = recursive ? makeRandomObj(false, false) : makeRandomObj(false, true);
                                    break;
                                }

                                default: {
                                    val = chance.word();
                                    break;
                                }
                            }

chance

Chance - Utility library to generate anything random

MIT
Latest version published 1 year ago

Package Health Score

76 / 100
Full package analysis