Socket
Socket
Sign inDemoInstall

can-simple-observable

Package Overview
Dependencies
15
Maintainers
9
Versions
55
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.4.1 to 2.4.2

34

async/async-test.js

@@ -31,11 +31,11 @@ var QUnit = require('steal-qunit');

// Unbound and unobserved behavior
QUnit.equal(canReflect.getValue(obs), 'default', 'getValue unbound');
assert.equal(canReflect.getValue(obs), 'default', 'getValue unbound');
// Unbound , being observed behavior
ObservationRecorder.start();
QUnit.equal(canReflect.getValue(obs), undefined, "getValue being bound");
assert.equal(canReflect.getValue(obs), undefined, "getValue being bound");
var dependencies = ObservationRecorder.stop();
QUnit.ok(!dependencies.valueDependencies.has(value), "did not record value");
QUnit.ok(dependencies.valueDependencies.has(obs), "did record observable");
QUnit.equal(dependencies.valueDependencies.size, 1, "only one value to listen to");
assert.ok(!dependencies.valueDependencies.has(value), "did not record value");
assert.ok(dependencies.valueDependencies.has(obs), "did record observable");
assert.equal(dependencies.valueDependencies.size, 1, "only one value to listen to");

@@ -46,6 +46,6 @@ var changes = 0;

if(changes === 1) {
QUnit.equal(newValue, 'a', 'onValue a');
assert.equal(newValue, 'a', 'onValue a');
value.set(2);
} else {
QUnit.equal(newValue, 'b', 'onValue b');
assert.equal(newValue, 'b', 'onValue b');
done();

@@ -59,3 +59,3 @@ }

