🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

classifyed

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

classifyed

A tiny yet powerful lib to create extensible JS Classes, with an elegant way of calling parent methods.

1.4.0
latest
Source
npm
Version published
Weekly downloads
6
100%
Maintainers
1
Weekly downloads
 
Created
Source

classifyed.js

A tiny yet powerful lib to create extensible JS Classes, with an elegant way of calling parent methods.

Usage

var MyClass = Classifyed.extend({
    constructor: function() { ... },
    doFoo: function () { ... }
},
{
    type: 'MyClass',
    staticFoo: function () {
        // This is a static method
    }
});

var SuperClass = MyClass.extend({
    constructor: function(){
        this.__super__('constructor', arguments); // call parent constructor
        // Continue with the constructor...
    },
    doFoo: function () {
        this.__super__('doFoo', arguments); // call parent method
        // Do stuff
    }
},
{
   type: 'SuperClass',
   staticFoo: function () {
        this.__super__.constructor.staticFoo(); // call parent static method
        this.parent().staticFoo(); // same as previous
   }
});

var myObj = new SuperClass();
myObj.doFoo();
myObj.__super__('doFoo');

console.log(myObj.constructor.type); // 'MyClass'
console.log(myObj.constructor.__super__.constructor.type); // 'SuperClass'
console.log(myObj.constructor.parent().type); // 'SuperClass' again

Keywords

class

FAQs

Package last updated on 09 Sep 2020

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