UNPKG

fyipe-staging

Version:

Fyipe is a JS package that tracks error event and send logs from your applications to your fyipe dashboard.

31 lines (30 loc) 875 B
class FyipeTimelineManager { constructor(options) { this.options = options; this.timeLineStack = []; } _addItemToTimeline(item) { // get the size of the stack if (this.timeLineStack.length === this.options.maxTimeline) { // this.timeLineStack.shift(); // remove the oldest item return; // It discards new timline update once maximum is reached } // add time to it item.timestamp = Date.now(); // add a new item to the stack this.timeLineStack.push(item); return true; } addToTimeline(item) { this._addItemToTimeline(item); } // return the timeline getTimeline() { return this.timeLineStack; } // clear the timeline clearTimeline() { this.timeLineStack = []; } } export default FyipeTimelineManager;