###Solution 1
Solution 1
###Solution 2
Solution 2
###Solution 3
Solution 3
###Solution 1
###Solution 2
###Solution 3
Solution 1
Solution 2
Solution 3
function resolveGitConflict(lines, mode) {
return lines.reduce((p, c) => {
let last = p[p.length-1]
if(typeof last === 'object' ) {
if(c === '>>>>>>>') last = [].concat(last[mode[0]] || [], last[mode[1]] || [])
else if(c === '=======') last.t = []
else last[last.t ? 't' : 'm'].push(c)
return p.slice(0, -1).concat(last)
} else if(c === '<<<<<<<') c = {m: []}
return p.concat(c)
}, [])
}
function resolveGitConflict(lines, mode) {
return lines.reduce((p, c) => {
let last = p[p.length-1]
if(typeof last === 'object' ) {
if(c === '>>>>>>>') last = [].concat(last[mode[0]] || [], last[mode[1]] || [])
else if(c === '=======') last.t = []
else last[last.t ? 't' : 'm'].push(c)
return p.slice(0, -1).concat(last)
} else if(c === '<<<<<<<') c = {m: []}
return p.concat(c)
}, [])
}
function resolveGitConflict(lines, mode) {
return lines.reduce((p, c) => {
let last = p[p.length-1]
if(typeof last === 'object' ) {
if(c === '>>>>>>>') last = [].concat(last[mode[0]] || [], last[mode[1]] || [])
else if(c === '=======') last.t = []
else last[last.t ? 't' : 'm'].push(c)
return p.slice(0, -1).concat(last)
} else if(c === '<<<<<<<') c = {m: []}
return p.concat(c)
}, [])
}
Loading
Loading
lang-js