Skip to content

Instantly share code, notes, and snippets.

View zhaoq2016's full-sized avatar

zhaoq2016

View GitHub Profile
@zhaoq2016
zhaoq2016 / gist:df2306c8878383bde601f01445561a80
Created October 3, 2025 10:31
delete duplicated object items in a array , filter item by some feature
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)
@zhaoq2016
zhaoq2016 / file-utils.ts
Last active October 3, 2025 09:47
local data time function
/*
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')