Created
July 24, 2015 06:02
-
-
Save iShafayet/e881bc886baf98086644 to your computer and use it in GitHub Desktop.
Serializing/Deserializing Javascript Functions with eval
This file contains 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
@__deserializeFunction = __deserializeFunction = (argumentArray)-> | |
Function.apply {}, argumentArray | |
@__serializeFunction = __serializeFunction = (fn)-> | |
deSF = fn.toString() | |
temp = deSF.indexOf '(' | |
temp1 = deSF.indexOf ')' | |
declaration = deSF.substring temp+1, temp1 | |
args = declaration.split ', ' | |
temp = deSF.indexOf '{' | |
temp1 = deSF.lastIndexOf '}' | |
body = deSF.substring temp+1, temp1 | |
args.push body | |
return args |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment