New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

Neuro

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Neuro - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

mixins/silence.js

108

cjs/Collection.js

@@ -8,15 +8,8 @@ exports.Collection={}.undefined;with(require("./Model"))

// (function(context){
// var Unit = require('../lib/company/Source/Company').Unit;
var Silence = require('../mixins/silence');
var Collection = new Class({
// Extends: Unit,
Implements: [Events, Options, Silence],
Implements: [Events, Options],
//Implements: [Unit],
// Set prefix when Extending to differentiate against other Collections
// Prefix: '',
// Model: Model,
_models: [],

@@ -28,4 +21,4 @@

// onEmpty: function(){},
// Prefix: '',
Model: Model
Model: Model,
silent: false
},

@@ -42,6 +35,5 @@

// this.setPrefix(this.options.Prefix);
// Silent property determines whether model will excute signals
this.silence(this.options.silent);
// this.setupUnit();
if (models) {

@@ -58,3 +50,7 @@ this.add(models);

// Silent signaling by using detachUnit before adding
/**
* Private add method
* @param {Class} model A Model instance
* @return {Class} Collection Instance
*/
_add: function(model){

@@ -64,2 +60,6 @@ model = new this._Model(model);

if (!this.hasModel(model)) {
// Remove the model if it destroys itself.
model.addEvent('destroy', this.remove.bind(this));
this._models.push(model);

@@ -73,4 +73,14 @@

/**
* Add a model or models
* @param {Class || Array} A single Model instance or an array of Model instances
* @return {Class} Collection Instance
*
* @example
* collectionInstance.add(model);
* collectionInstance.add(model, model);
* collectionInstance.add([model, model, model]);
*/
add: function(){
var models = arguments,
var models = Array.from(arguments).flatten(),
len = models.length,

@@ -110,7 +120,8 @@ i = 0;

/**
* Private remove method
* @param {Class} model A Model instance
* @return {Class} Collection Instance
*/
_remove: function(model){
if (model.destroy) {
model.destroy();
}
this._models.erase(model);

@@ -123,4 +134,14 @@

/**
* Remove a model or models
* @param {Class || Array} A single Model instance or an array of Model instances
* @return {Class} Collection Instance
*
* @example
* collectionInstance.remove(model);
* collectionInstance.remove(model, model);
* collectionInstance.remove([model, model, model]);
*/
remove: function(){
var models = Array.from(arguments),
var models = Array.from(arguments).flatten(),
l = models.length,

@@ -136,2 +157,31 @@ i = 0;

/**
* Replace an existing model with a new one
* @param {Class} oldModel A Model instance that will be replaced with the new
* @param {Object || Class} newModel An object or Model instance that will replace the old
* @param {Boolean} signal A switch to signal add and remove event listeners
* @return {Class} Collection Instance
*/
replace: function(oldModel, newModel, signal){
var index;
if (oldModel && newModel) {
index = this.indexOf(oldModel);
if (index > -1) {
newModel = new this._Model(newModel);
this._models.splice(index, 1, newModel);
if (signal) {
this.signalAdd(newModel);
this.signalRemove(oldModel);
}
}
}
return this;
},
empty: function(){

@@ -146,4 +196,3 @@ this.remove.apply(this, this._models);

signalAdd: function(model){
// this.publish('add', [this, model]);
this.fireEvent('add', [this, model]);
!this.isSilent() && this.fireEvent('add', [this, model]);
return this;

@@ -153,5 +202,3 @@ },

signalRemove: function(model){
// Silent publishing by using detachUnit before removing
// this.publish('remove', [this, model]);
this.fireEvent('remove', [this, model]);
!this.isSilent() && this.fireEvent('remove', [this, model]);
return this;

@@ -161,4 +208,3 @@ },

signalEmpty: function(){
// this.publish('empty', this);
this.fireEvent('empty', this);
!this.isSilent() && this.fireEvent('empty', this);
return this;

@@ -174,5 +220,5 @@ },

['forEach', 'each', 'invoke', 'every', 'filter', 'clean', 'indexOf', 'map', 'some', 'associate', 'link', 'contains', /*'append',*/ 'getLast', 'getRandom', /*'include', 'combine', 'erase', 'empty',*/ 'flatten', 'pick'].each(function(method){
['forEach', 'each', 'invoke', 'every', 'filter', 'clean', 'indexOf', 'map', 'some', 'associate', 'link', 'contains', 'getLast', 'getRandom', 'flatten', 'pick'].each(function(method){
Collection.implement(method, function(){
return Array[method].apply( Array, [this._models].append( Array.from(arguments) ) );
return Array.prototype[method].apply(this._models, arguments);
});

@@ -179,0 +225,0 @@ });

@@ -7,28 +7,6 @@ exports.Model={}.undefined;with(require("../lib/util/Is"))

/*
---
name: Model
// (function(context){
description: Model to handle data
var Silence = require('../mixins/silence');
version: .10
license: TBD
authors:
- Garrick Cheung
requires:
- MooTools-Core/1.3
- Company
- Is.js
provides: [Model]
...
*/
// (function(context){
// var Unit = require('../lib/company/Source/Company').Unit;
var createGetter = function(type){

@@ -52,6 +30,4 @@ /**

var Model = new Class({
// Extends: Unit,
Implements: [Events, Options, Silence],
Implements: [Events, Options],
_data: {},

@@ -78,5 +54,5 @@

// onDestroy: function(){},
// Prefix: '',
accessors: {},
defaults: {}
defaults: {},
silent: false
},

@@ -95,4 +71,7 @@

this.setAccessor(Object.clone(this.options.accessors));
this.setAccessor(this.options.accessors);
// Silent property determines whether model will excute signals
this.silence(this.options.silent);
if (data) { this._data = Object.merge({}, this.options.defaults, data); }

@@ -261,4 +240,3 @@

signalChange: function(){
// this.publish('change', this);
this.fireEvent('change', this);
!this.isSilent() && this.fireEvent('change', this);
return this;

@@ -268,4 +246,3 @@ },

signalChangeProperty: function(prop, val){
// this.publish('change:' + prop, [this, prop, val]);
this.fireEvent('change:' + prop, [this, prop, val]);
!this.isSilent() && this.fireEvent('change:' + prop, [this, prop, val]);
return this;

@@ -275,4 +252,3 @@ },

signalDestroy: function(){
// this.publish('destroy', this);
this.fireEvent('destroy', this);
!this.isSilent() && this.fireEvent('destroy', this);
return this;

@@ -304,3 +280,2 @@ },

['clone', 'subset', 'map', 'filter', 'every', 'some', 'keys', 'values', 'getLength', 'keyOf', 'contains', 'toQueryString'].each(function(method){
//['clone', 'subset', 'keys', 'values', 'getLength', 'contains'].each(function(method){
Model.implement(method, function(){

@@ -307,0 +282,0 @@ return Object[method].apply( Object, [this._data].append( Array.from(arguments) ) );

@@ -1,6 +0,4 @@

exports.View={}.undefined;with(require("../lib/class-extras/Source/Class.Binds.js"))
with(require("../lib/util/Is"))
exports.View={}.undefined;with(require("../utilities/Is"))
with(exports)(function(){with(this){
require: '../lib/class-extras/Source/Class.Binds.js', '../lib/util/Is';
// require: '../lib/util/Is';
require: '../utilities/Is';

@@ -10,9 +8,13 @@ exports: View

// (function(context){
var Unit = require('../lib/company/Source/Company').Unit;
var Unit = require('company').Unit;
//var Is = require('is')
// creates functions to subscribe/unsubscribe based on handlers
var currySub = function(bindType){
var subCurry = function(bindType){
return function(){
var prefix = this.getSubPrefix();
var prefix = this.getPrefix();
// Prepare the prefix to prepend to the keys for subscribe/unsubscribing
prefix && (prefix += '.');
Object.each(this.subscriberMap, function(val, key){

@@ -39,13 +41,7 @@ var methods = Array.from(val),

var View = new Class({
Extends: Unit,
Implements: [Class.Binds, Options, Unit],
Implements: [Class.Binds, Options],
subPrefix: undefined,
// Model publishers / View methods mapping
subscribeMap: undefined,
eventsMap: undefined,
element: undefined,

@@ -58,7 +54,2 @@

// ,'change:id': function(){}
},
eventsMap: {
// 'click': 'create',
// 'focus': ['focus'],
// 'click:relay(a)': function(){}
}

@@ -76,4 +67,2 @@ },

this.eventsMap = this.options.eventsMap;
this.setPrefix(this.options.Prefix);

@@ -90,55 +79,9 @@

attachEvents: function(){
var events = this.eventsMap,
element = this.element;
attachEvents: function(){ return this; },
if (element && events) {
Object.each(events, function(val, key){
var methods = Array.from(val),
len = fnc.length,
i = 0, method;
detachEvents: function(){ return this; },
while(len--){
method = methods[i++];
this.element.addEvent(key, Is.Function(method) ? method : this.bound(method));
}
}, this);
}
bindModel: subCurry('subscribe'),
return this;
},
detachEvents: function(){
var events = this.eventsMap,
element = this.element;
if (element && events) {
Object.each(events, function(val, key){
var methods = Array.from(val),
len = fnc.length,
i = 0, method;
while(len--){
method = methods[i++];
this.element.removeEvent(key, Is.Function(method) ? method : this.bound(method));
}
}, this);
}
return this;
},
setSubPrefix: function(){
var prefix = this.getPrefix();
this.subPrefix = prefix ? (prefix + '.') : prefix;
},
getSubPrefix: function(){
var subPrefix = this.subPrefix;
return subPrefix != void 0 ? subPrefix : (this.setSubPrefix(), this.subPrefix);
},
bindModel: currySub('subscribe'),
unbindModel: currySub('unsubscribe'),
unbindModel: subCurry('unsubscribe'),

@@ -168,2 +111,3 @@ create: function(){

// })(typeof exports != 'undefined' ? exports : window);
}}.call(exports));

@@ -23,7 +23,9 @@ (function(modules) {

exports : Collection;
var Silence = require("4");
var Collection = new Class({
Implements: [ Events, Options ],
Implements: [ Events, Options, Silence ],
_models: [],
options: {
Model: Model
Model: Model,
silent: false
},

@@ -36,2 +38,3 @@ initialize: function(models, options) {

this._Model = this.options.Model;
this.silence(this.options.silent);
if (models) {

@@ -48,2 +51,3 @@ this.add(models);

if (!this.hasModel(model)) {
model.addEvent("destroy", this.remove.bind(this));
this._models.push(model);

@@ -55,3 +59,3 @@ this.signalAdd(model);

add: function() {
var models = arguments, len = models.length, i = 0;
var models = Array.from(arguments).flatten(), len = models.length, i = 0;
while (len--) {

@@ -74,5 +78,2 @@ this._add(models[i++]);

_remove: function(model) {
if (model.destroy) {
model.destroy();
}
this._models.erase(model);

@@ -83,3 +84,3 @@ this.signalRemove(model);

remove: function() {
var models = Array.from(arguments), l = models.length, i = 0;
var models = Array.from(arguments).flatten(), l = models.length, i = 0;
while (l--) {

@@ -90,2 +91,17 @@ this._remove(models[i++]);

},
replace: function(oldModel, newModel, signal) {
var index;
if (oldModel && newModel) {
index = this.indexOf(oldModel);
if (index > -1) {
newModel = new this._Model(newModel);
this._models.splice(index, 1, newModel);
if (signal) {
this.signalAdd(newModel);
this.signalRemove(oldModel);
}
}
}
return this;
},
empty: function() {

@@ -97,11 +113,11 @@ this.remove.apply(this, this._models);

signalAdd: function(model) {
this.fireEvent("add", [ this, model ]);
!this.isSilent() && this.fireEvent("add", [ this, model ]);
return this;
},
signalRemove: function(model) {
this.fireEvent("remove", [ this, model ]);
!this.isSilent() && this.fireEvent("remove", [ this, model ]);
return this;
},
signalEmpty: function() {
this.fireEvent("empty", this);
!this.isSilent() && this.fireEvent("empty", this);
return this;

@@ -117,3 +133,3 @@ },

Collection.implement(method, function() {
return Array[method].apply(Array, [ this._models ].append(Array.from(arguments)));
return Array.prototype[method].apply(this._models, arguments);
});

@@ -130,2 +146,3 @@ });

exports : Model;
var Silence = require("4");
var createGetter = function(type) {

@@ -139,3 +156,3 @@ var isPrevious = type == "_previousData" || void 0;

var Model = new Class({
Implements: [ Events, Options ],
Implements: [ Events, Options, Silence ],
_data: {},

@@ -148,3 +165,4 @@ _changed: false,

accessors: {},
defaults: {}
defaults: {},
silent: false
},

@@ -159,3 +177,4 @@ initialize: function(data, options) {

this.setOptions(options);
this.setAccessor(Object.clone(this.options.accessors));
this.setAccessor(this.options.accessors);
this.silence(this.options.silent);
if (data) {

@@ -232,11 +251,11 @@ this._data = Object.merge({}, this.options.defaults, data);

signalChange: function() {
this.fireEvent("change", this);
!this.isSilent() && this.fireEvent("change", this);
return this;
},
signalChangeProperty: function(prop, val) {
this.fireEvent("change:" + prop, [ this, prop, val ]);
!this.isSilent() && this.fireEvent("change:" + prop, [ this, prop, val ]);
return this;
},
signalDestroy: function() {
this.fireEvent("destroy", this);
!this.isSilent() && this.fireEvent("destroy", this);
return this;

@@ -377,3 +396,16 @@ },

})(typeof exports != "undefined" ? exports : window);
},
"4": function(require, module, exports, global) {
var Silence = new Class({
_silent: false,
silence: function(silent) {
this._silent = !!silent;
return this;
},
isSilent: function() {
return !!this._silent;
}
});
exports = module.exports = Silence;
}
});
{
"name": "Neuro",
"description": "A MVC written with MooTools.",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT (http://mootools.net/license.txt)",

@@ -6,0 +6,0 @@ "main": "cjs/main.js",

@@ -6,3 +6,3 @@ Neuro

### Version: 0.1.0 (Alpha)
### Version: 0.1.1 (Alpha)

@@ -119,2 +119,2 @@ ### Influences:

* Add a Router mechanism
* Add a Sync mechanism
* Add a Sync mechanism

@@ -6,15 +6,8 @@ require: './Model';

// (function(context){
// var Unit = require('../lib/company/Source/Company').Unit;
var Silence = require('../mixins/silence');
var Collection = new Class({
// Extends: Unit,
Implements: [Events, Options, Silence],
Implements: [Events, Options],
//Implements: [Unit],
// Set prefix when Extending to differentiate against other Collections
// Prefix: '',
// Model: Model,
_models: [],

@@ -26,4 +19,4 @@

// onEmpty: function(){},
// Prefix: '',
Model: Model
Model: Model,
silent: false
},

@@ -40,6 +33,5 @@

// this.setPrefix(this.options.Prefix);
// Silent property determines whether model will excute signals
this.silence(this.options.silent);
// this.setupUnit();
if (models) {

@@ -56,3 +48,7 @@ this.add(models);

// Silent signaling by using detachUnit before adding
/**
* Private add method
* @param {Class} model A Model instance
* @return {Class} Collection Instance
*/
_add: function(model){

@@ -62,2 +58,6 @@ model = new this._Model(model);

if (!this.hasModel(model)) {
// Remove the model if it destroys itself.
model.addEvent('destroy', this.remove.bind(this));
this._models.push(model);

@@ -71,4 +71,14 @@

/**
* Add a model or models
* @param {Class || Array} A single Model instance or an array of Model instances
* @return {Class} Collection Instance
*
* @example
* collectionInstance.add(model);
* collectionInstance.add(model, model);
* collectionInstance.add([model, model, model]);
*/
add: function(){
var models = arguments,
var models = Array.from(arguments).flatten(),
len = models.length,

@@ -108,7 +118,8 @@ i = 0;

/**
* Private remove method
* @param {Class} model A Model instance
* @return {Class} Collection Instance
*/
_remove: function(model){
if (model.destroy) {
model.destroy();
}
this._models.erase(model);

@@ -121,4 +132,14 @@

/**
* Remove a model or models
* @param {Class || Array} A single Model instance or an array of Model instances
* @return {Class} Collection Instance
*
* @example
* collectionInstance.remove(model);
* collectionInstance.remove(model, model);
* collectionInstance.remove([model, model, model]);
*/
remove: function(){
var models = Array.from(arguments),
var models = Array.from(arguments).flatten(),
l = models.length,

@@ -134,2 +155,31 @@ i = 0;

/**
* Replace an existing model with a new one
* @param {Class} oldModel A Model instance that will be replaced with the new
* @param {Object || Class} newModel An object or Model instance that will replace the old
* @param {Boolean} signal A switch to signal add and remove event listeners
* @return {Class} Collection Instance
*/
replace: function(oldModel, newModel, signal){
var index;
if (oldModel && newModel) {
index = this.indexOf(oldModel);
if (index > -1) {
newModel = new this._Model(newModel);
this._models.splice(index, 1, newModel);
if (signal) {
this.signalAdd(newModel);
this.signalRemove(oldModel);
}
}
}
return this;
},
empty: function(){

@@ -144,4 +194,3 @@ this.remove.apply(this, this._models);

signalAdd: function(model){
// this.publish('add', [this, model]);
this.fireEvent('add', [this, model]);
!this.isSilent() && this.fireEvent('add', [this, model]);
return this;

@@ -151,5 +200,3 @@ },

signalRemove: function(model){
// Silent publishing by using detachUnit before removing
// this.publish('remove', [this, model]);
this.fireEvent('remove', [this, model]);
!this.isSilent() && this.fireEvent('remove', [this, model]);
return this;

@@ -159,4 +206,3 @@ },

signalEmpty: function(){
// this.publish('empty', this);
this.fireEvent('empty', this);
!this.isSilent() && this.fireEvent('empty', this);
return this;

@@ -172,5 +218,5 @@ },

['forEach', 'each', 'invoke', 'every', 'filter', 'clean', 'indexOf', 'map', 'some', 'associate', 'link', 'contains', /*'append',*/ 'getLast', 'getRandom', /*'include', 'combine', 'erase', 'empty',*/ 'flatten', 'pick'].each(function(method){
['forEach', 'each', 'invoke', 'every', 'filter', 'clean', 'indexOf', 'map', 'some', 'associate', 'link', 'contains', 'getLast', 'getRandom', 'flatten', 'pick'].each(function(method){
Collection.implement(method, function(){
return Array[method].apply( Array, [this._models].append( Array.from(arguments) ) );
return Array.prototype[method].apply(this._models, arguments);
});

@@ -177,0 +223,0 @@ });

@@ -5,28 +5,6 @@ require: '../lib/util/Is';

/*
---
name: Model
// (function(context){
description: Model to handle data
var Silence = require('../mixins/silence');
version: .10
license: TBD
authors:
- Garrick Cheung
requires:
- MooTools-Core/1.3
- Company
- Is.js
provides: [Model]
...
*/
// (function(context){
// var Unit = require('../lib/company/Source/Company').Unit;
var createGetter = function(type){

@@ -50,6 +28,4 @@ /**

var Model = new Class({
// Extends: Unit,
Implements: [Events, Options, Silence],
Implements: [Events, Options],
_data: {},

@@ -76,5 +52,5 @@

// onDestroy: function(){},
// Prefix: '',
accessors: {},
defaults: {}
defaults: {},
silent: false
},

@@ -93,4 +69,7 @@

this.setAccessor(Object.clone(this.options.accessors));
this.setAccessor(this.options.accessors);
// Silent property determines whether model will excute signals
this.silence(this.options.silent);
if (data) { this._data = Object.merge({}, this.options.defaults, data); }

@@ -259,4 +238,3 @@

signalChange: function(){
// this.publish('change', this);
this.fireEvent('change', this);
!this.isSilent() && this.fireEvent('change', this);
return this;

@@ -266,4 +244,3 @@ },

signalChangeProperty: function(prop, val){
// this.publish('change:' + prop, [this, prop, val]);
this.fireEvent('change:' + prop, [this, prop, val]);
!this.isSilent() && this.fireEvent('change:' + prop, [this, prop, val]);
return this;

@@ -273,4 +250,3 @@ },

signalDestroy: function(){
// this.publish('destroy', this);
this.fireEvent('destroy', this);
!this.isSilent() && this.fireEvent('destroy', this);
return this;

@@ -302,3 +278,2 @@ },

['clone', 'subset', 'map', 'filter', 'every', 'some', 'keys', 'values', 'getLength', 'keyOf', 'contains', 'toQueryString'].each(function(method){
//['clone', 'subset', 'keys', 'values', 'getLength', 'contains'].each(function(method){
Model.implement(method, function(){

@@ -305,0 +280,0 @@ return Object[method].apply( Object, [this._data].append( Array.from(arguments) ) );

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

require: '../lib/class-extras/Source/Class.Binds.js', '../lib/util/Is';
// require: '../lib/util/Is';
require: '../utilities/Is';

@@ -7,9 +6,13 @@ exports: View

// (function(context){
var Unit = require('../lib/company/Source/Company').Unit;
var Unit = require('company').Unit;
//var Is = require('is')
// creates functions to subscribe/unsubscribe based on handlers
var currySub = function(bindType){
var subCurry = function(bindType){
return function(){
var prefix = this.getSubPrefix();
var prefix = this.getPrefix();
// Prepare the prefix to prepend to the keys for subscribe/unsubscribing
prefix && (prefix += '.');
Object.each(this.subscriberMap, function(val, key){

@@ -36,13 +39,7 @@ var methods = Array.from(val),

var View = new Class({
Extends: Unit,
Implements: [Class.Binds, Options, Unit],
Implements: [Class.Binds, Options],
subPrefix: undefined,
// Model publishers / View methods mapping
subscribeMap: undefined,
eventsMap: undefined,
element: undefined,

@@ -55,7 +52,2 @@

// ,'change:id': function(){}
},
eventsMap: {
// 'click': 'create',
// 'focus': ['focus'],
// 'click:relay(a)': function(){}
}

@@ -73,4 +65,2 @@ },

this.eventsMap = this.options.eventsMap;
this.setPrefix(this.options.Prefix);

@@ -87,55 +77,9 @@

attachEvents: function(){
var events = this.eventsMap,
element = this.element;
attachEvents: function(){ return this; },
if (element && events) {
Object.each(events, function(val, key){
var methods = Array.from(val),
len = fnc.length,
i = 0, method;
detachEvents: function(){ return this; },
while(len--){
method = methods[i++];
this.element.addEvent(key, Is.Function(method) ? method : this.bound(method));
}
}, this);
}
bindModel: subCurry('subscribe'),
return this;
},
detachEvents: function(){
var events = this.eventsMap,
element = this.element;
if (element && events) {
Object.each(events, function(val, key){
var methods = Array.from(val),
len = fnc.length,
i = 0, method;
while(len--){
method = methods[i++];
this.element.removeEvent(key, Is.Function(method) ? method : this.bound(method));
}
}, this);
}
return this;
},
setSubPrefix: function(){
var prefix = this.getPrefix();
this.subPrefix = prefix ? (prefix + '.') : prefix;
},
getSubPrefix: function(){
var subPrefix = this.subPrefix;
return subPrefix != void 0 ? subPrefix : (this.setSubPrefix(), this.subPrefix);
},
bindModel: currySub('subscribe'),
unbindModel: currySub('unsubscribe'),
unbindModel: subCurry('unsubscribe'),

@@ -164,2 +108,2 @@ create: function(){

});
// })(typeof exports != 'undefined' ? exports : window);
// })(typeof exports != 'undefined' ? exports : window);

@@ -28,2 +28,14 @@ buster.testCase('Neuro Collection', {

'should add a model instance if it does not exist in the Collection instance': function(){
var model = new Neuro.Model(this.mockData);
this.mockCollection.add(model, model);
assert.same(this.mockCollection._models.length, 1);
assert.equals(model, this.mockCollection.get(0));
assert.equals(model.getData(), this.mockCollection.get(0).getData());
},
'should get a Model instance / instances by index number': function(){

@@ -56,2 +68,14 @@ var model, models;

'should replace an existing model with a new one': function(){
var oldModel, test = {e: false};
this.mockCollection.add(this.mockData, {d: true});
oldModel = this.mockCollection.get(0);
this.mockCollection.replace(oldModel, test);
assert.equals(test, this.mockCollection.get(0).getData());
},
'should empty the Collection instance of all models': function(){

@@ -113,2 +137,44 @@ var models = this.mockCollection._models;

'should trigger add and remove events during replace if signaled to': function(){
var addSpy = this.spy(),
removeSpy = this.spy(),
newModel = new Neuro.Model(this.mockData),
oldModel = new Neuro.Model(this.mockData).set('d', true)
collection = this.mockCollection;
collection.add(oldModel);
collection.addEvent('add', addSpy);
collection.addEvent('remove', removeSpy);
collection.replace(oldModel, newModel, true);
assert.called(addSpy);
assert.calledWith(addSpy, collection, newModel);
assert.called(removeSpy);
assert.calledWith(removeSpy, collection, oldModel);
},
'should enable/disable signal execution with the silence method': function(){
var spy = this.spy(),
collection = this.mockCollection,
model1 = new Neuro.Model(this.mockData),
model2 = new Neuro.Model(this.mockData);
collection.addEvent('add', spy);
collection.add(model1);
collection.silence(true);
collection.add(model2);
assert.equals(collection._models.length, 2);
assert.calledWith(spy, collection, model1);
refute.calledWith(spy, collection, model2);
},
'Array Methods': {

@@ -115,0 +181,0 @@ 'Each should loop over each Model instance': function(){

@@ -177,2 +177,20 @@ buster.testCase('Neuro Model', {

'should enable/disable signal execution with the silence method': function(){
var spy = this.spy(),
model = new Neuro.Model();
model.addEvent('change', spy);
model.set('a', 'rts');
model.silence(true);
model.set('b', {});
assert.equals(model.get('a'), 'rts');
assert.equals(model.get('b'), {});
assert.calledOnceWith(spy, model);
},
'Object Methods': {

@@ -179,0 +197,0 @@ setUp: function(){

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