1.0.2 • Published 10 years ago
coffee-script-model v1.0.2
coffee-script-model
A simple wrapper over the coffee-script class with getters, setters, fields, and event bindings
npm install coffee-script-model --save
Example
Model = require 'coffee-script-model'
class Person extends Model
@property 'firstName'
@property 'lastName'
@property 'fullName',
get: -> "#{@firstName} #{@lastName}"
set: (name) -> [@firstName, @lastName] = name.split ' '
@property 'username'
@property 'sick', default: false
person = new Person firstName: 'bob', lastName: 'smith'
console.log person.fullName
# 'bob smith'
person.fullName = 'thomas vi'
console.log person.firstName
# 'thomas'
See example.coffee for more examples.
Supports
- Node
- Modern browsers
- IE 9+