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.
custom-ability
Advanced tools
make custom ability more easy. generate the ability which can be added to any class directly.
generate the ability which can be added to any class directly. It makes custom ability more easy.
just one function:
var customAbility = require('custom-ability')
arguments
AbilityClass
is a function(aClass, aOptions)
to return the real Ability Class
if true. defaults to false.return
the custom ability function has two arguments: function(class[, options])
class
: the class to be injected the ability.options
(object): optional options
include
(array|string): only these emitter methods will be added to the classexclude
(array|string): theses emitter methods would not be added to the class
coreMethod
could not be excluded. It's always added to the class.methods
(object): hooked methods to the class
this.super()
to call the original method.this.self
is the original this
object.classMethods
(object): hooked class methods to the classsuppose we wanna add the RefCount ability to any class directly.
the RefCount ability will add the following members to your class.
and you should implement the destroy
method which will be called
by release
/free
.
release()
/free()
: Decrements reference count for this instance.
If it is becoming less than 0, the object would be (self) destroyed.addRef()
: Increments the reference count for this instance
and returns the new reference count.customAbility = require 'custom-ability'
class RefCountable
# define the instance methods here:
release: ->
result = --@RefCount
@destroy() unless result >= 0
result
free: @::release
addRef: ->
if not isUndefined @RefCount
++@RefCount
else
@RefCount = 1
# the class methods if any:
@someClassMethod: ->
module.exports = customAbility RefCountable, 'addRef'
do not forget to add the "ability"
keyword to your package.json which means
the ability power with it.
// package.json
"keywords": [
"ability",
...
],
do not forget to add the "ability.js"
file on your package root folder too.
now user use this ability like this:
refable = require 'ref-object/ability'
class MyClass
refable MyClass
destroy: ->console.log 'destroy'
my = new MyClass
my.addRef()
my.free() # nothing
my.free() # print the 'destroy' here.
More complicated example, you can see the events-ex/src/eventable.coffee.
FAQs
make custom ability more easy. generate the ability which can be added to any class directly.
The npm package custom-ability receives a total of 293 weekly downloads. As such, custom-ability popularity was classified as not popular.
We found that custom-ability demonstrated a healthy version release cadence and project activity because the last version was released less than 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.