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

jahcode

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jahcode - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

16

jahcode.js

@@ -1,7 +0,7 @@

/*! Jahcode v1.1.5 | jahcode.com | Copyright 2011-2014 by Florian Buecklers | MIT license */
/*! Jahcode v1.1.6 | jahcode.com | Copyright 2011-2014 by Florian Buecklers | MIT license */
(function(global) {
var fakePrototype = Object.getPrototypeOf({
constructor : String
}) == String.prototype;
constructor : String
}) == String.prototype;

@@ -46,3 +46,4 @@ if (!Function.prototype.extend) {

inherit : function() {
var klass = function(toCast) {
var objectDescriptor = arguments[arguments.length - 1];
var klass = objectDescriptor.constructor !== Object? objectDescriptor.constructor: function Class(toCast) {
if (!(this instanceof klass)) {

@@ -53,6 +54,5 @@ return klass.asInstance(toCast);

if (this.initialize)
arguments.length ? this.initialize.apply(this, arguments) : this.initialize.call(this);
arguments.length ? this.initialize.apply(this, arguments) : this.initialize();
};
var objectDescriptor = arguments[arguments.length - 1];
var proto = Object.createPrototypeChain(klass, this, Array.prototype.slice.call(arguments, 0, arguments.length - 1));

@@ -348,3 +348,3 @@

var method = proto[name];
if (name != 'initialize' && method instanceof Function) {
if (name != 'initialize' && name != 'constructor' && method instanceof Function) {
callback(name, method);

@@ -392,3 +392,3 @@ }

stack = stack.substring(stack.indexOf('\n') + 1);
this.stack = message + '\n' + stack;

@@ -395,0 +395,0 @@ this.message = message;

@@ -1,3 +0,3 @@

/*! Jahcode v1.1.5 | jahcode.com | Copyright 2011-2014 by Florian Buecklers | MIT license */
!function(t){var e=Object.getPrototypeOf({constructor:String})==String.prototype;Function.prototype.extend||(Function.prototype.extend=function(t,e){e||(e=t,t=this);for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}),Object.extend(Function.prototype,{linearizedTypes:[Object],inherit:function(){for(var t=function(e){return this instanceof t?(this.initialize&&(arguments.length?this.initialize.apply(this,arguments):this.initialize.call(this)),void 0):t.asInstance(e)},e=arguments[arguments.length-1],r=Object.createPrototypeChain(t,this,Array.prototype.slice.call(arguments,0,arguments.length-1)),n=Object.getOwnPropertyNames(e),i=0;i<n.length;++i){var o=n[i],a=!1;if(Object.properties.hasOwnProperty(o)&&(a=Object.properties[o](r,e,o)),!a){var s=Object.getOwnPropertyDescriptor(e,o);if(s.value){var c=s.value;c instanceof Function?/this\.superCall/.test(c.toString())&&(s.value=Object.createSuperCallWrapper(t,o,c)):c&&(c.hasOwnProperty("get")||c.hasOwnProperty("value"))&&(s=c)}Object.defineProperty(r,o,s)}}return t.initialize&&t.initialize(),t},isA:function(t){return this.prototype instanceof t||-1!=this.linearizedTypes.lastIndexOf(t)},isInstance:function(t){return null===t||void 0===t?!1:Object(t)instanceof this||-1!=n(t).linearizedTypes.lastIndexOf(this)},asInstance:function(t){return this.isInstance(t)?t:this.conv(t)},conv:function(){return null}}),Object.extend({properties:{},cloneOwnProperties:function(t,e){for(var r=Object.getOwnPropertyNames(e),n=0;n<r.length;++n){var i=r[n];if("__proto__"!=i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o)}}},createPrototypeChain:function(t,r,n){for(var o,a=r.prototype,s=r.linearizedTypes.slice(),c=r.prototypeChain?r.prototypeChain.slice():[a],p=0;o=n[p];++p){if(!(o.prototype instanceof i))throw new TypeError("Only traits can be mixed in.");for(var l,u=o.linearizedTypes,h=0;l=u[h];++h)-1==s.indexOf(l)&&l!=i&&(a=Object.create(a),Object.cloneOwnProperties(a,l.wrappedPrototype?l.wrappedPrototype:l.prototype),a.constructor=l,s.push(l),c.push(a))}return a=Object.create(a),a.constructor=t,s.push(t),c.push(a),e?(t.wrappedPrototype=a,t.prototype=Object.create(a)):t.prototype=a,t.linearizedTypes=s,t.prototypeChain=c,a},createSuperCallWrapper:function(t,e,r){var i=function(){var r=n(this),i=r.linearizedTypes.lastIndexOf(t);if(-1==i)throw new ReferenceError("superCall can't determine any super method");var o=r.prototypeChain[i-1];return"initialize"!=e||o[e]?arguments.length?o[e].apply(this,arguments):o[e].call(this):void 0};return function(){var t=this.superCall;this.superCall=i;try{return arguments.length?r.apply(this,arguments):r.call(this)}finally{t?this.superCall=t:delete this.superCall}}}}),Object.extend(Object.properties,{initialize:function(t,e){var r=e.initialize,o=/this\.superCall/.test(r.toString());if(t instanceof i){if(o)throw new TypeError("Trait constructors can not call super constructors directly.");e.initialize=function(){arguments.length?this.superCall.apply(this,arguments):this.superCall.call(this),r.call(this)}}else o||n(t)==Object||(e.initialize=function(){this.superCall.call(this),arguments.length?r.apply(this,arguments):r.call(this)})},extend:function(t,e){return Object.extend(t.constructor,e.extend),!0}});for(var r,n=function(t){return null===t||void 0===t?t:Object.getPrototypeOf(Object(t)).constructor},i=Object.inherit({}),o=(i.inherit({extend:{initialize:function(){try{Object.defineProperty(this.prototype,"bind",{get:function(){return this.bind=o.create(this)},set:function(t){Object.defineProperty(this,"bind",{value:t})},configurable:!0}),this.Object=Object.inherit({initialize:function(t){this.self=t}})}catch(t){this.Object=Object.inherit({initialize:function(t){this.self=t;var e=this;o.each(t,function(t,r){e[t]=r.bind(e.self)})}})}},create:function(t){if(!t.constructor.Bind)try{var e={};o.each(t,function(t,r){e[t]={get:function(){return this[t]=r.bind(this.self)},set:function(e){Object.defineProperty(this,t,{value:e})},configurable:!0}}),t.constructor.Bind=o.Object.inherit(e)}catch(r){t.constructor.Bind=o.Object.inherit({})}return new t.constructor.Bind(t)},each:function(t,e){var r=Object.getPrototypeOf(t);for(var n in r){var i=r[n];"initialize"!=n&&i instanceof Function&&e(n,i)}}},initialize:function(){"bind"in this||(this.bind=o.create(this))}})),a=[Boolean,Number,String,Function,RegExp,Error],s=0;r=a[s];++s)r.conv=r;Date.conv=function(t){return new Date(t)},Array.conv=function(t){return Array.prototype.slice.call(t)},Array.prototype.initialize=function(){for(var t=0;t<arguments.length;++t)this[t]=arguments[t];this.length=arguments.length},Error.prototype.initialize=function(t){var e=(new Error).stack||"Error";e=e.substring(e.indexOf("\n")+1),this.stack=t+"\n"+e,this.message=t},TypeError instanceof Error&&(Error.prototype.isInstance=Error.isInstance,Error.prototype.asInstance=Error.asInstance,Error.prototype.conv=Error.conv),Object.extend(t,{classOf:n,Trait:i,Bind:o})}("undefined"!=typeof window?window:global);
/*! Jahcode v1.1.6 | jahcode.com | Copyright 2011-2014 by Florian Buecklers | MIT license */
!function(t){var e=Object.getPrototypeOf({constructor:String})==String.prototype;Function.prototype.extend||(Function.prototype.extend=function(t,e){e||(e=t,t=this);for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}),Object.extend(Function.prototype,{linearizedTypes:[Object],inherit:function(){for(var t=arguments[arguments.length-1],e=t.constructor!==Object?t.constructor:function(t){return this instanceof e?(this.initialize&&(arguments.length?this.initialize.apply(this,arguments):this.initialize()),void 0):e.asInstance(t)},r=Object.createPrototypeChain(e,this,Array.prototype.slice.call(arguments,0,arguments.length-1)),n=Object.getOwnPropertyNames(t),i=0;i<n.length;++i){var o=n[i],a=!1;if(Object.properties.hasOwnProperty(o)&&(a=Object.properties[o](r,t,o)),!a){var c=Object.getOwnPropertyDescriptor(t,o);if(c.value){var s=c.value;s instanceof Function?/this\.superCall/.test(s.toString())&&(c.value=Object.createSuperCallWrapper(e,o,s)):s&&(s.hasOwnProperty("get")||s.hasOwnProperty("value"))&&(c=s)}Object.defineProperty(r,o,c)}}return e.initialize&&e.initialize(),e},isA:function(t){return this.prototype instanceof t||-1!=this.linearizedTypes.lastIndexOf(t)},isInstance:function(t){return null===t||void 0===t?!1:Object(t)instanceof this||-1!=n(t).linearizedTypes.lastIndexOf(this)},asInstance:function(t){return this.isInstance(t)?t:this.conv(t)},conv:function(){return null}}),Object.extend({properties:{},cloneOwnProperties:function(t,e){for(var r=Object.getOwnPropertyNames(e),n=0;n<r.length;++n){var i=r[n];if("__proto__"!=i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o)}}},createPrototypeChain:function(t,r,n){for(var o,a=r.prototype,c=r.linearizedTypes.slice(),s=r.prototypeChain?r.prototypeChain.slice():[a],p=0;o=n[p];++p){if(!(o.prototype instanceof i))throw new TypeError("Only traits can be mixed in.");for(var u,l=o.linearizedTypes,h=0;u=l[h];++h)-1==c.indexOf(u)&&u!=i&&(a=Object.create(a),Object.cloneOwnProperties(a,u.wrappedPrototype?u.wrappedPrototype:u.prototype),a.constructor=u,c.push(u),s.push(a))}return a=Object.create(a),a.constructor=t,c.push(t),s.push(a),e?(t.wrappedPrototype=a,t.prototype=Object.create(a)):t.prototype=a,t.linearizedTypes=c,t.prototypeChain=s,a},createSuperCallWrapper:function(t,e,r){var i=function(){var r=n(this),i=r.linearizedTypes.lastIndexOf(t);if(-1==i)throw new ReferenceError("superCall can't determine any super method");var o=r.prototypeChain[i-1];return"initialize"!=e||o[e]?arguments.length?o[e].apply(this,arguments):o[e].call(this):void 0};return function(){var t=this.superCall;this.superCall=i;try{return arguments.length?r.apply(this,arguments):r.call(this)}finally{t?this.superCall=t:delete this.superCall}}}}),Object.extend(Object.properties,{initialize:function(t,e){var r=e.initialize,o=/this\.superCall/.test(r.toString());if(t instanceof i){if(o)throw new TypeError("Trait constructors can not call super constructors directly.");e.initialize=function(){arguments.length?this.superCall.apply(this,arguments):this.superCall.call(this),r.call(this)}}else o||n(t)==Object||(e.initialize=function(){this.superCall.call(this),arguments.length?r.apply(this,arguments):r.call(this)})},extend:function(t,e){return Object.extend(t.constructor,e.extend),!0}});for(var r,n=function(t){return null===t||void 0===t?t:Object.getPrototypeOf(Object(t)).constructor},i=Object.inherit({}),o=(i.inherit({extend:{initialize:function(){try{Object.defineProperty(this.prototype,"bind",{get:function(){return this.bind=o.create(this)},set:function(t){Object.defineProperty(this,"bind",{value:t})},configurable:!0}),this.Object=Object.inherit({initialize:function(t){this.self=t}})}catch(t){this.Object=Object.inherit({initialize:function(t){this.self=t;var e=this;o.each(t,function(t,r){e[t]=r.bind(e.self)})}})}},create:function(t){if(!t.constructor.Bind)try{var e={};o.each(t,function(t,r){e[t]={get:function(){return this[t]=r.bind(this.self)},set:function(e){Object.defineProperty(this,t,{value:e})},configurable:!0}}),t.constructor.Bind=o.Object.inherit(e)}catch(r){t.constructor.Bind=o.Object.inherit({})}return new t.constructor.Bind(t)},each:function(t,e){var r=Object.getPrototypeOf(t);for(var n in r){var i=r[n];"initialize"!=n&&"constructor"!=n&&i instanceof Function&&e(n,i)}}},initialize:function(){"bind"in this||(this.bind=o.create(this))}})),a=[Boolean,Number,String,Function,RegExp,Error],c=0;r=a[c];++c)r.conv=r;Date.conv=function(t){return new Date(t)},Array.conv=function(t){return Array.prototype.slice.call(t)},Array.prototype.initialize=function(){for(var t=0;t<arguments.length;++t)this[t]=arguments[t];this.length=arguments.length},Error.prototype.initialize=function(t){var e=(new Error).stack||"Error";e=e.substring(e.indexOf("\n")+1),this.stack=t+"\n"+e,this.message=t},TypeError instanceof Error&&(Error.prototype.isInstance=Error.isInstance,Error.prototype.asInstance=Error.asInstance,Error.prototype.conv=Error.conv),Object.extend(t,{classOf:n,Trait:i,Bind:o})}("undefined"!=typeof window?window:global);
//# sourceMappingURL=jahcode.map
{
"name": "jahcode",
"version": "1.1.5",
"version": "1.1.6",
"description": "Scala like Classes and Traits in JavaScript",

@@ -5,0 +5,0 @@ "author": {

@@ -131,2 +131,17 @@ require('../jahcode.js');

describe("with property", function() {
it("constructor should overwrite the default constructor", function() {
var myClass = Object.inherit({
constructor: function(a,b,c) {
this.a = a;
this.b = b;
this.c = c;
}
});
var cls = new myClass(1,2,3);
expect(cls.a).toEqual(1);
expect(cls.b).toEqual(2);
expect(cls.c).toEqual(3);
});
it("should define simple property", function() {

@@ -133,0 +148,0 @@ var myClass = Object.inherit({

Sorry, the diff of this file is not supported yet

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