
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
Returns function parameter names using the acorn parser, thus slower than regex implementations. Works with all kinds of functions and parameters. Also works with classes returning the constructor parameter names. Deconstructed parameter names are undefined.
getParameterNames(fn: Function): Array<string | undefined>
Returns undefined if the argument is not a function.
Deconstructed parameter names are undefined.
Native function's parameter names are [].
If a class does not have a constructor the function will try to look it up in the prototype.
It will go up the inheritance hierarchy until it finds the constructor or hits a native function.
If the constructor is still not found, it will return the default constructor's parameter names [].
const getParameterNames = require("paramnames");
function add(a, b) {
return a + b;
}
console.log(getParameterNames(add)); // ["a", "b"]
const getParameterNames = require("paramnames");
const fn = (a, [b, c], ...d) => {};
console.log(getParameterNames(fn)); // ["a", undefined, "d"]
const getParameterNames = require("paramnames");
const obj = {
async *["f" + "n"](a = (1, 2, 3), b = [{}, x => {}], { x, y: { z } }, ...rest) {}
};
console.log(getParameterNames(obj.fn)); // ["a", "b", undefined, "rest"]
const getParameterNames = require("paramnames");
class Sample {
constructor(a, b) {}
}
console.log(getParameterNames(Sample)); // ["a", "b"]
const getParameterNames = require("paramnames");
class Sample {}
console.log(getParameterNames(Sample)); // []
const getParameterNames = require("paramnames");
class Base {
constructor(a, b) {}
}
class Child extends Base {}
console.log(getParameterNames(Child)); // ["a", "b"]
const getParameterNames = require("paramnames");
class Base {
constructor(a, b) {}
}
class Child1 extends Base {}
class Child2 extends Child1 {
constructor(c, d) {
super(a, b);
}
}
class Child3 extends Child2 {}
console.log(getParameterNames(Child3)); // ["c", "d"]
const getParameterNames = require("paramnames");
console.log(getParameterNames(console.log)); // []
console.log(getParameterNames(isNaN)); // []
console.log(getParameterNames(Object)); // []
console.log(getParameterNames(Number)); // []
FAQs
Returns function parameter names.
The npm package paramnames receives a total of 3 weekly downloads. As such, paramnames popularity was classified as not popular.
We found that paramnames demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.