{"ScriptPreparationCode":"/**\r\n *\r\n * \u003Cp\u003EThis script provides inheritance support and is inspired by base2 and Prototype\u003C/p\u003E\r\n *\r\n * \u003Cp\u003EThe constructor is named \u003Cpre\u003Einit()\u003C/pre\u003E\u003C/p\u003E\r\n *\r\n * \u003Cp\u003EIf a needs to override a method of a superclass, the overridden method can always be\r\n * called using\u003C/p\u003E\r\n * \u003Cpre\u003Ethis._super();\u003C/pre\u003E\r\n *\r\n * \u003Cp\u003EThis is true for the constructor as well as for any other method.\u003C/p\u003E\r\n *\r\n * @see http://etobi.de/blog/artikel/weiterlesen/vererbung-mit-javascript/\r\n *\r\n * @module util/Class\r\n */\r\n\r\n/**\r\n * Base class which allows simple inheritance.\r\n *\r\n * @class module:util/Class~Class\r\n * @example\r\n * var MyClass = Class.extends({\r\n * init : function(){\r\n * // do some construction\r\n * }\r\n * })\r\n *\r\n * // you can call the super class\u0027s method from within any method like this\r\n * ...\r\n * myMethod : function(){\r\n * // call \u0027myMethod\u0027 of super class\r\n * this._super();\r\n * }\r\n */\r\n// Hack, because vars cannot be imported in DW, only functions\r\n/**\r\n * @class\r\n */\r\nfunction Class() {}\r\n\r\n// eslint-disable-next-line wrap-iife\r\n(function () {\r\n var initializing = false;\r\n var fnTest = /xyz/.test(function () {}) ? /\\b_super\\b/ : /.*/;\r\n\r\n // The base Class implementation (does nothing)\r\n // this.Class = function(){};\r\n\r\n /**\r\n * Create a new sub class\r\n * @param {Object} prop An object defining the members of the sub class\r\n * @return {Object} The sub class\r\n * @instance\r\n */\r\n Class.extends = function (prop) {\r\n var _super = this.prototype;\r\n\r\n // Instantiate a base class (but only create the instance,\r\n // don\u0027t run the init constructor)\r\n initializing = true;\r\n var prototype = new this();\r\n initializing = false;\r\n\r\n // Copy the properties over onto the new prototype\r\n var callback = function (name, fn) {\r\n return function () {\r\n var tmp = this._super;\r\n\r\n // Add a new ._super() method that is the same method\r\n // but on the super-class\r\n this._super = _super[name];\r\n\r\n // The method only need to be bound temporarily, so we\r\n // remove it when we\u0027re done executing\r\n var ret = fn.apply(this, arguments);\r\n this._super = tmp;\r\n\r\n return ret;\r\n };\r\n };\r\n // eslint-disable-next-line guard-for-in, no-restricted-syntax\r\n for (var name in prop) {\r\n // Check if we\u0027re overwriting an existing function\r\n prototype[name] =\r\n typeof prop[name] === \u0027function\u0027 \u0026\u0026 typeof _super[name] === \u0027function\u0027 \u0026\u0026 fnTest.test(prop[name]) ? callback(name, prop[name]) : prop[name];\r\n }\r\n\r\n /**\r\n * The dummy class constructor\r\n * @constructor\r\n */\r\n function Class() { // eslint-disable-line no-shadow\r\n // All construction is actually done in the init method\r\n if (!initializing \u0026\u0026 this.init) {\r\n this.init.apply(this, arguments);\r\n }\r\n }\r\n\r\n // Populate our constructed prototype object\r\n Class.prototype = prototype;\r\n\r\n // Enforce the constructor to be what we expect\r\n Class.constructor = Class;\r\n\r\n // And make this class extendable\r\n // eslint-disable-next-line no-caller\r\n Class.extends = arguments.callee;\r\n\r\n return Class;\r\n };\r\n})();\r\n","TestCases":[{"Name":" Class.extends","Code":"\r\n/** @type {module:util/Class~Class} */\r\n//module.exports = Class;\r\nconst cls = Class.extends({\r\n /**\r\n * @constructor\r\n * @param {*} resource resource\r\n * @param {string\r\n } type type of resource, can be value|fabric (value is default)\r\n */\r\n init: function () {\r\n\r\n },\r\n doTest: function () {\r\n\r\n }\r\n});\r\n\r\nconst cls2 = cls.extends({\r\n\tdoTest: function () {\r\n\t\t\r\n }\r\n\r\n});\r\n\r\nvar obj = new cls2();\r\nobj.doTest();\r\n","IsDeferred":false},{"Name":"cls.prototype","Code":"function cls() {\r\n\r\n}\r\n\r\ncls.prototype = {};\r\ncls.prototype.constructor = cls;\r\n\r\ncls.prototype.doTest= function() {\r\n\t\r\n}\r\n\r\n\r\nfunction cls2 () {\r\n cls.call(this);\r\n}\r\n\r\ncls2.prototype = Object.create(cls.prototype);\r\ncls2.prototype.constructor = cls;\r\n\r\ncls2.prototype.doTest= function() {\r\n}\r\n\r\nvar obj = new cls();\r\nobj.doTest();","IsDeferred":false}]}