Socket
Socket
Sign inDemoInstall

can-globals

Package Overview
Dependencies
Maintainers
9
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 1.2.1 to 1.2.2

120

can-globals-test.js

@@ -25,40 +25,40 @@ 'use strict';

QUnit.test('getKeyValue of undefined property', function() {
QUnit.test('getKeyValue of undefined property', function(assert) {
globals = new Globals();
globals.getKeyValue('test');
ok(true);
assert.ok(true);
});
QUnit.test('setKeyValue of undefined property', function() {
QUnit.test('setKeyValue of undefined property', function(assert) {
globals = new Globals();
globals.setKeyValue('foo', 'bar');
equal(globals.getKeyValue('foo'), 'bar');
assert.equal(globals.getKeyValue('foo'), 'bar');
});
QUnit.test('deleteKeyValue of undefined property', function() {
QUnit.test('deleteKeyValue of undefined property', function(assert) {
globals = new Globals();
globals.deleteKeyValue('test');
ok(true);
assert.ok(true);
});
QUnit.test('onKeyValue of undefined property', function() {
QUnit.test('onKeyValue of undefined property', function(assert) {
globals = new Globals();
globals.onKeyValue('test', function() {});
ok(true);
assert.ok(true);
globals.offKeyValue('test');
});
QUnit.test('offKeyValue of undefined property', function() {
QUnit.test('offKeyValue of undefined property', function(assert) {
globals = new Globals();
globals.offKeyValue('test', function() {});
ok(true);
assert.ok(true);
});
QUnit.test('makeExport of undefined property', function() {
QUnit.test('makeExport of undefined property', function(assert) {
globals = new Globals();
globals.makeExport('test');
ok(true);
assert.ok(true);
});
QUnit.test('define with cache disabled', function() {
QUnit.test('define with cache disabled', function(assert) {
var getter = spy('bar');

@@ -70,6 +70,6 @@ globals = new Globals();

}, 5);
equal(getter.callCount, 5);
assert.equal(getter.callCount, 5);
});
QUnit.test('define with cache enabled', function() {
QUnit.test('define with cache enabled', function(assert) {
var getter = spy('bar');

@@ -81,26 +81,26 @@ globals = new Globals();

}, 5);
equal(getter.callCount, 1);
assert.equal(getter.callCount, 1);
});
QUnit.test('define and get a new property', function() {
QUnit.test('define and get a new property', function(assert) {
globals = new Globals();
globals.define('test', 'default');
equal(globals.getKeyValue('test'), 'default');
assert.equal(globals.getKeyValue('test'), 'default');
});
QUnit.test('setKeyValue of existing property to string', function() {
QUnit.test('setKeyValue of existing property to string', function(assert) {
globals = new Globals();
globals.define('test', 'default');
globals.setKeyValue('test', 'updated');
equal(globals.getKeyValue('test'), 'updated');
assert.equal(globals.getKeyValue('test'), 'updated');
});
QUnit.test('setKeyValue of existing property to undefined', function() {
QUnit.test('setKeyValue of existing property to undefined', function(assert) {
globals = new Globals();
globals.define('test', 'default');
globals.setKeyValue('test', undefined);
equal(globals.getKeyValue('test'), undefined);
assert.equal(globals.getKeyValue('test'), undefined);
});
QUnit.test('setKeyValue of existing property to a function', function() {
QUnit.test('setKeyValue of existing property to a function', function(assert) {
globals = new Globals();

@@ -111,6 +111,6 @@ globals.define('test', 'default');

});
equal(globals.getKeyValue('test'), 'foo');
assert.equal(globals.getKeyValue('test'), 'foo');
});
QUnit.test('setKeyValue on an existing property should reset cache', function(){
QUnit.test('setKeyValue on an existing property should reset cache', function(assert) {
var globals = new Globals();

@@ -125,6 +125,6 @@ var bar = function() {

});
equal(globals.getKeyValue('foo'), 'baz');
assert.equal(globals.getKeyValue('foo'), 'baz');
});
QUnit.test('deleteKeyValue to reset property to default', function() {
QUnit.test('deleteKeyValue to reset property to default', function(assert) {
var globals = new Globals();

@@ -134,6 +134,6 @@ globals.define('test', 'default');

globals.deleteKeyValue('test');
equal(globals.getKeyValue('test'), 'default');
assert.equal(globals.getKeyValue('test'), 'default');
});
QUnit.test('deleteKeyValue should clear cache', function() {
QUnit.test('deleteKeyValue should clear cache', function(assert) {
var globals = new Globals();

@@ -148,6 +148,6 @@ var bar = spy('bar');

globals.getKeyValue('foo');
equal(bar.callCount, 2);
assert.equal(bar.callCount, 2);
});
QUnit.test('listen for key change', function() {
QUnit.test('listen for key change', function(assert) {
var globals = new Globals();

@@ -161,4 +161,4 @@ var handler = spy();

globals.deleteKeyValue('test');
equal(handler.callCount, 2);
deepEqual(mapEvents(handler), [
assert.equal(handler.callCount, 2);
assert.deepEqual(mapEvents(handler), [
'updated',

@@ -170,3 +170,3 @@ 'default'

QUnit.test('remove event listener for key', function() {
QUnit.test('remove event listener for key', function(assert) {
var globals = new Globals();

@@ -178,28 +178,28 @@ var handler = spy();

globals.setKeyValue('test', 'updated');
equal(handler.callCount, 0);
assert.equal(handler.callCount, 0);
});
QUnit.test('makeExport of key', function() {
QUnit.test('makeExport of key', function(assert) {
var globals = new Globals();
globals.define('foo', 'bar');
var e = globals.makeExport('foo');
equal(e(), 'bar');
assert.equal(e(), 'bar');
e('baz');
equal(e(), 'baz');
assert.equal(e(), 'baz');
e(undefined);
equal(e(), 'bar');
assert.equal(e(), 'bar');
});
QUnit.test('reset export value with null (can-stache#288)', function() {
QUnit.test('reset export value with null (can-stache#288)', function(assert) {
var globals = new Globals();
globals.define('foo', 'bar');
var e = globals.makeExport('foo');
equal(e(), 'bar');
assert.equal(e(), 'bar');
e('baz');
equal(e(), 'baz');
assert.equal(e(), 'baz');
e(null);
equal(e(), 'bar');
assert.equal(e(), 'bar');
});
QUnit.test('reset cleares cache on all keys', function(){
QUnit.test('reset cleares cache on all keys', function(assert) {
var globals = new Globals();

@@ -219,7 +219,7 @@ var bar = spy('bar');

}, 5);
equal(bar.callCount, 2);
equal(qux.callCount, 2);
assert.equal(bar.callCount, 2);
assert.equal(qux.callCount, 2);
});
QUnit.test('reset should reset all keys to default value (#31)', function(){
QUnit.test('reset should reset all keys to default value (#31)', function(assert) {
var globals = new Globals();

@@ -231,7 +231,7 @@ globals.define('foo', 'bar');

globals.reset();
equal(globals.getKeyValue('foo'), 'bar');
equal(globals.getKeyValue('baz'), 'qux');
assert.equal(globals.getKeyValue('foo'), 'bar');
assert.equal(globals.getKeyValue('baz'), 'qux');
});
QUnit.test('reset triggers events', function(){
QUnit.test('reset triggers events', function(assert) {
var globals = new Globals();

@@ -247,4 +247,4 @@ var fooHandler = spy();

globals.reset();
equal(fooHandler.callCount, 1);
equal(barHandler.callCount, 1);
assert.equal(fooHandler.callCount, 1);
assert.equal(barHandler.callCount, 1);
globals.offKeyValue('foo');

@@ -254,3 +254,3 @@ globals.offKeyValue('bar');

QUnit.test('export helper value can be set to a function', function(){
QUnit.test('export helper value can be set to a function', function(assert) {
var globals = new Globals();

@@ -263,10 +263,10 @@ var foo = spy();

fooExport(foo);
QUnit.equal(typeof fooExport(), 'function');
QUnit.equal(foo.callCount, 0);
assert.equal(typeof fooExport(), 'function');
assert.equal(foo.callCount, 0);
fooExport()();
QUnit.equal(foo.callCount, 1);
assert.equal(foo.callCount, 1);
});
QUnit.test('onKeyValue should dispatch the resolved value (#29)', function(){
QUnit.test('onKeyValue should dispatch the resolved value (#29)', function(assert) {
var globals = new Globals();

@@ -276,3 +276,3 @@ var foo = 'foo';

globals.onKeyValue('foo', function(value){
QUnit.equal(value, foo);
assert.equal(value, foo);
});

@@ -285,3 +285,3 @@ globals.setKeyValue('foo', function(){

QUnit.test('onKeyValue should not trigger multiple calls of the value function (#33)', function(){
QUnit.test('onKeyValue should not trigger multiple calls of the value function (#33)', function(assert) {
var globals = new Globals();

@@ -293,3 +293,3 @@ var baz = spy('baz');

globals.getKeyValue('foo');
equal(baz.callCount, 1);
assert.equal(baz.callCount, 1);
});

@@ -12,7 +12,7 @@ 'use strict';

test('basics', function(){
QUnit.test('basics', function(assert) {
if(isBrowserWindow()) {
ok(getGlobal() === window);
assert.ok(getGlobal() === window);
} else {
ok(getGlobal() === global);
assert.ok(getGlobal() === global);
}

@@ -23,7 +23,7 @@ });

QUnit.module('in Node with fake window', {
setup: function(){
beforeEach: function(assert) {
this.oldWindow = global.window;
global.window = {};
},
teardown: function(){
afterEach: function(assert) {
global.window = this.oldWindow;

@@ -33,5 +33,5 @@ }

test('Gets the Node global', function(){
ok(getGlobal() === global);
QUnit.test('Gets the Node global', function(assert) {
assert.ok(getGlobal() === global);
});
}

@@ -8,4 +8,4 @@ 'use strict';

QUnit.test("basics", function(){
equal(typeof isBrowserWindow(), "boolean");
QUnit.test("basics", function(assert) {
assert.equal(typeof isBrowserWindow(), "boolean");
});

@@ -8,4 +8,4 @@ 'use strict';

QUnit.test("basics", function(){
equal(typeof isWebWorker(), "boolean");
QUnit.test("basics", function(assert) {
assert.equal(typeof isWebWorker(), "boolean");
});
{
"name": "can-globals",
"version": "1.2.1",
"version": "1.2.2",
"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.",

@@ -48,8 +48,7 @@ "main": "can-globals.js",

"jshint": "^2.9.5",
"qunitjs": "^2.4.0",
"steal": "^1.5.6",
"steal-qunit": "^1.0.1",
"steal-tools": "^1.7.0",
"testee": "^0.7.0"
"steal": "^2.2.1",
"steal-qunit": "^2.0.0",
"steal-tools": "^2.2.1",
"testee": "^0.9.0"
}
}
# can-globals
[![Join the chat at https://gitter.im/canjs/canjs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/canjs/canjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join our Slack](https://img.shields.io/badge/slack-join%20chat-611f69.svg)](https://www.bitovi.com/community/slack?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join our Discourse](https://img.shields.io/discourse/https/forums.bitovi.com/posts.svg)](https://forums.bitovi.com/?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/canjs/can-globals/blob/master/LICENSE)
[![npm version](https://badge.fury.io/js/can-globals.svg)](https://www.npmjs.com/package/can-globals)
[![Build Status](https://travis-ci.org/canjs/can-globals.svg?branch=master)](https://travis-ci.org/canjs/can-globals)
[![Build Status](https://travis-ci.org/canjs/can-globals.svg?branch=master)](https://travis-ci.org/canjs/can-globals) [![Greenkeeper badge](https://badges.greenkeeper.io/canjs/can-globals.svg)](https://greenkeeper.io/)

@@ -8,0 +9,0 @@ An environment agnostic container for global variables. Useful for testing and server-side rendering (SSR), typically used internally by CanJS.

@@ -9,8 +9,8 @@ "use strict";

QUnit.assert.async = function () {
QUnit.stop();
var done = assert.async();
return function done (error) {
if (error) {
return QUnit.ok(false, '' + error);
return assert.ok(false, '' + error);
}
QUnit.start();
done();
};

@@ -22,5 +22,5 @@ };

} else if (isQunit) {
module.exports = require('qunitjs');
module.exports = require('qunit');
} else {
module.exports = require('steal-qunit');
}
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