packages/extension-map/lib/regex_extension.js
/**
 * Given a variable name, looks up its prefix, and  replacing the shorthand
 * prefix name in the variable with l name.
 *
 * @param shortPrefixedVar a short prefixed variable name to expand e.g., dem:id
 * @param prefixes a list of the prefix short name/full name mappings
 *
 * @return the fully expanded name
 */
Given a variable name, looks up its prefix, and  replacing the shorthand
prefix name in the variable with l name.

@param shortPrefixedVar a short prefixed variable name to expand e.g., dem:id
@param prefixes a list of the prefix short name/full name mappings

@return the fully expanded name
Given a variable name looks up its prefix and replacing the shorthand prefix name in the variable with l name . @param shortPrefixedVar a short prefixed variable name to expand e . g . dem : id @param prefixes a list of the prefix short name / full name mappings @return the fully expanded name
function applyPrefix(varName, prefixes) {
  const matches = varName.match(/^ *(?:<([^>]*)>|([^:]*):([^ ]*)) *$/);
  if (matches === null)
    throw Error("variable \"" + varName + "\" did not match expected pattern!");
  let expandedVarName;
  if (matches[1]) {
    expandedVarName = matches[1];
  } else if (matches[2] in prefixes) {
    expandedVarName = prefixes[matches[2]] + matches[3];
  } else
    throw Error("Unknown prefix " + matches[2] + " in \"" + varName + "\"!");
  return expandedVarName;
}
function applyPrefix ( varName , prefixes ) { const matches = varName . match ( / ^ *(?:<([^>]*)>|([^:]*):([^ ]*)) *$ / ) ; if ( matches === null ) throw Error ( "variable \"" + varName + "\" did not match expected pattern!" ) ; let expandedVarName ; if ( matches [ 1 ] ) { expandedVarName = matches [ 1 ] ; } else if ( matches [ 2 ] in prefixes ) { expandedVarName = prefixes [ matches [ 2 ] ] + matches [ 3 ] ; } else throw Error ( "Unknown prefix " + matches [ 2 ] + " in \"" + varName + "\"!" ) ; return expandedVarName ; }
Given a variable name, looks up its prefix, and  replacing the shorthand
 prefix name in the variable with l name.
Given a variable name looks up its prefix and replacing the shorthand prefix name in the variable with l name .
// Figure out what variable syntax we have.  It could be <varname> or <prefix:varname> // Got <varname> // prefixed const e.g., dem:id // unknown prefix