1 Star 0 Fork 0

TERA Toolbox Mods/packets-logger

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
set_migrator.js 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
海比天蓝 提交于 2022-12-19 03:13 . Initial commit
const DefaultSettings = {
"logC": false,
"logS": false,
"logF": "Only",
"logJ": false,
"logR": false,
"logP": "String"
}
module.exports = function MigrateSettings(from_ver, to_ver, settings) {
if (from_ver === undefined) {
// Migrate legacy config file
return Object.assign(Object.assign({}, DefaultSettings), settings)
} else if (from_ver === null) {
// No config file exists, use default settings
return DefaultSettings
} else {
// Migrate from older version (using the new system) to latest one
if (from_ver + 1 < to_ver) { // Recursively upgrade in one-version steps
settings = MigrateSettings(from_ver, from_ver + 1, settings)
return MigrateSettings(from_ver + 1, to_ver, settings)
}
// If we reach this point it's guaranteed that from_ver === to_ver - 1, so we can implement
// a switch for each version step that upgrades to the next version. This enables us to
// upgrade from any version to the latest version without additional effort!
switch (to_ver) {
default:
let oldsettings = settings
settings = Object.assign(DefaultSettings, {})
for (let option in oldsettings) {
if (settings[option]) {
settings[option] = oldsettings[option]
}
}
break
}
return settings
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/tera-toolbox-mods/packets-logger.git
[email protected]:tera-toolbox-mods/packets-logger.git
tera-toolbox-mods
packets-logger
packets-logger
master

搜索帮助