A script check of how many troop enemies are present?

Is there a way to script check enemy troop amount? The only thing close I found is $gameTroop.members()
I need it for state, that does different things based on how many enemies are present
JavaScript:
$gameTroop.members().length; // get total amount of enemies, both dead and alive included
$gameTroop.aliveMembers().length; // get total amount of enemies, only alive ones.
Thanks <3

Original thread: https://forums.rpgmakerweb.com/threads/a-script-check-of-how-many-troop-enemies-are-present.165572/