convert Direction to ts

This commit is contained in:
Bruno Windels 2021-08-18 18:21:43 +02:00
parent ed082c9869
commit 85c8415acd
4 changed files with 11 additions and 16 deletions

View file

@ -15,34 +15,29 @@ limitations under the License.
*/ */
export class Direction { export class Direction {
constructor(isForward) { constructor(public readonly isForward: boolean) {
this._isForward = isForward;
} }
get isForward() { get isBackward(): boolean {
return this._isForward;
}
get isBackward() {
return !this.isForward; return !this.isForward;
} }
asApiString() { asApiString(): string {
return this.isForward ? "f" : "b"; return this.isForward ? "f" : "b";
} }
reverse() { reverse(): Direction {
return this.isForward ? Direction.Backward : Direction.Forward return this.isForward ? Direction.Backward : Direction.Forward
} }
static get Forward() { static get Forward(): Direction {
return _forward; return _forward;
} }
static get Backward() { static get Backward(): Direction {
return _backward; return _backward;
} }
} }
const _forward = Object.freeze(new Direction(true)); const _forward = new Direction(true);
const _backward = Object.freeze(new Direction(false)); const _backward = new Direction(false);

View file

@ -17,7 +17,7 @@ limitations under the License.
import {SortedArray, AsyncMappedList, ConcatList, ObservableArray} from "../../../observable/index.js"; import {SortedArray, AsyncMappedList, ConcatList, ObservableArray} from "../../../observable/index.js";
import {Disposables} from "../../../utils/Disposables.js"; import {Disposables} from "../../../utils/Disposables.js";
import {Direction} from "./Direction.js"; import {Direction} from "./Direction";
import {TimelineReader} from "./persistence/TimelineReader.js"; import {TimelineReader} from "./persistence/TimelineReader.js";
import {PendingEventEntry} from "./entries/PendingEventEntry.js"; import {PendingEventEntry} from "./entries/PendingEventEntry.js";
import {RoomMember} from "../members/RoomMember.js"; import {RoomMember} from "../members/RoomMember.js";

View file

@ -15,7 +15,7 @@ limitations under the License.
*/ */
import {BaseEntry} from "./BaseEntry"; import {BaseEntry} from "./BaseEntry";
import {Direction} from "../Direction.js"; import {Direction} from "../Direction";
import {isValidFragmentId} from "../common.js"; import {isValidFragmentId} from "../common.js";
import {KeyLimits} from "../../../storage/common"; import {KeyLimits} from "../../../storage/common";

View file

@ -15,7 +15,7 @@ limitations under the License.
*/ */
import {directionalConcat, directionalAppend} from "./common.js"; import {directionalConcat, directionalAppend} from "./common.js";
import {Direction} from "../Direction.js"; import {Direction} from "../Direction";
import {EventEntry} from "../entries/EventEntry.js"; import {EventEntry} from "../entries/EventEntry.js";
import {FragmentBoundaryEntry} from "../entries/FragmentBoundaryEntry.js"; import {FragmentBoundaryEntry} from "../entries/FragmentBoundaryEntry.js";