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

can-stache-key

Package Overview
Dependencies
Maintainers
7
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-stache-key - npm Package Compare versions

Comparing version 1.0.0-pre.11 to 1.0.0-pre.12

72

can-stache-key-test.js

@@ -5,4 +5,4 @@ var observeReader = require("can-stache-key");

var eventQueue = require('can-event-queue/map/legacy/legacy');
var dev = require('can-util/js/dev/dev');
var SimpleObservable = require("can-simple-observable");
var testHelpers = require('can-test-helpers');

@@ -198,27 +198,3 @@ var SimpleMap = require("can-simple-map");

});
if(System.env.indexOf("production") < 0) {
test("promise readers throw errors (#70)", function() {
expect(1);
var oldError = dev.error;
dev.error = function() {
dev.error = oldError;
ok(true);
start();
};
var promise = new Promise(function(resolve, reject) {
setTimeout(function() {
reject("Something");
}, 0);
});
var c = new Observation(function() {
return observeReader.read(promise, observeReader.reads("value"), {}).value;
}, null, { updater: function() {} });
c.start();
stop();
});
}
QUnit.test("reads can be passed a number (can-stache#207)", function(){

@@ -256,1 +232,47 @@ var reads = observeReader.reads(0);

});
testHelpers.dev.devOnlyTest("a warning is displayed when functions are called by read()", function() {
var teardown = testHelpers.dev.willWarn(/"func" is being called as a function/);
var func = function() {
QUnit.ok(true, "method called");
};
var data = { func: func };
var reads = observeReader.reads("func");
observeReader.read(data, reads, {
warnOnFunctionCall: "A Warning"
});
QUnit.equal(teardown(), 1, "warning displayed");
});
testHelpers.dev.devOnlyTest("a warning is displayed when methods on observables are called by read()", function() {
var teardown = testHelpers.dev.willWarn(/"func" is being called as a function/);
var func = function() {
QUnit.ok(true, "method called");
};
var data = new SimpleMap({ func: func });
var reads = observeReader.reads("func");
observeReader.read(data, reads, {
callMethodsOnObservables: true
});
QUnit.equal(teardown(), 1, "warning displayed");
});
testHelpers.dev.devOnlyTest("a warning is not displayed when functions are read but not called", function() {
var teardown = testHelpers.dev.willWarn(/"func" is being called as a function/);
var func = function() {
QUnit.ok(false, "method called");
};
var data = new SimpleMap({ func: func });
var reads = observeReader.reads("@func");
observeReader.read(data, reads, {
callMethodsOnObservables: true,
warnOnFunctionCall: "A Warning"
});
QUnit.equal(teardown(), 0, "warning not displayed");
});
var Observation = require('can-observation');
var dev = require('can-util/js/dev/dev');
var dev = require('can-log/dev/dev');
var each = require('can-util/js/each/each');

@@ -164,3 +164,14 @@ var canSymbol = require("can-symbol");

}
else if(options.callMethodsOnObservables && canReflect.isObservableLike(prev) && canReflect.isMapLike(prev)) {
//!steal-remove-start
dev.warn(
(options.filename ? options.filename + ':' : '') +
(options.lineNumber ? options.lineNumber + ': ' : '') +
'"' + reads[0].key + '" is being called as a function.\n' +
'\tThis will not happen automatically in an upcoming release.\n' +
'\tYou should call it explicitly using "' + reads[0].key + '()".\n\n'
);
//!steal-remove-end
if(options.callMethodsOnObservables && canReflect.isObservableLike(prev) && canReflect.isMapLike(prev)) {
return value.apply(prev, options.args || []);

@@ -171,2 +182,3 @@ }

}
return value.apply(prev, options.args || []);

@@ -240,3 +252,2 @@ }

dev.warn("Use %"+prop.key+" in place of @"+prop.key+".");
//!steal-remove-end

@@ -243,0 +254,0 @@

{
"name": "can-stache-key",
"version": "1.0.0-pre.11",
"version": "1.0.0-pre.12",
"description": "Read and write keys on a value",

@@ -47,8 +47,9 @@ "homepage": "https://canjs.com",

"dependencies": {
"can-log": "^0.1.2",
"can-namespace": "1.0.0",
"can-observation": "^4.0.0-pre.2",
"can-reflect": "^1.1.0",
"can-reflect-promise": "^2.0.0-pre.2",
"can-symbol": "^1.0.0",
"can-util": "^3.9.0",
"can-observation": "^4.0.0-pre.2"
"can-util": "^3.9.0"
},

@@ -59,2 +60,3 @@ "devDependencies": {

"can-simple-observable": "^2.0.0-pre.11",
"can-test-helpers": "^1.1.0",
"detect-cyclic-packages": "^1.1.0",

@@ -61,0 +63,0 @@ "jshint": "^2.9.1",

Sorry, the diff of this file is not supported yet

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