function-names-at-line
I was working on this run test by line number feature for teenytest, and needed a way to tell what functions might be described by a given line number.
For example, say you have this file:
// 1var { // 2var baz = 'lol' // 3{} // 4} // 5// 6
And read the file into a string named someSource
, then you can:
var functionNamesAtLine =// []// ['foo']// ['foo']// ['bar', 'foo']// ['foo']// []
This is a pretty naive implementation, focused just on getting basic (not nested) names of functions.