Socket
Socket
Sign inDemoInstall

ampersand-state

Package Overview
Dependencies
Maintainers
3
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.3.7 to 4.3.8

2

package.json
{
"name": "ampersand-state",
"description": "An observable, extensible state object with derived watchable properties.",
"version": "4.3.7",
"version": "4.3.8",
"author": "Henrik Joreteg <henrik@andyet.net>",

@@ -6,0 +6,0 @@ "bugs": {

@@ -125,2 +125,4 @@ # ampersand-state

Defaults to `ignore`.
```javascript

@@ -215,6 +217,8 @@ var StateA = AmpersandState.extend({

* As a string with the expected dataType. One of `string`, `number`, `boolean`, `array`, `object`, `date`, or `any`. Eg: `name: 'string'`. Can also be set to the name of a custom `dataTypes` if any are defined for the class.
* An array of `[dataType, required, default]`.
* An object `{ type: 'string', required: true, default: '' , allowNull: false}`.
* An array of `[dataType, required, default]`
* An object `{ type: 'string', required: true, default: '' , values: [], allowNull: false, setOnce: false }`
* `default` will be the value that the property will be set to if it is undefined, either by not being set during initialization, or by being explicit set to undefined.
* If `required` is true, one of two things will happen. If a `default` is set for the property, the property will start with that value, and revert to it after a call to `unset(propertyName)`. If a `default` is not set for the property, an error will be thrown after a call to `unset(propertyName)`.
* If `values` array is passed, then you'll be able to change a property to one of those values only.
* If `setOnce` is true, then you'll be able to set property only once.
* Trying to set a property to an invalid type will raise an exception.

@@ -229,6 +233,6 @@

age: 'number',
paying: ['boolean', true, false], //required attribute, defaulted to false
paying: ['boolean', true, false], // required attribute, defaulted to false
type: {
type: 'string',
values: ['regular-hero', 'super-hero', 'mega-hero' ]
values: ['regular-hero', 'super-hero', 'mega-hero']
}

@@ -235,0 +239,0 @@ }

@@ -759,2 +759,16 @@ /*jshint expr: true*/

test("unset even if value has been specified", function (t) {
var Model = State.extend({
props: {
foo: 'string'
}
});
var model = new Model({ foo: 'bar' });
model.on('change:foo', function () {
t.equal(model.get('foo'), undefined);
});
model.set({ foo: 'baz' }, { unset: true });
t.equal(model.get('foo'), undefined);
t.end();
});

@@ -761,0 +775,0 @@ test("nested `set` during `'change:attr'`", function (t) {

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