Socket
Socket
Sign inDemoInstall

ampersand-state

Package Overview
Dependencies
Maintainers
7
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ampersand-state - npm Package Compare versions

Comparing version 4.7.0 to 4.8.0

14

ampersand-state.js

@@ -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

2

package.json
{
"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({

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