Skip to content

Instantly share code, notes, and snippets.

@disnet
Created March 28, 2013 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save disnet/5267782 to your computer and use it in GitHub Desktop.
Save disnet/5267782 to your computer and use it in GitHub Desktop.
macro class {
case $className { constructor $constParam $constBody $rest ... } => {
function $className $constParam $constBody
class $className { $rest ... }
}
case $className { private_function $pMethodName $pMethodParam $pMethodBody $rest ...} => {
function $pMethodName $pMethodParam $pMethodBody
class $className { $rest ... }
}
case $className { $($methodName $methodParam $methodBody) ... } => {
$($className.prorotype.$methodName = function $methodName $methodParam $methodBody;) ...
}
}
class Person {
constructor(name) {
this.name = name;
}
private_function myMethod() { console.log('private'); }
private_function otherPrivate() { console.log('private'); }
say(msg) {
console.log(this.name + " says: " + msg);
}
other(foo) {
console.log("other method");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment