0.2.0 • Published 8 years ago
typed-class v0.2.0
prop-it
Instantiate classes with a string type
Installation
Install with npm
npm install typed-class
Example
Request: our Base Class
# lib/request/Request.coffee
TypedClass = require( 'typed-class' ) __dirname
module.exports = class Request extends TypedClass
Start: a Specialized Request
# lib/request/Start.coffee
Request = require './Request'
module.exports = class StartRequest extends Request
Instantiate Start
# elsewhere.coffee
Request = require './lib/request/Request'
start = Request.create type: 'start', {other: 'options'}
console.log start instanceOf Request # => true
console.log start instanceOf require './lib/request/Start' # => true