<commit_before># ProtoTyper [![Build Status](https://secure.travis-ci.org/operandom/prototyper.png?branch=master)](http://travis-ci.org/operandom/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`

```javascript
var prototyper = require('proto-typer');
```

## Documentation
_(Coming soon)_

## Examples
```javascript
// In Node.js

'use strict';

var prototyper = require('proto-typer'),
	define = prototyper.define,
	util = require('util'),
	Emitter = require('events').EventEmitter;

function User() { this.id = 'User01' }
util.inherits(User, Emitter);

function Pet() {  }
function Dog() { this._type = 'a dog'; }
function Cat() { this._type = 'a cat, but a REALLY big one'; }

util.inherits(Dog, Pet);
util.inherits(Cat, Pet);

function Car() {}


// PROTOTYPES
prototyper

// user
.define(User.prototype)
.c('v', 2.1).nk.f
.p('id').t(String).e('idChange').f
.p('lastName').t(String).e('nameChange').f
.p('firstName').t(String).e('nameChange').f
.p('toString', getFullName).t(Function).nk.f
.p('birthday').type(Date).e().f
.p('pet').t(Pet).e('petChange').f
.p('extensions').e()


// pet
.define(Pet.prototype)
.p('_type', 'an undefined pet').nk.f
.u('type', function() {
	return {
		'get': function() { return this._type; },
		'enumerable': true
	};
});


// METHODS

function getFullName() {
	return (this.firstName || '')  + (this.lastName && this.firstName ? ' ' : '') + (this.lastName || '');
}


// USER

var user = new User;

user.on(prototyper.Change, function(event) {
	
});

user.on('nameChange', function (event) {
	console.log('User', event.target.id, 'has changed his name to "' + event.target.toString() + '".');
});

user.on('petChange', function(event) {
	console.log(this.toString(), "has a new pet, it's", event.newValue.type, '!');
});

user.on('idChange', function(event) {
	console.log('User "' + event.oldValue + '" change his identity to "' + event.newValue + '".');
});

user.id = ('User02'); // -> User "User01" change his identity to "User02".

user.firstName = 'Jhon'; // -> User User02 has changed his name to "Jhon".
user.lastName = 'Doe'; // -> User User02 has changed his name to "<NAME>".

user.pet = new Pet; // -> <NAME> has a new pet, it's an undefined pet !
user.pet = new Dog; // -> <NAME> has a new pet, it's a dog !
user.pet = new Cat; // -> <NAME> has a new pet, it's a cat, but a REALLY big one !

try {
	user.pet = new Car; // -> It's seems that this car is not a pet
}catch(e){
	console.log("It's seems that this car is not a pet");
}

console.log('User version:', user.v);
user.v = 2.2; // -> 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](http://gruntjs.com/).

## 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 <NAME>. Licensed under the MIT license.
See the file LICENSE.md in this distribution for more details.
<commit_msg>Minor change.<commit_after># ProtoTyper [![Build Status](https://secure.travis-ci.org/operandom/prototyper.png?branch=master)](http://travis-ci.org/operandom/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`

```javascript
var prototyper = require('proto-typer');
```

## Documentation
_(Coming soon)_

## Examples
```javascript
// In Node.js

'use strict';

var prototyper = require('proto-typer'),
	define = prototyper.define,
	util = require('util'),
	Emitter = require('events').EventEmitter;

function User() { this.id = 'User01' }
util.inherits(User, Emitter);

function Pet() {  }
function Dog() { this._type = 'a dog'; }
function Cat() { this._type = 'a cat, but a REALLY big one'; }

util.inherits(Dog, Pet);
util.inherits(Cat, Pet);

function Car() {}


// PROTOTYPES
prototyper

// user
.define(User.prototype)
.c('v', 2.1).nk.f
.p('id').t(String).e('idChange').f
.p('lastName').t(String).e('nameChange').f
.p('firstName').t(String).e('nameChange').f
.p('toString', getFullName).t(Function).nk.f
.p('birthday').type(Date).e().f
.p('pet').t(Pet).e('petChange').f
.p('extensions').e()


// pet
.define(Pet.prototype)
.p('_type', 'an undefined pet').nk.f
.u('type', function() {
	return {
		'get': function() { return this._type; },
		'enumerable': true
	};
});


// METHODS

function getFullName() {
	return (this.firstName || '')  + (this.lastName && this.firstName ? ' ' : '') + (this.lastName || '');
}


// USER

var user = new User;

user.on(prototyper.Change, function(event) {
	
});

user.on('nameChange', function (event) {
	console.log('User', event.target.id, 'has changed his name to "' + event.target.toString() + '".');
});

user.on('petChange', function(event) {
	console.log(this.toString(), "has a new pet, it's", event.newValue.type, '!');
});

user.on('idChange', function(event) {
	console.log('User "' + event.oldValue + '" change his identity to "' + event.newValue + '".');
});

user.id = ('User02'); // -> User "User01" change his identity to "User02".

user.firstName = 'Jhon'; // -> User User02 has changed his name to "Jhon".
user.lastName = 'Doe'; // -> User User02 has changed his name to "<NAME>".

user.pet = new Pet; // -> <NAME> has a new pet, it's an undefined pet !
user.pet = new Dog; // -> <NAME> has a new pet, it's a dog !
user.pet = new Cat; // -> <NAME> has a new pet, it's a cat, but a REALLY big one !

try {
	user.pet = new Car; // -> It's seems that this car is not a pet
}catch(e){
	console.log("It seems that this car is not a pet");
}

console.log('User version:', user.v);
user.v = 2.2; // -> 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](http://gruntjs.com/).

## 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 <NAME>. Licensed under the MIT license.
See the file LICENSE.md in this distribution for more details.

{'fraction_non_alphanumeric': 0.1806020066889632, 'fraction_numerical': 0.006080875646093037, 'mean_word_length': 4.111888111888112, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2287481', 'n_tokens_mistral': 2277, 'n_tokens_neox': 2199, 'n_words': 663}