diff --git a/Gruntfile.js b/Gruntfile.js index c11f774..f42050a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,5 +1,5 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. // diff --git a/bower.json b/bower.json index 2bd9a82..5f2c8d6 100644 --- a/bower.json +++ b/bower.json @@ -1,30 +1,33 @@ { - "name": "enofjs", - "version": "3.0.0", - "main": "src/enofjs", - "devDependencies": { - "jasmine": "^2.0" - }, - "homepage": "http://enof.github.io/EnoFJS/", - "authors": [ - "(Andy Tang)" - ], - "description": "Enhancing javascript", - "keywords": [ - "enof", - "enofjs", - "inheritance", - "linkedHashMap", - "protected", - "super", - "whereIt" - ], - "license": "MIT", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ] + "name": "enofjs", + "version": "3.1.0", + "main": "src/enofjs", + "devDependencies": { + "jasmine": "^2.0" + }, + "homepage": "http://enof.github.io/EnoFJS/", + "authors": [ + "(Andy Tang)" + ], + "description": "Enhancing javascript", + "keywords": [ + "enof", + "enofjs", + "inheritance", + "linkedHashMap", + "protected", + "super", + "whereIt" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ], + "dependencies": { + "requirejs": "~2.1.15" + } } diff --git a/dist/enofjs/min.ArrayConverters.js b/dist/enofjs/min.ArrayConverters.js index c567469..4fea9fd 100644 --- a/dist/enofjs/min.ArrayConverters.js +++ b/dist/enofjs/min.ArrayConverters.js @@ -1 +1 @@ -/* !!EnoFJS!! Version: 3.0.0, Author: EnoF (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(){"use strict";function a(){for(var a=this,b=new Uint32Array(a.length/4),c=0;c>>0;return b}function b(a){for(var b=this,c=new Uint8Array(a.buffer),d=0;d (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(){"use strict";function a(){for(var a=this,b=new Uint32Array(a.length/4),c=0;c>>0;return b}function b(a){for(var b=this,c=new Uint8Array(a.buffer),d=0;d (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(a,b,c){"use strict";var d=a.require("./clazz.js"),e=d(function(){this.private={key:{getSet:null},value:{getSet:null},previous:{getSet:null},next:{getSet:null}},this.constructor=function(a,b){this.private.key=a,this.private.value=b}}),LinkedHashMap=d(function(){this.private={duplicateKeyError:"key already exists in LinkedHashMap",keyNotFoundError:"key not found",size:{get:0},first:{get:null},last:{get:null},hashMap:{},add:function(a,b){if(this.private.hashMap.hasOwnProperty(a))throw new Error(this.private.duplicateKeyError);var c=new e(a,b);return this.private.hashMap[a]=c,this.private.size++,c},remove:function(a){var b=a.getKey();a===this.private.first?(this.private.first=this.private.first.getNext(),this.private.first instanceof e&&this.private.first.setPrevious(null)):a===this.private.last?(this.private.last=this.private.last.getPrevious(),this.private.last.setNext(null)):(a.getPrevious().setNext(a.getNext()),a.getNext().setPrevious(a.getPrevious())),this.private.size--,delete this.private.hashMap[b]}},this.protected={addAfter:function(a,b){var c=a.getNext();null!==c?(c.setPrevious(b),b.setNext(c)):this.private.last=b,a.setNext(b),b.setPrevious(a)},addBefore:function(a,b){var c=a.getPrevious();null!==c?(c.setNext(b),b.setPrevious(c)):this.private.first=b,a.setPrevious(b),b.setNext(a)}},this.public={add:function(a,b){var c=this.private.add(a,b);return 1===this.private.size?this.private.first=c:this.protected.addAfter(this.private.last,c),this.private.last=c,c},addAfter:function(a,b,c){var d=this.private.add(b,c),e=this.public.getById(a);return this.protected.addAfter(e,d),d},addBefore:function(a,b,c){var d=this.private.add(b,c),e=this.public.getById(a);return this.protected.addBefore(e,d),d},addFirst:function(a,b){var c=this.private.add(a,b),d=this.private.first;return null!==d&&this.protected.addBefore(d,c),c},addLast:function(a,b){return this.public.add(a,b)},getById:function(a){var b=this.private.hashMap[a];if(b===c)throw new Error(this.private.keyNotFoundError);return b},isEmpty:function(){return 0===this.private.size},remove:function(a){return this.private.hashMap.hasOwnProperty(a)?this.private.remove(this.public.getById(a)):!1},removeFirst:function(){return null===this.private.first?!1:this.private.remove(this.private.first)},removeLast:function(){return null===this.private.last?!1:this.private.remove(this.private.last)}},this.constructor=function(){this.private.hashMap={}}});a.exports(b,LinkedHashMap,"./LinkedHashMap.js")}(require("./node-shim.js"),module); \ No newline at end of file +/* !!EnoFJS!! Version: 3.1.0, Author: EnoF (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(a,b,c){"use strict";var d=a.require("./clazz.js"),e=d(function(){this.private={key:{getSet:null},value:{getSet:null},previous:{getSet:null},next:{getSet:null}},this.constructor=function(a,b){this.private.key=a,this.private.value=b}}),LinkedHashMap=d(function(){this.private={duplicateKeyError:"key already exists in LinkedHashMap",keyNotFoundError:"key not found",size:{get:0},first:{get:null},last:{get:null},hashMap:{},add:function(a,b){if(this.private.hashMap.hasOwnProperty(a))throw new Error(this.private.duplicateKeyError);var c=new e(a,b);return this.private.hashMap[a]=c,this.private.size++,c},remove:function(a){var b=a.getKey();a===this.private.first?(this.private.first=this.private.first.getNext(),this.private.first instanceof e&&this.private.first.setPrevious(null)):a===this.private.last?(this.private.last=this.private.last.getPrevious(),this.private.last.setNext(null)):(a.getPrevious().setNext(a.getNext()),a.getNext().setPrevious(a.getPrevious())),this.private.size--,delete this.private.hashMap[b]}},this.protected={addAfter:function(a,b){var c=a.getNext();null!==c?(c.setPrevious(b),b.setNext(c)):this.private.last=b,a.setNext(b),b.setPrevious(a)},addBefore:function(a,b){var c=a.getPrevious();null!==c?(c.setNext(b),b.setPrevious(c)):this.private.first=b,a.setPrevious(b),b.setNext(a)}},this.public={add:function(a,b){var c=this.private.add(a,b);return 1===this.private.size?this.private.first=c:this.protected.addAfter(this.private.last,c),this.private.last=c,c},addAfter:function(a,b,c){var d=this.private.add(b,c),e=this.public.getById(a);return this.protected.addAfter(e,d),d},addBefore:function(a,b,c){var d=this.private.add(b,c),e=this.public.getById(a);return this.protected.addBefore(e,d),d},addFirst:function(a,b){var c=this.private.add(a,b),d=this.private.first;return null!==d&&this.protected.addBefore(d,c),c},addLast:function(a,b){return this.public.add(a,b)},getById:function(a){var b=this.private.hashMap[a];if(b===c)throw new Error(this.private.keyNotFoundError);return b},isEmpty:function(){return 0===this.private.size},remove:function(a){return this.private.hashMap.hasOwnProperty(a)?this.private.remove(this.public.getById(a)):!1},removeFirst:function(){return null===this.private.first?!1:this.private.remove(this.private.first)},removeLast:function(){return null===this.private.last?!1:this.private.remove(this.private.last)}},this.constructor=function(){this.private.hashMap={}}});a.exports(b,LinkedHashMap,"./LinkedHashMap.js")}(require("./node-shim.js"),module); \ No newline at end of file diff --git a/dist/enofjs/min.Serializable.js b/dist/enofjs/min.Serializable.js index 128dbf4..2be2557 100644 --- a/dist/enofjs/min.Serializable.js +++ b/dist/enofjs/min.Serializable.js @@ -1 +1 @@ -/* !!EnoFJS!! Version: 3.0.0, Author: EnoF (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(a,b){"use strict";function Serializable(){this.private={deserialize:function(a){for(var b in a)b in this.protected?this.protected[b]=a[b]:b in this.private&&(this.private[b]=a[b])},serialize:function(a,b){for(var c in a){var d=a[c];this.private.isNumberOrString(d)?b[c]=a[c]:d instanceof Array&&(b[c]=[],this.private.serializeArray(d,b[c]),0===b[c].length&&delete b[c])}},isNumberOrString:function(a){var b=typeof a;return"number"===b||"string"===b},serializeArray:function(a,b){for(var c=0;c (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(a,b){"use strict";function Serializable(){this.private={deserialize:function(a){for(var b in a)b in this.protected?this.protected[b]=a[b]:b in this.private&&(this.private[b]=a[b])},serialize:function(a,b){for(var c in a){var d=a[c];this.private.isNumberOrString(d)?b[c]=a[c]:d instanceof Array&&(b[c]=[],this.private.serializeArray(d,b[c]),0===b[c].length&&delete b[c])}},isNumberOrString:function(a){var b=typeof a;return"number"===b||"string"===b},serializeArray:function(a,b){for(var c=0;c (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(a,b,c){"use strict";function d(a){var b=a.extractFunctionName();return e(b,a)}function e(a,b){var d,e,j=q(new b);i("private",j.private,j.public),i("protected",j.protected,j.public),j.extend!==c&&(d=u[j.extend],e=f(j,d));var k=g(j,d);return j.extend!==c&&h(k,e),u[a]=k,o(a,k)}function f(a,b){var c={"private":new b.Private,"protected":new b.Protected,"public":new b.Public,constructor:b.constructor};return m(c.private,a.private),m(c.protected,a.protected),m(c.public,a.public),c}function g(a,b){function d(){}function e(){}function f(){}d.prototype=a.private,e.prototype=a.protected,f.prototype=a.public;var g={extend:a.extend,constructor:a.constructor,sup:b!==c?b.constructor:function(){},Private:d,Protected:e,Public:f};return g}function h(a,b){a.Private.prototype.sup=b.private,a.Protected.prototype.sup=b.protected,a.Public.prototype.sup=b.public,p(a,a.Private.prototype.sup),p(a,a.Private.prototype.sup),p(a,a.Public.prototype.sup)}function i(a,b,c){for(var d in b){var e=b[d],f=!1,g=!1,h=d.capitaliseFirstLetter();e instanceof Object&&(r(e)?(b[d]=e.get,c["get"+h]=j(a,d),f=!0):t(e)&&(b[d]=e.is,c["is"+h]=k(a,d),g=!0),s(e)&&(b[d]=f?e.getSet:g?e.isSet:e.set,c["set"+h]=l(a,d)))}}function j(a,b){return function(){return this[a][b]}}function k(a,b){return function(){return this[a][b]}}function l(a,b){return function(c){this[a][b]=c}}function m(a,b){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}function n(a,b){for(var c in b)a[c]=b[c]}function o(a,b){function d(){var a={"private":new b.Private,"protected":new b.Protected,"public":new b.Public,constructor:b.constructor,sup:b.sup};p(a,a.private),p(a,a.protected),p(a,a.public),n(this,a.public),a.constructor.apply(a,arguments)}return b.extend!==c&&(d.prototype=new v[b.extend]),v[a]=d,d}function p(a,b){b.private=a.private||a.Private.prototype,b.protected=a.protected||a.Protected.prototype,b.public=a.public||a.Public.prototype}function q(a){return a.private=a.private||{},a.protected=a.protected||{},a.public=a.public||{},a.sup=a.sup||{},a.constructor=a.constructor||function(){},a}function r(a){return a.hasOwnProperty("get")||a.hasOwnProperty("getSet")}function s(a){return a.hasOwnProperty("set")||a.hasOwnProperty("getSet")||a.hasOwnProperty("isSet")}function t(a){return a.hasOwnProperty("is")||a.hasOwnProperty("isSet")}var u={},v={};Function.prototype.extractFunctionName=function(){var a=this.toString();return a=a.substr("function ".length),a=a.substr(0,a.indexOf("("))},Function.prototype.bindScope=function(a){var b=this;return function(){return b.apply(a,arguments)}},String.prototype.capitaliseFirstLetter=function(){return this.charAt(0).toUpperCase()+this.slice(1)},a.exports(b,d,"./clazz.js")}(require("./node-shim.js"),module); \ No newline at end of file +/* !!EnoFJS!! Version: 3.1.0, Author: EnoF (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(a,b,c){"use strict";function d(a){var b=a.extractFunctionName();return e(b,a)}function e(a,b){var d,e,j=q(new b);i("private",j.private,j.public),i("protected",j.protected,j.public),j.extend!==c&&(d=u[j.extend],e=f(j,d));var k=g(j,d);return j.extend!==c&&h(k,e),u[a]=k,o(a,k)}function f(a,b){var c={"private":new b.Private,"protected":new b.Protected,"public":new b.Public,constructor:b.constructor};return m(c.private,a.private),m(c.protected,a.protected),m(c.public,a.public),c}function g(a,b){function d(){}function e(){}function f(){}d.prototype=a.private,e.prototype=a.protected,f.prototype=a.public;var g={extend:a.extend,constructor:a.constructor,sup:b!==c?b.constructor:function(){},Private:d,Protected:e,Public:f};return g}function h(a,b){a.Private.prototype.sup=b.private,a.Protected.prototype.sup=b.protected,a.Public.prototype.sup=b.public,p(a,a.Private.prototype.sup),p(a,a.Private.prototype.sup),p(a,a.Public.prototype.sup)}function i(a,b,c){for(var d in b){var e=b[d],f=!1,g=!1,h=d.capitaliseFirstLetter();e instanceof Object&&(r(e)?(b[d]=e.get,c["get"+h]=j(a,d),f=!0):t(e)&&(b[d]=e.is,c["is"+h]=k(a,d),g=!0),s(e)&&(b[d]=f?e.getSet:g?e.isSet:e.set,c["set"+h]=l(a,d)))}}function j(a,b){return function(){return this[a][b]}}function k(a,b){return function(){return this[a][b]}}function l(a,b){return function(c){this[a][b]=c}}function m(a,b){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}function n(a,b){for(var c in b)a[c]=b[c]}function o(a,b){function d(){var a={"private":new b.Private,"protected":new b.Protected,"public":new b.Public,constructor:b.constructor,sup:b.sup};p(a,a.private),p(a,a.protected),p(a,a.public),n(this,a.public),a.constructor.apply(a,arguments)}return b.extend!==c&&(d.prototype=new v[b.extend]),v[a]=d,d}function p(a,b){b.private=a.private||a.Private.prototype,b.protected=a.protected||a.Protected.prototype,b.public=a.public||a.Public.prototype}function q(a){return a.private=a.private||{},a.protected=a.protected||{},a.public=a.public||{},a.sup=a.sup||{},a.constructor=a.constructor||function(){},a}function r(a){return a.hasOwnProperty("get")||a.hasOwnProperty("getSet")}function s(a){return a.hasOwnProperty("set")||a.hasOwnProperty("getSet")||a.hasOwnProperty("isSet")}function t(a){return a.hasOwnProperty("is")||a.hasOwnProperty("isSet")}var u={},v={};Function.prototype.extractFunctionName=function(){var a=this.toString();return a=a.substr("function ".length),a=a.substr(0,a.indexOf("("))},Function.prototype.bindScope=function(a){var b=this;return function(){return b.apply(a,arguments)}},String.prototype.capitaliseFirstLetter=function(){return this.charAt(0).toUpperCase()+this.slice(1)},a.exports(b,d,"./clazz.js")}(require("./node-shim.js"),module); \ No newline at end of file diff --git a/dist/enofjs/min.enof.js b/dist/enofjs/min.enof.js index 5906525..a482ade 100644 --- a/dist/enofjs/min.enof.js +++ b/dist/enofjs/min.enof.js @@ -1 +1 @@ -/* !!EnoFJS!! Version: 3.0.0, Author: EnoF (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(a){"use strict";void 0!==a?(a.module=a.module||{},a.require=function(b){return a[b.replace(/(.\/)|.js/g,"")]||a},a.exports=function(b,c,d){a[d]=c,a[d.replace(/(.\/)|.js/g,"")]=c}):module.exports={require:require,exports:function(a,b){a.exports=b}}}(this.window),function(a,b,c){"use strict";function d(a){var b=a.extractFunctionName();return e(b,a)}function e(a,b){var d,e,j=q(new b);i("private",j.private,j.public),i("protected",j.protected,j.public),j.extend!==c&&(d=u[j.extend],e=f(j,d));var k=g(j,d);return j.extend!==c&&h(k,e),u[a]=k,o(a,k)}function f(a,b){var c={"private":new b.Private,"protected":new b.Protected,"public":new b.Public,constructor:b.constructor};return m(c.private,a.private),m(c.protected,a.protected),m(c.public,a.public),c}function g(a,b){function d(){}function e(){}function f(){}d.prototype=a.private,e.prototype=a.protected,f.prototype=a.public;var g={extend:a.extend,constructor:a.constructor,sup:b!==c?b.constructor:function(){},Private:d,Protected:e,Public:f};return g}function h(a,b){a.Private.prototype.sup=b.private,a.Protected.prototype.sup=b.protected,a.Public.prototype.sup=b.public,p(a,a.Private.prototype.sup),p(a,a.Private.prototype.sup),p(a,a.Public.prototype.sup)}function i(a,b,c){for(var d in b){var e=b[d],f=!1,g=!1,h=d.capitaliseFirstLetter();e instanceof Object&&(r(e)?(b[d]=e.get,c["get"+h]=j(a,d),f=!0):t(e)&&(b[d]=e.is,c["is"+h]=k(a,d),g=!0),s(e)&&(b[d]=f?e.getSet:g?e.isSet:e.set,c["set"+h]=l(a,d)))}}function j(a,b){return function(){return this[a][b]}}function k(a,b){return function(){return this[a][b]}}function l(a,b){return function(c){this[a][b]=c}}function m(a,b){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}function n(a,b){for(var c in b)a[c]=b[c]}function o(a,b){function d(){var a={"private":new b.Private,"protected":new b.Protected,"public":new b.Public,constructor:b.constructor,sup:b.sup};p(a,a.private),p(a,a.protected),p(a,a.public),n(this,a.public),a.constructor.apply(a,arguments)}return b.extend!==c&&(d.prototype=new v[b.extend]),v[a]=d,d}function p(a,b){b.private=a.private||a.Private.prototype,b.protected=a.protected||a.Protected.prototype,b.public=a.public||a.Public.prototype}function q(a){return a.private=a.private||{},a.protected=a.protected||{},a.public=a.public||{},a.sup=a.sup||{},a.constructor=a.constructor||function(){},a}function r(a){return a.hasOwnProperty("get")||a.hasOwnProperty("getSet")}function s(a){return a.hasOwnProperty("set")||a.hasOwnProperty("getSet")||a.hasOwnProperty("isSet")}function t(a){return a.hasOwnProperty("is")||a.hasOwnProperty("isSet")}var u={},v={};Function.prototype.extractFunctionName=function(){var a=this.toString();return a=a.substr("function ".length),a=a.substr(0,a.indexOf("("))},Function.prototype.bindScope=function(a){var b=this;return function(){return b.apply(a,arguments)}},String.prototype.capitaliseFirstLetter=function(){return this.charAt(0).toUpperCase()+this.slice(1)},a.exports(b,d,"./clazz.js")}(require("./node-shim.js"),module),function(){"use strict";function a(){for(var a=this,b=new Uint32Array(a.length/4),c=0;c>>0;return b}function b(a){for(var b=this,c=new Uint8Array(a.buffer),d=0;d (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(a){"use strict";function b(b){return d[b.replace(/(.\/)|.js/g,"")]||a}function c(c){try{return"string"==typeof c?e(c):e.apply(a,arguments)}catch(d){var f=b(c);if(f)return f;throw d}}var d={};if(void 0!==a){var e=a.require,f="function"==typeof e;a.module=a.module||{},a.require=f?c:b,a.exports=function(a,b,c){d[c]=b,d[c.replace(/(.\/)|.js/g,"")]=b}}else module.exports={require:require,exports:function(a,b){a.exports=b}}}(this.window),function(a,b,c){"use strict";function d(a){var b=a.extractFunctionName();return e(b,a)}function e(a,b){var d,e,j=q(new b);i("private",j.private,j.public),i("protected",j.protected,j.public),j.extend!==c&&(d=u[j.extend],e=f(j,d));var k=g(j,d);return j.extend!==c&&h(k,e),u[a]=k,o(a,k)}function f(a,b){var c={"private":new b.Private,"protected":new b.Protected,"public":new b.Public,constructor:b.constructor};return m(c.private,a.private),m(c.protected,a.protected),m(c.public,a.public),c}function g(a,b){function d(){}function e(){}function f(){}d.prototype=a.private,e.prototype=a.protected,f.prototype=a.public;var g={extend:a.extend,constructor:a.constructor,sup:b!==c?b.constructor:function(){},Private:d,Protected:e,Public:f};return g}function h(a,b){a.Private.prototype.sup=b.private,a.Protected.prototype.sup=b.protected,a.Public.prototype.sup=b.public,p(a,a.Private.prototype.sup),p(a,a.Private.prototype.sup),p(a,a.Public.prototype.sup)}function i(a,b,c){for(var d in b){var e=b[d],f=!1,g=!1,h=d.capitaliseFirstLetter();e instanceof Object&&(r(e)?(b[d]=e.get,c["get"+h]=j(a,d),f=!0):t(e)&&(b[d]=e.is,c["is"+h]=k(a,d),g=!0),s(e)&&(b[d]=f?e.getSet:g?e.isSet:e.set,c["set"+h]=l(a,d)))}}function j(a,b){return function(){return this[a][b]}}function k(a,b){return function(){return this[a][b]}}function l(a,b){return function(c){this[a][b]=c}}function m(a,b){for(var c in a)b.hasOwnProperty(c)||(b[c]=a[c])}function n(a,b){for(var c in b)a[c]=b[c]}function o(a,b){function d(){var a={"private":new b.Private,"protected":new b.Protected,"public":new b.Public,constructor:b.constructor,sup:b.sup};p(a,a.private),p(a,a.protected),p(a,a.public),n(this,a.public),a.constructor.apply(a,arguments)}return b.extend!==c&&(d.prototype=new v[b.extend]),v[a]=d,d}function p(a,b){b.private=a.private||a.Private.prototype,b.protected=a.protected||a.Protected.prototype,b.public=a.public||a.Public.prototype}function q(a){return a.private=a.private||{},a.protected=a.protected||{},a.public=a.public||{},a.sup=a.sup||{},a.constructor=a.constructor||function(){},a}function r(a){return a.hasOwnProperty("get")||a.hasOwnProperty("getSet")}function s(a){return a.hasOwnProperty("set")||a.hasOwnProperty("getSet")||a.hasOwnProperty("isSet")}function t(a){return a.hasOwnProperty("is")||a.hasOwnProperty("isSet")}var u={},v={};Function.prototype.extractFunctionName=function(){var a=this.toString();return a=a.substr("function ".length),a=a.substr(0,a.indexOf("("))},Function.prototype.bindScope=function(a){var b=this;return function(){return b.apply(a,arguments)}},String.prototype.capitaliseFirstLetter=function(){return this.charAt(0).toUpperCase()+this.slice(1)},a.exports(b,d,"./clazz.js")}(require("./node-shim.js"),module),function(){"use strict";function a(){for(var a=this,b=new Uint32Array(a.length/4),c=0;c>>0;return b}function b(a){for(var b=this,c=new Uint8Array(a.buffer),d=0;d (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(a){"use strict";void 0!==a?(a.module=a.module||{},a.require=function(b){return a[b.replace(/(.\/)|.js/g,"")]||a},a.exports=function(b,c,d){a[d]=c,a[d.replace(/(.\/)|.js/g,"")]=c}):module.exports={require:require,exports:function(a,b){a.exports=b}}}(this.window); \ No newline at end of file +/* !!EnoFJS!! Version: 3.1.0, Author: EnoF (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(a){"use strict";function b(b){return d[b.replace(/(.\/)|.js/g,"")]||a}function c(c){try{return"string"==typeof c?e(c):e.apply(a,arguments)}catch(d){var f=b(c);if(f)return f;throw d}}var d={};if(void 0!==a){var e=a.require,f="function"==typeof e;a.module=a.module||{},a.require=f?c:b,a.exports=function(a,b,c){d[c]=b,d[c.replace(/(.\/)|.js/g,"")]=b}}else module.exports={require:require,exports:function(a,b){a.exports=b}}}(this.window); \ No newline at end of file diff --git a/dist/enofjs/min.whereIt.js b/dist/enofjs/min.whereIt.js index 1fe58ee..3d6eb8c 100644 --- a/dist/enofjs/min.whereIt.js +++ b/dist/enofjs/min.whereIt.js @@ -1 +1 @@ -/* !!EnoFJS!! Version: 3.0.0, Author: EnoF (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(a,LinkedHashMap){"use strict";function b(b,d,e){var g=f(e);a(c(b,g),function(){d.apply(this,g)})}function c(a,b){return a+" ["+b+"]"}function d(a,b){var c,d=a.toString(),f=new LinkedHashMap;for(var g in b)b.hasOwnProperty(g)&&(c=d.indexOf(g+","),-1===c&&(c=d.indexOf(g+")")),e(c,b[g],f));return f}function e(a,b,c){for(var d=c.getFirst();d;d=d.getNext())if(a (http://enof.github.io/EnoFJS, Fork me on Github: https://github.com/EnoF/EnoFJS */!function(a,LinkedHashMap){"use strict";function b(b,d,e){var g=f(e);a(c(b,g),function(){d.apply(this,g)})}function c(a,b){return a+" ["+b+"]"}function d(a,b){var c,d=a.toString(),f=new LinkedHashMap;for(var g in b)b.hasOwnProperty(g)&&(c=d.indexOf(g+","),-1===c&&(c=d.indexOf(g+")")),e(c,b[g],f));return f}function e(a,b,c){for(var d=c.getFirst();d;d=d.getNext())if(a (http://enof.github.io/EnoFJS", - "version": "3.0.0", + "version": "3.1.0", "dependencies": {}, "devDependencies": { "grunt": "^0.4", diff --git a/src/ArrayConverters.js b/src/ArrayConverters.js index d0bdfb8..f8aa964 100644 --- a/src/ArrayConverters.js +++ b/src/ArrayConverters.js @@ -1,5 +1,5 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. // diff --git a/src/LinkedHashMap.js b/src/LinkedHashMap.js index b1a2bbe..459821d 100644 --- a/src/LinkedHashMap.js +++ b/src/LinkedHashMap.js @@ -1,5 +1,5 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. // diff --git a/src/Serializable.js b/src/Serializable.js index 30784a6..73e2f52 100644 --- a/src/Serializable.js +++ b/src/Serializable.js @@ -1,5 +1,5 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. // diff --git a/src/clazz.js b/src/clazz.js index 17eea98..44465be 100644 --- a/src/clazz.js +++ b/src/clazz.js @@ -1,5 +1,5 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. // diff --git a/src/node-shim.js b/src/node-shim.js index f2ae795..b84a1d8 100644 --- a/src/node-shim.js +++ b/src/node-shim.js @@ -1,29 +1,63 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. // // Author Andy Tang // Fork me on Github: https://github.com/EnoF/EnoFJS - +/* istanbul ignore next */ (function nodeShimScope(window) { 'use strict'; - /* istanbul ignore else */ + // Our map of modules. + var registeredModules = {}; + + // A shim for require. + function requireShim(moduleName) { + return registeredModules[moduleName.replace(/(.\/)|.js/g, '')]; + } + + // A require wrapper for when requirejs exists. + function requirejsWrapper(moduleName) { + try { + if (typeof moduleName === 'string') { + return originalRequire(moduleName); + } else { + return originalRequire.apply(window, arguments); + } + } catch (originalRequireError) { + // When `require('module')` throws an error, we assume the module should be loaded + // via the requireShim. + var module = requireShim(moduleName); + if (module) { + return module; + } else { + throw originalRequireError; + } + } + } + if (window !== undefined) { - // A namespace for our modules to be published on. - window.module = window.module || {}; + // We are in a browser. + var originalRequire = window.require; + var requireExists = typeof originalRequire === 'function'; - // To unify the way commonjs is used. - window.require = function require(moduleName) { - return window[moduleName.replace(/(.\/)|.js/g, '')] || window; - }; + if (requireExists) { + // Use the wrapper to load the module the correct way for requirejs. + window.require = requirejsWrapper; + } else { + // To unify the way commonjs is used. + window.require = requireShim; + } // To unify the way we can export modules. window.exports = function exports(modules, module, moduleName) { - window[moduleName] = module; - window[moduleName.replace(/(.\/)|.js/g, '')] = module; + registeredModules[moduleName.replace(/(.\/)|.js/g, '')] = module; }; + + // Register the node shim. + registeredModules['node-shim'] = window; + window.module = window; } else { // Now we assume this is a node.js app. module.exports = { diff --git a/src/whereIt.js b/src/whereIt.js index 7afe8ff..d4532cc 100644 --- a/src/whereIt.js +++ b/src/whereIt.js @@ -1,5 +1,5 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. // diff --git a/test/karma.conf.js b/test/karma.conf.js index 7f02ec5..60bece3 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -1,5 +1,5 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. // @@ -16,6 +16,7 @@ module.exports = function (config) { // list of files / patterns to load in the browser files: [ + 'bower_components/requirejs/require.js', 'src/node-shim.js', 'src/clazz.js', 'src/*.js', @@ -54,6 +55,7 @@ module.exports = function (config) { // source files, that you wanna generate coverage for // do not include tests or libraries // (these files will be instrumented by Istanbul) + '!src/!node-shim.js': ['coverage'], 'src/*.js': ['coverage'] }, diff --git a/test/nodifyTest.js b/test/nodifyTest.js index 3ec0cda..7d7f432 100644 --- a/test/nodifyTest.js +++ b/test/nodifyTest.js @@ -1,5 +1,5 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. // diff --git a/test/spec/ArrayConvertersSpec.js b/test/spec/ArrayConvertersSpec.js index 6fc70d2..30c6d67 100644 --- a/test/spec/ArrayConvertersSpec.js +++ b/test/spec/ArrayConvertersSpec.js @@ -1,5 +1,5 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. // diff --git a/test/spec/ClassFactorySpec.js b/test/spec/ClassFactorySpec.js index 7168fe8..89f4cbe 100644 --- a/test/spec/ClassFactorySpec.js +++ b/test/spec/ClassFactorySpec.js @@ -1,5 +1,5 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. // diff --git a/test/spec/LinkedHashMapSpec.js b/test/spec/LinkedHashMapSpec.js index 55d6f04..48c9781 100644 --- a/test/spec/LinkedHashMapSpec.js +++ b/test/spec/LinkedHashMapSpec.js @@ -1,5 +1,5 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. // diff --git a/test/spec/RequireJSSpec.js b/test/spec/RequireJSSpec.js new file mode 100644 index 0000000..cbf95f6 --- /dev/null +++ b/test/spec/RequireJSSpec.js @@ -0,0 +1,32 @@ +// EnoFJS +// Version: 3.1.0 +// +// Copyright (c) 2014. +// +// Author Andy Tang +// Fork me on Github: https://github.com/EnoF/EnoFJS +(function RequireJSSpecScope(define) { + 'use strict'; + + describe('RequireJS insurance specs', function requireJSSpecs() { + it('should make sure the original require can be used', function originalRequire() { + define('Dependant', function Dependant() { + return 'Hello'; + }); + + var loading = true; + waitsFor(function waitingForLoad() { + return !loading; + }); + + require(['Dependant'], function loadModule(dependant){ + loading = false; + expect(dependant).toEqual('Hello'); + }); + + runs(function checkForModule() { + expect(require('Dependant')).toEqual('Hello'); + }); + }); + }); +}(window.define)); \ No newline at end of file diff --git a/test/spec/SerializableSpec.js b/test/spec/SerializableSpec.js index 61e5f39..5f8364f 100644 --- a/test/spec/SerializableSpec.js +++ b/test/spec/SerializableSpec.js @@ -1,5 +1,5 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. // diff --git a/test/spec/whereItSpec.js b/test/spec/whereItSpec.js index fd03301..a7def66 100644 --- a/test/spec/whereItSpec.js +++ b/test/spec/whereItSpec.js @@ -1,5 +1,5 @@ // EnoFJS -// Version: 3.0.0 +// Version: 3.1.0 // // Copyright (c) 2014. //