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

extends-classes

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

extends-classes - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

48

lib/extends-classes.js

@@ -12,2 +12,8 @@ /*!

/**
* Module dependencies.
*/
const MethodMissing = require('method-missing');
/**
* Main multi-class function.

@@ -22,21 +28,37 @@ *

args.reverse();
/**
* Skeleton Class.
*
* @class Class
* @extends {MethodMissing}
*/
class Class {
class Class extends MethodMissing {
/**
* Creates an instance of Class.
*
* @memberOf Class
*/
constructor() {
super();
for (const arg of args) {
const props = Object.getOwnPropertyNames(arg.prototype);
for (const prop of props) {
if (prop === 'constructor') {
constructors.push(arg.prototype.constructor);
} else {
Class.prototype[prop] = arg.prototype[prop];
}
}
}
for (const constructor of constructors) {
Object.assign(Class.prototype, new constructor(arguments));
Object.assign(Class.prototype, new constructor(...arguments));
}
}
}
for (const arg of args) {
const props = Object.getOwnPropertyNames(arg.prototype);
for (const prop of props) {
if (prop === 'constructor') {
constructors.push(arg.prototype.constructor);
} else {
Class.prototype[prop] = arg.prototype[prop];
}
}
}

@@ -43,0 +65,0 @@

{
"name": "extends-classes",
"version": "1.0.2",
"engines" : {
"node" : ">=6.0.0"
"version": "1.0.3",
"engines": {
"node": ">=6.0.0"
},

@@ -33,3 +33,6 @@ "engineStrict": true,

},
"homepage": "https://github.com/jarradseers/extends-classes#readme"
"homepage": "https://github.com/jarradseers/extends-classes#readme",
"dependencies": {
"method-missing": "^1.1.2"
}
}

@@ -14,2 +14,25 @@ # Extend Multiple Classes

Method missing:
```js
const classes = require('extends-classes');
class Test extends classes (A, B, C) {
constructor() {
super();
}
__call(method, args) {
console.log(`'${method}()' is missing!`);
}
}
const test = new Test();
test.somethingThatIsNonExistent();
// 'somethingThatIsNonExistent()' is missing!
```
MethodMissing is included in the stack, see [method-missing](https://www.npmjs.com/package/method-missing).
Check out the [test folder](test) for more!

@@ -26,3 +49,4 @@

* Extend multiple es6 classes.
* Simple and light-weight with no external dependencies.
* Simple and light-weight.
* Includes MethodMissing.
* Written in ES6+ for node.js 6+.

@@ -29,0 +53,0 @@ * Clean solution to extending from multiple classes.

@@ -20,3 +20,3 @@ /*!

class A {
constructor() {
constructor(options) {
console.log('A class constructed');

@@ -31,3 +31,3 @@ }

class B {
constructor() {
constructor(options) {
console.log('B class constructed');

@@ -41,4 +41,4 @@ }

class C {
constructor() {
console.log('C class constructed');
constructor(options) {
console.log(`C class constructed with hello option ${options.hello}`);
}

@@ -53,13 +53,21 @@ three() {

constructor() {
super();
console.log('Test class constructed');
constructor(options) {
super(options);
this.options = options;
console.log(`Test class constructed with hello option '${options.hello}'`);
}
__call(method, args){
console.log(`Method is missing '${method}()'`)
}
}
const test = new Test();
const test = new Test({
hello: 'passed into constructor'
});
test.one('hi');
test.two();
test.three();
test.one('p1m1', 'p2m1');
test.two('p1m2', 'p2m2');
test.three('p1m3', 'p2m3');
test.nothing('p1m4', 'p2m4');
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