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.12 to 1.0.0-pre.13

45

can-stache-key-test.js

@@ -111,3 +111,3 @@ var observeReader = require("can-stache-key");

test("foundObservable called with observable object (#7)", function(){
var map = {
var map = new SimpleMap({
isSaving: function(){

@@ -117,3 +117,3 @@ Observation.add(this, "_saving");

addEventListener: function(){}
};
});

@@ -125,3 +125,4 @@ // must use an observation to make sure things are listening.

QUnit.equal(obs, map);
}
},
callMethodsOnObservables: true
});

@@ -234,6 +235,5 @@ });

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/);
testHelpers.dev.devOnlyTest("functions are not called by read()", function() {
var func = function() {
QUnit.ok(true, "method called");
QUnit.ok(false, "method called");
};

@@ -243,20 +243,16 @@ var data = { func: func };

observeReader.read(data, reads, {
warnOnFunctionCall: "A Warning"
});
observeReader.read(data, reads);
QUnit.equal(teardown(), 1, "warning displayed");
QUnit.ok(true);
});
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/);
testHelpers.dev.devOnlyTest("a warning is displayed when using @", function() {
var teardown = testHelpers.dev.willWarn("functions are no longer called by default so @ is unnecessary in '@func'.");
var func = function() {
QUnit.ok(true, "method called");
QUnit.ok(false, "method called");
};
var data = new SimpleMap({ func: func });
var reads = observeReader.reads("func");
var data = { func: func };
var reads = observeReader.reads("@func");
observeReader.read(data, reads, {
callMethodsOnObservables: true
});
observeReader.read(data, reads);

@@ -266,16 +262,15 @@ 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/);
testHelpers.dev.devOnlyTest("a warning is given for `callMethodsOnObservables: true`", function() {
var teardown = testHelpers.dev.willWarn("can-stache-key: read() called with `callMethodsOnObservables: true`.");
var func = function() {
QUnit.ok(false, "method called");
QUnit.ok(true, "method called");
};
var data = new SimpleMap({ func: func });
var reads = observeReader.reads("@func");
var reads = observeReader.reads("func");
observeReader.read(data, reads, {
callMethodsOnObservables: true,
warnOnFunctionCall: "A Warning"
callMethodsOnObservables: true
});
QUnit.equal(teardown(), 0, "warning not displayed");
QUnit.ok(teardown(), 1, "warning displayed");
});

@@ -65,4 +65,2 @@ var Observation = require('can-observation');

// actually check
// - isArgument - should be renamed to something like "onLastPropertyReadReturnFunctionInsteadOfCallingIt".
// This is used to make a compute out of that function if necessary.
// - readCompute - can be set to `false` to prevent reading an ending compute. This is used by component to get a

@@ -163,23 +161,17 @@ // compute as a delegate. In 3.0, this should be removed and force people to write "{@prop} change"

if( isAt(i, reads) ) {
return i === reads.length ? bindName.call(value, prev) : value;
dev.warn(
(options.filename ? options.filename + ':' : '') +
(options.lineNumber ? options.lineNumber + ': ' : '') +
"functions are no longer called by default so @ is unnecessary in '" +
"@" + reads[0].key + "'."
);
}
//!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)) {
dev.warn("can-stache-key: read() called with `callMethodsOnObservables: true`.");
if(options.callMethodsOnObservables && canReflect.isObservableLike(prev) && canReflect.isMapLike(prev)) {
return value.apply(prev, options.args || []);
}
else if ( options.isArgument && i === reads.length ) {
return options.proxyMethods !== false ? bindName.call(value, prev) : value;
}
return value.apply(prev, options.args || []);
return options.proxyMethods !== false ? bindName.call(value, prev) : value;
}

@@ -186,0 +178,0 @@ },

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

@@ -5,0 +5,0 @@ "homepage": "https://canjs.com",

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