acclimate-variables
rename all invalid identifiers in an AST
Motivation
When compiling to JS its a pain to worry if the identifiers you generate are safe to use in JS code. And if not what is. With this module you just don't worry it at all then, just before you generate your JS, run your AST through the acclimate
function.
Installation
With your favorite package manager:
- packin:
packin add jkroso/acclimate-variables
- component:
component install jkroso/acclimate-variables
- npm:
npm install acclimate-variables
then in your app:
var acclimate = require('acclimate-variables')
API
acclimate(node)
translate all identifiers in node
to ones safe to use in JS code.
acclimate({type:'Identifier', name: 'number->string'})
acclimate({type:'Identifier', name: 'string?'})