inspect-function
Inspects a function and returns informations about it (e.g. name, parameters names, parameters and default values, signature).
Useful when creating automated tasks, e.g., docs generations.
Installation
npm install inspect-function
Usage
inspectFunction(fn, name);
const inspectFunction = require('inspect-function');
const testFunction = (a = 'z', b = [1,2,3], c) => console.log(a,b,c);
const result = inspectFunction(testFunction);
{
"name": "testFunction",
"parametersDefinitions": [
"a='z'",
"b=[1,2,3]",
"c"
],
"parameters": {
"names": [
"a",
"b",
"c"
],
"defaultValues": {
"a": "'z'",
"b": "[1,2,3]"
}
},
"signature": "testFunction(a = 'z', b = [1,2,3], c);"
}