Skip to content

Commit

Permalink
Optimised and new features.
Browse files Browse the repository at this point in the history
* Optimised the interals
* Added Creation.getProto()
* Added Creation.getSuper()
  • Loading branch information
Michaelangelo Jong committed Apr 22, 2015
1 parent fba861f commit c534bae
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 186 deletions.
38 changes: 27 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
* [ Generation.isGeneration(test) ](#generation-is-generation)
* [ Class: Creation ](#class-creation)
* [ Creation.defineProperties([descriptor,] properties) ](#creation-define-properties)
* [ Creation.getProto() ](#creation-get-proto)
* [ Creation.getSuper() ](#creation-get-super)


<a name="generator"></a>
Generator
=========
# Generator

An easy to use prototypal inheritance model and generator. All generations inherit from Generator.
An easy to use prototypal inheritance model and generator. All generations inherit from Generator.

### Install:
```
Expand All @@ -41,8 +43,8 @@ var Person = Generator.generate(
/* create method */
function Person(name, age, sex) {
this.name = name || 'no-name';
this.age = age || 0;
this.sex = sex || 'unknown';
this.age = age || 0;
this.sex = sex || 'unknown';
}
);
```
Expand All @@ -69,7 +71,7 @@ Example:
```javascript
// generatorize NodeJS' EventEmitter
var Generator = require('generate-js'),
events = require('events');
events = require('events');

var EventEmitter = Generator.toGenerator(events.EventEmitter);

Expand Down Expand Up @@ -173,8 +175,8 @@ jim.name // 'Jim'
jim.age // 10
jim.sex // 'male'

jim.sayHello(); // prints out: 'Hello, my name is Jim. What is yours?'
jim.sayBye(); // prints out: 'Goodbye.'
jim.sayHello(); // prints out: 'Hello, my name is Jim. What is yours?'
jim.sayBye(); // prints out: 'Goodbye.'

```

Expand Down Expand Up @@ -211,9 +213,9 @@ Student.definePrototype(

var sarah = Student.create('Sarah', 17, 'female', 'A0123456789');

sarah.name // 'Sarah'
sarah.age // 17
sarah.sex // 'female'
sarah.name // 'Sarah'
sarah.age // 17
sarah.sex // 'female'
sarah.studentId // 'A0123456789'

sarah.sayHello(); // prints out: 'Sup? My student ID is: A0123456789'
Expand Down Expand Up @@ -282,6 +284,20 @@ sarah.defineProperties(

```

<a name="creation-get-proto"></a>
## Creation.getProto()

* *return*: `Object` Prototype of *this* Creation.

Returns the prototype of *this* Creation.

<a name="creation-get-super"></a>
## Creation.getSuper()

* *return*: `Object` super Prototype of *this* Creation.

Returns the super prototype of *this* Creation.

## Author:
Michaelangelo Jong

Expand Down
Loading

0 comments on commit c534bae

Please sign in to comment.