Skip to content

mz026/ExtendMe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Extendme!!!

A dummy prototype inheritance tool for javascript.

Installation:

For nodeJS:

Require the file and you are done:

var extendme = require('/path/to/extendme.js');

For browser:

Simply include the extendme.js file, it would add extendme under window namespace.

Usage:

To create a type of object:

var Person = {
    type: 'person'
  , sayHi: function() {
    return 'hello, dude';
  }
};

var person = extendme.create(Person);
person.sayHi(); // 'hello, dude.'

To extend a type of object:

var Ninja = extendme.extend(Person, {
  type: 'ninja'
  , weapon: 'sword'
  , attack: function() {
    return 'whaaaaa!!!!';
  }
});
var ninja = extendme.create(Ninja);

ninja.sayHi(); // 'hello dude.'
ninja.attack(); // 'whaaaaa!!!'
console.log(ninja.type); // 'ninja'
console.log(ninja.weapon); // 'sword'

That's it, ENJOY!!!

About

A dummy prototype inheritance tool for javascript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published