This package has been deprecated

Author message:

this package has been deprecated

prototype-and-class

0.3.1 • Public • Published

prototype-and-class

Простое прототипирование и наследование

Easy prototyping and inheritance

Install

$ npm i protorype-and-class --save

//html
<script type="text/javascript" src="class.js"></script>

//require.js
require.config({
    paths: {
        class: 'lib/class'
    }
    shim: {
        "class": {
            exports: "Class"
        }
    }
});

//Common.js
var Class = require('prototype-and-class');

Example

var Class = require('prototype-and-class');

var Animal = Class.extend({
    say: function(){
        console.log('Animal: say');
    }
});

var animal = new Animal();
animal.say();

var Cat = Animal.extend({
    sayMeow: function(){
        console.log('cat: meow');
    }
});

var cat = new Cat();
cat.say();
cat.sayMeow();

var bigCat = cat.extend({
    sayMeow: function(){
        console.log('bigCat: MEOW')
    },
    weight: 10.5
});

bigCat.sayMeow();
console.log('weight:', bigCat.weight);

Init

var Base = Class.extend({
    init: function(){
        console.log('Method init');
    }
);

var base = new Class();//write to the console 'Method init'

Package Sidebar

Install

npm i prototype-and-class

Weekly Downloads

1

Version

0.3.1

License

ISC

Last publish

Collaborators

  • defenderbass