Skip to content

Commit 0d1fb0d

Browse files
committed
appease linter
1 parent 4fb9cc0 commit 0d1fb0d

File tree

2 files changed

+37
-35
lines changed

2 files changed

+37
-35
lines changed

packages/candid/src/idl.ts

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -915,50 +915,51 @@ export class OptClass<T> extends ConstructType<[T] | []> {
915915

916916
public decodeValue(b: Pipe, t: Type): [T] | [] {
917917
if (t instanceof NullClass) {
918-
return [];
919-
};
918+
return []
919+
}
920920
if (t instanceof ReservedClass) {
921-
return [];
922-
};
921+
return []
922+
}
923923
const wireType = this.checkType(t);
924924
if (wireType instanceof OptClass) {
925925
switch (safeReadUint8(b)) {
926-
case 0:
927-
return [];
928-
case 1:
929-
let checkpoint = b.save();
930-
try {
931-
let v = this._type.decodeValue(b, wireType._type)
932-
return [v];
933-
} catch (e : any) {
934-
b.restore(checkpoint);
935-
// skip value at wire type (to advance b)
936-
let skipped = wireType._type.decodeValue(b, wireType._type)
937-
// retun none
938-
return [];
939-
};
940-
default:
941-
throw new Error('Not an option value');
926+
case 0:
927+
return [];
928+
case 1: {
929+
const checkpoint = b.save();
930+
try {
931+
const v = this._type.decodeValue(b, wireType._type);
932+
return [v];
933+
} catch (e : any) {
934+
b.restore(checkpoint);
935+
// skip value at wire type (to advance b)
936+
const skipped = wireType._type.decodeValue(b, wireType._type);
937+
// retun none
938+
return [];
939+
}
940+
}
941+
default:
942+
throw new Error('Not an option value');
942943
}
943944
} else if (this._type instanceof NullClass || this._type instanceof OptClass || this._type instanceof ReservedClass) {
944945
// this check corresponds to `not (null <: <t>)` in the spec
945946
// skip value at wire type (to advance b) and return "null", i.e. []
946-
let skipped = wireType.decodeValue(b, wireType);
947+
const skipped = wireType.decodeValue(b, wireType);
947948
return [];
948949
} else {
949950
// try constituent type
950-
let checkpoint = b.save();
951+
const checkpoint = b.save();
951952
try {
952-
let v = this._type.decodeValue(b, wireType)
953-
return [v];
953+
const v = this._type.decodeValue(b, wireType)
954+
return [v];
954955
} catch (e : any) {
955-
// decoding failed, but this is opt, so return "null", i.e. []
956-
b.restore(checkpoint);
957-
// skip value at wire type (to advance b)
958-
let skipped = wireType.decodeValue(b, wireType)
959-
// return "null"
960-
return [];
961-
};
956+
// decoding failed, but this is opt, so return "null", i.e. []
957+
b.restore(checkpoint);
958+
// skip value at wire type (to advance b)
959+
const skipped = wireType.decodeValue(b, wireType)
960+
// return "null"
961+
return [];
962+
}
962963
}
963964
}
964965

packages/candid/src/utils/buffer.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ export class PipeArrayBuffer {
4242
* Save a checkpoint of the reading view (for backtracking)
4343
*/
4444
public save() : Uint8Array {
45-
return this._view;
46-
};
45+
return this._view
46+
}
4747

4848
/**
4949
* Restore a checkpoint of the reading view (for backtracking)
50+
* @param checkPoint a previously saved checkpoint
5051
*/
5152
public restore(checkPoint: Uint8Array) {
52-
this._view = checkPoint;
53-
};
53+
this._view = checkPoint
54+
}
5455

5556
/**
5657
* The actual buffer containing the bytes.

0 commit comments

Comments
 (0)