Skip to content

Instantly share code, notes, and snippets.

@jugglinmike
Created January 22, 2014 00:25
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 jugglinmike/8551293 to your computer and use it in GitHub Desktop.
Save jugglinmike/8551293 to your computer and use it in GitHub Desktop.
suite.js: `nin` operator macro
// Use suite.js to define a JavaScript macro for a "not in" operator
// http://sweetjs.org/
macro nin {
rule infix {
$key:expr | $obj:expr
} => {
!($key in $obj)
}
}
// Now,
if (key nin obj) {
return null;
}
// ...compiles to:
if (!(key in obj)) {
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment