Skip to content

Commit 9b9e6e0

Browse files
committed
🚧 Setting default values of options
1 parent 3bbce65 commit 9b9e6e0

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/generate.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/* eslint-disable no-param-reassign */
2+
// eslint-disable-next-line import/no-unresolved, import/extensions
3+
import { Options } from './options';
4+
5+
function generate(options: Options): string {
6+
// Set default values for options
7+
options = options || {};
8+
if (!Object.prototype.hasOwnProperty.call(options, 'length'))
9+
options.length = 8;
10+
if (!Object.prototype.hasOwnProperty.call(options, 'numbers'))
11+
options.numbers = false;
12+
if (!Object.prototype.hasOwnProperty.call(options, 'symbols'))
13+
options.symbols = false;
14+
if (!Object.prototype.hasOwnProperty.call(options, 'uppercase'))
15+
options.uppercase = true;
16+
if (!Object.prototype.hasOwnProperty.call(options, 'lowercase'))
17+
options.lowercase = true;
18+
if (
19+
!Object.prototype.hasOwnProperty.call(options, 'excludeSimilarCharacters')
20+
)
21+
options.excludeSimilarCharacters = false;
22+
23+
return '';
24+
}
25+
26+
export default generate;

0 commit comments

Comments
 (0)