Socket
Socket
Sign inDemoInstall

node.class

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node.class

A port of John Resig Class Implementation


Version published
Weekly downloads
171
increased by14%
Maintainers
1
Install size
6.34 kB
Created
Weekly downloads
 

Changelog

Source

1.1.4 / 2013-12-17

  • [bug fix] Instance issue in inject

Readme

Source

node.class

A port of John Resig Simple JavaScript Inheritance on node.js plus multiple inheritance.

Requires

Checkout package.json for dependencies.

Installation

Install through npm

npm install node.class

Usage

Require the module before using

var Class = require( 'node.class' );

Basic

var Person = Class.extend({

  // constructor
  init : function ( name, height ){
    this.name   = name;
    this.height = height;
  },

  show_name : function (){
    return this.name;
  },

  show_height : function (){
    return this.height;
  }
});

var ben = new Person( 'ben', '176' );

console.log( ben.height()); // 176

Inject to prototype chain

var car = {

  init : function ( name ){
    this.name = name;
  },

  run : function (){
    // ...
  },

  stop : function (){
    // ...
  }
};

var sports_car = {

  turbo : function (){
    // ...
  }
};


var Porsche = Class.extend( car ).inject( sports_car );

var nine11 = new Porsche( '911' );

nine11.turbo();

Keywords

FAQs

Last updated on 17 Dec 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc