mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 02:52:27 +08:00
refactor(routes/api/recovery_codes): use .map instead of .forEach
it doesn't make sense to use a forEach here, when all we do is push values into an array => just use .map directly as it returns an array
This commit is contained in:
parent
05917fd815
commit
68ea84a2cb
@ -43,12 +43,10 @@ function getUsedRecoveryCodes() {
|
||||
|
||||
const dateRegex = RegExp(/^\d{4}\/\d{2}\/\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$/gm);
|
||||
const recoveryCodes = recovery_codes.getRecoveryCodes();
|
||||
const usedStatus: string[] = [];
|
||||
|
||||
recoveryCodes.forEach((recoveryKey: string) => {
|
||||
if (dateRegex.test(recoveryKey)) usedStatus.push(recoveryKey);
|
||||
else usedStatus.push(String(recoveryCodes.indexOf(recoveryKey)));
|
||||
});
|
||||
const usedStatus = recoveryCodes.map(recoveryKey => {
|
||||
return (dateRegex.test(recoveryKey)) ? recoveryKey : String(recoveryCodes.indexOf(recoveryKey))
|
||||
})
|
||||
|
||||
return {
|
||||
success: true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user