Object-Accessor
Initially this module was developed for designing SDKs in a similar way you would in OOP based languages and therefore make the SDK more maintainable. Using this module you get:
- ✅ truly private variables
- ✅ getters
- ✅ setters
to restrict the accessibility and to make sdk's across multiple languages more maintainble by designing them in a similar way.
Setup
npm install object-acessibility -s
Usage
{ // Add a state const state = { // q can't be modified stateq = 2; // "priate" ths is really private stateprivate = 100; // we could add something calculated here like // state.calced = this.state.private / 100; return state; }{}; // Add Getters const getters = stateq statevalue statevalue / stateq * stateprivate ; // Add Setters const setters = {statevalue = val} // Use the accessibility lib return ;} const testClient = ; console;// undefined // Set a valuetestClientvalue = 500; console;// 500 // We can't set values without a settertestClientq = 200console;// 2 // We can't access values without a getterconsole// undefined