Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
function-name
Advanced tools
Function
objectsVery simple module. Sets the non-writable name
property of Function
objects. In older versions of node, this functionality is exposed internally to
V8, but not exposed to JavaScript, so a native module is required. In newer
versions of node, function names can be redefined with Object.defineProperty
,
which this module uses.
Note that unfortunately only String values are allowed.
NOTE: For users of node prior to
iojs@3.0.0
, you'll need to use an earlier version of this module,function-name@1
, which provides a C++ implementation.
Install with npm
:
$ npm install function-name
var set = require('function-name');
function test () {
throw new Error('blah');
}
console.log(test.name);
// "test"
// change the "name" property to 'foo'
set(test, 'foo');
console.log(test.name);
// "foo"
// spaces, and even usually illegal UTF8 chars, are allowed
set(test, ' ☃ ');
console.log(test.name);
// " ☃ "
// the newly set "name" also appears in stack traces!
test();
// Error: blah
// at ☃ (/Users/nrajlich/node-function-name/t.js:4:9)
// at Object.<anonymous> (/Users/nrajlich/node-function-name/t.js:23:1)
// at Module._compile (module.js:449:26)
// at Object.Module._extensions..js (module.js:467:10)
// at Module.load (module.js:356:32)
// at Function.Module._load (module.js:312:12)
// at Module.runMain (module.js:492:10)
// at process.startup.processNextTick.process._tickCallback (node.js:244:9)
That's it!
FAQs
Set the "name" property of `function` objects
The npm package function-name receives a total of 77 weekly downloads. As such, function-name popularity was classified as not popular.
We found that function-name 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
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.