diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
commit | cc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 (patch) | |
tree | 92c5d88706a6ffc654d1b133618d357890e7096b /node_modules/randomatic/index.js | |
parent | 3771b4d6b67b34c130f3a9a1a15f42deefdb2eda (diff) |
remove node_modules
Diffstat (limited to 'node_modules/randomatic/index.js')
-rw-r--r-- | node_modules/randomatic/index.js | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/node_modules/randomatic/index.js b/node_modules/randomatic/index.js deleted file mode 100644 index 64e4f5487..000000000 --- a/node_modules/randomatic/index.js +++ /dev/null @@ -1,92 +0,0 @@ -/*! - * randomatic <https://github.com/jonschlinkert/randomatic> - * - * Copyright (c) 2014-2017, Jon Schlinkert. - * Released under the MIT License. - */ - -'use strict'; - -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 - */ - -var type = { - lower: 'abcdefghijklmnopqrstuvwxyz', - upper: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', - number: '0123456789', - special: '~!@#$%^&()_+-={}[];\',.' -}; - -type.all = type.lower + type.upper + type.number + type.special; - -/** - * Generate random character sequences of a specified `length`, - * based on the given `pattern`. - * - * @param {String} `pattern` The pattern to use for generating the random string. - * @param {String} `length` The length of the string to generate. - * @param {String} `options` - * @return {String} - * @api public - */ - -function randomatic(pattern, length, options) { - if (typeof pattern === 'undefined') { - throw new Error('randomatic expects a string or number.'); - } - - var custom = false; - if (arguments.length === 1) { - if (typeof pattern === 'string') { - length = pattern.length; - - } else if (isNumber(pattern)) { - options = {}; - length = pattern; - pattern = '*'; - } - } - - if (typeOf(length) === 'object' && length.hasOwnProperty('chars')) { - options = length; - pattern = options.chars; - length = pattern.length; - custom = true; - } - - var opts = options || {}; - var mask = ''; - var res = ''; - - // Characters to be used - if (pattern.indexOf('?') !== -1) mask += opts.chars; - if (pattern.indexOf('a') !== -1) mask += type.lower; - if (pattern.indexOf('A') !== -1) mask += type.upper; - if (pattern.indexOf('0') !== -1) mask += type.number; - if (pattern.indexOf('!') !== -1) mask += type.special; - 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(mathRandom() * mask.length, 10)); - } - return res; -}; |