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 0.2.8 to 0.3.0

112

lib/class.js

@@ -5,21 +5,25 @@ !function(global){

// clone whatever comes
var clone = function( input ){
/*
* the clone method recursively clones varaibles of any type
*
* @param <Mixed> anything
*/
var clone = function(input) {
var result, i, keys;
switch ( typeof input ){
case "object":
if ( Array.isArray( input ) ){
result = input.length > 0 ? input.slice( 0 ) : [];
switch (typeof input) {
case 'object':
if (Array.isArray(input)) {
result = input.length > 0 ? input.slice(0) : [];
i = result.length;
while( i-- ) result[ i ] = clone( result[ i ] );
while(i--) result[i] = clone(result[i]);
}
else if ( Buffer.isBuffer( input ) ){
result = new Buffer( input.length );
input.copy( result );
else if (Buffer.isBuffer(input)){
result = new Buffer(input.length);
input.copy(result);
}
else if ( input === null ){
else if (input === null){
return null;
}
else if ( input instanceof RegExp ){
else if (input instanceof RegExp){
return input;

@@ -29,5 +33,5 @@ }

result = {};
keys = Object.keys( input );
keys = Object.keys(input);
i = keys.length;
while( i-- ) result[ keys[ i ] ] = clone( input[ keys[ i ] ] );
while(i--) result[keys[i]] = clone(input[keys[i]]);
}

@@ -44,8 +48,21 @@ break;

// create an properties object
var makeProperties = function( input ){
var properties = {}
, keys = Object.keys( input )
/*
* the makeProperties method creates a properties object
* that can be consumed by «Object-create» api
*
* @param <Mixed> anything
*/
var makeProperties = function(input) {
var properties = {}
, keys = Object.keys(input)
, i = keys.length;
while( i-- ) properties[ keys[ i ] ] = { value: input[ keys[ i ] ], writable: true, configurable: true, enumerable: true };
while(i--) {
properties[keys[i]] = {
value: input[keys[i]]
, writable: true
, configurable: true
, enumerable: true
};
}
return properties;

@@ -55,6 +72,12 @@ }

var findProto = function( proto, name ){
if ( typeof proto[ name ] === "function" ) return proto[ name ];
else if (Object.getPrototypeOf(proto)) return findProto(Object.getPrototypeOf(proto), name );
/*
* the findProto method seeks the next function of the same name
* in the prototype chain, returns it
*
* @param <Object> prototype
* @param <name> name of the function
*/
var findProto = function(proto, name) {
if (typeof proto[name] === 'function') return proto[name];
else if (Object.getPrototypeOf(proto)) return findProto(Object.getPrototypeOf(proto), name);
else null;

@@ -64,20 +87,20 @@ }

var bindFunctions = function( thisObject, proto ){
/*
* the bindFunctions method binds function on the prototype to
* the given scope (thisObject)
*
* @param <Object> thisObject
* @param <Object> proto to map functions
*/
var bindFunctions = function(thisObject, proto) {
var parent = Object.getPrototypeOf(proto);
if (!parent) return;
Object.keys( proto ).forEach( function( name ){
if( typeof proto[ name ] === "function" ){
var p = findProto( parent, name );
if (p){
proto[name].super = function(){
console.log( 'Ee-class: the «super» property is deprecated, please use the «parent» property instead!' );
p.apply(thisObject, Array.prototype.slice.call(arguments));
}.bind(thisObject);
proto[name].parent = p.bind(thisObject);
}
Object.keys(proto).forEach(function(functionName) {
if (typeof proto[functionName] === 'function') {
var parentFunction = findProto(parent, functionName);
if (parentFunction) proto[functionName].parent = parentFunction.bind(thisObject);
}
} );
});
}

@@ -186,16 +209,3 @@

// parent ( deprecated )
if ( parent ) {
Object.defineProperty( instance, "parent", {
get: function(){
/*console.log( "the «parent» property is deprecated, it will be removed on the next version!" );
console.log( "use the «super» property on each functions instead. see the README.md file." );
console.log( "docs: https://npmjs.org/package/ee-class" );*/
return parent;
}
, enumerable: true
, configurable: true
} );
}
// bind super functions to current function

@@ -202,0 +212,0 @@ var binder = function( proto ){

{
"name" : "ee-class"
, "description" : "Javascript Class implementation for node.js"
, "version" : "0.2.8"
, "description" : "Javascript Class implementation for node.js & ecma script 5 compatible browsers"
, "version" : "0.3.0"
, "homepage" : "https://github.com/eventEmitter/ee-class"

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

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