1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | /// <reference types="node" />
|
---|
9 | import { BaseException } from '@angular-devkit/core';
|
---|
10 | import { LinkedList } from './linked-list';
|
---|
11 | export declare class IndexOutOfBoundException extends BaseException {
|
---|
12 | constructor(index: number, min: number, max?: number);
|
---|
13 | }
|
---|
14 | export declare class ContentCannotBeRemovedException extends BaseException {
|
---|
15 | constructor();
|
---|
16 | }
|
---|
17 | /**
|
---|
18 | * A Chunk description, including left/right content that has been inserted.
|
---|
19 | * If _left/_right is null, this means that content was deleted. If the _content is null,
|
---|
20 | * it means the content itself was deleted.
|
---|
21 | *
|
---|
22 | * @see UpdateBuffer
|
---|
23 | */
|
---|
24 | export declare class Chunk {
|
---|
25 | start: number;
|
---|
26 | end: number;
|
---|
27 | originalContent: Buffer;
|
---|
28 | private _content;
|
---|
29 | private _left;
|
---|
30 | private _right;
|
---|
31 | private _assertLeft;
|
---|
32 | private _assertRight;
|
---|
33 | next: Chunk | null;
|
---|
34 | constructor(start: number, end: number, originalContent: Buffer);
|
---|
35 | get length(): number;
|
---|
36 | toString(encoding?: string): string;
|
---|
37 | slice(start: number): Chunk;
|
---|
38 | append(buffer: Buffer, essential: boolean): void;
|
---|
39 | prepend(buffer: Buffer, essential: boolean): void;
|
---|
40 | assert(left: boolean, _content: boolean, right: boolean): void;
|
---|
41 | remove(left: boolean, content: boolean, right: boolean): void;
|
---|
42 | copy(target: Buffer, start: number): number;
|
---|
43 | }
|
---|
44 | /**
|
---|
45 | * An utility class that allows buffers to be inserted to the _right or _left, or deleted, while
|
---|
46 | * keeping indices to the original buffer.
|
---|
47 | *
|
---|
48 | * The constructor takes an original buffer, and keeps it into a linked list of chunks, smaller
|
---|
49 | * buffers that keep track of _content inserted to the _right or _left of it.
|
---|
50 | *
|
---|
51 | * Since the Node Buffer structure is non-destructive when slicing, we try to use slicing to create
|
---|
52 | * new chunks, and always keep chunks pointing to the original content.
|
---|
53 | */
|
---|
54 | export declare class UpdateBuffer {
|
---|
55 | protected _originalContent: Buffer;
|
---|
56 | protected _linkedList: LinkedList<Chunk>;
|
---|
57 | constructor(_originalContent: Buffer);
|
---|
58 | protected _assertIndex(index: number): void;
|
---|
59 | protected _slice(start: number): [Chunk, Chunk];
|
---|
60 | /**
|
---|
61 | * Gets the position in the content based on the position in the string.
|
---|
62 | * Some characters might be wider than one byte, thus we have to determine the position using
|
---|
63 | * string functions.
|
---|
64 | */
|
---|
65 | protected _getTextPosition(index: number): number;
|
---|
66 | get length(): number;
|
---|
67 | get original(): Buffer;
|
---|
68 | toString(encoding?: string): string;
|
---|
69 | generate(): Buffer;
|
---|
70 | insertLeft(index: number, content: Buffer, assert?: boolean): void;
|
---|
71 | insertRight(index: number, content: Buffer, assert?: boolean): void;
|
---|
72 | remove(index: number, length: number): void;
|
---|
73 | }
|
---|