fashion-model-defaults
1.1.1 • Public • Published fashion-model-defaults
fashion-model mixin that attaches
an applyDefaults
method to the model prototype.
Using default
as a standard value:
var DefaultsMixin = require('fashion-model-defaults');
var Person = Model.extend({
mixins: [DefaultsMixin],
properties: {
name: {
type: String,
default: 'Bob'
},
age: Number
}
});
var bob = new Person({
age: 30
});
bob.applyDefaults();
bob.getName();
Using default
as a function:
var DefaultsMixin = require('fashion-model-defaults');
var Person = Model.extend({
mixins: [DefaultsMixin],
properties: {
name: {
type: String,
default: function() {
return 'Bob';
}
},
age: Number
}
});
var bob = new Person({
age: 30
});
bob.applyDefaults();
bob.getName();
Versions
Version | Downloads (Last 7 Days) | Tag |
---|
1.1.1 | 194 | latest |
Version History
Version | Downloads (Last 7 Days) | Published |
---|
1.1.1 | 194 | |
1.1.0 | 0 | |
1.0.2 | 0 | |
1.0.1 | 0 | |
1.0.0 | 0 | |
Package Sidebar
Install
npm i fashion-model-defaults
Weekly Downloads