Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed Sep 22, 2023
1 parent aff707b commit bf7efca
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 58 deletions.
48 changes: 19 additions & 29 deletions src/value/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,7 @@ import {ValueInteger} from './integer';
import {ValueReal} from './real';
import {ValueString} from './string';

let getChildTagNamesCache: Map<string, new () => Value> | null = null;

/**
* Get child tag names.
*
* @returns The map.
*/
const getChildTagNames = () => {
if (!getChildTagNamesCache) {
getChildTagNamesCache = new Map();
for (const Value of [
// eslint-disable-next-line @typescript-eslint/no-use-before-define
ValueArray,
ValueBoolean,
ValueData,
ValueDate,
ValueDict,
ValueInteger,
ValueReal,
ValueString
]) {
for (const t of Value.TAG_NAMES) {
getChildTagNamesCache.set(t, Value);
}
}
}
return getChildTagNamesCache;
};
let childTagNames: Map<string, new () => Value>;

/**
* ValueArray object.
Expand All @@ -59,7 +32,24 @@ export class ValueArray extends Value {
* @returns Child tag names map.
*/
public static get CHILD_TAG_NAMES() {
return getChildTagNames();
if (!childTagNames) {
childTagNames = new Map();
for (const Value of [
ValueArray,
ValueBoolean,
ValueData,
ValueDate,
ValueDict,
ValueInteger,
ValueReal,
ValueString
]) {
for (const t of Value.TAG_NAMES) {
childTagNames.set(t, Value);
}
}
}
return childTagNames;
}

/**
Expand Down
48 changes: 19 additions & 29 deletions src/value/dict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,7 @@ import {ValueInteger} from './integer';
import {ValueReal} from './real';
import {ValueString} from './string';

let getChildTagNamesCache: Map<string, new () => Value> | null = null;

/**
* Get child tag names.
*
* @returns The map.
*/
const getChildTagNames = () => {
if (!getChildTagNamesCache) {
getChildTagNamesCache = new Map();
for (const Value of [
ValueArray,
ValueBoolean,
ValueData,
ValueDate,
// eslint-disable-next-line @typescript-eslint/no-use-before-define
ValueDict,
ValueInteger,
ValueReal,
ValueString
]) {
for (const t of Value.TAG_NAMES) {
getChildTagNamesCache.set(t, Value);
}
}
}
return getChildTagNamesCache;
};
let childTagNames: Map<string, new () => Value>;

/**
* ValueDict object.
Expand All @@ -59,7 +32,24 @@ export class ValueDict extends Value {
* @returns Child tag names map.
*/
public static get CHILD_TAG_NAMES() {
return getChildTagNames();
if (!childTagNames) {
childTagNames = new Map();
for (const Value of [
ValueArray,
ValueBoolean,
ValueData,
ValueDate,
ValueDict,
ValueInteger,
ValueReal,
ValueString
]) {
for (const t of Value.TAG_NAMES) {
childTagNames.set(t, Value);
}
}
}
return childTagNames;
}

/**
Expand Down

0 comments on commit bf7efca

Please sign in to comment.