refactor(globaltocjs): use one condition check for equivalent branches