sucrase
Version:
Super-fast alternative to Babel for when you can target modern JS runtimes
11 lines (10 loc) • 401 B
JavaScript
/**
* For an import or export statement, check if this might be actually a property
* name like in `{import: 1}`. If not, then we can trust that it's a real import
* or export.
*/
export default function isMaybePropertyName(tokens, index) {
return tokens.matchesAtIndex(index - 1, ['.']) ||
tokens.matchesAtIndex(index + 1, [':']) ||
tokens.matchesAtIndex(index + 1, ['(']);
}