QUnit.test("get and set Priority", function(){
QUnit.test("get and set Priority", function(assert) {
var value = new SimpleObservable(1);

@@ -80,6 +80,6 @@

QUnit.equal(canReflect.getPriority(obs), 5, "set priority");
assert.equal(canReflect.getPriority(obs), 5, "set priority");
});
QUnit.test("prevent a getter returning undefined from overwriting last resolved value", function(){
QUnit.test("prevent a getter returning undefined from overwriting last resolved value", function(assert) {
var value = new SimpleObservable(1);

@@ -96,10 +96,10 @@

obs.on(function(){});
QUnit.equal( obs.get(), null );
assert.equal( obs.get(), null );
value.set(2);
QUnit.equal( obs.get(), 4 );
assert.equal( obs.get(), 4 );
});
QUnit.test("prevent a getter returning undefined from overwriting last resolved value at the start", function(){
QUnit.test("prevent a getter returning undefined from overwriting last resolved value at the start", function(assert) {
var value = new SimpleObservable(1);

@@ -111,6 +111,6 @@

obs.on(function(){});
QUnit.equal( obs.get(), 2 );
assert.equal( obs.get(), 2 );
value.set(2);
QUnit.equal( obs.get(), 4 );
assert.equal( obs.get(), 4 );

@@ -277,3 +277,3 @@ });

QUnit.test("proactive binding doesn't last past binding (can-stache#486)", function(){
QUnit.test("proactive binding doesn't last past binding (can-stache#486)", function(assert) {
var value = new SimpleObservable(2);

@@ -313,4 +313,4 @@

QUnit.equal(readCount, 1, "internal observation only updated once");
assert.equal(readCount, 1, "internal observation only updated once");
});

@@ -13,16 +13,16 @@ var steal = require("@steal");

QUnit.test('basics', function(){
expect(5);
QUnit.test('basics', function(assert) {
assert.expect(5);
var obs = new SimpleObservable('one');
QUnit.equal(canReflect.getValue(obs), 'one', 'getValue');
assert.equal(canReflect.getValue(obs), 'one', 'getValue');
canReflect.setValue(obs, 'two');
ObservationRecorder.start();
QUnit.equal(canReflect.getValue(obs), 'two', 'setValue');
assert.equal(canReflect.getValue(obs), 'two', 'setValue');
var dependencies = ObservationRecorder.stop();
QUnit.ok(dependencies.valueDependencies.has(obs), "was recorded");
assert.ok(dependencies.valueDependencies.has(obs), "was recorded");
var handler = function(newValue) {
QUnit.equal(newValue, 'three', 'onValue');
assert.equal(newValue, 'three', 'onValue');
};

@@ -35,19 +35,19 @@ canReflect.onValue(obs, handler);

QUnit.equal(canReflect.getValue(obs), 'four', 'getValue after offValue');
assert.equal(canReflect.getValue(obs), 'four', 'getValue after offValue');
});
QUnit.test('basics with .value', function(){
expect(5);
QUnit.test('basics with .value', function(assert) {
assert.expect(5);
var obs = new SimpleObservable('one');
QUnit.equal(obs.value, 'one', 'getValue');
assert.equal(obs.value, 'one', 'getValue');
obs.value = 'two';
ObservationRecorder.start();
QUnit.equal(obs.value, 'two', 'setValue');
assert.equal(obs.value, 'two', 'setValue');
var dependencies = ObservationRecorder.stop();
QUnit.ok(dependencies.valueDependencies.has(obs), "was recorded");
assert.ok(dependencies.valueDependencies.has(obs), "was recorded");
var handler = function(newValue) {
QUnit.equal(newValue, 'three', 'onValue');
assert.equal(newValue, 'three', 'onValue');
};

@@ -60,3 +60,3 @@ canReflect.onValue(obs, handler);

QUnit.equal(obs.value, 'four', 'getValue after offValue');
assert.equal(obs.value, 'four', 'getValue after offValue');
});

@@ -63,0 +63,0 @@

@@ -50,6 +50,6 @@ var QUnit = require("steal-qunit");

if (supportsFunctionNames) {
onlyDevTest("observable has a helpful name", function() {
onlyDevTest("observable has a helpful name", function(assert) {
var outer = {inner: {key: "hello"}};
var observable = keyObservable(outer, "inner.key");
QUnit.equal(
assert.equal(
canReflect.getName(observable),

@@ -56,0 +56,0 @@ "keyObservable<Object{}.inner.key>",

@@ -8,11 +8,12 @@ var QUnit = require('steal-qunit');

QUnit.test('basics', 4, function(){
QUnit.test('basics', function(assert) {
assert.expect(4);
var compute = makeCompute(new SimpleObservable(5));
QUnit.equal( compute(), 5, "read");
assert.equal( compute(), 5, "read");
compute(6);
QUnit.equal( compute(), 6, "write");
assert.equal( compute(), 6, "write");
compute.on("change", function(ev, newVal, oldVal){
QUnit.equal(newVal, 7, "bound newVal");
QUnit.equal(oldVal, 6, "bound newVal");
assert.equal(newVal, 7, "bound newVal");
assert.equal(oldVal, 6, "bound newVal");
});

@@ -22,3 +23,3 @@ compute(7);

QUnit.test("unbind('change')", function(){
QUnit.test("unbind('change')", function(assert) {
var observable = new SimpleObservable(5);

@@ -28,5 +29,5 @@ var compute = makeCompute(observable);

compute.on('change', function(){});
QUnit.equal(observable.handlers.get([]).length, 2, "2 observables");
assert.equal(observable.handlers.get([]).length, 2, "2 observables");
compute.unbind("change");
QUnit.equal(observable.handlers.get([]).length, 0, "2 observables");
assert.equal(observable.handlers.get([]).length, 0, "2 observables");
});
{
"name": "can-simple-observable",
"version": "2.4.1",
"version": "2.4.2",
"description": "Create an observable value.",

@@ -56,8 +56,8 @@ "homepage": "https://canjs.com/doc/can-simple-observable.html",

"jshint": "^2.9.1",
"steal": "^1.3.1",
"steal-qunit": "^1.0.1",
"steal-tools": "^1.2.0",
"testee": "^0.3.0"
"steal": "^2.2.1",
"steal-qunit": "^2.0.0",
"steal-tools": "^2.2.1",
"testee": "^0.9.0"
},
"license": "MIT"
}
# can-simple-observable
[![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-simple-observable/blob/master/LICENSE)

@@ -13,3 +14,3 @@ [![npm version](https://badge.fury.io/js/can-simple-observable.svg)](https://www.npmjs.com/package/can-simple-observable)

Read the [API docs on CanJS.com](https://canjs.com/doc/can-simple-observable.html).
Read the [can-simple-observable API docs on CanJS.com](https://canjs.com/doc/can-simple-observable.html).

@@ -26,3 +27,2 @@ ## Changelog

[MIT](https://github.com/canjs/can-simple-observable/blob/master/LICENSE.md)
[MIT](https://github.com/canjs/can-simple-observable/blob/master/LICENSE)

@@ -12,4 +12,4 @@ var QUnit = require('steal-qunit');

QUnit.test("timer with teardown", function(){
QUnit.stop();
QUnit.test("timer with teardown", function(assert) {
var done = assert.async();

@@ -33,19 +33,19 @@ var CALLS = [];

QUnit.equal( obs.get(), 0, "got initial value unbound");
QUnit.deepEqual(CALLS,["GENERATOR","TEARDOWN"], "initial unbound read");
assert.equal( obs.get(), 0, "got initial value unbound");
assert.deepEqual(CALLS,["GENERATOR","TEARDOWN"], "initial unbound read");
CALLS = [];
var handler = function(newVal){
QUnit.equal( newVal, 1, "got first emitted value");
QUnit.equal( obs.get(), 1, "got first emitted value");
QUnit.deepEqual(CALLS,["INTERVAL"], "emitted value");
assert.equal( newVal, 1, "got first emitted value");
assert.equal( obs.get(), 1, "got first emitted value");
assert.deepEqual(CALLS,["INTERVAL"], "emitted value");
CALLS = [];
obs.off(handler);
QUnit.deepEqual(CALLS,["TEARDOWN"], "emitted value");
QUnit.start();
assert.deepEqual(CALLS,["TEARDOWN"], "emitted value");
done();
};
obs.on(handler);
QUnit.equal( obs.get(), 0, "got initial value after bind");
QUnit.deepEqual(CALLS,["GENERATOR"], "initial bind");
assert.equal( obs.get(), 0, "got initial value after bind");
assert.deepEqual(CALLS,["GENERATOR"], "initial bind");
CALLS = [];

@@ -55,3 +55,4 @@

var queues = require("can-queues");
QUnit.test('basics listenTo', 14, function(assert){
QUnit.test('basics listenTo', function(assert){
assert.expect(14);
var number = new SimpleObservable(1);

@@ -64,3 +65,3 @@

var obs = new ResolverObservable(function testee(value){
QUnit.equal( value.resolve(6), 6, "resolve returns passed value");
assert.equal( value.resolve(6), 6, "resolve returns passed value");

@@ -71,3 +72,3 @@

assert.equal(this, map, "listenTo this is the context");
QUnit.equal( value.resolve(5), 5, "resolve returns passed value");
assert.equal( value.resolve(5), 5, "resolve returns passed value");
});

@@ -80,10 +81,10 @@

var listenHandlers = obs.binder[ canSymbol.for("can.meta") ].listenHandlers;
QUnit.equal(listenHandlers.size(), 0, "0 handlers after read");
assert.equal(listenHandlers.size(), 0, "0 handlers after read");
obs.on(function(newVal){
QUnit.equal(newVal, 5, "got the new value");
assert.equal(newVal, 5, "got the new value");
});
assert.equal(obs.get(), 6, "got unbound value");
listenHandlers = obs.binder[ canSymbol.for("can.meta") ].listenHandlers;
QUnit.equal(listenHandlers.size(), 1, "1 handlers after bind");
assert.equal(listenHandlers.size(), 1, "1 handlers after bind");
number.set(2);

@@ -95,3 +96,4 @@

QUnit.test("setter", 6, function(){
QUnit.test("setter",function(assert) {
assert.expect(6);
var state = new SimpleObservable("IL");

@@ -110,6 +112,6 @@

city.set("Chicago");
QUnit.equal(city.get(), "Chicago", "got unbound value");
assert.equal(city.get(), "Chicago", "got unbound value");
city.set("Rockford");
QUnit.equal(city.get(), "Rockford", "got unbound value after another set");
assert.equal(city.get(), "Rockford", "got unbound value after another set");

@@ -121,13 +123,13 @@ var CITIES = [];

QUnit.equal(city.get(), "Rockford", "got bound value after binding");
assert.equal(city.get(), "Rockford", "got bound value after binding");
state.set("CA");
QUnit.equal(city.get(), null, "updated city after state set");
assert.equal(city.get(), null, "updated city after state set");
city.set("San Jose");
QUnit.equal(city.get(), "San Jose", "updated city after state set");
assert.equal(city.get(), "San Jose", "updated city after state set");
QUnit.deepEqual(CITIES,[null,"San Jose"], "events right");
assert.deepEqual(CITIES,[null,"San Jose"], "events right");
});

@@ -234,3 +236,3 @@

QUnit.test("proactive binding doesn't last past binding (can-stache#486)", function(){
QUnit.test("proactive binding doesn't last past binding (can-stache#486)", function(assert) {
var v = new SimpleObservable(2);

@@ -259,7 +261,7 @@

QUnit.equal(readCount, 0, "internal observation only updated once");
assert.equal(readCount, 0, "internal observation only updated once");
});
QUnit.test("reading observables does not leak the observable read", function(){
QUnit.test("reading observables does not leak the observable read", function(assert) {
// if an observation is listening is reading this value, the value

@@ -281,11 +283,11 @@ // should not ObservationRecorder.add its deps

QUnit.equal(records.keyDependencies.size, 0, "there are no key dependencies");
QUnit.equal(records.valueDependencies.size, 0, "there are no valueDependencies");
assert.equal(records.keyDependencies.size, 0, "there are no key dependencies");
assert.equal(records.valueDependencies.size, 0, "there are no valueDependencies");
});
QUnit.test("initial value on lastSet can be set (can-define#397)", function () {
QUnit.test("initial value on lastSet can be set (can-define#397)", function(assert) {
var defaulted = new ResolverObservable(function(props) {
QUnit.equal(props.lastSet.get(), 5, "observable has default value");
assert.equal(props.lastSet.get(), 5, "observable has default value");
}, {}, 5);
defaulted.get();
});

@@ -15,3 +15,3 @@ var steal = require('@steal');

QUnit.test('basics', function(){
QUnit.test('basics', function(assert) {

@@ -26,3 +26,3 @@ var value = new SimpleObservable(2);

// Unbound and unobserved behavior
QUnit.equal(canReflect.getValue(obs), 2, 'getValue unbound');
assert.equal(canReflect.getValue(obs), 2, 'getValue unbound');

@@ -35,9 +35,9 @@

if(changes === 1) {
QUnit.equal(newValue, 4, 'set observable');
assert.equal(newValue, 4, 'set observable');
obs.set(3);
} else if(changes === 2){
QUnit.equal(newValue, 6, 'set observable in handler');
assert.equal(newValue, 6, 'set observable in handler');
value.set(3);
} else {
QUnit.equal(newValue, 9, 'set source');
assert.equal(newValue, 9, 'set source');
}

@@ -48,10 +48,10 @@ };

QUnit.equal( canReflect.getValue(obs), 9, "after bound");
assert.equal( canReflect.getValue(obs), 9, "after bound");
canReflect.offValue(obs, handler);
canReflect.setValue(obs, 5);
QUnit.equal( canReflect.getValue(obs), 15, "after unbound");
assert.equal( canReflect.getValue(obs), 15, "after unbound");
});
QUnit.test('basics with .value', function(){
QUnit.test('basics with .value', function(assert) {

@@ -66,3 +66,3 @@ var value = new SimpleObservable(2);

// Unbound and unobserved behavior
QUnit.equal(obs.value, 2, 'getValue unbound');
assert.equal(obs.value, 2, 'getValue unbound');

@@ -75,9 +75,9 @@

if(changes === 1) {
QUnit.equal(newValue, 4, 'set observable');
assert.equal(newValue, 4, 'set observable');
obs.value = (3);
} else if(changes === 2){
QUnit.equal(newValue, 6, 'set observable in handler');
assert.equal(newValue, 6, 'set observable in handler');
value.value = (3);
} else {
QUnit.equal(newValue, 9, 'set source');
assert.equal(newValue, 9, 'set source');
}

@@ -88,10 +88,10 @@ };

QUnit.equal( obs.value, 9, "after bound");
assert.equal( obs.value, 9, "after bound");
canReflect.offValue(obs, handler);
obs.value = 5;
QUnit.equal( obs.value, 15, "after unbound");
assert.equal( obs.value, 15, "after unbound");
});
QUnit.test("get and set Priority", function(){
QUnit.test("get and set Priority", function(assert) {
var value = new SimpleObservable(2);

@@ -107,3 +107,3 @@

QUnit.equal(canReflect.getPriority(obs), 5, "set priority");
assert.equal(canReflect.getPriority(obs), 5, "set priority");
});

@@ -205,3 +205,3 @@

QUnit.test("proactive binding doesn't last past binding (can-stache#486)", function(){
QUnit.test("proactive binding doesn't last past binding (can-stache#486)", function(assert) {
var value = new SimpleObservable(2);

@@ -227,4 +227,4 @@

QUnit.equal(readCount, 1, "internal observation only updated once");
assert.equal(readCount, 1, "internal observation only updated once");
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc