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

can-map

Package Overview
Dependencies
Maintainers
5
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-map - npm Package Compare versions

Comparing version 3.0.0-pre.13 to 3.0.0-pre.14

27

can-map_test.js

@@ -313,1 +313,28 @@ /* jshint asi:true */

});
test("Basic Map.prototype.compute", function () {
var state = new Map({
category: 5,
productType: 4
});
var catCompute = state.compute('category');
var prodCompute = state.compute('productType');
catCompute.bind("change", function (ev, val, old) {
equal(val, 6, "correct");
equal(old, 5, "correct");
});
state.bind('productType', function(ev, val, old) {
equal(val, 5, "correct");
equal(old, 4, "correct");
});
state.attr("category", 6);
prodCompute(5);
catCompute.unbind("change");
state.unbind("productType");
});

@@ -24,2 +24,4 @@ /* jshint -W079 */

var Observation = require('can-observation');
var ObserveReader = require('can-observation/reader/reader');
var canCompute = require('can-compute');

@@ -30,2 +32,3 @@ var namespace = require("can-util/namespace");

var deepAssign = require("can-util/js/deep-assign/deep-assign");
var isFunction = require("can-util/js/is-function/is-function");
var assign = require("can-util/js/assign/assign");

@@ -606,2 +609,23 @@ var types = require("can-util/js/types/types");

// ### compute
// Creates a compute that represents a value on this map. If the property is a function
// on the prototype, a "function" compute wil be created.
// Otherwise, a compute will be created that reads the observable attributes
compute: function (prop) {
if (isFunction(this.constructor.prototype[prop])) {
return canCompute(this[prop], this);
} else {
var reads = ObserveReader.reads(prop);
var last = reads.length - 1;
return canCompute(function (newVal) {
if (arguments.length) {
ObserveReader.write(this, reads[last].key, newVal);
} else {
return ObserveReader.get(this, reads[last].key);
}
}, this);
}
},
// ### each

@@ -608,0 +632,0 @@ // loops through all the key-value pairs on this map.

3

package.json
{
"name": "can-map",
"version": "3.0.0-pre.13",
"version": "3.0.0-pre.14",
"description": "Observable Objects",

@@ -49,2 +49,3 @@ "homepage": "http://canjs.com",

"dependencies": {
"can-compute": "^3.0.0-pre.15",
"can-construct": "^3.0.0-pre.8",

@@ -51,0 +52,0 @@ "can-event": "^3.0.0-pre.9",

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