ProtoTyper
ProtoTyper is a utility module for Node.js. Based on Object.defineProperty
, it allows type verification and event dispatching on property change.
Getting Started
Install the module with: npm install proto-typer
var prototyper = ;
Documentation
(Coming soon)
Examples
// In Node.js 'use strict'; var prototyper = define = prototyperdefine util = Emitter = EventEmitter; { thisid = 'User01' }util; { } { this_type = 'a dog'; } { this_type = 'a cat, but a REALLY big one'; } util;util; {} // PROTOTYPESprototyper // usernkffffnkftypeDateff // petnkf; // METHODS { return thisfirstName || '' + thislastName && thisfirstName ? ' ' : '' + thislastName || '';} // USER var user = ; user; user; user; user; userid = 'User02'; // -> User "User01" change his identity to "User02". userfirstName = 'Jhon'; // -> User User02 has changed his name to "Jhon".userlastName = 'Doe'; // -> User User02 has changed his name to "Jhon Doe". userpet = ; // -> Jhon Doe has a new pet, it's an undefined pet !userpet = ; // -> Jhon Doe has a new pet, it's a dog !userpet = ; // -> Jhon Doe has a new pet, it's a cat, but a REALLY big one ! try userpet = ; // -> It's seems that this car is not a petcatche console; console;userv = 22; // -> exception
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Release History
(Nothing yet)
Known issues
When event and type are added to property definition, the "private" method automatically created becomes enumerable. (Pull requests are welcome)
License
Copyright (c) 2013 Valéry Herlaud. Licensed under the MIT license. See the file LICENSE.md in this distribution for more details.