Skip to content

Commit 9918e5b

Browse files
committed
Use nullish coalescing operator where applicable
1 parent fb20ad1 commit 9918e5b

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

src/core/Value.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ export abstract class Value<D = unknown, S = D> extends Serializable {
1212
}
1313

1414
protected extractValueFromJSONPayload(payload: unknown) {
15-
const value = getValueFromObject(payload);
16-
return value !== undefined ? value : payload;
15+
return getValueFromObject(payload) ?? payload;
1716
}
1817

1918
protected getValueForEncoding() {

src/values/DoubleValue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ export class DoubleValue extends FloatValue {
1717
}
1818

1919
public toString() {
20-
return (this._value !== undefined ? this._value : NaN).toPrecision(15);
20+
return (this._value ?? NaN).toPrecision(15);
2121
}
2222
}

src/values/FloatValue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class FloatValue extends Value<number> {
3535
}
3636

3737
public toString() {
38-
return (this._value !== undefined ? this._value : NaN).toPrecision(7);
38+
return (this._value ?? NaN).toPrecision(7);
3939
}
4040

4141
public valueOf() {

src/values/IntegerValue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ export class IntegerValue extends Value<number> {
3535
}
3636

3737
public valueOf() {
38-
return this._value !== undefined ? this._value : null;
38+
return this._value ?? null;
3939
}
4040
}

0 commit comments

Comments
 (0)