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

ee-class

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ee-class - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

23

lib/class.js

@@ -13,3 +13,3 @@ !function(){

setSuper = function(name, base, proto) {
base.super = function(){
base.super = function() {
if (base.___super) return base.___super.apply(this, Array.prototype.slice.call(arguments));

@@ -160,2 +160,23 @@ else throw new Error('The method «'+name+'» has no super «'+name+'» method on any protoype!')

}
// list all methods of a class
Class.inspect = function(obj, description) {
description = description || {};
Object.getOwnPropertyNames(obj).sort().forEach(function(name) {
if (typeof obj[name] === 'function') {
description[name] = function(){};
}
else if (name !== '___isEeClass') {
description[name] = obj[name];
}
});
if (Object.getPrototypeOf(obj)) {
description.super = {};
Class.inspect(Object.getPrototypeOf(obj), description.super);
}
return description;
}
}();

4

package.json
{
"name" : "ee-class"
, "description" : "A fast prototype based Javascript Class implementation"
, "version" : "1.0.8"
, "description" : "Fast prototype based javascript classes"
, "version" : "1.0.9"
, "homepage" : "https://github.com/eventEmitter/ee-class"

@@ -6,0 +6,0 @@ , "author" : "Michael van der Weg <michael@eventemitter.com> (http://eventemitter.com/)"

@@ -171,2 +171,3 @@ # ee-class

, isAlive: Class(false).Enumerable().Writable()
, die: function(){}
});

@@ -182,2 +183,4 @@

}
, sing: function() {}
});

@@ -197,2 +200,6 @@

}
, run: function(){}
, jump: function(){}
});

@@ -281,2 +288,41 @@

#### Class.inspect()
Inspects the internal structure of the class, returns it. Is helpful for debugging.
// inspecting the class instance created in the inheritnace example above
var description = Class.inspect(dylan);
log(description);
// { isAlive: true,
// name: 'Dylan',
// super:
// { init: [Function],
// jump: [Function],
// run: [Function],
// super:
// { sing: [Function],
// talk: [Function],
// super:
// { die: [Function],
// init: [Function],
// isAlive: false,
// super:
// { super:
// { __defineGetter__: [Function],
// __defineSetter__: [Function],
// __lookupGetter__: [Function],
// __lookupSetter__: [Function],
// constructor: [Function],
// hasOwnProperty: [Function],
// isPrototypeOf: [Function],
// propertyIsEnumerable: [Function],
// toLocaleString: [Function],
// toString: [Function],
// valueOf: [Function] } } } } } }
# Version History

@@ -302,2 +348,3 @@

- 1.0.7: If the class inherits from a native javascript object it will map the super of the init function to it
- 1.0.8: If a class is instantiated without the new keyword it now throws a menaingful error
- 1.0.8: If a class is instantiated without the new keyword it now throws a menaingful error
- 1.0.9: Added the Class.inspect method

@@ -342,2 +342,52 @@

});
it ('Describe the classes methods', function() {
var LifeForm = new Class({
init: function(isAlive) {
Class.define(this, 'isAlive', Class(isAlive).Enumerable().Writable());
}
, isAlive: Class(false).Enumerable().Writable()
, die: function(){}
});
var Person = new Class({
inherits: LifeForm
, talk: function(){
console.log('Hi my name is %s, i\'m '+(this.isAlive ? 'alive :)' : 'dead :('), this.name);
}
, sing: function() {}
});
var Boy = new Class({
inherits: Person
, init: function constructor(name, alive) {
// you need to give the function a name in order to be able to call its super
// you must «call» or «apply» the super function to give it the correct context
constructor.super.call(this, alive);
this.name = Class.define(this, 'name', Class(name).Enumerable());
}
, run: function(){}
, jump: function(){}
});
var instance = new Boy('Dylan', true);
/*console.log(JSON.stringify(util.inspect(Class.inspect(instance), {
depth: 10
})));*/
})

@@ -344,0 +394,0 @@

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