Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
keep-func-props
Advanced tools
Wrap a function without changing its name, length and other properties.
Function wrappers are commonly used in functional programming. They take a function as input and return it wrapped. Examples include memoizing or ensuring a function is only called once.
However those wrappers return a new function which means the original
function's name
, length
and other properties are lost. This module
enhances a function wrapper to keep those properties.
const keepFuncProps = require('keep-func-props')
const memoize = require('lodash/memoize')
const betterMemoize = keepFuncProps(memoize)
const anyFunction = function() {
return true
}
// Function name is `memoized`
console.log(memoize(anyFunction))
// Function name is `anyFunction`
console.log(betterMemoize(anyFunction))
npm install keep-func-props
const keepFuncProps = require('keep-func-props')
const functionWrapper = function(func) {
return (...args) => func(...args)
}
// `betterWrapper` is like `functionWrapper` but it keeps the function
// properties
const betterWrapper = keepFuncProps(functionWrapper)
The function wrapper must:
Each of those requirements is optional.
If you want to modify a function that is not a function wrapper, check out
mimic-fn
.
FAQs
Wrap a function without changing its name and other properties
The npm package keep-func-props receives a total of 115,779 weekly downloads. As such, keep-func-props popularity was classified as popular.
We found that keep-func-props 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.