UNPKG

@phroun/paged-buffer

Version:

High-performance buffer system for editing massive files with intelligent memory management and undo/redo capabilities

90 lines 2.93 kB
/** * @fileoverview Enhanced BufferOperation with position tracking and distance calculation - FIXED * @author Jeffrey R. Day * @version 1.0.0 */ /// <reference types="node" /> /// <reference types="node" /> import { OperationType, type BufferOperation as IBufferOperationInterface, type DistanceCalculationOptions } from './types/common'; /** * Reset the global operation counter (for testing) */ declare function resetOperationCounter(): void; /** * Get current operation counter value (for testing) */ declare function getOperationCounter(): number; interface MergedOperationResult { type: OperationType; position: number; data: Buffer; originalData: Buffer; } /** * Enhanced BufferOperation with position tracking and distance calculation - FIXED */ declare class BufferOperation implements IBufferOperationInterface { type: OperationType; preExecutionPosition: number; data: Buffer | undefined; originalData: Buffer | undefined; timestamp: number; operationNumber: number; id: string; postExecutionPosition: number | null; constructor(type: OperationType, position: number, data?: Buffer, originalData?: Buffer | null, timestamp?: number | null); /** * Legacy position property for backwards compatibility */ get position(): number; /** * Set position for backwards compatibility */ set position(value: number); /** * Set the position after this operation has executed */ setPostExecutionPosition(position: number): void; /** * Calculate logical distance to another operation using the distance module */ getLogicalDistance(other: BufferOperation, options?: DistanceCalculationOptions): number; /** * Get the size impact of this operation */ getSizeImpact(): number; /** * Get the end position of this operation (legacy method) */ getEndPosition(): number; /** * Get the length of content that an operation inserts into the final buffer */ getInsertedLength(): number; /** * Check if this operation can be merged with another - FIXED */ canMergeWith(other: BufferOperation, timeWindow?: number, positionWindow?: number): boolean; /** * Check if two operation types are compatible for merging */ private _areOperationsCompatible; /** * Merge another operation into this one - FIXED VERSION */ mergeWith(other: BufferOperation): void; /** * FIXED: Merge two insert operations */ private _mergeInsertOperations; /** * FIXED: Merge two delete operations */ private _mergeDeleteOperations; /** * FIXED: Merge mixed operations as overwrite */ private _mergeAsOverwrite; } export { BufferOperation, OperationType, resetOperationCounter, getOperationCounter, type MergedOperationResult }; //# sourceMappingURL=buffer-operation.d.ts.map