import { Emitter, Event } from './event'; export interface ISplice { readonly start: number; readonly deleteCount: number; readonly toInsert: T[]; } export interface ISpliceable { splice(start: number, deleteCount: number, toInsert: T[]): void; } export interface ISequence { readonly elements: T[]; readonly onDidSplice: Event>; } export class Sequence implements ISequence, ISpliceable { readonly elements: T[] = []; private _onDidSplice = new Emitter>(); readonly onDidSplice: Event> = this._onDidSplice.event; splice(start: number, deleteCount: number, toInsert: T[] = []): void { this.elements.splice(start, deleteCount, ...toInsert); this._onDidSplice.fire({ start, deleteCount, toInsert }); } }