Coding for older versions of postman

Hi the new pm command doesn’t exist in older versions of Postman. I was thinking of creating functions of the same name for older versions of postman.

First up, how can I detect the version of postman running from the scripting.
Secondly what are the alternatives to the following pm commands for postman v7.

pm.environment.set|get
pm.variables.set|get
pm info.requestName
pm.response.to.be.ok|found|unauthorized
pm.response.status
pm.response.json()
pm.cookies.has|get(“name”)
pm.response.headers.has|get(“name”)
postman.setNextRequest(null)

Many thanks!