tubux
v1.0.3
Published
Classy Constructors and Accessors in JavaScript
Downloads
6
Readme
Tubux
Classy Constructors and Accessors in JavaScript
JavaScript has a class problem.
The traditional (pre-ES6) approach to object-oriented programming in JavaScript (where you define a constructor function and then assign methods to its prototype) feels clunky and involves a lot of repetitive code.
But ES6 classes can't have private instance variables like regular function closures can. As of early 2020, private fields aren't supported in all major browsers, and private methods are still in draft status. So it'll be a while before we can expect support across browsers.
Tubux is a way to define a constructor in a way that resembles a class. It also lets you easily generate accessors, which are access-controlled getter/setter methods that can sanitize input and register listeners.
Documentation
https://thomasperi.github.io/tubux/
Pronunciation
"Two bucks"