Skip to content

Commit 89468d1

Browse files
committed
improvements
1 parent 8cb0691 commit 89468d1

File tree

5 files changed

+57
-86
lines changed

5 files changed

+57
-86
lines changed

README.md

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ After you've included it into your project, using the module is straightforward:
4646
### Server-side
4747
```javascript
4848
// require the module
49-
const str = require('generate-strings');
49+
const str = require('generate-strings')
5050
5151
// invoke generate() to generate a random string
52-
const string = str.generate(/* settings into object */)
52+
let string = str.generate(/* settings into object */)
5353
5454
// shows the result
5555
console.log(string) // something like ,9nlg4^]
@@ -58,93 +58,111 @@ console.log(string) // something like ,9nlg4^]
5858
### In-browser
5959
```javascript
6060
// in the browser, including the script will make a generate() function available.
61-
const str = generate() // will return a string
61+
let str = generate() // will return a string
6262
```
6363
6464
Configuring
6565
-----------
6666
The module may be configured as follows:
6767
6868
```javascript
69-
const str = require('generate-strings');
69+
const str = require('generate-strings')
7070
7171
// Pass a hash of settings into an object. The settings shown here are the defaults.
72-
const settings = {
72+
let settings = {
7373
/*
7474
*************************************************
7575
Settings for all modes
7676
*************************************************
7777
*/
7878
amount: 1,
79-
// set the amount of strings to generate
79+
// Number, set the amount of strings to generate
8080
8181
mode: 'random',
82-
// set the mode. Allows "random", "mask" and "password"
82+
// String, set the mode. Allows "random", "mask" and "password"
8383
8484
upperCases: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
85-
// upperCases characters
85+
// String, upperCases characters that will be generated
8686
8787
lowerCases: 'abcdefghijklmnopqrstuvwxyz',
88-
// lowerCase characters
88+
// String, lowerCase characters that will be generated
8989
9090
specials: '!@#$%&*()=[]{}',
91-
// special characters
91+
// String, special characters that will be generated
9292
9393
numbers: '0123456789',
94-
// numbers
94+
// String, numbers that will be generated
9595
9696
/*
9797
*************************************************
9898
Settings for random string and password modes
9999
**************************************************
100100
*/
101101
length: 8,
102-
// length of the strings
102+
// Number, length of the strings
103+
// when mode is password, must be > 1
103104
104105
upperCase: true,
105-
// set a boolean value to generate strings with upperCase characters
106+
// Boolean, set a boolean value to generate strings with upperCase characters
106107
107108
lowerCase: true,
108-
// set a boolean value to generate strings with lowerCase characters
109+
// Boolean, set a boolean value to generate strings with lowerCase characters
109110
110111
special: false,
111-
// set a boolean value to generate strings with special characters
112+
// Boolean, set a boolean value to generate strings with special characters
112113
113114
number: true,
114-
// set a boolean value to generate strings with numbers
115+
// Boolean, set a boolean value to generate strings with numbers
115116
116117
/*
117118
*************************************************
118119
Settings for password mode
119120
*************************************************
120121
*/
121122
showStrength: false,
122-
// Shows the password strength
123+
// Boolean, shows the password strength
123124
// like: strength: high. Possible results: unacceptable, terrible, medium, good and high.
124125
125126
firstCharType: 'random',
126-
// set the type of first character when generate a password
127+
// String, set the type of first character when generate a password
127128
// 'random' - random type
128129
// 'upperCase' - to upperCase character
129130
// 'lowerCase' - to lowerCase character
130131
// 'special' - to special character
131132
// 'number' - to number
132133
134+
excludeEqualChars: true,
135+
// Boolean, exclude characters that are equals
136+
// E.g: aa, AA, @@, 00
137+
133138
/*
134139
*************************************************
135140
Settings for mask mode
136141
*************************************************
137142
*/
138-
mask: '@#$%-@#$%-@#$%-@#$%' // mask of string
143+
mask: '@#$%-@#$%-@#$%-@#$%',
144+
// String, mask to generate the strings
139145
// @ - to upperCase characters
140146
// # - to lowerCase characters
141147
// $ - to special characters
142148
// % - to numbers
143149
// others: no will be changed
150+
151+
upperCaseMask: '@',
152+
// String, must be 1 character
153+
154+
lowerCaseMask: '#',
155+
// String, must be 1 character
156+
157+
specialMask: '$',
158+
// String, must be 1 character
159+
160+
numberMask: '%'
161+
// String, must be 1 character
144162
}
145163
146164
// and then:
147-
const string = str.generate(settings)
165+
let string = str.generate(settings)
148166
```
149167

150168
Testing
@@ -154,7 +172,6 @@ may first need to run `npm install` to install the required development
154172
dependencies. (These dependencies are **not** required in a production
155173
environment, and facilitate only unit testing.)
156174

157-
158175
Contributing
159176
------------
160-
If you'd like to contribute, please fork this repository, change the default branch typing git checkout dev, make your changes, and then submit a pull-request.
177+
If you'd like to contribute, please fork this repository, change the default branch typing git checkout dev, make your changes, make a new branch and then submit a pull-request.

dist/generate-strings.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

generate-strings.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generate-strings",
3-
"version": "1.0.6",
3+
"version": "1.1.0",
44
"description": "Generate random strings, strings with mask and strength passwords with password-strength tester",
55
"main": "generate-strings.js",
66
"scripts": {
@@ -27,8 +27,5 @@
2727
"bugs": {
2828
"url": "https://github.com/LucasNaja/generate-strings/issues"
2929
},
30-
"homepage": "https://github.com/LucasNaja/generate-strings#readme",
31-
"devDependencies": {
32-
"@zeit/ncc": "^0.8.1"
33-
}
30+
"homepage": "https://github.com/LucasNaja/generate-strings#readme"
3431
}

test.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,32 @@ const str = require('./generate-strings')
33
const randomString = str.generate({
44
amount: 3,
55
special: true,
6-
length: 20
6+
length: 10
77
})
88

9-
console.log('Generating a random string: ', randomString)
9+
console.log('Generating a random string:\n', randomString)
1010

1111
const password = str.generate({
1212
mode: 'password',
13-
length: 12,
13+
amount: 10,
14+
length: 6,
1415
special: true,
15-
showStrength: true
16+
showStrength: true,
17+
excludeEqualChars: false
1618
})
1719

18-
console.log('\n\nGenerating a random password: ', password)
20+
console.log('\n\nGenerating a random password:\n', password)
1921

2022
const stringWithMask = str.generate({
2123
mode: 'mask',
22-
mask: 'String mask: @ # $ %',
23-
upperCases: 'A',
24-
lowerCases: 'a',
24+
upperCaseMask: '&',
25+
lowerCaseMask: '0',
26+
mask: 'i\'m a string mask, and the result is: & 0 @ # $ %',
27+
upperCases: 'ABCDEF',
28+
lowerCases: 'abcdef',
2529
special: true,
26-
specials: '+',
27-
numbers: '0'
30+
specials: '+-=[]~',
31+
numbers: '012345',
2832
})
2933

30-
console.log('\n\nGenerating a random string with mask: ', stringWithMask)
34+
console.log('\n\nGenerating a random string with mask:\n', stringWithMask)

0 commit comments

Comments
 (0)