forked from mystiq/hydrogen-web
Switch BaseEntry to TypeScript
This commit is contained in:
parent
b8c8325292
commit
3c5b186e31
4 changed files with 15 additions and 9 deletions
|
@ -18,20 +18,26 @@ limitations under the License.
|
||||||
import {EventKey} from "../EventKey.js";
|
import {EventKey} from "../EventKey.js";
|
||||||
export const PENDING_FRAGMENT_ID = Number.MAX_SAFE_INTEGER;
|
export const PENDING_FRAGMENT_ID = Number.MAX_SAFE_INTEGER;
|
||||||
|
|
||||||
|
interface FragmentIdComparer {
|
||||||
|
compare: (a: number, b: number) => number
|
||||||
|
}
|
||||||
|
|
||||||
export class BaseEntry {
|
export class BaseEntry {
|
||||||
constructor(fragmentIdComparer) {
|
protected _fragmentIdComparer: FragmentIdComparer
|
||||||
|
|
||||||
|
constructor(fragmentIdComparer: FragmentIdComparer) {
|
||||||
this._fragmentIdComparer = fragmentIdComparer;
|
this._fragmentIdComparer = fragmentIdComparer;
|
||||||
}
|
}
|
||||||
|
|
||||||
get fragmentId() {
|
get fragmentId(): number {
|
||||||
throw new Error("unimplemented");
|
throw new Error("unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
get entryIndex() {
|
get entryIndex(): number {
|
||||||
throw new Error("unimplemented");
|
throw new Error("unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
compare(otherEntry) {
|
compare(otherEntry: BaseEntry): number {
|
||||||
if (this.fragmentId === otherEntry.fragmentId) {
|
if (this.fragmentId === otherEntry.fragmentId) {
|
||||||
return this.entryIndex - otherEntry.entryIndex;
|
return this.entryIndex - otherEntry.entryIndex;
|
||||||
} else if (this.fragmentId === PENDING_FRAGMENT_ID) {
|
} else if (this.fragmentId === PENDING_FRAGMENT_ID) {
|
||||||
|
@ -44,9 +50,9 @@ export class BaseEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
asEventKey() {
|
asEventKey(): EventKey {
|
||||||
return new EventKey(this.fragmentId, this.entryIndex);
|
return new EventKey(this.fragmentId, this.entryIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFrom() {}
|
updateFrom(other: BaseEntry) {}
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {BaseEntry} from "./BaseEntry.js";
|
import {BaseEntry} from "./BaseEntry";
|
||||||
import {REDACTION_TYPE} from "../../common.js";
|
import {REDACTION_TYPE} from "../../common.js";
|
||||||
import {createAnnotation, ANNOTATION_RELATION_TYPE, getRelationFromContent} from "../relations.js";
|
import {createAnnotation, ANNOTATION_RELATION_TYPE, getRelationFromContent} from "../relations.js";
|
||||||
import {PendingAnnotation} from "../PendingAnnotation.js";
|
import {PendingAnnotation} from "../PendingAnnotation.js";
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {BaseEntry} from "./BaseEntry.js";
|
import {BaseEntry} from "./BaseEntry";
|
||||||
import {Direction} from "../Direction.js";
|
import {Direction} from "../Direction.js";
|
||||||
import {isValidFragmentId} from "../common.js";
|
import {isValidFragmentId} from "../common.js";
|
||||||
import {KeyLimits} from "../../../storage/common.js";
|
import {KeyLimits} from "../../../storage/common.js";
|
||||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {PENDING_FRAGMENT_ID} from "./BaseEntry.js";
|
import {PENDING_FRAGMENT_ID} from "./BaseEntry";
|
||||||
import {BaseEventEntry} from "./BaseEventEntry.js";
|
import {BaseEventEntry} from "./BaseEventEntry.js";
|
||||||
|
|
||||||
export class PendingEventEntry extends BaseEventEntry {
|
export class PendingEventEntry extends BaseEventEntry {
|
||||||
|
|
Loading…
Reference in a new issue