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

ampersand-events

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ampersand-events - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

3

ampersand-events.js

@@ -107,3 +107,6 @@ /*$AMPERSAND_VERSION*/

Events.bind = Events.on;
Events.unbind = Events.off;
// Implement fancy features of the Events API such as multiple event

@@ -110,0 +113,0 @@ // names `"change blur"` and jQuery-style event maps `{change: action}`

2

package.json
{
"name": "ampersand-events",
"description": "Module that can be mixed into any object to provide eventing. Heavily based on Backbone Events.",
"version": "1.0.1",
"version": "1.1.0",
"author": "Henrik Joreteg <henrik@andyet.net>",

@@ -6,0 +6,0 @@ "browserify": {

@@ -91,2 +91,4 @@ # ampersand-events

(aliased as `bind` for backwards compatibility)
Bind a function to be called each time the `eventName` is triggered on that object.

@@ -104,3 +106,3 @@

### once `eventObj.on(eventName, callback, [context])`
### once `eventObj.once(eventName, callback, [context])`

@@ -111,2 +113,4 @@ Exactly like `on` but removes itself after getting called once no matter how many times the event is triggered.

(aliased as `unbind` for backwards compatibility)
Remove previously bound callback(s) from the object. If no context is specified all versions of callback no matter what context was given will be removed. If no callback was specified, all callbacks for that given `eventName` will be removed. If no `eventName` was specified callbacks for all events are removed.

@@ -118,2 +122,3 @@

These can be used in any combination as shown below:

@@ -120,0 +125,0 @@

@@ -28,2 +28,24 @@ var test = require('tape');

test('bind/unbind and trigger (for backwards compatibility)', function (t) {
t.plan(3);
var obj = {
counter: 0
};
extend(obj, Events);
obj.bind('event', function () {
obj.counter += 1;
});
obj.trigger('event');
t.equal(obj.counter,1,'counter should be incremented.');
obj.trigger('event');
obj.trigger('event');
obj.trigger('event');
obj.trigger('event');
t.equal(obj.counter, 5, 'counter should be incremented five times.');
obj.unbind('event');
obj.trigger('event');
t.equal(obj.counter, 5, 'counter should not be further incremented as unbound.');
t.end();
});
test('binding and triggering multiple events', function (t) {

@@ -30,0 +52,0 @@ t.plan(4);

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