private structure for SS 2.1

example of a private class strcuture for suitescript 2.1

by Gerald Gillespie

HTML

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.14/require.js"></script>
  <title>JS Bin</title>
</head>
<body>


</body>
</html>

JavaScript

/**
 * @NApiVersion 2.1
 */
define('PRIVATE_ES6', function() {
  //https://5490577-sb2.app.netsuite.com/core/media/media.nl?id=48395&c=5490577_SB2&h=jY01tqIvVfQjWniSY2nY4zx7TM2HSgiqszg1D5lQ58ep7jOW&_xt=.js

  const NCO = {};
  NCO.shared = {};

  /**
   *
   */
  class PRIVATE_ES6 {

    /**
     *
     * @param input
     */
    constructor({
      //done
      shared, //shared publically and set publically and apply to all instances  e.g. shared information b/t them
      pub, //readily listed and readily set properties for this object
      publicreadonly, //readily listed but cannot set them i.e. protected
      priv, //outside cannot examine these NOR set them 
      hidden,
      privatereadonly,
      //todo:
      sharedstatic, //shared publically and apply to all instances but readonly -- set by class developer
      sharedprivate, //outside cannot see them nor set them and they apply to all instances e.g. a config to change for all

      constructoronly
    }) {
      //private to the instance
      const secret = Symbol('private');

      this.publicProp = 'publicProp';

      const _ = NCO._defineProperties(this, secret, {
        pub,
        shared,
        publicreadonly,
        hidden,
        priv,
        privatereadonly
      });

      this.getProxy = (...args)=>{
        return this[_.get](...args); 
      }
      
      this.setProxy = (...args)=>{
        return this[_.set](...args);
      }
    } //constructor

    //DO NOT ASSIGN PUBLIC NOR PRIVATE METHODS HERE UNLESS THEY DO NOT NEED ACCESS TO OTHER PRIVATE METHODS
    //ANY METHODS DECLARED HERE WILL BE OVERWRITTEN IF THEY ALSO EXIST IN THE PUBLIC /PRIVATE DEFINITION
    getPublic() {
      return 'this will get overwritten 😔';
    }   

    //ASSIGN STATIC METHODS HERE
    static Alive() {
      return 'alive';
    }
  } //class

  //get a this reference to the global registry (for sharing and / or obfuscating sharing )
  PRIVATE_ES6.prototype.global = NCO.shared

  //ASSIGN...