
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@forivall/decorator
Advanced tools
Simple function decorator/wrapping util, in typescript
npm install --save @forivall/decorator
Using the following wrapper function for our examples
function log<F extends (...args: any[]): any>(fn: F, label: string): F {
return (...args: Parameters<F>) => {
console.log(`enter ${label}`)
const out: ReturnType<F> = fn(...args)
console.log(`exit ${label}`)
return out
} as F
}
wrap()import {wrap} from '@forivall/decorator'
const doStuff = wrap(log, () => console.log('stuff'), 'doStuff')
doStuff()
// Output:
// enter doStuff
// stuff
// exit doStuff
decorator()Create a decorator function
import decorator from '@forivall/decorator'
const logDecorator = decorator(log)
class Stuff {
@logDecorator('doStuff')
doIt() {
console.log('stuff')
}
}
new Stuff().doIt()
// Output:
// enter doStuff
// stuff
// exit doStuff
proxied()Add metadata to a function that proxies another. Useful for the proxy pattern.
class Stuff {
doIt() {
console.log('stuff')
}
somethingElse() {
console.log('more stuff')
}
}
import {proxied} from '@forivall/decorator'
class StuffWrapper {
stuff = new Stuff()
}
interface StuffWrapper implements Stuff {}
Object.keys(Stuff.prototype).forEach((k) => {
StuffWrapper.prototype[k] = proxied(Stuff, k, function(this: StuffWrapper, ...args: unknown[]) {
return this.stuff[k](...args)
})
})
ISC
FAQs
Simple function decorator/wrapping util, in typescript
We found that @forivall/decorator 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.