ampersand-state
Advanced tools
Comparing version 4.3.7 to 4.3.8
{ | ||
"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) { |
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
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
107343
2761
483
1