// When a regex has the global flag set, test() will advance the lastIndex of the regex. export const extJsReg = /\.jsx?$/i export const extTsReg = /\.tsx?$/i export function isExtJs(filepath: string): boolean { return extJsReg.test(filepath) } export function isExtTs(filepath: string): boolean { return extTsReg.test(filepath) } export function extTsToJs(filepath: string): string { return filepath.replace(extTsReg, (match) => { return match === '.ts' ? '.js' : '.jsx' }) }