random-rule
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

random-rule

简介

random-rule 是一个使用十分简单按照固定规则生成随机字符串的库

在线demo

在线demo

安装

npm install random-rule --save

使用

/**
 *
 * @param {!Object}
 *
 * @param {Boolean} Object.capitalLetters 是否包含大写字母
 * @param {Boolean} Object.lowercaseLetters 是否包含小写字母
 * @param {Boolean} Object.number 是否包含数字
 * @param {Boolean} Object.symbols 是否包含符号
 * @param {Number} Object.length 生成字符串长度
 *
 * @return string
 */

randomRule({
  capitalLetters: true,
  lowercaseLetters: true,
  number: true,
  symbols: true,
  length: 10
})

// => 'KGRuf^381K'
/**
 *
 * @param {String} 字符串模板,根据该字符串生成长度与数字大小写符号位置商都相对应的随机字符串
 *
 * @return string
 *
 */

randomRule('123qweQWE!@#')

// => '085pnwPNF)^#'

Readme

Keywords

Package Sidebar

Install

npm i random-rule

Weekly Downloads

6

Version

1.0.5

License

ISC

Unpacked Size

11.6 kB

Total Files

9

Last publish

Collaborators

  • wolyshaw