ampersand-state
Advanced tools
Comparing version 4.4.2 to 4.4.3
@@ -527,3 +527,3 @@ /*$AMPERSAND_VERSION*/ | ||
if (desc.setOnce) def.setOnce = true; | ||
if (def.required && _.isUndefined(def.default)) def.default = object._getDefaultForType(type); | ||
if (def.required && _.isUndefined(def.default) && !def.setOnce) def.default = object._getDefaultForType(type); | ||
def.test = desc.test; | ||
@@ -530,0 +530,0 @@ def.values = desc.values; |
{ | ||
"name": "ampersand-state", | ||
"description": "An observable, extensible state object with derived watchable properties.", | ||
"version": "4.4.2", | ||
"version": "4.4.3", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -6,0 +6,0 @@ "browserify": { |
@@ -1512,1 +1512,23 @@ var tape = require('tape'); | ||
}); | ||
test('#114 setOnce allows values to be set once and only once', function (t) { | ||
var Model = State.extend({ | ||
props: { | ||
x: { | ||
type: 'string', | ||
setOnce: true, | ||
required: true, | ||
} | ||
} | ||
}); | ||
var model = new Model({ x: 'foo' }); | ||
t.equal(model.x, 'foo'); | ||
t.throws(function () { | ||
model.x = 'bar'; | ||
}, /can only be set once/); | ||
t.end(); | ||
}); |
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
120481
2942