Module reflection API for nodejs
npm install reflection-js
foo.prototype.bar = function() /**
* This comment is valid and can describe the function behavior
* This syntax allow reflection API to work, as the comment will be serialized in the function body
*/ {
return 43;
}
class Bar {
async static bar() /**
* This comment is valid and can describe the function behavior
* This syntax allow reflection API to work, as the comment will be serialized in the function body
*/ {
return 43;
}
}
`
Usage
`
const parsefunc = require('reflection-js/parsefunc');
var heavyComputation = function (a, b = 1) /**
* This function computer bar
* @param {string} a Initial rotation speed
* @param {string} [b=1] this is foo
*/ {
return a + b;
};
console.log(parsefunc(heavyComputation));
{
"name": "heavyComputation",
"params": {
"a": {
"type": "string",
"descr": "Initial rotation speed",
"optional": false
},
"b": {
"type": "string",
"descr": "this is foo",
"value": "1",
"optional": true
}
},
"blocs": // all parsed @sections
"doc": [
"This function computer bar"
],
"jsdoc": // raw comment string
}
``