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

can-globals

Package Overview
Dependencies
Maintainers
5
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-globals - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

13

can-globals-proto.js

@@ -5,3 +5,3 @@ 'use strict';

function dispatch(key, value) {
function dispatch(key) {
// jshint -W040

@@ -11,5 +11,3 @@ var handlers = this.eventHandlers[key];

var handlersCopy = handlers.slice();
if (typeof value === 'function') {
value = value();
}
var value = this.getKeyValue(key);
for (var i = 0; i < handlersCopy.length; i++) {

@@ -260,3 +258,3 @@ handlersCopy[i](value);

property.cachedValue = undefined;
dispatch.call(this, key, property.value);
dispatch.call(this, key);
}

@@ -300,3 +298,3 @@ return this;

property.cachedValue = undefined;
dispatch.call(this, key, value);
dispatch.call(this, key);
return this;

@@ -327,4 +325,5 @@ };

if (this.properties.hasOwnProperty(key)) {
this.properties[key].value = this.properties[key].default;
this.properties[key].cachedValue = undefined;
dispatch.call(this, key, this.getKeyValue(key));
dispatch.call(this, key);
}

@@ -331,0 +330,0 @@ }

@@ -194,3 +194,3 @@ 'use strict';

QUnit.test('reset all keys', function(){
QUnit.test('reset cleares cache on all keys', function(){
var globals = new Globals();

@@ -214,2 +214,13 @@ var bar = spy('bar');

QUnit.test('reset should reset all keys to default value (#31)', function(){
var globals = new Globals();
globals.define('foo', 'bar');
globals.define('baz', 'qux');
globals.setKeyValue('foo', 'red');
globals.setKeyValue('baz', 'green');
globals.reset();
equal(globals.getKeyValue('foo'), 'bar');
equal(globals.getKeyValue('baz'), 'qux');
});
QUnit.test('reset triggers events', function(){

@@ -259,1 +270,11 @@ var globals = new Globals();

});
QUnit.test('onKeyValue should not trigger multiple calls of the value function (#33)', function(){
var globals = new Globals();
var baz = spy('baz');
globals.define('foo', 'bar');
globals.onKeyValue('foo', function(){});
globals.setKeyValue('foo', baz);
globals.getKeyValue('foo');
equal(baz.callCount, 1);
});
{
"name": "can-globals",
"version": "0.2.5",
"version": "0.2.6",
"description": "This module provides a dependency injection container. Modules may define a key and specify a default value (which can be static, cached lazy, or dynamic lazy), but other code can set and reset the value as needed. There is also an event system, for alerting on value changes, both specific to a key and for any key.",

@@ -5,0 +5,0 @@ "main": "can-globals.js",

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