split-time
Version:
A JavaScript library for measuring FCP, LCP. Report real user measurements to tracking tool.
23 lines (18 loc) • 686 B
text/typescript
export default class EntryList extends Array<PerformanceEntry> implements PerformanceObserverEntryList {
private _entries: PerformanceEntry[]
public constructor(entries: PerformanceEntry[]) {
super(...entries)
this._entries = entries
}
public getEntries(): PerformanceEntry[] {
return this._entries
}
public getEntriesByType(type: string): PerformanceEntry[] {
return this._entries.filter((e): boolean => e.entryType === type)
}
public getEntriesByName(name: string, type?: string): PerformanceEntry[] {
return this._entries
.filter((e): boolean => e.name === name)
.filter((e): boolean => (type ? e.entryType === type : true))
}
}