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

inherits

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inherits

Browser-friendly inheritance fully compatible with standard node.js inherits()

2.0.4
latest
Source
npm
Version published
Weekly downloads
121M
22.1%
Maintainers
1
Weekly downloads
 
Created

What is inherits?

The inherits npm package is a simple utility module that allows you to implement inheritance in JavaScript. It facilitates the prototype chain linkage between a constructor function (child) and another constructor function (parent) to achieve classical inheritance patterns.

What are inherits's main functionalities?

Inheritance

This code demonstrates how to use the inherits package to set up classical inheritance between a custom constructor MyStream and the built-in EventEmitter constructor. It allows instances of MyStream to inherit methods and properties from EventEmitter.

var inherits = require('inherits');
var EventEmitter = require('events').EventEmitter;

function MyStream() {
  EventEmitter.call(this);
}

inherits(MyStream, EventEmitter);

MyStream.prototype.write = function(data) {
  this.emit('data', data);
};

var stream = new MyStream();
console.log(stream instanceof EventEmitter); // true
console.log(MyStream.super_ === EventEmitter); // true

Other packages similar to inherits

Keywords

inheritance

FAQs

Package last updated on 19 Jun 2019

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