Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Convert objects into event emitters, that emit events before and after calling the specified methods.
Dependencies:
npm install eventize
The package is also available as a UMD module (compatible with AMD, CommonJS and exposing a global variable eventize
) in dist/eventize.js
and dist/eventize.min.js
(1.9 KB minified and gzipped).
It can be installed with npm, bower or downloading the release from GitHub:
npm install eventize
bower install eventize
eventize.object
converts plain objects into event emitters (if it they are not) and wraps the specified methods to emit events before and after being called:
var eventize = require('eventize');
var myObject = {
name: 'John',
getName: function() {
return this.name;
},
setName: function(name) {
this.name = name;
return name;
}
};
// equivalent to eventize.object(myObject, ['setName']);
eventize.object(myObject, ['setName']);
myObject.on('setName:before', function(args, method, target) {});
myObject.on('setName', function(args, returnValue, method, target) {});
myObject.setName('Jack'); // emits setName:before and setName
eventize.methods
wraps the specified methods to emit events before and after being called (the target must be an event emitter):
var eventize = require('eventize');
var util = require('util');
var EventEmitter = require('util');
function MyConstructor() {
EventEmitter.call(this);
}
util.inherits(MyConstructor, EventEmitter);
MyConstructor.prototype.addOne = function(value) {
return value + 1;
};
eventize.methods(MyConstructor.prototype, ['addOne']);
var myObject = new MyConstructor();
myObject.on('addOne:before', function(args, method, target) {});
myObject.on('addOne', function(args, returnValue, method, target) {});
myObject.addOne(1); // Emits addOne:before and addOne
eventize.method
wraps a single method to emit events (the target must be an event emitter):
eventize.method(myObject, 'getName');
myObject.on('getName:before', function(args, method, target) {});
myObject.on('getName', function(args, returnValue, method, target) {});
myObject.getName(); // emits setName:before and setName
To run the tests with Jasmine:
npm install
npm test
git checkout -b my-new-feature
git commit -am 'Add some feature'
npm run build
git push origin my-new-feature
0.6.0:
0.5.1:
0.5.0:
0.4.0:
0.3.0:
eventize.methods
(mostly for classes)0.2.0:
eventize.object
and eventize.method
eventize
(eventize.object
) is now idempotent (as well as eventize.method
)0.1.0:
The MIT License (MIT)
Copyright (c) 2015 Rubén Norte
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Make your methods emit events
The npm package eventize receives a total of 0 weekly downloads. As such, eventize popularity was classified as not popular.
We found that eventize 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.