Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

minivents

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minivents - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

tests/test.js

5

minivents.js

@@ -28,7 +28,6 @@ /**

list = events[args.shift()] || []
args = args[0] instanceof A && args[0] || args
i = list.length
//while(~--i<0) list[i-l].f.apply(list[i].c, args)
for(j=0;j<i;j++) list[j].f.apply(list[j].c, args)
}
};
}
module.exports = Events

3

minivents.min.js

@@ -1,2 +0,1 @@

function Events(e){var t={},n,r,i,s=Array;e=e||this;e.on=function(e,n,r){t[e]||(t[e]=[]);t[e].push({f:n,c:r})};e.off=function(e,i){r=t[e]||[];n=r.length=i?r.length:0;while(~--n<0)i==r[n].f&&r.splice(n,1)};e.emit=function(){i=s.apply([],arguments);r=t[i.shift()]||[];i=i[0]instanceof s&&i[0]||i;n=r.length;while(~--n<0)r[n].f.apply(r[n].c,i)}}
module.exports = Events;
function Events(a){var c,d,e,b={},f=Array;a=a||this,a.on=function(a,c,d){b[a]||(b[a]=[]),b[a].push({f:c,c:d})},a.off=function(a,e){for(d=b[a]||[],c=d.length=e?d.length:0;~--c<0;)e==d[c].f&&d.splice(c,1)},a.emit=function(){for(e=f.apply([],arguments),d=b[e.shift()]||[],c=d.length,j=0;c>j;j++)d[j].f.apply(d[j].c,e)}}module.exports=Events;
{
"name": "minivents",
"version": "1.0.1",
"version": "1.1.0",
"description": "Tiny eventing for javascript",
"main": "minivents.min.js",
"main": "minivents.js",
"directories": {

@@ -20,7 +20,14 @@ "test": "tests"

],
"author": "Fabien O'Carroll - allouis",
"author": {
"name": "Fabien O'Carroll - allouis"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/allouis/minivents/issues"
}
},
"readme": "minivents\n=========\n\nhttp://allouis.github.io/minivents/\n\nAPI\n===\n\n`on` : Listen to event. Params { type:`String`, callback:`Function` | context:`Object` }\n \n`off` : Stop listening to event. Params { type:`String` | callback:`Function` } \n \n`emit`: Emit event. Params { type:`String` | data:`Object` } \n\n`trigger` is no longer supported!!\n\n`:%s/myobj.trigger(/myobj.emit(/` should do the trick in VIM\n \nExample\n=======\n\n var sandbox = new Events\n \n sandbox.on(\"event\", function(){\n // do stuff\n })\n\n sandbox.emit(\"event\") //does stuff\n\n sandbox.off(\"event\")\n\n sandbox.emit(\"event\") //does not do stuff\n \nMixin Example\n=======\n\n var sandbox = {\n otherStuff: true\n }\n \n Events(sandbox)\n \n sandbox.on(\"event\", function(){\n // do stuff\n })\n\n sandbox.emit(\"event\") //does stuff\n\n sandbox.off(\"event\")\n\n sandbox.emit(\"event\") //does not do stuff\n \n",
"readmeFilename": "README.md",
"_id": "minivents@1.0.1",
"_from": "minivents@"
}

@@ -22,13 +22,13 @@ minivents

var sandbox = new Events
var sandbox = new Events();
sandbox.on("event", function(){
// do stuff
})
});
sandbox.emit("event") //does stuff
sandbox.emit("event"); //does stuff
sandbox.off("event")
sandbox.off("event");
sandbox.emit("event") //does not do stuff
sandbox.emit("event"); //does not do stuff

@@ -40,15 +40,15 @@ Mixin Example

otherStuff: true
}
};
Events(sandbox)
Events(sandbox);
sandbox.on("event", function(){
// do stuff
})
});
sandbox.emit("event") //does stuff
sandbox.emit("event"); //does stuff
sandbox.off("event")
sandbox.off("event");
sandbox.emit("event") //does not do stuff
sandbox.emit("event"); //does not do stuff
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc