项目
在 GitHub 查看
talyssonoc/structure
关于
A simple schema/attributes library built on top of modern JavaScript
开发工具实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文A simple schema/attributes library built on top of modern JavaScript
Structure provides a simple interface which allows you to add attributes to your classes based on a schema, with validations and type coercion.
Packages
Documentation
Example Structure usage
For each attribute on your schema, a getter and a setter will be created into the given class. It'll also auto-assign those attributes passed to the constructor.
const { attributes } = require('structure');
const User = attributes({
name: String,
age: {
type: Number,
default: 18,
},
birthday: Date,
})(
class User {
greet() {
return `Hello ${this.name}`;
}
}
);
const user = new User({
name: 'John Foo',
});
user.name; // 'John Foo'
user.greet(); // 'Hello John Foo'
Contributing
LICENSE
探索相关项目
加载中…
