ampersand-state
Advanced tools
Comparing version 4.7.0 to 4.8.0
@@ -287,2 +287,7 @@ 'use strict'; | ||
if (attr == null) return !!Object.keys(this._changed).length; | ||
if (has(this._derived, attr)) { | ||
return this._derived[attr].depList.some(function (dep) { | ||
return this.hasChanged(dep); | ||
}, this); | ||
} | ||
return has(this._changed, attr); | ||
@@ -321,2 +326,3 @@ }, | ||
var def = self._definition[key]; | ||
if (!def) return; | ||
var val; | ||
@@ -376,3 +382,3 @@ if (def.required) { | ||
_ensureValidType: function (type) { | ||
return includes(['string', 'number', 'boolean', 'array', 'object', 'date', 'any'] | ||
return includes(['string', 'number', 'boolean', 'array', 'object', 'date', 'state', 'any'] | ||
.concat(Object.keys(this._dataTypes)), type) ? type : undefined; | ||
@@ -535,3 +541,2 @@ }, | ||
} else { | ||
//Transform array of ['type', required, default] to object form | ||
@@ -566,2 +571,7 @@ if (Array.isArray(desc)) { | ||
if (!type) { | ||
type = isString(desc) ? desc : desc.type; | ||
throw new TypeError('Invalid data type of `' + type + '` for `' + name + '` property. Use one of the default types or define your own'); | ||
} | ||
// define a getter/setter on the prototype | ||
@@ -568,0 +578,0 @@ // but they get/set on the instance |
{ | ||
"name": "ampersand-state", | ||
"description": "An observable, extensible state object with derived watchable properties.", | ||
"version": "4.7.0", | ||
"version": "4.8.0", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -6,0 +6,0 @@ "files": [ |
@@ -218,4 +218,6 @@ # ampersand-state | ||
ampersand-state defines several built-in datatypes: `string`, `number`, `boolean`, `array`, `object`, `date`, `state`, or `any`. Of these, `object`, `array` and `any` allow for a lot of extra flexibility. However sometimes it may be useful to define your own custom datatypes. Then you can use these types in the `props` below with all their features (like `required`, `default`, etc). | ||
ampersand-state defines several built-in datatypes: `string`, `number`, `boolean`, `array`, `object`, `date`, `state`, or `any`. Of these, `object`, `array` and `any` allow for a lot of extra flexibility. However sometimes it may be useful to define your own custom datatypes. Then you can use these types in the `props` below with all their features (like `required`, `default`, etc). | ||
Setting `type` is required and `typeError` will be thrown if it's missing or has not been choosen either from default types or your custom ones. | ||
To define a type, you generally will provide an object with 4 member functions (though only 2 are usually necessary) `get`, `set`, `default`, and `compare`. | ||
@@ -602,4 +604,7 @@ | ||
Shortcut to toggle boolean properties, or cycle through “ENUM” type properties with a `values` array in their definition. Fires `"change"` events, as you would expect from `set()`. | ||
Shortcut to toggle boolean properties, or cycle through array of specified property's `values` (see `values` option section and example below). | ||
When you reach the last available value from given array, `toggle` will go back to the beginning and use first one. | ||
Fires `"change"` events, as you would expect from `set()`. | ||
```javascript | ||
@@ -606,0 +611,0 @@ var Person = AmpersandState.extend({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
62304
727
715
0