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.3.1 to 0.4.2

.jshintignore

23

lib/List.js

@@ -235,10 +235,11 @@ "use strict";

/**
* Calls the given function with the List as argument. Plugins can be used to hook into class methods by
* overriding them.
* Calls the given function with the View as first argument and the given config (optionally). Plugins can be used
* to hook into class methods by overriding them.
*
* @param {Function} plugin
* @param {Object=} config
* @returns {List}
*/
List.use = function (plugin) {
plugin(this);
List.use = function (plugin, config) {
plugin(this, config);

@@ -259,3 +260,3 @@ return this;

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

@@ -272,3 +273,3 @@

*/
AddEvent.prototype.name = "add";
AddEvent.prototype.type = "add";

@@ -300,3 +301,3 @@ /**

*/
RemoveEvent.prototype.name = "remove";
RemoveEvent.prototype.type = "remove";

@@ -319,5 +320,5 @@ /**

function SortEvent(target, type) {
function SortEvent(target, sortType) {
this.target = target;
this.type = type;
this.sortType = sortType;
}

@@ -328,3 +329,3 @@

*/
SortEvent.prototype.name = "sort";
SortEvent.prototype.type = "sort";

@@ -343,4 +344,4 @@ /**

*/
SortEvent.prototype.type = null;
SortEvent.prototype.sortType = null;
module.exports = List;
{
"name": "alamid-list",
"version": "0.3.1",
"version": "0.4.2",
"description": "Simple observable arrays",
"main": "./lib/List.js",
"scripts": {
"test": "node node_modules/webpack-dev-server/bin/webpack-dev-server.js --entry mocha\\!./test/main.js"
"test": "node node_modules/mocha/bin/mocha -R spec"
},

@@ -40,3 +40,3 @@ "keywords": [

"browsers": {
"iexplore": [7, 8, 9, 10],
"iexplore": [9, 10],
"chrome": [20, 25, "canary"],

@@ -43,0 +43,0 @@ "firefox": [20, 22, "nightly"],

@@ -17,2 +17,5 @@ "use strict";

for (key in proto) { /* jshint forin: false */
if (List.prototype.hasOwnProperty(key)) {
throw new Error("Cannot apply nodeEvents-plugin: There is already a '" + key + "'-property defined.");
}
List.prototype[key] = proto[key];

@@ -19,0 +22,0 @@ }

@@ -36,11 +36,24 @@ "use strict";

describe(".use()", function () {
var plugin,
config;
it("should provide an plugin-interface", function () {
var plugin = sinon.spy();
beforeEach(function () {
plugin = sinon.spy();
config = {};
});
List.use(plugin);
expect(plugin).to.have.been.calledWith(List);
expect(List.use(plugin)).to.equal(List);
it("should provide a plugin-interface", function () {
List.use(plugin, config);
expect(plugin).to.have.been.calledWith(List, config);
});
it("should be usable on other objects too", function () {
var otherObj = {
use: List.use
};
otherObj.use(plugin);
expect(plugin).to.have.been.calledWith(otherObj);
});
it("should be chainable", function () {

@@ -348,5 +361,5 @@ expect(List.use(function () {})).to.equal(List);

expect(event).to.eql({
name: "sort",
type: "sort",
target: list,
type: "reverse"
sortType: "reverse"
});

@@ -381,5 +394,5 @@ });

expect(event).to.eql({
name: "sort",
type: "sort",
target: list,
type: "sort"
sortType: "sort"
});

@@ -451,3 +464,3 @@ });

expect(event).to.eql({
name: "remove",
type: "remove",
target: list,

@@ -461,3 +474,3 @@ element: 1,

expect(event).to.eql({
name: "add",
type: "add",
target: list,

@@ -763,3 +776,3 @@ element: "a",

expect(event).to.eql({
name: "add",
type: "add",
target: list,

@@ -774,3 +787,3 @@ element: 1,

expect(event).to.eql({
name: "add",
type: "add",
target: list,

@@ -791,3 +804,3 @@ element: 2,

expect(event).to.eql({
name: "remove",
type: "remove",
target: list,

@@ -801,3 +814,3 @@ element: firstCall.element,

expect(event).to.eql({
name: "remove",
type: "remove",
target: list,

@@ -804,0 +817,0 @@ element: secondCall.element,

@@ -15,6 +15,17 @@ "use strict";

function MyList() {
List.apply(this, arguments);
}
before(function () {
MyList.prototype = Object.create(List.prototype);
MyList.use = List.use;
MyList.use(nodeEvents);
});
beforeEach(function () {
list = new MyList();
});
it("should adjust the config", function () {
List.use(nodeEvents);
list = new List();
expect(list.config.emit).to.equal(emitter.emit);

@@ -29,5 +40,2 @@ expect(list.config.on).to.equal(emitter.on);

List.use(nodeEvents);
list = new List();
expect(list.on).to.be.a("function");

@@ -45,2 +53,14 @@ expect(list.removeListener).to.be.a("function");

it("should throw an error if the target api clashes with the EventEmitter api", function () {
function WontWork() {}
WontWork.prototype = Object.create(List.prototype);
WontWork.prototype.on = function () {};
WontWork.use = List.use;
expect(function () {
WontWork.use(nodeEvents);
}).to.throw(Error, "There is already a 'on'-property defined");
});
});

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

expect(event).to.eql({
name: "add",
type: "add",
target: list,

@@ -59,3 +59,3 @@ element: 2,

expect(event).to.eql({
name: "add",
type: "add",
target: list,

@@ -70,3 +70,3 @@ element: 4,

expect(event).to.eql({
name: "add",
type: "add",
target: list,

@@ -86,3 +86,3 @@ element: 5,

expect(event).to.eql({
name: "remove",
type: "remove",
target: list,

@@ -99,5 +99,5 @@ element: 5,

expect(event).to.eql({
name: "sort",
type: "sort",
target: list,
type: "sort"
sortType: "sort"
});

@@ -104,0 +104,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