Skip to content

Instantly share code, notes, and snippets.

@joshblack
Created September 30, 2015 04:21
Show Gist options
  • Save joshblack/8ee1ede560f9ee7881b5 to your computer and use it in GitHub Desktop.
Save joshblack/8ee1ede560f9ee7881b5 to your computer and use it in GitHub Desktop.

Babel Types, Construction

Identifier

t.identifier: (string) => identifier

Only really useful thing about an identifier is getting its name.

visitor: {
  Identifier(node) {
    // node.name will give you the name of the identifier
  }
}

You can build up an identifier by just passing in a string to t.identifier.

visitor: {
  Identifier(node) {
    return t.identifier(node.name.split('').revser().join(''));
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment