Best way to re-use javascript methods, error messages across Postman?

Best way to re-use javascript methods, error messages across Postman?

I have several functions that I’d like to replicate across different use cases in various requests and folders within the same collection (I’m using it as a template mostly, so it’ll be pulling in variables externally)

There are many different suggestions in the Postman documentation but what’s the best way to re-use code for such a use case?