Actually, you suggested 4.0.
https://community.openhab.org/t/js-scripting-error-undefined-has-no-such-function-persist/155826/16
You can try to upgrade to 4.0 and see if that works, then try to move up to 4.1 and so on until it breaks. But keep in mind that almost every release in those earlier versions had breaking changes which means you have to make changes to your code to keep them working.