Created
April 2, 2016 18:18
-
-
Save tzmartin/d2028f6a5a82094ec28172d5ee8a63ef to your computer and use it in GitHub Desktop.
js transform function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Test() { | |
this.data = { | |
"foo":"bar" | |
}; | |
} | |
Test.prototype.transform = function(str) { | |
var err = false; | |
var input = this.data; | |
var output = false; | |
try { | |
function run() { | |
eval(str); | |
return output; | |
} | |
output = run(); | |
}catch(e) { | |
err = e; | |
} | |
console.log((err)?err:output); | |
//console.log(this.data); | |
} | |
var a = new Test(); | |
a.transform('output = input'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment