Skip to content

Commit 6044323

Browse files
author
alexperez
committed
fix: simplify null and undefined checks for raw variable in ExampleGenerator
1 parent 33b07ef commit 6044323

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/ExampleGenerator.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,9 @@ export class ExampleGenerator extends AmfHelperMixin(Object) {
641641
example,
642642
this.ns.aml.vocabularies.document.raw
643643
));
644-
if (raw === null || raw === undefined) {
644+
const rawIsNull = raw === null;
645+
const rawIsUndefined = raw === undefined;
646+
if (rawIsNull || rawIsUndefined) {
645647
raw = /** @type {string} */ (this._getValue(
646648
example,
647649
this.ns.w3.shacl.raw
@@ -707,7 +709,7 @@ export class ExampleGenerator extends AmfHelperMixin(Object) {
707709
example,
708710
this.ns.aml.vocabularies.core.description
709711
));
710-
const hasRaw = raw !== null && raw !== undefined;
712+
const hasRaw = !rawIsNull && !rawIsUndefined;
711713
const result = {};
712714
result.hasTitle = !!title;
713715
result.hasUnion = false;
@@ -717,7 +719,7 @@ export class ExampleGenerator extends AmfHelperMixin(Object) {
717719
if (result.hasTitle) {
718720
result.title = title;
719721
}
720-
if (opts.rawOnly && (raw === null || raw === undefined)) {
722+
if (opts.rawOnly && (rawIsNull || rawIsUndefined)) {
721723
return undefined;
722724
}
723725
if (opts.rawOnly) {

0 commit comments

Comments
 (0)