ampersand-state
Advanced tools
Comparing version 4.4.6 to 4.5.0
@@ -321,12 +321,15 @@ /*$AMPERSAND_VERSION*/ | ||
unset: function (attr, options) { | ||
var def = this._definition[attr]; | ||
var type = def.type; | ||
var val; | ||
if (def.required) { | ||
val = result(def, 'default'); | ||
return this.set(attr, val, options); | ||
} else { | ||
return this.set(attr, val, assign({}, options, {unset: true})); | ||
} | ||
unset: function (attrs, options) { | ||
attrs = Array.isArray(attrs) ? attrs : [attrs]; | ||
forEach(attrs, function (key) { | ||
var def = this._definition[key]; | ||
var type = def.type; | ||
var val; | ||
if (def.required) { | ||
val = result(def, 'default'); | ||
return this.set(key, val, options); | ||
} else { | ||
return this.set(key, val, assign({}, options, {unset: true})); | ||
} | ||
}, this); | ||
}, | ||
@@ -333,0 +336,0 @@ |
{ | ||
"name": "ampersand-state", | ||
"description": "An observable, extensible state object with derived watchable properties.", | ||
"version": "4.4.6", | ||
"version": "4.5.0", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -6,0 +6,0 @@ "files": [ |
@@ -541,5 +541,5 @@ # ampersand-state | ||
### unset `state.unset(attribute, [options])` | ||
### unset `state.unset(attribute|attributes[], [options])` | ||
Clear the named attribute from the state object. Fires a `"change"` event and a `"change:attributeName"` event unless `silent` is passed as an option. | ||
Clear the named attribute or an array of named attributes from the state object. Fires a `"change"` event and a `"change:attributeName"` event unless `silent` is passed as an option. | ||
@@ -549,5 +549,11 @@ If the attribute being unset is `required` and has a `default` value as defined in either `props` or `session`, it will be set to that value, otherwise it will be `undefined`. | ||
```javascript | ||
// unset a single attribute | ||
person.unset('firstName') | ||
``` | ||
```javascript | ||
// unset multiple attributes | ||
person.unset(['firstName', 'lastName']) | ||
``` | ||
### clear `state.clear([options])` | ||
@@ -554,0 +560,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
55666
710
634
0