Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for functional macros #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

BobVarioa
Copy link

@BobVarioa BobVarioa commented Apr 26, 2021

Adds support for function based macros

Examples :

assert(jscc("$_HI()", '', {
   values: {
       _HI: () => "hi"
   }
}).code === "hi")
assert(jscc('$_HI("one", "two", "three")', '', {
   values: {
       _HI: (...args) => args.join(",")
   }
}).code === "one,two,three")
assert(jscc('$_HI("one", "two", "three")', '', {
   values: {
       _HI: "hi"
   }
}).code === 'hi("one", "two", "three")') // doesn't change existing behavior of non functional values

Function based macros can only be a the top level (e.g. no $_LIB.fs.blah.read(/*etc.*/)) and arguments must be either a string or a number.

I tried to keep the same style as your code and I wrote a few tests (but since they are so simple I didn't really know what else to test).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant