MCPcopy Create free account
hub / github.com/antimatter15/ocrad.js / parseJSFunc

Function parseJSFunc

ocrad.js:483–487  ·  view source on GitHub ↗
(jsfunc)

Source from the content-addressed store, hash-verified

481
482 var sourceRegex = /^function\s*[a-zA-Z$_0-9]*\s*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;
483 function parseJSFunc(jsfunc) {
484 // Match the body and the return value of a javascript function source
485 var parsed = jsfunc.toString().match(sourceRegex).slice(1);
486 return {arguments : parsed[0], body : parsed[1], returnValue: parsed[2]}
487 }
488
489 // sources of useful functions. we create this lazily as it can trigger a source decompression on this entire file
490 var JSsource = null;

Callers 2

ensureJSsourceFunction · 0.85
createOcradInstanceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected