Reformated/commented for clarity

This commit is contained in:
airjp73 2018-02-06 11:21:33 -05:00
parent 6dce24cc53
commit ce342d528a

View File

@ -42,29 +42,32 @@ if (typeof storeData !== 'function') {
continue
}
//if file is user/index.js
//it should save as user
var isIndex = (name === 'index')
//if file is foo/index.js
//it should save as foo
let isIndex = (name === 'index')
if (isIndex)
namePath.pop()
let module = getModuleNamespace(storeData, namePath)
let module = getModuleNamespace(storeData, namePath)
let fileModule = getModule(filename)
name = namePath.pop()
module[name] = module[name] || {}
var fileModule = getModule(filename)
//if file is foo.js, existing properties take priority
//because it's the least specific case
if (!isIndex) {
module[name] = Object.assign({}, fileModule, module[name])
module[name].namespaced = true
continue
}
//if file is foo/index.js we want to overwrite properties from foo.js
//but not from appended mods like foo/actions.js
var appendedMods = []
if (module[name].appends) {
fileModule.appends = module[name].appends
for (let append of module[name].appends) {
for (let append of module[name].appends)
appendedMods[append] = module[name][append]
}
}
module[name] = Object.assign(module[name], fileModule, appendedMods)
}