MV Preventing discarding of regular items in Theo - Limited Inventory (for MV)

Theo's - Limited Inventory is a wonderful plugin, however it's possible for the player to discard regular items / weapons / armor and I'm looking for a way to prevent that. The plugin does prevent discarding key items (which is great) and the plugin's author did originally solve the issue in their original version of the plugin they made for RPG Maker VX by adding the following Ruby script to the end of the plugin:

Code:
class Window_ItemUseCommand
  def discardable?(item)
    return false if item.nil? || !item.note[/<undiscardable>/].nil?
    !(item.is_a?(RPG::Item) && item.itype_id == 2)
  end
end


Their code suggests that adding <undiscardable> in the item / weapon / armor notetag will cause the item / weapon / armor to not be able to discarded. This seems like a fantastic and elegant solution, but I don't know if it's possible to translate Ruby into JS.

Would anyone know how to translate this code into JS so that it could perhaps work in the MV version of this plugin (if that's even possible or feasible)?

Thanks for the help, and have a great day!

Original thread: https://forums.rpgmakerweb.com/threads/preventing-discarding-of-regular-items-in-theo-limited-inventory-for-mv.156922/