Switch BaseEntry to TypeScript

This commit is contained in:
Danila Fedorin 2021-08-06 12:54:06 -07:00
parent b8c8325292
commit 3c5b186e31
4 changed files with 15 additions and 9 deletions

View File

@ -18,20 +18,26 @@ limitations under the License.
import {EventKey} from "../EventKey.js";
export const PENDING_FRAGMENT_ID = Number.MAX_SAFE_INTEGER;
interface FragmentIdComparer {
compare: (a: number, b: number) => number
}
export class BaseEntry {
constructor(fragmentIdComparer) {
protected _fragmentIdComparer: FragmentIdComparer
constructor(fragmentIdComparer: FragmentIdComparer) {
this._fragmentIdComparer = fragmentIdComparer;
}
get fragmentId() {
get fragmentId(): number {
throw new Error("unimplemented");
}
get entryIndex() {
get entryIndex(): number {
throw new Error("unimplemented");
}
compare(otherEntry) {
compare(otherEntry: BaseEntry): number {
if (this.fragmentId === otherEntry.fragmentId) {
return this.entryIndex - otherEntry.entryIndex;
} else if (this.fragmentId === PENDING_FRAGMENT_ID) {
@ -44,9 +50,9 @@ export class BaseEntry {
}
}
asEventKey() {
asEventKey(): EventKey {
return new EventKey(this.fragmentId, this.entryIndex);
}
updateFrom() {}
updateFrom(other: BaseEntry) {}
}

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {BaseEntry} from "./BaseEntry.js";
import {BaseEntry} from "./BaseEntry";
import {REDACTION_TYPE} from "../../common.js";
import {createAnnotation, ANNOTATION_RELATION_TYPE, getRelationFromContent} from "../relations.js";
import {PendingAnnotation} from "../PendingAnnotation.js";

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {BaseEntry} from "./BaseEntry.js";
import {BaseEntry} from "./BaseEntry";
import {Direction} from "../Direction.js";
import {isValidFragmentId} from "../common.js";
import {KeyLimits} from "../../../storage/common.js";

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {PENDING_FRAGMENT_ID} from "./BaseEntry.js";
import {PENDING_FRAGMENT_ID} from "./BaseEntry";
import {BaseEventEntry} from "./BaseEventEntry.js";
export class PendingEventEntry extends BaseEventEntry {