This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface DeduplicateItem { | |
itemKey: string, | |
filterKey: boolean | |
} | |
deduplicateByKey<T extends DeduplicateItem>(items: T):void { | |
const resultMap = new Map<string, T & {index: number}>() | |
const toBeDeleted = new Set<number>() | |
items.forEach((item,index) => { | |
const existing = resultMap.get(item.itemKey) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
get local data and time | |
and can convert back to Date Object | |
console.log(new Date(getCurrentDateTime())) | |
*/ | |
export function getCurrentDateTime(): string { | |
const now = new Date() | |
const year = now.getFullYear() | |
const month = String(now.getMonth() + 1).padStart(2, '0') | |
const day = String(now.getDate()).padStart(2, '0') |