function extractVariablesFromFunction(fn) {
  // TODO: Make it also detect bracket notation

  const string = fn.toString()
  const pattern = /(?:[^\w_$.]|^)([a-zA-Z_$][\w_$]*)\.([\w_$.]+)/g
  const list = {}

  let matches

  while ((matches = pattern.exec(string)) !== null) {
    const base = matches[1] // base in base.pa.th
    const path = matches[2] // pa.th in base.pa.th

    if (!(base in list))
      list[base] = {}

    if (!(path in list[base]))
      list[base][path] = []

    if (!list[base][path].includes(fn))
      list[base][path].push(fn)
  }

  return list
}
/**
 * Turns the input function to a string and extracts what looks like this: stateName.varName1
 * @param {*} fn
 */
Turns the input function to a string and extracts what looks like this: stateName.varName1
@param {*} fn
Turns the input function to a string and extracts what looks like this : stateName . varName1 @param { * } fn
function extractVariablesFromFunction(fn) {
  const string = fn.toString()
  const pattern = /(?:[^\w_$.]|^)([a-zA-Z_$][\w_$]*)\.([\w_$.]+)/g
  const list = {}
  let matches
  while ((matches = pattern.exec(string)) !== null) {
    const base = matches[1] 
    const path = matches[2] 
    if (!(base in list))
      list[base] = {}
    if (!(path in list[base]))
      list[base][path] = []
    if (!list[base][path].includes(fn))
      list[base][path].push(fn)
  }
  return list
}
function extractVariablesFromFunction ( fn ) { const string = fn . toString ( ) const pattern = / (?:[^\w_$.]|^)([a-zA-Z_$][\w_$]*)\.([\w_$.]+) / g const list = { } let matches while ( ( matches = pattern . exec ( string ) ) !== null ) { const base = matches [ 1 ] const path = matches [ 2 ] if ( ! ( base in list ) ) list [ base ] = { } if ( ! ( path in list [ base ] ) ) list [ base ] [ path ] = [ ] if ( ! list [ base ] [ path ] . includes ( fn ) ) list [ base ] [ path ] . push ( fn ) } return list }
Turns the input function to a string and extracts what looks like this: stateName.varName1
 @param {*} fn
Turns the input function to a string and extracts what looks like this : stateName . varName1 @param { * } fn
// TODO: Make it also detect bracket notation // base in base.pa.th // pa.th in base.pa.th