- const d = '18/06/2024; // Date today
+ const dateToday = '18/06/2024;
// See in this case the list refers to a Set no an Array
- const aIdList = new Set([1,2,3,4,5]);
// Now we don't need to worry about changing the name if the type changes
+ const accountsIds = new Set([1,2,3,4,5]);
Old
function findArrayDifference<T>(a1: T[], a2: T[]): T[] {
const diffA1 = a1.filter((item) => !a2.includes(item));
const diffA2 = a2.filter((item) => !a1.includes(item));
return diffA1.concat(diffA2);
}
New
function findArrayDifference<T>(source: T[], destination: T[]): T[] {
const differenceFromSource = source.filter((item) => !destination.includes(item));
const differenceFromDestination = destination.filter((item) => !source.includes(item));
return differenceFromSource.concat(differenceFromDestination);
}
Old
const acts = getActs();
const npActsIds = new Set();
for (const ac of acts) {
if (ac.pst === 0) {
npActsIds.add(ac.i)
}
}
** New **
enum PaymentStatus {
NotPaid,
Paid,
}
/*
...
*/
const acounts = getAcounts();
const notPaidAccounts = new Set();
for (const account of accounts) {
if (account.paymentStatus === PaymentStatus.NotPaid) {
notPaidAccounts.add(account.id)
}
}