assertvanish
Version:
assert that an object will vanish
21 lines (17 loc) • 457 B
text/coffeescript
extractWayFromTree = (tree, line) ->
lines = tree.split '\n'
way = []
while line?
way.unshift lines[line]
line = getParentLine lines, line
way.join '\n'
getIndentation = (line) ->
line.match(/^ */)[0].length
getParentLine = (lines, line) ->
childIndentation = getIndentation lines[line]
while line > 0
line--
if childIndentation-2 is getIndentation lines[line]
return line
null
module.exports = {extractWayFromTree}