Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ee-class

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ee-class

Javascript Class implementation for node.js

  • 0.2.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.8K
decreased by-37.69%
Maintainers
1
Weekly downloads
 
Created
Source

ee-class

Javascript Class implementation for node.js

installation

npm install ee-class

build status

Build Status

usage

var Class = require( "ee-class" );


var LifeForm = new Class( {
    isAlive: false

    , init: function( options ){
        this.isAlive = !!options.isAlive;
    }
} );



var Human = new Class( {
    inherits: LifeForm
    
    , name: ""

    // pay attention to give the function a name so you can reference it when you are calling the parent function
    , init: function myInitFunction( options ){
        myInitFunction.parent( options );
        this.name = options.name;
    }
} );



var Boy = new Class( {
    inherits: Human

    , age: 0

    // pay attention to give the function a name so you can reference it when you are calling the parent function
    , init: function myInitFunction( options ){
        myInitFunction.parent( options );
        if ( options.age > 18 ) throw new Error( "Too old to be a boy!" )
        this.age = options.age;
    }


    , describe: function(){
        console.log( "Hi, my name is %s, i'm %s years old and i'm " + ( this.isAlive ? "alive :)" : "dead :(" ), this.name, this.age );
    }
} );



var fabian = new Boy( {
      name:     "fabian"
    , age:      15
    , isAlive:  true
} );

fabian.describe(); // Hi, my name is fabian, i'm 15 years old and i'm alive :)

Version History

  • 0.1.0: initial version
  • 0.1.3: fixed integration with eventemitter objects
  • 0.2.0: Added proper implementation for calling super functions, deprecated the «parent» property
  • 0.2.1: Bugfix for the «super implementation»
  • 0.2.2: Deprecated the «super» property and replaced it with the «parent» property beacuse super is a javascript reserved keyword
  • 0.2.3: The constructor takes now n instead of 1 arguments
  • 0.2.4: The constructor may now return a function when overriding the class implementation

Keywords

FAQs

Package last updated on 28 Nov 2013

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc