From bbff7403fbf46f9ad92240ac213df8d30ef31b64 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 20 Sep 2018 02:56:13 +0200 Subject: update packages --- node_modules/randomatic/index.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'node_modules/randomatic/index.js') diff --git a/node_modules/randomatic/index.js b/node_modules/randomatic/index.js index 4681b03e7..64e4f5487 100644 --- a/node_modules/randomatic/index.js +++ b/node_modules/randomatic/index.js @@ -9,12 +9,14 @@ var isNumber = require('is-number'); var typeOf = require('kind-of'); +var mathRandom = require('math-random'); /** * Expose `randomatic` */ module.exports = randomatic; +module.exports.isCrypto = !!mathRandom.cryptographic; /** * Available mask characters @@ -51,7 +53,9 @@ function randomatic(pattern, length, options) { length = pattern.length; } else if (isNumber(pattern)) { - options = {}; length = pattern; pattern = '*'; + options = {}; + length = pattern; + pattern = '*'; } } @@ -75,8 +79,14 @@ function randomatic(pattern, length, options) { if (pattern.indexOf('*') !== -1) mask += type.all; if (custom) mask += pattern; + // Characters to exclude + if (opts.exclude) { + var exclude = typeOf(opts.exclude) === 'string' ? opts.exclude : opts.exclude.join(''); + mask = mask.replace(new RegExp('[' + exclude + ']+', 'g'), ''); + } + while (length--) { - res += mask.charAt(parseInt(Math.random() * mask.length, 10)); + res += mask.charAt(parseInt(mathRandom() * mask.length, 10)); } return res; }; -- cgit v1.2.3