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

can-map-define

Package Overview
Dependencies
Maintainers
10
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-map-define - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

17

can-map-define_test.js
/* jshint asi: false */
var QUnit = require('steal-qunit');
var isArray = require('can-util/js/is-array/is-array');
var string = require('can-util/js/string/string');

@@ -322,3 +321,3 @@ var CanMap = require('can-map');

ok(t1.attr("prop") !== t2.attr("prop"), "different array instances");
ok(isArray(t1.attr("prop")), "its an array");
ok(Array.isArray(t1.attr("prop")), "its an array");

@@ -342,3 +341,3 @@

ok(t1.attr("prop") !== t2.attr("prop"), "different array instances");
ok(isArray(t1.attr("prop")), "its an array");
ok(Array.isArray(t1.attr("prop")), "its an array");

@@ -1311,3 +1310,3 @@

var string2 = 'another string';
var MapA = CanMap.extend({

@@ -1346,3 +1345,3 @@ define: {

var map = new MapB();
equal(map.attr('propC'), string2, 'props only in the child have the correct values');

@@ -1417,6 +1416,6 @@ equal(map.attr('propB'), string2, 'props in both have the child values');

}
}
}
}
});
var map = new MapB();

@@ -1426,3 +1425,3 @@

equal(map.attr('propB'), object2, 'props in both have the child values');
equal(map.attr('propA'), object1, 'props only in the parent have the correct values');
equal(map.attr('propA'), object1, 'props only in the parent have the correct values');
});

@@ -1448,3 +1447,3 @@

map.attr('foo', undefined);
equal(typeof map.attr('foo'), 'undefined', 'foo should be undefined');
equal(typeof map.attr('foo'), 'undefined', 'foo should be undefined');
});

@@ -1451,0 +1450,0 @@

@@ -7,3 +7,3 @@ @typedef {{}} can-map-define.attrDefinition attribute definition

@option {can-map-define.value|*} value Specifies the initial value of the attribute or
a function that returns the initial value. For example, a default value of `0` can be
a function that returns the initial value. For example, a default value of `0` can be
specified like:

@@ -18,3 +18,3 @@

`Object` types should not be specified directly on `value` because that same object will
be shared on every instance of the Map. Instead, a [can-map-define.value value function] that
be shared on every instance of the Map. Instead, a [can-map-define.value value function] that
returns a fresh copy can be provided:

@@ -39,4 +39,4 @@

@option {can-map-define._type|String} type Specifies the type of the
attribute. The type can be specified as either a [can-map-define._type type function]
@option {can-map-define._type|String} type Specifies the type of the
attribute. The type can be specified as either a [can-map-define._type type function]
that returns the type coerced value or one of the following strings:

@@ -58,3 +58,3 @@

return newValue.split(",")
} else if( can.isArray(newValue) ) {
} else if( Array.isArray(newValue) ) {
return newValue;

@@ -66,4 +66,4 @@ }

@option {can-map-define.TypeConstructor} Type A constructor function that takes
the value passed to [can-map.prototype.attr attr] as the first argument and called with
@option {can-map-define.TypeConstructor} Type A constructor function that takes
the value passed to [can-map.prototype.attr attr] as the first argument and called with
new. For example, if you want whatever

@@ -87,3 +87,3 @@ gets passed to go through `new Array(newValue)` you can do that like:

set: function(newVal){
this.attr('offset', (parseInt(newVal) - 1) *
this.attr('offset', (parseInt(newVal) - 1) *
this.attr('limit'));

@@ -94,3 +94,3 @@ }

@option {can-map-define.get} get A function that specifies how the value is retrieved. The get function is
@option {can-map-define.get} get A function that specifies how the value is retrieved. The get function is
converted to an [can-compute.async async compute]. It should derive its value from other values

@@ -103,3 +103,3 @@ on the map. The following

get: function (newVal) {
return Math.floor(this.attr('offset') /
return Math.floor(this.attr('offset') /
this.attr('limit')) + 1;

@@ -109,3 +109,3 @@ }

}
A `get` definition makes the property __computed__ which means it will not be serialized by default.

@@ -124,4 +124,4 @@

@option {can-map-define.serialize|Boolean} serialize Specifies the behavior of the
property when [can-map.prototype.serialize serialize] is called.
@option {can-map-define.serialize|Boolean} serialize Specifies the behavior of the
property when [can-map.prototype.serialize serialize] is called.

@@ -139,3 +139,3 @@ By default, serialize does not include computed values. Properties with a `get` definition

});
p = new Paginate({offset: 40});

@@ -148,3 +148,3 @@ p.serialize() //-> {offset: 40}

define: {
pageNum: {
pageNum: {
get: function(){ return this.offset() / 20 },

@@ -158,4 +158,4 @@ serialize: true

p.serialize() //-> {offset: 40, pageNum: 2}
If `false` is specified, non-computed properties will not be added to the result.

@@ -189,2 +189,1 @@

p.serialize() //-> {offset: 3}

@@ -38,3 +38,3 @@ @function can-map-define._type type

return newValue.split(",")
} else if( can.isArray(newValue) ) {
} else if( Array.isArray(newValue) ) {
return newValue;

@@ -41,0 +41,0 @@ }

{
"name": "can-map-define",
"version": "3.1.0",
"version": "3.1.1",
"description": "Define rich attribute behavior",

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

# can-map-define
[![Greenkeeper badge](https://badges.greenkeeper.io/canjs/can-map-define.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.org/canjs/can-map-define.png?branch=master)](https://travis-ci.org/canjs/can-map-define)

@@ -4,0 +6,0 @@

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