New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

inherits-ex

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inherits-ex - npm Package Compare versions

Comparing version 1.5.4 to 1.6.0

lib/getClosestCommonAncestorCtor.d.ts

12

lib/inherits.js

@@ -7,2 +7,4 @@ var isArray = Array.isArray;

var getSuperCtor = require('./getSuperCtor');
var getRootCtor = require('./getRootCtor');
var getClosestCommonAncestorCtor= require('./getClosestCommonAncestorCtor');

@@ -28,9 +30,5 @@ /**

inheritsDirectly(ctor, superCtor, staticInherit);
// patch the missing prototype chain if exists ctor.super.
while (v != null && v !== Object && superCtor !== v) {
ctor = superCtor;
superCtor = v;
inheritsDirectly(ctor, superCtor, staticInherit);
v = getSuperCtor(ctor);
}
var rootCtor = getClosestCommonAncestorCtor(v, superCtor)
superCtor = getRootCtor(superCtor, rootCtor)
if (v && v !== Object) inheritsDirectly(superCtor, v)
result = true;

@@ -37,0 +35,0 @@ } else if (isInherited) {

@@ -5,3 +5,3 @@ {

"homepage": "https://github.com/snowyu/inherits-ex.js",
"version": "1.5.4",
"version": "1.6.0",
"author": {

@@ -8,0 +8,0 @@ "name": "Riceball LEE",

@@ -7,2 +7,4 @@ var isArray = Array.isArray;

var getSuperCtor = require('./getSuperCtor');
var getRootCtor = require('./getRootCtor');
var getClosestCommonAncestorCtor= require('./getClosestCommonAncestorCtor');

@@ -28,9 +30,5 @@ /**

inheritsDirectly(ctor, superCtor, staticInherit);
// patch the missing prototype chain if exists ctor.super.
while (v != null && v !== Object && superCtor !== v) {
ctor = superCtor;
superCtor = v;
inheritsDirectly(ctor, superCtor, staticInherit);
v = getSuperCtor(ctor);
}
var rootCtor = getClosestCommonAncestorCtor(v, superCtor)
superCtor = getRootCtor(superCtor, rootCtor)
if (v && v !== Object) inheritsDirectly(superCtor, v)
result = true;

@@ -37,0 +35,0 @@ } else if (isInherited) {

@@ -169,3 +169,7 @@ var chai = require('chai')

class MyClass{}
assert.equal(inherits(C, Root), true)
class B{}
// C -> Root
assert.equal(inherits(C, Root), true);
// B -> Root
assert.equal(inherits(B, Root), true);

@@ -183,2 +187,22 @@ //# MyClass -> B -> Root

})
it("should multi-inheritances and void circular inherit2", () => {
class Ctor {}
class CtorParent {}
class CtorRoot {}
inherits(Ctor, [CtorParent, CtorRoot])
class SuperCtor {}
class SuperParent {}
inherits(SuperCtor, SuperParent)
assert.equal(inherits(Ctor, SuperCtor), true);
assert.deepEqual(getProtoChain(Ctor), ['CtorRoot', 'CtorParent', 'SuperParent', 'SuperCtor', 'Ctor']);
});
it("should multi-inheritances and void circular inherit3", () => {
class CtorRoot {}
class CtorParent extends CtorRoot{}
class Ctor extends CtorParent{}
class SuperParent {}
class SuperCtor extends SuperParent{}
assert.equal(inherits(Ctor, SuperCtor), true);
assert.deepEqual(getProtoChain(Ctor), ['CtorRoot', 'CtorParent', 'SuperParent', 'SuperCtor', 'Ctor']);
});
it("test isInheritedFrom with class name", function(){

@@ -185,0 +209,0 @@ isInheritedFrom = isInheritedFrom

@@ -168,3 +168,7 @@ var chai = require('chai')

function MyClass() {};
function B() {};
// C -> Root
assert.equal(inherits(C, Root), true);
// B -> Root
assert.equal(inherits(B, Root), true);
// MyClass -> B -> Root

@@ -180,2 +184,15 @@ assert.equal(inherits(MyClass, B), true);

});
it("should multi-inheritances and void circular inherit2", () => {
function Ctor() {}
function CtorParent() {}
function CtorRoot() {}
function SuperCtor() {}
function SuperParent() {}
// Ctor -> CtorParent -> CtorRoot
inherits(Ctor, [CtorParent, CtorRoot])
// SuperCtor -> SuperParent
inherits(SuperCtor, SuperParent)
assert.equal(inherits(Ctor, SuperCtor), true);
assert.deepEqual(getProtoChain(Ctor), ['CtorRoot', 'CtorParent', 'SuperParent', 'SuperCtor', 'Ctor']);
});
it("test isInheritedFrom with class name", function() {

@@ -182,0 +199,0 @@ assert.equal(isInheritedFrom(A, 'Root'), A);

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