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

alamid-list

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alamid-list - npm Package Compare versions

Comparing version 0.1.4 to 0.2.0

12

lib/List.js

@@ -27,10 +27,8 @@ "use strict";

*
* @type {{events: {emit: *, removeAllListeners: *}}}
* @type {{emit: Function, on: Function, removeListener: Function}}
*/
List.prototype.config = {
events: {
emit: throwMethodMissingError("emit"),
on: throwMethodMissingError("on"),
removeListener: throwMethodMissingError("removeListener")
}
emit: throwMethodMissingError("emit"),
on: throwMethodMissingError("on"),
removeListener: throwMethodMissingError("removeListener")
};

@@ -260,3 +258,3 @@

function emit(self, Event, arg1, arg2, arg3) {
self.config.events.emit.call(self, Event.prototype.name, new Event(self, arg1, arg2, arg3));
self.config.emit.call(self, Event.prototype.name, new Event(self, arg1, arg2, arg3));
}

@@ -263,0 +261,0 @@

{
"name": "alamid-list",
"version": "0.1.4",
"version": "0.2.0",
"description": "Simple observable arrays",

@@ -5,0 +5,0 @@ "main": "./lib/List.js",

"use strict";
var EventEmitter = require("events").EventEmitter,
instance = EventEmitter.prototype;
proto = EventEmitter.prototype;
function nodeEvents(List) {
var events = List.prototype.config.events,
var config = List.prototype.config,
constructor = List.prototype.constructor,
key;
events.emit = instance.emit;
events.on = instance.on;
events.removeListener = instance.removeListener;
config.emit = proto.emit;
config.on = proto.on;
config.removeListener = proto.removeListener;
for (key in instance) { /* jshint forin: false */
List.prototype[key] = instance[key];
for (key in proto) { /* jshint forin: false */
List.prototype[key] = proto[key];
}
List.prototype.constructor = function () {
EventEmitter.call(this);
constructor.apply(this, arguments);
};
}
module.exports = nodeEvents;

@@ -15,3 +15,3 @@ "use strict";

on = master.on || master.config.events.on;
on = master.on || master.config.on;

@@ -49,3 +49,3 @@ if (!this.config.watch) {

removeListener = master.removeListener || master.config.events.removeListener;
removeListener = master.removeListener || master.config.removeListener;

@@ -52,0 +52,0 @@ config.master = null;

@@ -20,12 +20,10 @@ "use strict";

List.configure({
events: {
emit: emit,
on: on,
removeListener: removeListener
}
emit: emit,
on: on,
removeListener: removeListener
});
expect(List.prototype.config.events.emit).to.equal(emit);
expect(List.prototype.config.events.on).to.equal(on);
expect(List.prototype.config.events.removeListener).to.equal(removeListener);
expect(List.prototype.config.emit).to.equal(emit);
expect(List.prototype.config.on).to.equal(on);
expect(List.prototype.config.removeListener).to.equal(removeListener);
});

@@ -58,3 +56,3 @@

list = new List();
List.prototype.config.events.emit = emit = sinon.spy();
List.prototype.config.emit = emit = sinon.spy();
});

@@ -61,0 +59,0 @@

@@ -15,2 +15,11 @@ "use strict";

it("should adjust the config", function () {
List.use(nodeEvents);
list = new List();
expect(list.config.emit).to.equal(emitter.emit);
expect(list.config.on).to.equal(emitter.on);
expect(list.config.removeListener).to.equal(emitter.removeListener);
});
it("should enable working with node's EventEmitter", function () {

@@ -22,6 +31,2 @@ var listener = sinon.spy();

expect(list.config.events.emit).to.equal(emitter.emit);
expect(list.config.events.on).to.equal(emitter.on);
expect(list.config.events.removeListener).to.equal(emitter.removeListener);
expect(list.on).to.be.a("function");

@@ -31,7 +36,7 @@ expect(list.removeListener).to.be.a("function");

list.on("add", listener);
list.push(1);
list.set("greeting", "hi");
expect(listener).to.have.been.calledOnce;
list.removeListener("add", listener);
list.push(2);
list.set("greeting", "ahoi");
expect(listener).to.have.been.calledOnce;

@@ -38,0 +43,0 @@ });

@@ -21,5 +21,3 @@ "use strict";

List.configure({
events: {
emit: function () {}
}
emit: function () {}
});

@@ -43,3 +41,3 @@ SortedList.use = List.use;

List.prototype.config.events.emit = emit = sinon.spy();
List.prototype.config.emit = emit = sinon.spy();
list.push(2, 4, 5);

@@ -79,3 +77,3 @@

List.prototype.config.events.emit = emit = sinon.spy();
List.prototype.config.emit = emit = sinon.spy();
list.pop();

@@ -94,3 +92,3 @@

List.prototype.config.events.emit = emit = sinon.spy();
List.prototype.config.emit = emit = sinon.spy();
list.sort();

@@ -97,0 +95,0 @@

@@ -25,7 +25,5 @@ "use strict";

Slave.configure({
events: {
emit: emitter.emit,
on: emitter.on,
removeListener: emitter.removeListener
}
emit: emitter.emit,
on: emitter.on,
removeListener: emitter.removeListener
});

@@ -32,0 +30,0 @@ });

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