1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-08 21:42:24 +03:00

Switch to a discriminated unions

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2020-07-20 16:33:53 +01:00
parent 2bf5e4b142
commit ed0d9973b7
9 changed files with 130 additions and 74 deletions

View File

@@ -16,15 +16,15 @@ limitations under the License.
import DocumentOffset from "./offset";
import EditorModel from "./model";
import {BasePart} from "./parts";
import {Part} from "./parts";
export interface IPosition {
index: number;
offset: number;
}
type Callback = (part: BasePart, startIdx: number, endIdx: number) => void;
type Predicate = (index: number, offset: number, part: BasePart) => boolean;
type Callback = (part: Part, startIdx: number, endIdx: number) => void;
type Predicate = (index: number, offset: number, part: Part) => boolean;
export default class DocumentPosition implements IPosition {
constructor(public readonly index: number, public readonly offset: number) {