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

heritable

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

heritable

Inheritance provider

  • 0.0.2-1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Heritable

Inheritance mechanisms for making prototypal classes

Installation

via [npm]

npm install heritable

Usage

var	Heritable = require('heritable.js'),
	Animal, Human,	// Constructors
	animal, human;	// instances

Animal = new Heritable('Animal');
animal = new Animal();
console.log('animal instanceof Animal: ' + (animal instanceof Animal));

Human = new Heritable('Human');
human = new Human();
console.log('human instanceof Animal: ' + (human instanceof Animal));
console.log('human instanceof Human: ' + (human instanceof Human));
console.log('animal instanceof Human: ' + (animal instanceof Human));

Some details

You can provide an initializer function and methods for a Heritable class:

animalInitializer = function (o) {
	o = o || {};
	this.type = o.type;
};

animalMethods = {
	getType: function () {
		return this.type;
	}
};

Animal = new Heritable('Animal', null, animalInitializer, animalMethods);
animal = new Animal({type: 'gorilla'});
console.log('animal type:   ' + animal.getType());

To Do

1 do not init if already an object
2 add a method for adding methods to a Heritable class
3 perhaps: distinguish Heritable class methods from members

Keywords

FAQs

Package last updated on 06 Jun 2011

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