Skip to content
Snippets Groups Projects
Commit 70ad18c9 authored by Jimmy's avatar Jimmy
Browse files

Style cleanup of constants loader

parent 5c6e7416
No related branches found
No related tags found
No related merge requests found
// eslint-disable-next-line no-var, no-unused-vars
var ConstantsLoader = (() => { var ConstantsLoader = (() => {
const allowedTypes = ['boolean', 'bigint', 'number', 'string']; const allowedTypes = ["boolean", "bigint", "number", "string"];
function init(data) { function init(data) {
/* Use a modified cloning function to protect data. */ /* Use a modified cloning function to protect data. */
...@@ -9,20 +10,21 @@ var ConstantsLoader = (() => { ...@@ -9,20 +10,21 @@ var ConstantsLoader = (() => {
function clone(obj) { function clone(obj) {
const fragment = Object.create({}); const fragment = Object.create({});
Object.entries(obj).forEach(([key, value]) => { Object.entries(obj).forEach(([key, value]) => {
if (typeof value === 'object') { if (typeof value === "object") {
/* Sub object within object. */ /* Sub object within object. */
Object.defineProperty(fragment, key, { Object.defineProperty(fragment, key, {
value: clone(value), value: clone(value),
writable: false, writable: false,
configurable: false configurable: false,
}); });
} else if (allowedTypes.includes(typeof value)) { } else if (allowedTypes.includes(typeof value)) {
/* A value type, ready for getter conversion. */ /* A value type, ready for getter conversion. */
Object.defineProperty(fragment, key, { Object.defineProperty(fragment, key, {
get: function() { get() {
return value; return value;
}, },
configurable: false writable: false,
configurable: false,
}); });
} }
}); });
...@@ -30,6 +32,7 @@ var ConstantsLoader = (() => { ...@@ -30,6 +32,7 @@ var ConstantsLoader = (() => {
} }
return Object.seal({ return Object.seal({
init init,
clone,
}); });
})(); })();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment