@phroun/paged-buffer
Version:
High-performance buffer system for editing massive files with intelligent memory management and undo/redo capabilities
114 lines • 3.72 kB
TypeScript
/**
* Enhanced BufferOperation with position tracking and distance calculation - FIXED
*/
export class BufferOperation {
constructor(type: any, position: any, data: any, originalData?: null, timestamp?: null);
type: any;
preExecutionPosition: any;
data: any;
originalData: any;
timestamp: number;
operationNumber: number;
id: string;
postExecutionPosition: any;
/**
* Set position for backwards compatibility
*/
set position(value: any);
/**
* Legacy position property for backwards compatibility
*/
get position(): any;
/**
* Set the position after this operation has executed
* @param {number} position - Position in buffer after operation executed
*/
setPostExecutionPosition(position: number): void;
/**
* Calculate logical distance to another operation using the distance module
* @param {BufferOperation} other - Other operation to compare with
* @param {Object} options - Calculation options
* @param {boolean} options.debug - Enable debug logging
* @returns {number} - Logical distance (0 = adjacent/overlapping)
*/
getLogicalDistance(other: BufferOperation, options?: {
debug: boolean;
}): number;
/**
* Get the size impact of this operation
* @returns {number} - Net size change (positive for growth, negative for shrinkage)
*/
getSizeImpact(): number;
/**
* Get the end position of this operation (legacy method)
* @returns {number} - End position
*/
getEndPosition(): number;
/**
* Get the length of content that an operation inserts into the final buffer
* @returns {number}
*/
_getInsertedLength(): number;
/**
* Check if this operation can be merged with another - FIXED
* @param {BufferOperation} other - Other operation
* @param {number} timeWindow - Time window for merging (ms)
* @param {number} positionWindow - Position window for merging (bytes)
* @returns {boolean} - True if mergeable
*/
canMergeWith(other: BufferOperation, timeWindow?: number, positionWindow?: number): boolean;
/**
* Check if two operation types are compatible for merging
* @param {string} type1 - First operation type
* @param {string} type2 - Second operation type
* @returns {boolean} - True if compatible
* @private
*/
private _areOperationsCompatible;
/**
* Merge another operation into this one - FIXED VERSION
* @param {BufferOperation} other - Operation to merge
*/
mergeWith(other: BufferOperation): void;
/**
* FIXED: Merge two insert operations
*/
_mergeInsertOperations(firstOp: any, secondOp: any): {
type: string;
position: any;
data: Buffer<ArrayBuffer>;
originalData: Buffer<ArrayBuffer>;
};
/**
* FIXED: Merge two delete operations
*/
_mergeDeleteOperations(firstOp: any, secondOp: any): {
type: string;
position: number;
data: Buffer<ArrayBuffer>;
originalData: Buffer<ArrayBuffer>;
};
/**
* FIXED: Merge mixed operations as overwrite
*/
_mergeAsOverwrite(firstOp: any, secondOp: any): {
type: string;
position: number;
data: any;
originalData: any;
};
}
export namespace OperationType {
let INSERT: string;
let DELETE: string;
let OVERWRITE: string;
}
/**
* Reset the global operation counter (for testing)
*/
export function resetOperationCounter(): void;
/**
* Get current operation counter value (for testing)
*/
export function getOperationCounter(): number;
//# sourceMappingURL=buffer-operation.d.ts.map