Comparing version 1.1.4 to 1.1.5
@@ -1,2 +0,2 @@ | ||
/*! Jahcode v1.1.4 | jahcode.com | Copyright 2011-2014 by Florian Buecklers | MIT license */ | ||
/*! Jahcode v1.1.5 | jahcode.com | Copyright 2011-2014 by Florian Buecklers | MIT license */ | ||
@@ -106,3 +106,3 @@ (function(global) { | ||
isInstance : function(obj) { | ||
if (obj === null || obj === undefined) | ||
if (obj === null || obj === void 0) | ||
return false; | ||
@@ -257,2 +257,5 @@ | ||
var classOf = function(object) { | ||
if (object === null || object === void 0) | ||
return object; | ||
return Object.getPrototypeOf(Object(object)).constructor; | ||
@@ -259,0 +262,0 @@ }; |
@@ -1,3 +0,3 @@ | ||
/*! Jahcode v1.1.4 | 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 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.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); | ||
//# sourceMappingURL=jahcode.map |
{ | ||
"name": "jahcode", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Scala like Classes and Traits in JavaScript", | ||
@@ -5,0 +5,0 @@ "author": { |
require('../jahcode.js'); | ||
describe("Native undefined", function() { | ||
it("should be instances of undefined", function() { | ||
expect(classOf(undefined)).toBeUndefined(); | ||
}); | ||
}); | ||
describe("Native null", function() { | ||
it("should be instances of null", function() { | ||
expect(null).toBeNull(); | ||
}); | ||
}); | ||
describe("Native booleans", function() { | ||
@@ -4,0 +16,0 @@ var vals = [true, false, Boolean(true), new Boolean(false)]; |
Sorry, the diff of this file is not supported yet
400929
8221