Socket
Book a DemoInstallSign in
Socket

unherit

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unherit

Clone a constructor without affecting the super-class

Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

unherit Build Status Coverage Status

Create a custom constructor which can be modified without affecting the original class.

Installation

npm:

npm install unherit

unherit is also available for bower, component, and duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.

Usage

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

/* Create a private class which acts just like
 * `EventEmitter`. */
var Emitter = unherit(EventEmitter);

Emitter.prototype.defaultMaxListeners = 0;
/* Now, all instances of `Emitter` have no maximum
 * listeners, without affecting other `EventEmitter`s. */

assert(new Emitter().defaultMaxListeners === 0); // true
assert(new EventEmitter().defaultMaxListeners === undefined); // true
assert(new Emitter() instanceof EventEmitter); // true

API

unherit(Super)

Create a custom constructor which can be modified without affecting the original class.

Parameters

  • Super (Function) — Super-class.

Returns

(Function) — Constructor acting like Super, which can be modified without affecting the original class.

License

MIT © Titus Wormer

Keywords

clone

FAQs

Package last updated on 27 Jul 2015

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