examples/undeployAndMaybeDelete.js
function revEnvReducer(org, name, revision) {
  return (p, env) =>
    p.then( () => org.proxies.undeploy({name, revision, environment: env.name}));
}
function revEnvReducer(org, name, revision) {
  return (p, env) =>
    p.then( () => org.proxies.undeploy({name, revision, environment: env.name}));
}
This script uses the Array.reduce() function extensively, to serially perform the asynchronous requests and responses for the various proxies, revisions, and environments. See https://decembersoft.com/posts/promises-in-serial-with-array-reduce/