Skip to content

Commit

Permalink
Replace const name to PascalCase
Browse files Browse the repository at this point in the history
  • Loading branch information
gwbaik9717 committed Jul 28, 2024
1 parent 35be776 commit 30330bb
Show file tree
Hide file tree
Showing 19 changed files with 141 additions and 141 deletions.
12 changes: 6 additions & 6 deletions src/document/crdt/element_rht.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ export class ElementRHT {
*/
public delete(createdAt: TimeTicket, executedAt: TimeTicket): CRDTElement {
if (!this.nodeMapByCreatedAt.has(createdAt.toIDString())) {
const ERROR_MESSAGE = `fail to find ${createdAt.toIDString()}`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `fail to find ${createdAt.toIDString()}`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}

const node = this.nodeMapByCreatedAt.get(createdAt.toIDString())!;
Expand Down Expand Up @@ -145,11 +145,11 @@ export class ElementRHT {
element.getCreatedAt().toIDString(),
);
if (!node) {
const ERROR_MESSAGE = `fail to find ${element
const ErrorMessage = `fail to find ${element
.getCreatedAt()
.toIDString()}`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}

const nodeByKey = this.nodeMapByKey.get(node.getStrKey());
Expand Down
24 changes: 12 additions & 12 deletions src/document/crdt/rga_tree_list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ export class RGATreeList {
): RGATreeListNode {
let node = this.nodeMapByCreatedAt.get(createdAt.toIDString());
if (!node) {
const ERROR_MESSAGE = `cant find the given node: ${createdAt.toIDString()}`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `cant find the given node: ${createdAt.toIDString()}`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}

while (
Expand Down Expand Up @@ -235,16 +235,16 @@ export class RGATreeList {
): void {
const prevNode = this.nodeMapByCreatedAt.get(prevCreatedAt.toIDString());
if (!prevNode) {
const ERROR_MESSAGE = `cant find the given node: ${prevCreatedAt.toIDString()}`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `cant find the given node: ${prevCreatedAt.toIDString()}`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}

const node = this.nodeMapByCreatedAt.get(createdAt.toIDString());
if (!node) {
const ERROR_MESSAGE = `cant find the given node: ${createdAt.toIDString()}`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `cant find the given node: ${createdAt.toIDString()}`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}

if (
Expand Down Expand Up @@ -291,11 +291,11 @@ export class RGATreeList {
element.getCreatedAt().toIDString(),
);
if (!node) {
const ERROR_MESSAGE = `fail to find the given createdAt: ${element
const ErrorMessage = `fail to find the given createdAt: ${element
.getCreatedAt()
.toIDString()}`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}
this.release(node!);
}
Expand Down
18 changes: 9 additions & 9 deletions src/document/crdt/rga_tree_split.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,9 @@ export class RGATreeSplit<T extends RGATreeSplitValue> implements GCParent {
? this.findFloorNodePreferToLeft(absoluteID)
: this.findFloorNode(absoluteID);
if (!node) {
const ERROR_MESSAGE = `the node of the given id should be found: ${absoluteID.toTestString()}`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `the node of the given id should be found: ${absoluteID.toTestString()}`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}
const index = this.treeByIndex.indexOf(node!);
const offset = node!.isRemoved()
Expand Down Expand Up @@ -794,9 +794,9 @@ export class RGATreeSplit<T extends RGATreeSplitValue> implements GCParent {
): RGATreeSplitNode<T> {
let node = this.findFloorNode(id);
if (!node) {
const ERROR_MESSAGE = `the node of the given id should be found: ${id.toTestString()}`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `the node of the given id should be found: ${id.toTestString()}`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}

if (id.getOffset() > 0 && node!.getID().getOffset() == id.getOffset()) {
Expand Down Expand Up @@ -848,9 +848,9 @@ export class RGATreeSplit<T extends RGATreeSplitValue> implements GCParent {
offset: number,
): RGATreeSplitNode<T> | undefined {
if (offset > node.getContentLength()) {
const ERROR_MESSAGE = `offset should be less than or equal to length`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `offset should be less than or equal to length`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}

if (offset === 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/document/crdt/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ export class CRDTRoot {
const createdAt = pair.element.getCreatedAt();
const subPath = pair.parent.subPathOf(createdAt);
if (subPath === undefined) {
const ERROR_MESSAGE = `cant find the given element: ${createdAt.toIDString()}`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `cant find the given element: ${createdAt.toIDString()}`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}

subPaths.unshift(subPath!);
Expand Down
6 changes: 3 additions & 3 deletions src/document/json/counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ export class Counter {
*/
public increase(v: number | Long): Counter {
if (!this.context || !this.counter) {
const ERROR_MESSAGE = 'Counter is not initialized yet';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE);
const ErrorMessage = 'Counter is not initialized yet';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage);
}

const ticket = this.context.issueTimeTicket();
Expand Down
60 changes: 30 additions & 30 deletions src/document/json/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ export class Text<A extends Indexable = Indexable> {
attributes?: A,
): [number, number] | undefined {
if (!this.context || !this.text) {
const ERROR_MESSAGE = 'Text is not initialized yet';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE);
const ErrorMessage = 'Text is not initialized yet';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage);
}

if (fromIdx > toIdx) {
const ERROR_MESSAGE = 'from should be less than or equal to to';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = 'from should be less than or equal to to';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}

const range = this.text.indexRangeToPosRange(fromIdx, toIdx);
Expand Down Expand Up @@ -157,15 +157,15 @@ export class Text<A extends Indexable = Indexable> {
*/
setStyle(fromIdx: number, toIdx: number, attributes: A): boolean {
if (!this.context || !this.text) {
const ERROR_MESSAGE = 'Text is not initialized yet';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE);
const ErrorMessage = 'Text is not initialized yet';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage);
}

if (fromIdx > toIdx) {
const ERROR_MESSAGE = 'from should be less than or equal to to';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = 'from should be less than or equal to to';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}

const range = this.text.indexRangeToPosRange(fromIdx, toIdx);
Expand Down Expand Up @@ -208,9 +208,9 @@ export class Text<A extends Indexable = Indexable> {
*/
indexRangeToPosRange(range: [number, number]): TextPosStructRange {
if (!this.context || !this.text) {
const ERROR_MESSAGE = 'Text is not initialized yet';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE);
const ErrorMessage = 'Text is not initialized yet';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage);
}

const textRange = this.text.indexRangeToPosRange(range[0], range[1]);
Expand All @@ -222,9 +222,9 @@ export class Text<A extends Indexable = Indexable> {
*/
posRangeToIndexRange(range: TextPosStructRange): [number, number] {
if (!this.context || !this.text) {
const ERROR_MESSAGE = 'Text is not initialized yet';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE);
const ErrorMessage = 'Text is not initialized yet';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage);
}

const textRange = this.text.findIndexesFromRange([
Expand All @@ -240,9 +240,9 @@ export class Text<A extends Indexable = Indexable> {
*/
toTestString(): string {
if (!this.context || !this.text) {
const ERROR_MESSAGE = 'Text is not initialized yet';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE);
const ErrorMessage = 'Text is not initialized yet';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage);
}

return this.text.toTestString();
Expand All @@ -253,9 +253,9 @@ export class Text<A extends Indexable = Indexable> {
*/
values(): Array<TextValueType<A>> {
if (!this.context || !this.text) {
const ERROR_MESSAGE = 'Text is not initialized yet';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE);
const ErrorMessage = 'Text is not initialized yet';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage);
}

return this.text.values();
Expand Down Expand Up @@ -290,9 +290,9 @@ export class Text<A extends Indexable = Indexable> {
*/
toString(): string {
if (!this.context || !this.text) {
const ERROR_MESSAGE = 'Text is not initialized yet';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE);
const ErrorMessage = 'Text is not initialized yet';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage);
}

return this.text.toString();
Expand Down Expand Up @@ -333,9 +333,9 @@ export class Text<A extends Indexable = Indexable> {
*/
createRangeForTest(fromIdx: number, toIdx: number): RGATreeSplitPosRange {
if (!this.context || !this.text) {
const ERROR_MESSAGE = 'Text is not initialized yet';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE);
const ErrorMessage = 'Text is not initialized yet';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage);
}

return this.text.indexRangeToPosRange(fromIdx, toIdx);
Expand Down
24 changes: 12 additions & 12 deletions src/document/json/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,9 @@ export class Tree {
range: [Array<number>, Array<number>],
): TreePosStructRange {
if (!this.context || !this.tree) {
const ERROR_MESSAGE = 'Tree is not initialized yet';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE);
const ErrorMessage = 'Tree is not initialized yet';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage);
}

const indexRange: [number, number] = [
Expand All @@ -757,9 +757,9 @@ export class Tree {
*/
indexRangeToPosRange(range: [number, number]): TreePosStructRange {
if (!this.context || !this.tree) {
const ERROR_MESSAGE = 'Tree is not initialized yet';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE);
const ErrorMessage = 'Tree is not initialized yet';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage);
}

return this.tree.indexRangeToPosStructRange(range);
Expand All @@ -770,9 +770,9 @@ export class Tree {
*/
posRangeToIndexRange(range: TreePosStructRange): [number, number] {
if (!this.context || !this.tree) {
const ERROR_MESSAGE = 'Tree is not initialized yet';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE);
const ErrorMessage = 'Tree is not initialized yet';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage);
}

const posRange: [CRDTTreePos, CRDTTreePos] = [
Expand All @@ -790,9 +790,9 @@ export class Tree {
range: TreePosStructRange,
): [Array<number>, Array<number>] {
if (!this.context || !this.tree) {
const ERROR_MESSAGE = 'Tree is not initialized yet';
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrOperationNotReady, ERROR_MESSAGE);
const ErrorMessage = 'Tree is not initialized yet';
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrOperationNotReady, ErrorMessage);
}

const posRange: [CRDTTreePos, CRDTTreePos] = [
Expand Down
12 changes: 6 additions & 6 deletions src/document/operation/add_operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ export class AddOperation extends Operation {
public execute(root: CRDTRoot): ExecutionResult {
const parentObject = root.findByCreatedAt(this.getParentCreatedAt());
if (!parentObject) {
const ERROR_MESSAGE = `fail to find ${this.getParentCreatedAt()}`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `fail to find ${this.getParentCreatedAt()}`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}
if (!(parentObject instanceof CRDTArray)) {
const ERROR_MESSAGE = `fail to execute, only array can execute add`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `fail to execute, only array can execute add`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}
const array = parentObject as CRDTArray;
const value = this.value.deepcopy();
Expand Down
12 changes: 6 additions & 6 deletions src/document/operation/edit_operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ export class EditOperation extends Operation {
public execute<A extends Indexable>(root: CRDTRoot): ExecutionResult {
const parentObject = root.findByCreatedAt(this.getParentCreatedAt());
if (!parentObject) {
const ERROR_MESSAGE = `fail to find ${this.getParentCreatedAt()}`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `fail to find ${this.getParentCreatedAt()}`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}
if (!(parentObject instanceof CRDTText)) {
const ERROR_MESSAGE = `fail to execute, only Text can execute edit`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `fail to execute, only Text can execute edit`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}

const text = parentObject as CRDTText<A>;
Expand Down
12 changes: 6 additions & 6 deletions src/document/operation/increase_operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ export class IncreaseOperation extends Operation {
public execute(root: CRDTRoot): ExecutionResult {
const parentObject = root.findByCreatedAt(this.getParentCreatedAt());
if (!parentObject) {
const ERROR_MESSAGE = `fail to find ${this.getParentCreatedAt()}`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `fail to find ${this.getParentCreatedAt()}`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}
if (!(parentObject instanceof CRDTCounter)) {
const ERROR_MESSAGE = `fail to execute, only Counter can execute increase`;
logger.fatal(ERROR_MESSAGE);
throw new YorkieError(Code.ErrInvalidArgument, ERROR_MESSAGE);
const ErrorMessage = `fail to execute, only Counter can execute increase`;
logger.fatal(ErrorMessage);
throw new YorkieError(Code.ErrInvalidArgument, ErrorMessage);
}
const counter = parentObject as CRDTCounter;
const value = this.value.deepcopy() as Primitive;
Expand Down
Loading

0 comments on commit 30330bb

Please sign in to comment.