Skip to content

Instantly share code, notes, and snippets.

@effection
effection / class-macro.js
Last active January 8, 2016 13:37 — forked from disnet/gist:5267782
Better class macro in Sweet.js
/**
* class which allows 'private' (just non-enumerable prototype object) methods and variables
*/
macro class {
case $className { constructor $constParam { $constBodyStatement... } public var {$public_vars ...} private var $private_vars $rest ... } => {
var $className = (function() {
function $className $constParam {
$public_vars ... Object.defineProperty(this, '_private_vars', { configurable: true, enumerable: false, value: $private_vars, writable: false})