JSFiddle - React, Tailwind, and code Playground

by f0t0n

JavaScript

var reFuncDecl = /^function\s*\(([^)]+)\)/g,
    reSplitArg = /[,\s]+/;

function funcInfo(s) {
    var matches = reFuncDecl.exec(s),
    args = matches[1].split(reSplitArg);
    reFuncDecl.lastIndex = 0;
    return {
        declaration: matches[0],
        args: args,
        input: s
    };
}


var s = "function (a, b,   c,d,e,\nf) { return \'hello\'; }",
    info = funcInfo(s);
for(var prop in info) {
    document.write(prop + ': ' + info[prop] + '<br />');
}
console.log(funcInfo(s));