Skip to content

Commit edc8d6f

Browse files
committed
feat: more refactoring and improvements
1 parent 679d9c5 commit edc8d6f

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/routes/Generate/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const EXPORT_TYPES = {
4040
serialize: (passwordArray) =>
4141
passwordArray
4242
.map((password) => `"${password.replaceAll('"', '""')}"`)
43-
.join(',\n'),
43+
.join('\n'),
4444
},
4545
'text/plain': {
4646
extension: 'txt',

src/utils/PasswordGenerator/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const PasswordGenerator = (
6666
}
6767

6868
const passwordArray = [];
69-
const generatedPasswords = new Set();
69+
const generatedPasswords = allowDuplicates ? null : new Set();
7070
const splitter = new GraphemerConstructor();
7171
const graphemes = splitter.splitGraphemes(totalCharacterSet);
7272
const graphemeCount = graphemes.length;
@@ -94,11 +94,11 @@ export const PasswordGenerator = (
9494
password += graphemes[getRandomIntInclusive(0, graphemeCount - 1)];
9595
}
9696

97-
if (!allowDuplicates && generatedPasswords.has(password)) {
97+
if (generatedPasswords?.has(password)) {
9898
continue;
9999
}
100100

101-
generatedPasswords.add(password);
101+
generatedPasswords?.add(password);
102102
passwordArray.push(password);
103103
}
104104

0 commit comments

Comments
 (0)