.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / randomatic / README.md
1 # randomatic [![NPM version](https://img.shields.io/npm/v/randomatic.svg?style=flat)](https://www.npmjs.com/package/randomatic) [![NPM monthly downloads](https://img.shields.io/npm/dm/randomatic.svg?style=flat)](https://npmjs.org/package/randomatic) [![NPM total downloads](https://img.shields.io/npm/dt/randomatic.svg?style=flat)](https://npmjs.org/package/randomatic) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/randomatic.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/randomatic)
2
3 > Generate randomized strings of a specified length using simple character sequences. The original generate-password.
4
5 Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
6
7 ## Install
8
9 Install with [npm](https://www.npmjs.com/):
10
11 ```sh
12 $ npm install --save randomatic
13 ```
14
15 ## Usage
16
17 ```js
18 var randomize = require('randomatic');
19 ```
20
21 ## API
22
23 ```js
24 randomize(pattern, length, options);
25 randomize.isCrypto;
26 ```
27
28 * `pattern` **{String}**: (required) The pattern to use for randomizing
29 * `length` **{Number}**: (optional) The length of the string to generate
30 * `options` **{Object}**: (optional) See available [options](#options)
31 * `randomize.isCrypto` will be `true` when a cryptographically secure function is being used to generate random numbers. The value will be `false` when the function in use is `Math.random`.
32
33 ### pattern
34
35 > The pattern to use for randomizing
36
37 Patterns can contain any combination of the below characters, specified in any order.
38
39 **Example:**
40
41 To generate a 10-character randomized string using all available characters:
42
43 ```js
44 randomize('*', 10);
45 //=> 'x2_^-5_T[$'
46
47 randomize('Aa0!', 10);
48 //=> 'LV3u~BSGhw'
49 ```
50
51 * `a`: Lowercase alpha characters (`abcdefghijklmnopqrstuvwxyz'`)
52 * `A`: Uppercase alpha characters (`ABCDEFGHIJKLMNOPQRSTUVWXYZ'`)
53 * `0`: Numeric characters (`0123456789'`)
54 * `!`: Special characters (`~!@#$%^&()_+-={}[];\',.`)
55 * `*`: All characters (all of the above combined)
56 * `?`: Custom characters (pass a string of custom characters to the options)
57
58 ### length
59
60 > The length of the string to generate
61
62 **Examples:**
63
64 * `randomize('A', 5)` will generate a 5-character, uppercase, alphabetical, randomized string, e.g. `KDJWJ`.
65 * `randomize('0', 2)` will generate a 2-digit random number
66 * `randomize('0', 3)` will generate a 3-digit random number
67 * `randomize('0', 12)` will generate a 12-digit random number
68 * `randomize('A0', 16)` will generate a 16-character, alpha-numeric randomized string
69
70 If `length` is left undefined, the length of the pattern in the first parameter will be used. For example:
71
72 * `randomize('00')` will generate a 2-digit random number
73 * `randomize('000')` will generate a 3-digit random number
74 * `randomize('0000')` will generate a 4-digit random number...
75 * `randomize('AAAAA')` will generate a 5-character, uppercase alphabetical random string...
76
77 These are just examples, [see the tests](./test.js) for more use cases and examples.
78
79 ## options
80
81 > These are options that can be passed as the third argument.
82
83 #### chars
84
85 Type: `String`
86
87 Default: `undefined`
88
89 Define a custom string to be randomized.
90
91 **Example:**
92
93 * `randomize('?', 20, {chars: 'jonschlinkert'})` will generate a 20-character randomized string from the letters contained in `jonschlinkert`.
94 * `randomize('?', {chars: 'jonschlinkert'})` will generate a 13-character randomized string from the letters contained in `jonschlinkert`.
95
96 #### exclude
97
98 Type: `String|Array`
99
100 Default: `undefined`
101
102 Specify a string or array of characters can are excluded from the possible characters used to generate the randomized string.
103
104 **Example:**
105
106 * `randomize('*', 20, { exclude: '0oOiIlL1' })` will generate a 20-character randomized string using all of possible characters except for `0oOiIlL1`.
107
108 ## Usage Examples
109
110 * `randomize('A', 4)` (_whitespace insenstive_) would result in randomized 4-digit uppercase letters, like, `ZAKH`, `UJSL`... etc.
111 * `randomize('AAAA')` is equivelant to `randomize('A', 4)`
112 * `randomize('AAA0')` and `randomize('AA00')` and `randomize('A0A0')` are equivelant to `randomize('A0', 4)`
113 * `randomize('aa')`: results in double-digit, randomized, lower-case letters (`abcdefghijklmnopqrstuvwxyz`)
114 * `randomize('AAA')`: results in triple-digit, randomized, upper-case letters (`ABCDEFGHIJKLMNOPQRSTUVWXYZ`)
115 * `randomize('0', 6)`: results in six-digit, randomized numbers (`0123456789`)
116 * `randomize('!', 5)`: results in single-digit randomized, _valid_ non-letter characters (`~!@#$%^&()_+-={}[]
117 * `randomize('A!a0', 9)`: results in nine-digit, randomized characters (any of the above)
118
119 _The order in which the characters are defined is insignificant._
120
121 ## About
122
123 <details>
124 <summary><strong>Contributing</strong></summary>
125
126 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
127
128 </details>
129
130 <details>
131 <summary><strong>Running Tests</strong></summary>
132
133 Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
134
135 ```sh
136 $ npm install && npm test
137 ```
138
139 </details>
140
141 <details>
142 <summary><strong>Building docs</strong></summary>
143
144 _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
145
146 To generate the readme, run the following command:
147
148 ```sh
149 $ npm install -g verbose/verb#dev verb-generate-readme && verb
150 ```
151
152 </details>
153
154 ### Related projects
155
156 You might also be interested in these projects:
157
158 * [pad-left](https://www.npmjs.com/package/pad-left): Left pad a string with zeros or a specified string. Fastest implementation. | [homepage](https://github.com/jonschlinkert/pad-left "Left pad a string with zeros or a specified string. Fastest implementation.")
159 * [pad-right](https://www.npmjs.com/package/pad-right): Right pad a string with zeros or a specified string. Fastest implementation. | [homepage](https://github.com/jonschlinkert/pad-right "Right pad a string with zeros or a specified string. Fastest implementation.")
160 * [repeat-string](https://www.npmjs.com/package/repeat-string): Repeat the given string n times. Fastest implementation for repeating a string. | [homepage](https://github.com/jonschlinkert/repeat-string "Repeat the given string n times. Fastest implementation for repeating a string.")
161
162 ### Contributors
163
164 | **Commits** | **Contributor** |  
165 | --- | --- |  
166 | 56 | [jonschlinkert](https://github.com/jonschlinkert) |  
167 | 6  | [doowb](https://github.com/doowb) |  
168 | 4  | [kivlor](https://github.com/kivlor) |  
169 | 2  | [realityking](https://github.com/realityking) |  
170 | 2  | [ywpark1](https://github.com/ywpark1) |  
171 | 1  | [TrySound](https://github.com/TrySound) |  
172 | 1  | [drag0s](https://github.com/drag0s) |  
173 | 1  | [paulmillr](https://github.com/paulmillr) |  
174 | 1  | [sunknudsen](https://github.com/sunknudsen) |  
175 | 1  | [faizulhaque-tp](https://github.com/faizulhaque-tp) |  
176 | 1  | [michaelrhodes](https://github.com/michaelrhodes) |  
177
178 ### Author
179
180 **Jon Schlinkert**
181
182 * [GitHub Profile](https://github.com/jonschlinkert)
183 * [Twitter Profile](https://twitter.com/jonschlinkert)
184 * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
185
186 ### License
187
188 Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
189 Released under the [MIT License](LICENSE).
190
191 ***
192
193 _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on October 23, 2018._