mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +03:00
Cleanup array.length checks and for() to forEach()
This commit is contained in:
parent
db5751cd00
commit
82bed1ed80
24 changed files with 135 additions and 169 deletions
|
|
@ -8,14 +8,9 @@ import { EmailModel } from 'Model/Email';
|
|||
* @returns {string}
|
||||
*/
|
||||
export function emailArrayToString(emails, friendlyView = false, wrapWithLink = false) {
|
||||
let index = 0,
|
||||
len = 0;
|
||||
|
||||
const result = [];
|
||||
if (isNonEmptyArray(emails)) {
|
||||
for (len = emails.length; index < len; index++) {
|
||||
result.push(emails[index].toLine(friendlyView, wrapWithLink));
|
||||
}
|
||||
emails.forEach(email => result.push(email.toLine(friendlyView, wrapWithLink)));
|
||||
}
|
||||
|
||||
return result.join(', ');
|
||||
|
|
@ -26,16 +21,13 @@ export function emailArrayToString(emails, friendlyView = false, wrapWithLink =
|
|||
* @returns {string}
|
||||
*/
|
||||
export function emailArrayToStringClear(emails) {
|
||||
let index = 0,
|
||||
len = 0;
|
||||
|
||||
const result = [];
|
||||
if (isNonEmptyArray(emails)) {
|
||||
for (len = emails.length; index < len; index++) {
|
||||
if (emails[index] && emails[index].email && '' !== emails[index].name) {
|
||||
result.push(emails[index].email);
|
||||
emails.forEach(email => {
|
||||
if (email && email.email && '' !== email.name) {
|
||||
result.push(email.email);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return result.join(', ');
|
||||
|
|
@ -46,18 +38,14 @@ export function emailArrayToStringClear(emails) {
|
|||
* @returns {Array.<EmailModel>}
|
||||
*/
|
||||
export function emailArrayFromJson(json) {
|
||||
let index = 0,
|
||||
len = 0,
|
||||
email = null;
|
||||
|
||||
const result = [];
|
||||
if (isNonEmptyArray(json)) {
|
||||
for (index = 0, len = json.length; index < len; index++) {
|
||||
email = EmailModel.newInstanceFromJson(json[index]);
|
||||
json.forEach(email => {
|
||||
email = EmailModel.newInstanceFromJson(email);
|
||||
if (email) {
|
||||
result.push(email);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -69,15 +57,12 @@ export function emailArrayFromJson(json) {
|
|||
* @param {Array} localEmails
|
||||
*/
|
||||
export function replyHelper(inputEmails, unic, localEmails) {
|
||||
if (inputEmails && 0 < inputEmails.length) {
|
||||
let index = 0;
|
||||
const len = inputEmails.length;
|
||||
|
||||
for (; index < len; index++) {
|
||||
if (isUnd(unic[inputEmails[index].email])) {
|
||||
unic[inputEmails[index].email] = true;
|
||||
localEmails.push(inputEmails[index]);
|
||||
if (inputEmails) {
|
||||
inputEmails.forEach(email => {
|
||||
if (isUnd(unic[email.email])) {
|
||||
unic[email.email] = true;
|
||||
localEmails.push(email);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue