coffee-script-model

1.0.2 • Public • Published

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+

Package Sidebar

Install

npm i coffee-script-model

Weekly Downloads

2

Version

1.0.2

License

MIT

Last publish

Collaborators

  • grant