Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@vates/decorate-with
Advanced tools
Creates a decorator from a function wrapper
Installation of the npm package:
> npm install --save @vates/decorate-with
decorateWith(fn, ...args)
Creates a new (legacy) method decorator from a function decorator, for instance, allows using Lodash's functions as decorators:
import { decorateWith } from '@vates/decorate-with'
class Foo {
@decorateWith(lodash.debounce, 150)
bar() {
// body
}
}
decorateMethodsWith(class, map)
Decorates a number of methods directly, without using the decorator syntax:
import { decorateMethodsWith } from '@vates/decorate-with'
class Foo {
bar() {
// body
}
baz() {
// body
}
}
decorateMethodsWith(Foo, {
// without arguments
bar: lodash.curry,
// with arguments
baz: [lodash.debounce, 150],
})
The decorated class is returned, so you can export it directly.
To apply multiple transforms to a method, you can either call decorateMethodsWith
multiple times or use @vates/compose
:
decorateMethodsWith(Foo, {
bar: compose([
[lodash.debounce, 150]
lodash.curry,
])
})
perInstance(fn, ...args)
Helper to decorate the method by instance instead of for the whole class.
This is often necessary for caching or deduplicating calls.
import { perInstance } from '@vates/decorateWith'
class Foo {
@decorateWith(perInstance, lodash.memoize)
bar() {
// body
}
}
Because it's a normal function, it can also be used with decorateMethodsWith
, with compose
or even by itself.
Contributions are very welcomed, either on the documentation or on the code.
You may:
FAQs
Creates a decorator from a function wrapper
The npm package @vates/decorate-with receives a total of 23 weekly downloads. As such, @vates/decorate-with popularity was classified as not popular.
We found that @vates/decorate-with demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 11 open source maintainers 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.