Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3010980
config-manager.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
955 B
Referenced Files
None
Subscribers
None
config-manager.js
View Options
const
dotProp
=
require
(
"dot-prop"
);
const
merge
=
require
(
"merge"
);
module
.
exports
=
class
ConfigManager
{
constructor
()
{
this
.
DEFAULT_CONFIG
=
{};
this
.
CUSTOM_CONFIG
=
{};
this
.
isLocked
=
false
;
}
setDefault
(
key
,
value
)
{
this
.
_setGivenConfig
(
this
.
DEFAULT_CONFIG
,
key
,
value
);
}
getDefaultConfig
(
key
)
{
return
dotProp
.
get
(
this
.
DEFAULT_CONFIG
,
key
);
}
set
(
key
,
value
)
{
this
.
_setGivenConfig
(
this
.
CUSTOM_CONFIG
,
key
,
value
);
}
_setGivenConfig
(
config
,
key
,
value
)
{
this
.
_warnIfLocked
();
dotProp
.
set
(
config
,
key
,
value
);
}
_warnIfLocked
()
{
if
(
this
.
isLocked
)
{
console
.
warn
(
"Warning: "
+
"you shouldn't change config after ConfigManager was locked"
);
}
}
setRoot
(
params
)
{
this
.
_warnIfLocked
();
merge
.
recursive
(
this
.
CUSTOM_CONFIG
,
params
);
}
get
(
key
)
{
return
dotProp
.
get
(
merge
.
recursive
(
true
,
this
.
DEFAULT_CONFIG
,
this
.
CUSTOM_CONFIG
),
key
);
}
lock
()
{
this
.
isLocked
=
true
;
}
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, May 7, 19:50 (3 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
626116
Default Alt Text
config-manager.js (955 B)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline
Log In to Comment