How to use the randexp.randexp function in randexp

To help you get started, we’ve selected a few randexp 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 FrediBach / Blowson / src / helpers.js View on Github external
data[type][row][field] = value.replace(/{{\s*([^\}]+)\s*}}/g, function (match, capture) {
                        let randomPart = _.sample(capture.split('||')),
                            defaultParts = randomPart.split('?'),
                            filterParts = defaultParts[0].split('|'),
                            parts = filterParts[0].split('.');

                        if (randomPart[0] === '/' && randomPart.endsWith('/')) {
                            return RandExp.randexp(randomPart.slice(1, -1).replace(/❵/g, '}'));
                        } else if (parts[0] === 'number' && parts.length === 1) {
                            return Math.floor(Math.random() * 10);
                        } else if (parts[0] === 'sentence' && parts.length === 1) {
                            return sentence();
                        } else if (parts[0] === 'paragraph' && parts.length === 1) {
                            return paragraph();
                        } else if (parts[0] === 'word' && parts.length === 2) {
                            if (typeof generator[parts[1]] !== 'undefined') {
                                if (filterParts.length > 1) {
                                    return applyFilters(generator[parts[1]](), filterParts);
                                } else {
                                    return generator[parts[1]]();
                                }
                            }
                        } else if (parts[0] === 'fake' && parts.length === 2) {
                            if (typeof chance[parts[1]] === 'function') {
github FrediBach / Blowson / dist / blowson.esm.js View on Github external
data[type][row][field] = value.replace(/{{\s*([^\}]+)\s*}}/g, function (match, capture) {
                        let randomPart = _.sample(capture.split('||')),
                            defaultParts = randomPart.split('?'),
                            filterParts = defaultParts[0].split('|'),
                            parts = filterParts[0].split('.');

                        if (randomPart[0] === '/' && randomPart.endsWith('/')) {
                            return RandExp.randexp(randomPart.slice(1, -1).replace(/❵/g, '}'));
                        } else if (parts[0] === 'number' && parts.length === 1) {
                            return Math.floor(Math.random() * 10);
                        } else if (parts[0] === 'sentence' && parts.length === 1) {
                            return sentence();
                        } else if (parts[0] === 'paragraph' && parts.length === 1) {
                            return paragraph();
                        } else if (parts[0] === 'word' && parts.length === 2) {
                            if (typeof generator[parts[1]] !== 'undefined') {
                                if (filterParts.length > 1) {
                                    return applyFilters(generator[parts[1]](), filterParts);
                                } else {
                                    return generator[parts[1]]();
                                }
                            }
                        } else if (parts[0] === 'fake' && parts.length === 2) {
                            if (typeof chance[parts[1]] === 'function') {
github subeeshcbabu / swagmock / lib / generators / format.js View on Github external
function hostname() {
    return Randexp(/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/gm);
}
github mariohmol / js-brasil / demo / js-brasil.js View on Github external
cepState: function (state) {
        return randexp_1.randexp(validate_1.CEPRange[state]);
    },
    cpf: function () {
github mariohmol / js-brasil / js-brasil.js View on Github external
cepState: function (state) {
        return randexp_1.randexp(validate_1.CEPRange[state]);
    },
    cpf: function () {
github mariohmol / js-brasil / js-brasil-addons.js View on Github external
cepState: function (state) {
        return randexp_1.randexp(validate_1.CEPRange[state]);
    },
    cpf: function () {
github mariohmol / js-brasil / src / faker.ts View on Github external
cepState: (state: string | number) => {
    return randexp(CEPRange[state]);
  },
  certidao: () => {
github subeeshcbabu / swagmock / lib / generators / index.js View on Github external
let opts = {};
    let minLength = schema.minLength || 1;
    let maxLength = schema.maxLength || minLength + 10;
    opts.min = minLength;
    opts.max = maxLength;

    if (schema.enum && schema.enum.length > 0) {
        /**
         * If `enum` is defined for the property
         */
        mockStr = enumMock(schema);
    } else if (schema.pattern) {
        /**
         * If `pattern` is defined for the property
         */
        mockStr = Randexp(schema.pattern);
    } else if(Format[schema.format]) {
        /**
         * If a `format` is defined for the property
         */
        mockStr = Format[schema.format].call(null, schema);
    } else {
        mockStr = Chance.string({
            length: Chance.integer(opts),
            alpha: true //Use only alpha characters
        });
    }

    return mockStr;
};

randexp

Create random strings that match a given regular expression.

MIT
Latest version published 6 years ago

Package Health Score

70 / 100
Full package analysis

Popular randexp functions