Skip to content

Instantly share code, notes, and snippets.

@disnet
Created April 10, 2017 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save disnet/acd2e7a67dbb31f2d12c68fcf68ffd6d to your computer and use it in GitHub Desktop.
Save disnet/acd2e7a67dbb31f2d12c68fcf68ffd6d to your computer and use it in GitHub Desktop.
import * as H from 'sweet.js/helpers' for syntax;
syntax m = ctx => {
let v = ctx.next().value;
if (H.isIdentifier(v, 'foo') {
return H.fromString(v, 'bar');
}
return H.fromString(v, 'baz');
}
m foo; // expands to 'bar'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment