Skip to content

Commit 3374560

Browse files
authored
Merge pull request #15 from lucasgdb/dev
2.1.0
2 parents c1cdc3c + 831c68d commit 3374560

11 files changed

+185
-55
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
node_modules
22
coverage
33

4+
dist/*
5+
!dist/*.js
6+
47
*.log

README.md

Lines changed: 61 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Generate random strings, strings with mask and strength passwords
44

5-
`generate-string` is a string generator that build random strings, strings with mask and passwords with password-strength tester.
5+
`generate-strings` is a string generator that build random strings, strings with mask and passwords with password-strength tester.
66
It is lightweight, extensible, has no dependencies, typescript support and can be used on the server with NodeJS or in-browser with JS.
77

88
[![Build Status](https://travis-ci.com/lucasgdb/generate-strings.svg?branch=master)](https://travis-ci.com/lucasgdb/generate-strings)
@@ -17,6 +17,12 @@ From the command line:
1717
npm install generate-strings --save
1818
```
1919

20+
or
21+
22+
```sh
23+
yarn add generate-strings
24+
```
25+
2026
### In-browser
2127

2228
Within your document (each one for the desired function)
@@ -30,24 +36,24 @@ Within your document (each one for the desired function)
3036
or
3137

3238
```html
33-
<script src="bundle.min.js"></script>
39+
<script src="generateStrings.min.js"></script>
3440
```
3541

3642
## Features
3743

38-
1. Generate random strings (default) like below:
44+
1. Generate random strings:
3945

4046
```sh
4147
',9nlg4^]'
4248
```
4349

44-
2. Generate strings with mask like below:
50+
2. Generate strings with mask:
4551

4652
```sh
4753
'@#$%-@#$%-@#$%-@#$%' = 'Aa!0-Aa!0-Aa!0-Aa!0'
4854
```
4955

50-
3. Generate passwords with password-strength tester like below:
56+
3. Generate passwords with password-strength tester:
5157

5258
```sh
5359
{ password: '2dt4hKIPO*=He', strength: 'high' }
@@ -67,9 +73,15 @@ After you've included it into your project, using the module is straightforward:
6773
6874
```javascript
6975
// require the module
70-
const { generateRandomString } = require('generate-strings');
76+
const {
77+
generateRandomString,
78+
generateRandomStringWithMask,
79+
generateRandomPassword,
80+
} = require('generate-strings');
7181
7282
console.log(generateRandomString());
83+
console.log(generateRandomStringWithMask());
84+
console.log(generateRandomPassword());
7385
```
7486
7587
### In-browser
@@ -87,29 +99,24 @@ The module may be configured as follows:
8799
OBS: The settings shown below are the defaults.
88100
89101
```javascript
90-
const { generateRandomPassword } = require('generate-strings');
91-
92-
// Pass a hash of settings into an object.
93-
const settings = {
94-
// available settings will be shown below
95-
};
102+
import { generateRandomString } from 'generate-strings';
96103
97104
// and then:
98-
const string = generateRandomPassword(settings);
105+
const randomString = generateRandomString();
99106
```
100107
101108
### Available options for generateRandomString
102109
103110
| Name | Type | Description | Default value | Allowed values |
104111
| ------------------- | ------- | ----------------------------------------- | ---------------------------- | ------------------------- |
105112
| stringLength | Integer | Size of the string that will be generated | 8 | 0-Number.MAX_SAFE_INTEGER |
106-
| upperCase | Boolean | Determines whether it will be generated | true | true and false |
113+
| upperCase | Boolean | Determines whether it will be generated | true | true, false |
107114
| upperCaseCharacters | String | UpperCase letters to be generated | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | 'A-Z' |
108-
| lowerCase | Boolean | Determines whether it will be generated | true | true and false |
115+
| lowerCase | Boolean | Determines whether it will be generated | true | true, false |
109116
| lowerCaseCharacters | String | LowerCase letters to be generated | 'abcdefghijklmnopqrstuvwxyz' | 'a-z' |
110-
| special | Boolean | Determines whether it will be generated | false | true and false |
117+
| special | Boolean | Determines whether it will be generated | false | true, false |
111118
| specialCharacters | String | Special letters to be generated | '!@#$%&\*()=[]{}' | All special characters |
112-
| number | Boolean | Determines whether it will be generated | true | true and false |
119+
| number | Boolean | Determines whether it will be generated | true | true, false |
113120
| numberCharacters | String | Numbers to be generated | '0123456789' | 0-9 |
114121
115122
### Available options for generateRandomStringWithMask
@@ -131,51 +138,64 @@ const string = generateRandomPassword(settings);
131138
| Name | Type | Description | Default value | Allowed values |
132139
| ------------------- | ------- | ----------------------------------------------- | ---------------------------- | ------------------------------------------------------- |
133140
| passwordLength | Integer | Size of the strings that will be generated | 8 | 0-Number.MAX_SAFE_INTEGER |
134-
| showStrength | Boolean | Shows the password strength | false | true and false |
135-
| excludeEqualChars | Boolean | Excludes characters that are consecutive equals | true | true and false |
141+
| showStrength | Boolean | Shows the password strength | false | true, false |
142+
| excludeEqualChars | Boolean | Excludes characters that are consecutive equals | false | true, false |
136143
| firstCharType | String | Determines the type of first character | 'random' | 'random', 'upperCase', 'lowerCase', 'special', 'number' |
137-
| upperCase | Boolean | Determines whether it will be generated | true | true and false |
144+
| upperCase | Boolean | Determines whether it will be generated | true | true, false |
138145
| upperCaseCharacters | String | UpperCase letters to be generated | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | 'A-Z' |
139-
| lowerCase | Boolean | Determines whether it will be generated | true | true and false |
146+
| lowerCase | Boolean | Determines whether it will be generated | true | true, false |
140147
| lowerCaseCharacters | String | LowerCase letters to be generated | 'abcdefghijklmnopqrstuvwxyz' | 'a-z' |
141-
| special | Boolean | Determines whether it will be generated | false | true and false |
148+
| special | Boolean | Determines whether it will be generated | false | true, false |
142149
| specialCharacters | String | Special letters to be generated | '!@#$%&\*()=[]{}' | All special characters |
143-
| number | Boolean | Determines whether it will be generated | true | true and false |
150+
| number | Boolean | Determines whether it will be generated | true | true, false |
144151
| numberCharacters | String | Numbers to be generated | '0123456789' | 0-9 |
145152
146153
## Examples
147154
148-
```javascript
149-
const { generateRandomPassword } = require('generate-strings');
155+
```typescript
156+
import {
157+
generateRandomString,
158+
generateRandomStringProps,
159+
} from 'generate-strings';
150160

151-
const settings = {
152-
passwordLength: 12,
161+
const settings: generateRandomStringProps = {
162+
stringLength: 15,
153163
special: true,
154-
showStrength: true,
155-
excludeEqualChars: true,
156164
};
157165

158-
const pass = generateRandomPassword(settings); // will return a random object like: { password: 'T2$he{Yk6pvf', strength: 'high' }
166+
const randomStringWithMask = generateRandomString(settings); // will return a string like: bov$Ia@}Rr8gzU*
159167
```
160168
161-
```javascript
162-
const { generateRandomStringWithMask } = require('generate-strings');
169+
```typescript
170+
import {
171+
generateRandomStringWithMask,
172+
generateRandomStringWithMaskProps,
173+
} from 'generate-strings';
163174

164-
const settings = {
175+
const settings: generateRandomStringWithMaskProps = {
165176
upperCaseMask: '&',
166177
mask: '####_####%@hotmail.com',
167178
};
168179

169-
const pass = generateRandomStringWithMask(settings); // will return a random string like: [email protected]
180+
const randomStringWithMask = generateRandomStringWithMask(settings); // will return a string like: [email protected]
170181
```
171182
172-
## Testing
183+
```typescript
184+
import {
185+
generateRandomPassword,
186+
generateRandomPasswordProps,
187+
} from 'generate-strings';
173188

174-
To run the test, simply run `yarn test`. You
175-
may first need to run `yarn` to install the required development
176-
dependencies. (These dependencies are **not** required in a production
177-
environment, and facilitate only unit testing.)
189+
const settings: generateRandomPasswordProps = {
190+
passwordLength: 12,
191+
special: true,
192+
showStrength: true,
193+
excludeEqualChars: true,
194+
};
178195

179-
## Contributing
196+
const randomPassword = generateRandomPassword(settings); // will return a object like: { password: 'T2$he{Yk6pvf', strength: 'high' }
197+
```
198+
199+
## Testing
180200
181-
If you'd like to contribute, please fork this repository, change the branch typing `git switch dev`, make a new branch typing `git checkout -b new-branch-name`, make your changes, make a push typing `git push -u origin new-branch-name` and then submit a pull-request.
201+
To test the application, run `yarn test`. You may first need to run `yarn` to install the required development dependencies. (These dependencies are **not** required in a production environment, and facilitate only unit testing.)

dist/generateRandomStringWithMask.min.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.

0 commit comments

Comments
 (0)