Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
addon-emitter
Advanced tools
Readme
event emitter class for native addons.
using a native addon (here foo
) with event emitter:
var Foo = require('foo')
var foo = new Foo()
foo.on('sus', function (a, b) {
console.log('Received:', a, b);
})
the Foo
class inherits the public interface of the Emitter
class:
// foo.h
#include <nan.h>
#include <emitter.h>
// inherit from the Emitter class
class Foo : public Emitter {
public:
static void Init(v8::Local<v8::Object> exports);
private:
explicit Foo ();
~Foo ();
void Bar ();
};
set the method for the event listening (usually the on
method):
// foo.cc
void Foo::Init(v8::Local<v8::Object> exports) {
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
// setting the prototype method for the event listening
Nan::SetPrototypeMethod(tpl, "on", Emitter::On);
}
to emit an event from Foo
:
void Foo::Bar(const Nan::FunctionCallbackInfo<v8::Value>& info) {
// the first parameter is the name of the event,
// after that you can write as many parameters as needed,
// but they have to convertible to v8's `Local<Value>` type
Emit(Nan::New("sus").ToLocalChecked()
, Nan::New("a string").ToLocalChecked(), 123);
}
the example above is just to show what you have to do to use the module. it's not a fully functioning program. for a working example check the test
folder.
npm i addon-emitter
in binding.gyp
:
{
'include_dirs': [ "<!(node -e \"require('addon-emitter')\")" ]
}
FAQs
event emitter class for native addons
The npm package addon-emitter receives a total of 1 weekly downloads. As such, addon-emitter popularity was classified as not popular.
We found that addon-emitter 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.