Optimize script in mv?

Hi all, I'm trying to get a script to optimize the equipment for my party member. In Ace the script

$game_actors[1].optimize_equipments 

did it for me, anyone know what the new script in mv is? Any help would be greatly appreciated, thanks!
It's defined on rpg_objects.js:

Game_Actor.prototype.optimizeEquipments = function() {    var maxSlots = this.equipSlots().length;    this.clearEquipments();    for (var i = 0; i < maxSlots; i++) {        if (this.isEquipChangeOk(i)) {            this.changeEquip(i, this.bestEquipItem(i));        }    }};
Game_Actors are created and populated in the $gameActors variable on rpg_managers.js
so something like ?

$gameActors.actor(1).optimizeEquipments
$gameActors.actor(1).optimizeEquipments();

Original thread: https://forums.rpgmakerweb.com/threads/optimize-script-in-mv.47759/