From 6cc655a09f454c813305fad1f4f48a9540f34cf0 Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 02:28:55 +0100 Subject: [PATCH 01/17] fixed link in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ca457dc..18afda9 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ .o..P' `Y8P' -[OOPsy](https+://github.com/Skelp/oopsy) makes it easier to use the Object-Orientated Programming (OOP) model in +[OOPsy](https://github.com/Skelp/oopsy) makes it easier to use the Object-Orientated Programming (OOP) model in JavaScript. [![Build Status](https://img.shields.io/travis/Skelp/oopsy/develop.svg?style=flat-square)](https://travis-ci.org/Skelp/oopsy) From f147fb698b540917a62ee2b3988e89b5859a53b9 Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 02:36:38 +0100 Subject: [PATCH 02/17] renamed OOPsy to Oopsy for better readability --- CONTRIBUTING.md | 2 +- Gruntfile.js | 6 +++--- README.md | 26 +++++++++++++------------- dist/oopsy.js | 10 +++++----- dist/oopsy.js.map | 2 +- dist/oopsy.min.js | 4 ++-- dist/oopsy.min.js.map | 2 +- lib/oopsy.js | 8 ++++---- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 287b247..f7bd1bb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing -If you have any questions about [OOPsy](https://github.com/Skelp/oopsy) please feel free to +If you have any questions about [Oopsy](https://github.com/Skelp/oopsy) please feel free to [raise an issue](https://github.com/Skelp/oopsy/issues/new). Please [search existing issues](https://github.com/Skelp/oopsy/issues) for the same feature and/or issue before raising diff --git a/Gruntfile.js b/Gruntfile.js index 068f220..2561076 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -51,7 +51,7 @@ module.exports = function(grunt) { options: { format: 'umd', moduleId: 'oopsy', - moduleName: 'OOPsy', + moduleName: 'Oopsy', sourceMap: true, sourceMapRelativePaths: true, plugins: function() { @@ -68,10 +68,10 @@ module.exports = function(grunt) { options: { format: 'umd', moduleId: 'oopsy', - moduleName: 'OOPsy', + moduleName: 'Oopsy', sourceMap: true, sourceMapRelativePaths: true, - banner: '/*! OOPsy v<%= pkg.version %> | (C) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | MIT License */', + banner: '/*! Oopsy v<%= pkg.version %> | (C) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | MIT License */', plugins: function() { return [ commonjs(), diff --git a/README.md b/README.md index 18afda9..46c8b69 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ - .oooooo. .oooooo. ooooooooo. - d8P' `Y8b d8P' `Y8b `888 `Y88. - 888 888 888 888 888 .d88' .oooo.o oooo ooo - 888 888 888 888 888ooo88P' d88( "8 `88. .8' - 888 888 888 888 888 `"Y88b. `88..8' - `88b d88' `88b d88' 888 o. )88b `888' - `Y8bood8P' `Y8bood8P' o888o 8""888P' .8' - .o..P' - `Y8P' - -[OOPsy](https://github.com/Skelp/oopsy) makes it easier to use the Object-Orientated Programming (OOP) model in + .oooooo. + d8P' `Y8b + 888 888 .ooooo. oo.ooooo. .oooo.o oooo ooo + 888 888 d88' `88b 888' `88b d88( "8 `88. .8' + 888 888 888 888 888 888 `"Y88b. `88..8' + `88b d88' 888 888 888 888 o. )88b `888' + `Y8bood8P' `Y8bod8P' 888bod8P' 8""888P' .8' + 888 .o..P' + o888o `Y8P' + +[Oopsy](https://github.com/Skelp/oopsy) makes it easier to use the Object-Orientated Programming (OOP) model in JavaScript. [![Build Status](https://img.shields.io/travis/Skelp/oopsy/develop.svg?style=flat-square)](https://travis-ci.org/Skelp/oopsy) @@ -46,7 +46,7 @@ TODO: Document ## Bugs -If you have any problems with OOPsy or would like to see changes currently in development you can do so +If you have any problems with Oopsy or would like to see changes currently in development you can do so [here](https://github.com/Skelp/oopsy/issues). ## Contributors @@ -55,7 +55,7 @@ If you want to contribute, you're a legend! Information on how you can do so can [CONTRIBUTING.md](https://github.com/Skelp/oopsy/blob/master/CONTRIBUTING.md). We want your suggestions and pull requests! -A list of OOPsy contributors can be found in [AUTHORS.md](https://github.com/Skelp/oopsy/blob/master/AUTHORS.md). +A list of Oopsy contributors can be found in [AUTHORS.md](https://github.com/Skelp/oopsy/blob/master/AUTHORS.md). ## License diff --git a/dist/oopsy.js b/dist/oopsy.js index 2811a47..2a461d8 100644 --- a/dist/oopsy.js +++ b/dist/oopsy.js @@ -1,7 +1,7 @@ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define('oopsy', factory) : - (global.OOPsy = factory()); + (global.Oopsy = factory()); }(this, (function () { 'use strict'; /* @@ -113,9 +113,9 @@ * The base constructor from which all others should extend. * * @public - * @class OOPsy + * @class Oopsy */ - function OOPsy() {} + function Oopsy() {} /** * Extends the constructor to which this method is associated with the prototype and/or @@ -133,7 +133,7 @@ * @public * @static */ - OOPsy.extend = function(constructor, prototype, statics) { + Oopsy.extend = function(constructor, prototype, statics) { var superConstructor = this if (typeof constructor !== 'function') { @@ -154,7 +154,7 @@ return constructor } - var oopsy = OOPsy + var oopsy = Oopsy return oopsy; diff --git a/dist/oopsy.js.map b/dist/oopsy.js.map index 757589e..01d324f 100644 --- a/dist/oopsy.js.map +++ b/dist/oopsy.js.map @@ -1 +1 @@ -{"version":3,"file":null,"sources":["../lib/oopsy.js"],"sourcesContent":["/*\n * Copyright (C) 2016 Alasdair Mercer, Skelp\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n'use strict'\n\n/**\n * A bare-bones constructor for surrogate prototype swapping.\n *\n * @private\n * @class Constructor\n */\nvar Constructor = function() {}\n/**\n * A reference to Object.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @class OOPsy\n */\nfunction OOPsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super prototype can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOOPsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor.prototype\n\n return constructor\n}\n\nmodule.exports = OOPsy\n"],"names":[],"mappings":";;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;;;AAQA,MAAI,WAAW,GAAG,WAAW,EAAE;;;;;;;AAO/B,MAAI,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc;;;;;;;AAOpD,MAAI,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK;;;;;;;;;;;;;;;AAejC,EAAA,SAAS,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;IACpC,IAAI,MAAM,IAAI,IAAI,EAAE;MAClB,MAAM;KACP;;IAED,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;;IAElC,IAAI,QAAQ;IACZ,IAAI,MAAM;;IAEV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO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,SAAS,EAAE,SAAS,CAAC;IACrE,WAAW,CAAC,SAAS,CAAC,WAAW,GAAG,WAAW;;IAE/C,WAAW,CAAC,OAAO,GAAG,gBAAgB,CAAC,SAAS;;IAEhD,OAAO,WAAW;GACnB;;AAED,cAAiB,KAAK;;;;"} \ No newline at end of file +{"version":3,"file":null,"sources":["../lib/oopsy.js"],"sourcesContent":["/*\n * Copyright (C) 2016 Alasdair Mercer, Skelp\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n'use strict'\n\n/**\n * A bare-bones constructor for surrogate prototype swapping.\n *\n * @private\n * @class Constructor\n */\nvar Constructor = function() {}\n/**\n * A reference to Object.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @class Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super prototype can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor.prototype\n\n return constructor\n}\n\nmodule.exports = Oops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U,CAAC;KACjC;;IAED,OAAO,MAAM;GACd;;;;;;;;AAQD,EAAA,SAAS,KAAK,GAAG,EAAE;;;;;;;;;;;;;;;;;;AAkBnB,EAAA,KAAK,CAAC,MAAM,GAAG,SAAS,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE;IACvD,IAAI,gBAAgB,GAAG,IAAI;;IAE3B,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE;MACrC,OAAO,GAAG,SAAS;MACnB,SAAS,GAAG,WAAW;MACvB,WAAW,GAAG,WAAW;QACvB,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC;OAC/C;KACF;;IAED,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,CAAC;;IAErD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC;IACrE,WAAW,CAAC,SAAS,CAAC,WAAW,GAAG,WAAW;;IAE/C,WAAW,CAAC,OAAO,GAAG,gBAAgB,CAAC,SAAS;;IAEhD,OAAO,WAAW;GACnB;;AAED,cAAiB,KAAK;;;;"} \ No newline at end of file diff --git a/dist/oopsy.min.js b/dist/oopsy.min.js index a7612a0..8f75cea 100644 --- a/dist/oopsy.min.js +++ b/dist/oopsy.min.js @@ -1,4 +1,4 @@ -/*! OOPsy v0.1.0alpha | (C) 2016 Alasdair Mercer | MIT License */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define("oopsy",e):t.OOPsy=e()}(this,function(){"use strict";function t(t,e,o){if(null!=e){o=p.call(arguments,2);for(var n,c,f=0,u=o.length;fObject.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @class OOPsy\n */\nfunction OOPsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super prototype can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOOPsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor.prototype\n\n return constructor\n}\n\nmodule.exports = OOPsy\n"],"names":["extend","own","target","sources","slice","call","arguments","property","source","i","length","hasOwnProperty","create","prototype","properties","result","Object","Constructor","OOPsy","Array","constructor","statics","superConstructor","this","apply","__super"],"mappings":";wLA2DA,SAASA,GAAOC,EAAKC,EAAQC,GAC3B,GAAc,MAAVD,EAAJ,CAIAC,EAAUC,EAAMC,KAAKC,UAAW,EAKhC,KAAK,GAHDC,GACAC,EAEKC,EAAI,EAAGC,EAASP,EAAQO,OAAQD,EAAIC,EAAQD,IAAK,CACxDD,EAASL,EAAQM,EAEjB,KAAKF,IAAYC,GACVP,IAAOU,EAAeN,KAAKG,EAAQD,KACtCL,EAAOK,GAAYC,EAAOD,MAgBlC,QAASK,GAAOC,EAAWC,GACzB,GAAIC,EAaJ,OAZ6B,kBAAlBC,QAAOJ,OAChBG,EAASC,OAAOJ,OAAOC,IAEvBI,EAAYJ,UAAYA,EACxBE,EAAS,GAAIE,GACbA,EAAYJ,UAAY,MAGtBC,GACFd,GAAO,EAAMe,EAAQD,GAGhBC,EAST,QAASG,SAnFLD,GAAc,aAOdN,EAAiBK,OAAOH,UAAUF,eAOlCP,EAAQe,MAAMN,UAAUT,KAuF5Bc,GAAMlB,OAAS,SAASoB,EAAaP,EAAWQ,GAC9C,GAAIC,GAAmBC,IAiBvB,OAf2B,kBAAhBH,KACTC,EAAUR,EACVA,EAAYO,EACZA,EAAc,WACZ,MAAOE,GAAiBE,MAAMD,KAAMjB,aAIxCN,GAAO,EAAOoB,EAAaE,EAAkBD,GAE7CD,EAAYP,UAAYD,EAAOU,EAAiBT,UAAWA,GAC3DO,EAAYP,UAAUO,YAAcA,EAEpCA,EAAYK,QAAUH,EAAiBT,UAEhCO,SAGQF"} \ No newline at end of file +{"version":3,"file":null,"sources":["../lib/oopsy.js"],"sourcesContent":["/*\n * Copyright (C) 2016 Alasdair Mercer, Skelp\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n'use strict'\n\n/**\n * A bare-bones constructor for surrogate prototype swapping.\n *\n * @private\n * @class Constructor\n */\nvar Constructor = function() {}\n/**\n * A reference to Object.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @class Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super prototype can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor.prototype\n\n return constructor\n}\n\nmodule.exports = Oopsy\n"],"names":["extend","own","target","sources","slice","call","arguments","property","source","i","length","hasOwnProperty","create","prototype","properties","result","Object","Constructor","Oopsy","Array","constructor","statics","superConstructor","this","apply","__super"],"mappings":";wLA2DA,SAASA,GAAOC,EAAKC,EAAQC,GAC3B,GAAc,MAAVD,EAAJ,CAIAC,EAAUC,EAAMC,KAAKC,UAAW,EAKhC,KAAK,GAHDC,GACAC,EAEKC,EAAI,EAAGC,EAASP,EAAQO,OAAQD,EAAIC,EAAQD,IAAK,CACxDD,EAASL,EAAQM,EAEjB,KAAKF,IAAYC,GACVP,IAAOU,EAAeN,KAAKG,EAAQD,KACtCL,EAAOK,GAAYC,EAAOD,MAgBlC,QAASK,GAAOC,EAAWC,GACzB,GAAIC,EAaJ,OAZ6B,kBAAlBC,QAAOJ,OAChBG,EAASC,OAAOJ,OAAOC,IAEvBI,EAAYJ,UAAYA,EACxBE,EAAS,GAAIE,GACbA,EAAYJ,UAAY,MAGtBC,GACFd,GAAO,EAAMe,EAAQD,GAGhBC,EAST,QAASG,SAnFLD,GAAc,aAOdN,EAAiBK,OAAOH,UAAUF,eAOlCP,EAAQe,MAAMN,UAAUT,KAuF5Bc,GAAMlB,OAAS,SAASoB,EAAaP,EAAWQ,GAC9C,GAAIC,GAAmBC,IAiBvB,OAf2B,kBAAhBH,KACTC,EAAUR,EACVA,EAAYO,EACZA,EAAc,WACZ,MAAOE,GAAiBE,MAAMD,KAAMjB,aAIxCN,GAAO,EAAOoB,EAAaE,EAAkBD,GAE7CD,EAAYP,UAAYD,EAAOU,EAAiBT,UAAWA,GAC3DO,EAAYP,UAAUO,YAAcA,EAEpCA,EAAYK,QAAUH,EAAiBT,UAEhCO,SAGQF"} \ No newline at end of file diff --git a/lib/oopsy.js b/lib/oopsy.js index 441e683..059d1d5 100644 --- a/lib/oopsy.js +++ b/lib/oopsy.js @@ -109,9 +109,9 @@ function create(prototype, properties) { * The base constructor from which all others should extend. * * @public - * @class OOPsy + * @class Oopsy */ -function OOPsy() {} +function Oopsy() {} /** * Extends the constructor to which this method is associated with the prototype and/or @@ -129,7 +129,7 @@ function OOPsy() {} * @public * @static */ -OOPsy.extend = function(constructor, prototype, statics) { +Oopsy.extend = function(constructor, prototype, statics) { var superConstructor = this if (typeof constructor !== 'function') { @@ -150,4 +150,4 @@ OOPsy.extend = function(constructor, prototype, statics) { return constructor } -module.exports = OOPsy +module.exports = Oopsy From a9979b2281e916a8f2aee0c1a60375970aa3943f Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 08:32:35 +0100 Subject: [PATCH 03/17] __super now references super constructor instead of the super prototype --- dist/oopsy.js | 4 ++-- dist/oopsy.js.map | 2 +- dist/oopsy.min.js | 2 +- dist/oopsy.min.js.map | 2 +- lib/oopsy.js | 4 ++-- test/oopsy.spec.js | 11 +++++++++++ 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/dist/oopsy.js b/dist/oopsy.js index 2a461d8..8c17b75 100644 --- a/dist/oopsy.js +++ b/dist/oopsy.js @@ -124,7 +124,7 @@ * If constructor is provided, it will be used as the constructor for the child, otherwise a simple * constructor which only calls the super constructor will be used instead. * - * The super prototype can be accessed via a special __super property on the child constructor. + * The super constructor can be accessed via a special __super property on the child constructor. * * @param {Function} [constructor] - the constructor for the child * @param {Object} [prototype] - the prototype properties to be defined for the child @@ -149,7 +149,7 @@ constructor.prototype = create(superConstructor.prototype, prototype) constructor.prototype.constructor = constructor - constructor.__super = superConstructor.prototype + constructor.__super = superConstructor return constructor } diff --git a/dist/oopsy.js.map b/dist/oopsy.js.map index 01d324f..5072c43 100644 --- a/dist/oopsy.js.map +++ b/dist/oopsy.js.map @@ -1 +1 @@ -{"version":3,"file":null,"sources":["../lib/oopsy.js"],"sourcesContent":["/*\n * Copyright (C) 2016 Alasdair Mercer, Skelp\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n'use strict'\n\n/**\n * A bare-bones constructor for surrogate prototype swapping.\n *\n * @private\n * @class Constructor\n */\nvar Constructor = function() {}\n/**\n * A reference to Object.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @class Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super prototype can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor.prototype\n\n return constructor\n}\n\nmodule.exports = Oopsy\n"],"names":[],"mappings":";;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;;;AAQA,MAAI,WAAW,GAAG,WAAW,EAAE;;;;;;;AAO/B,MAAI,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc;;;;;;;AAOpD,MAAI,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK;;;;;;;;;;;;;;;AAejC,EAAA,SAAS,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;IACpC,IAAI,MAAM,IAAI,IAAI,EAAE;MAClB,MAAM;KACP;;IAED,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;;IAElC,IAAI,QAAQ;IACZ,IAAI,MAAM;;IAEV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;MACxD,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;;MAEnB,KAAK,QAAQ,IAAI,MAAM,EAAE;QACvB,IAAI,CAAC,GAAG,IAAI,cAAc,CAA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line at end of file +{"version":3,"file":null,"sources":["../lib/oopsy.js"],"sourcesContent":["/*\n * Copyright (C) 2016 Alasdair Mercer, Skelp\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n'use strict'\n\n/**\n * A bare-bones constructor for surrogate prototype swapping.\n *\n * @private\n * @class Constructor\n */\nvar Constructor = function() {}\n/**\n * A reference to Object.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @class Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super constructor can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor\n\n return constructor\n}\n\nmodule.exports = Oopsy\n"],"names":[],"mappings":";;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;;;AAQA,MAAI,WAAW,GAAG,WAAW,EAAE;;;;;;;AAO/B,MAAI,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc;;;;;;;AAOpD,MAAI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,IAAI,gBAAgB,GAAG,IAAI;;IAE3B,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE;MACrC,OAAO,GAAG,SAAS;MACnB,SAAS,GAAG,WAAW;MACvB,WAAW,GAAG,WAAW;QACvB,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC;OAC/C;KACF;;IAED,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,CAAC;;IAErD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC;IACrE,WAAW,CAAC,SAAS,CAAC,WAAW,GAAG,WAAW;;IAE/C,WAAW,CAAC,OAAO,GAAG,gBAAgB;;IAEtC,OAAO,WAAW;GACnB;;AAED,cAAiB,KAAK;;;;"} \ No newline at end of file diff --git a/dist/oopsy.min.js b/dist/oopsy.min.js index 8f75cea..5a41830 100644 --- a/dist/oopsy.min.js +++ b/dist/oopsy.min.js @@ -1,4 +1,4 @@ /*! Oopsy v0.1.0alpha | (C) 2016 Alasdair Mercer | MIT License */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define("oopsy",e):t.Oopsy=e()}(this,function(){"use strict";function t(t,e,o){if(null!=e){o=p.call(arguments,2);for(var n,c,f=0,u=o.length;fObject.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @class Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super prototype can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor.prototype\n\n return constructor\n}\n\nmodule.exports = Oopsy\n"],"names":["extend","own","target","sources","slice","call","arguments","property","source","i","length","hasOwnProperty","create","prototype","properties","result","Object","Constructor","Oopsy","Array","constructor","statics","superConstructor","this","apply","__super"],"mappings":";wLA2DA,SAASA,GAAOC,EAAKC,EAAQC,GAC3B,GAAc,MAAVD,EAAJ,CAIAC,EAAUC,EAAMC,KAAKC,UAAW,EAKhC,KAAK,GAHDC,GACAC,EAEKC,EAAI,EAAGC,EAASP,EAAQO,OAAQD,EAAIC,EAAQD,IAAK,CACxDD,EAASL,EAAQM,EAEjB,KAAKF,IAAYC,GACVP,IAAOU,EAAeN,KAAKG,EAAQD,KACtCL,EAAOK,GAAYC,EAAOD,MAgBlC,QAASK,GAAOC,EAAWC,GACzB,GAAIC,EAaJ,OAZ6B,kBAAlBC,QAAOJ,OAChBG,EAASC,OAAOJ,OAAOC,IAEvBI,EAAYJ,UAAYA,EACxBE,EAAS,GAAIE,GACbA,EAAYJ,UAAY,MAGtBC,GACFd,GAAO,EAAMe,EAAQD,GAGhBC,EAST,QAASG,SAnFLD,GAAc,aAOdN,EAAiBK,OAAOH,UAAUF,eAOlCP,EAAQe,MAAMN,UAAUT,KAuF5Bc,GAAMlB,OAAS,SAASoB,EAAaP,EAAWQ,GAC9C,GAAIC,GAAmBC,IAiBvB,OAf2B,kBAAhBH,KACTC,EAAUR,EACVA,EAAYO,EACZA,EAAc,WACZ,MAAOE,GAAiBE,MAAMD,KAAMjB,aAIxCN,GAAO,EAAOoB,EAAaE,EAAkBD,GAE7CD,EAAYP,UAAYD,EAAOU,EAAiBT,UAAWA,GAC3DO,EAAYP,UAAUO,YAAcA,EAEpCA,EAAYK,QAAUH,EAAiBT,UAEhCO,SAGQF"} \ No newline at end of file +{"version":3,"file":null,"sources":["../lib/oopsy.js"],"sourcesContent":["/*\n * Copyright (C) 2016 Alasdair Mercer, Skelp\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n'use strict'\n\n/**\n * A bare-bones constructor for surrogate prototype swapping.\n *\n * @private\n * @class Constructor\n */\nvar Constructor = function() {}\n/**\n * A reference to Object.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @class Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super constructor can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor\n\n return constructor\n}\n\nmodule.exports = Oopsy\n"],"names":["extend","own","target","sources","slice","call","arguments","property","source","i","length","hasOwnProperty","create","prototype","properties","result","Object","Constructor","Oopsy","Array","constructor","statics","superConstructor","this","apply","__super"],"mappings":";wLA2DA,SAASA,GAAOC,EAAKC,EAAQC,GAC3B,GAAc,MAAVD,EAAJ,CAIAC,EAAUC,EAAMC,KAAKC,UAAW,EAKhC,KAAK,GAHDC,GACAC,EAEKC,EAAI,EAAGC,EAASP,EAAQO,OAAQD,EAAIC,EAAQD,IAAK,CACxDD,EAASL,EAAQM,EAEjB,KAAKF,IAAYC,GACVP,IAAOU,EAAeN,KAAKG,EAAQD,KACtCL,EAAOK,GAAYC,EAAOD,MAgBlC,QAASK,GAAOC,EAAWC,GACzB,GAAIC,EAaJ,OAZ6B,kBAAlBC,QAAOJ,OAChBG,EAASC,OAAOJ,OAAOC,IAEvBI,EAAYJ,UAAYA,EACxBE,EAAS,GAAIE,GACbA,EAAYJ,UAAY,MAGtBC,GACFd,GAAO,EAAMe,EAAQD,GAGhBC,EAST,QAASG,SAnFLD,GAAc,aAOdN,EAAiBK,OAAOH,UAAUF,eAOlCP,EAAQe,MAAMN,UAAUT,KAuF5Bc,GAAMlB,OAAS,SAASoB,EAAaP,EAAWQ,GAC9C,GAAIC,GAAmBC,IAiBvB,OAf2B,kBAAhBH,KACTC,EAAUR,EACVA,EAAYO,EACZA,EAAc,WACZ,MAAOE,GAAiBE,MAAMD,KAAMjB,aAIxCN,GAAO,EAAOoB,EAAaE,EAAkBD,GAE7CD,EAAYP,UAAYD,EAAOU,EAAiBT,UAAWA,GAC3DO,EAAYP,UAAUO,YAAcA,EAEpCA,EAAYK,QAAUH,EAEfF,SAGQF"} \ No newline at end of file diff --git a/lib/oopsy.js b/lib/oopsy.js index 059d1d5..2099608 100644 --- a/lib/oopsy.js +++ b/lib/oopsy.js @@ -120,7 +120,7 @@ function Oopsy() {} * If constructor is provided, it will be used as the constructor for the child, otherwise a simple * constructor which only calls the super constructor will be used instead. * - * The super prototype can be accessed via a special __super property on the child constructor. + * The super constructor can be accessed via a special __super property on the child constructor. * * @param {Function} [constructor] - the constructor for the child * @param {Object} [prototype] - the prototype properties to be defined for the child @@ -145,7 +145,7 @@ Oopsy.extend = function(constructor, prototype, statics) { constructor.prototype = create(superConstructor.prototype, prototype) constructor.prototype.constructor = constructor - constructor.__super = superConstructor.prototype + constructor.__super = superConstructor return constructor } diff --git a/test/oopsy.spec.js b/test/oopsy.spec.js index 3cdbddd..492063a 100644 --- a/test/oopsy.spec.js +++ b/test/oopsy.spec.js @@ -21,3 +21,14 @@ */ 'use strict' + +var expect = require('chai').expect + +var Oopsy = require('../lib/oopsy') + +describe('Oopsy', function() { + it('should be a constructor', function() { + expect(Oopsy).to.be.a('function') + expect(new Oopsy()).to.be.an('object') + }) +}) From 75a731400009c0be336b666a4e58ffa89fbff430 Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 08:37:00 +0100 Subject: [PATCH 04/17] replaced @class JSDoc annotation with @constructor --- dist/oopsy.js | 4 ++-- dist/oopsy.js.map | 2 +- dist/oopsy.min.js.map | 2 +- lib/oopsy.js | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/oopsy.js b/dist/oopsy.js index 8c17b75..5cb0eb3 100644 --- a/dist/oopsy.js +++ b/dist/oopsy.js @@ -30,7 +30,7 @@ * A bare-bones constructor for surrogate prototype swapping. * * @private - * @class Constructor + * @constructor Constructor */ var Constructor = function() {} /** @@ -113,7 +113,7 @@ * The base constructor from which all others should extend. * * @public - * @class Oopsy + * @constructor Oopsy */ function Oopsy() {} diff --git a/dist/oopsy.js.map b/dist/oopsy.js.map index 5072c43..cafc0e9 100644 --- a/dist/oopsy.js.map +++ b/dist/oopsy.js.map @@ -1 +1 @@ -{"version":3,"file":null,"sources":["../lib/oopsy.js"],"sourcesContent":["/*\n * Copyright (C) 2016 Alasdair Mercer, Skelp\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n'use strict'\n\n/**\n * A bare-bones constructor for surrogate prototype swapping.\n *\n * @private\n * @class Constructor\n */\nvar Constructor = function() {}\n/**\n * A reference to Object.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @class Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super constructor can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor\n\n return constructor\n}\n\nmodule.exports = Oopsy\n"],"names":[],"mappings":";;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;;;AAQA,MAAI,WAAW,GAAG,WAAW,EAAE;;;;;;;AAO/B,MAAI,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc;;;;;;;AAOpD,MAAI,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK;;;;;;;;;;;;;;;AAejC,EAAA,SAAS,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;IACpC,IAAI,MAAM,IAAI,IAAI,EAAE;MAClB,MAAM;KACP;;IAED,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;;IAElC,IAAI,QAAQ;IACZ,IAAI,MAAM;;IAEV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;MACxD,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;;MAEnB,KAAK,QAAQ,IAAI,MAAM,EAAE;QACvB,IAAI,CAAC,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE;UACjD,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;SACpC;OACF;KACF;GACF;;;;;;;;;;;;AAYD,EAAA,SAAS,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE;IACrC,IAAI,MAAM;IACV,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;MACvC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;KAClC,MAAM;MACL,WAAW,CAAC,SAAS,GAAG,SAAS;MACjC,MAAM,GAAG,IAAI,WAAW,EAAE;MAC1B,WAAW,CAAC,SAAS,GAAG,IAAI;KAC7B;;IAED,IAAI,UAAU,EAAE;MACd,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC;KACjC;;IAED,OAAO,MAAM;GACd;;;;;;;;AAQD,EAAA,SAAS,KAAK,GAAG,EAAE;;;;;;;;;;;;;;;;;;AAkBnB,EAAA,KAAK,CAAC,MAAM,GAAG,SAAS,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE;IACvD,IAAI,gBAAgB,GAAG,IAAI;;IAE3B,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE;MACrC,OAAO,GAAG,SAAS;MACnB,SAAS,GAAG,WAAW;MACvB,WAAW,GAAG,WAAW;QACvB,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC;OAC/C;KACF;;IAED,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,CAAC;;IAErD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC;IACrE,WAAW,CAAC,SAAS,CAAC,WAAW,GAAG,WAAW;;IAE/C,WAAW,CAAC,OAAO,GAAG,gBAAgB;;IAEtC,OAAO,WAAW;GACnB;;AAED,cAAiB,KAAK;;;;"} \ No newline at end of file +{"version":3,"file":null,"sources":["../lib/oopsy.js"],"sourcesContent":["/*\n * Copyright (C) 2016 Alasdair Mercer, Skelp\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n'use strict'\n\n/**\n * A bare-bones constructor for surrogate prototype swapping.\n *\n * @private\n * @constructor Constructor\n */\nvar Constructor = function() {}\n/**\n * A reference to Object.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @constructor Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super constructor can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor\n\n return constructor\n}\n\nmodule.exports = Oopsy\n"],"names":[],"mappings":";;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;;;AAQA,MAAI,WAAW,GAAG,WAAW,EAAE;;;;;;;AAO/B,MAAI,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc;;;;;;;AAOpD,MAAI,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK;;;;;;;;;;;;;;;AAejC,EAAA,SAAS,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;IACpC,IAAI,MAAM,IAAI,IAA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O,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC;OAC/C;KACF;;IAED,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,CAAC;;IAErD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC;IACrE,WAAW,CAAC,SAAS,CAAC,WAAW,GAAG,WAAW;;IAE/C,WAAW,CAAC,OAAO,GAAG,gBAAgB;;IAEtC,OAAO,WAAW;GACnB;;AAED,cAAiB,KAAK;;;;"} \ No newline at end of file diff --git a/dist/oopsy.min.js.map b/dist/oopsy.min.js.map index d02a7df..5e47121 100644 --- a/dist/oopsy.min.js.map +++ b/dist/oopsy.min.js.map @@ -1 +1 @@ -{"version":3,"file":null,"sources":["../lib/oopsy.js"],"sourcesContent":["/*\n * Copyright (C) 2016 Alasdair Mercer, Skelp\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n'use strict'\n\n/**\n * A bare-bones constructor for surrogate prototype swapping.\n *\n * @private\n * @class Constructor\n */\nvar Constructor = function() {}\n/**\n * A reference to Object.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @class Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super constructor can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor\n\n return constructor\n}\n\nmodule.exports = Oopsy\n"],"names":["extend","own","target","sources","slice","call","arguments","property","source","i","length","hasOwnProperty","create","prototype","properties","result","Object","Constructor","Oopsy","Array","constructor","statics","superConstructor","this","apply","__super"],"mappings":";wLA2DA,SAASA,GAAOC,EAAKC,EAAQC,GAC3B,GAAc,MAAVD,EAAJ,CAIAC,EAAUC,EAAMC,KAAKC,UAAW,EAKhC,KAAK,GAHDC,GACAC,EAEKC,EAAI,EAAGC,EAASP,EAAQO,OAAQD,EAAIC,EAAQD,IAAK,CACxDD,EAASL,EAAQM,EAEjB,KAAKF,IAAYC,GACVP,IAAOU,EAAeN,KAAKG,EAAQD,KACtCL,EAAOK,GAAYC,EAAOD,MAgBlC,QAASK,GAAOC,EAAWC,GACzB,GAAIC,EAaJ,OAZ6B,kBAAlBC,QAAOJ,OAChBG,EAASC,OAAOJ,OAAOC,IAEvBI,EAAYJ,UAAYA,EACxBE,EAAS,GAAIE,GACbA,EAAYJ,UAAY,MAGtBC,GACFd,GAAO,EAAMe,EAAQD,GAGhBC,EAST,QAASG,SAnFLD,GAAc,aAOdN,EAAiBK,OAAOH,UAAUF,eAOlCP,EAAQe,MAAMN,UAAUT,KAuF5Bc,GAAMlB,OAAS,SAASoB,EAAaP,EAAWQ,GAC9C,GAAIC,GAAmBC,IAiBvB,OAf2B,kBAAhBH,KACTC,EAAUR,EACVA,EAAYO,EACZA,EAAc,WACZ,MAAOE,GAAiBE,MAAMD,KAAMjB,aAIxCN,GAAO,EAAOoB,EAAaE,EAAkBD,GAE7CD,EAAYP,UAAYD,EAAOU,EAAiBT,UAAWA,GAC3DO,EAAYP,UAAUO,YAAcA,EAEpCA,EAAYK,QAAUH,EAEfF,SAGQF"} \ No newline at end of file +{"version":3,"file":null,"sources":["../lib/oopsy.js"],"sourcesContent":["/*\n * Copyright (C) 2016 Alasdair Mercer, Skelp\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n'use strict'\n\n/**\n * A bare-bones constructor for surrogate prototype swapping.\n *\n * @private\n * @constructor Constructor\n */\nvar Constructor = function() {}\n/**\n * A reference to Object.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @constructor Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super constructor can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor\n\n return constructor\n}\n\nmodule.exports = Oopsy\n"],"names":["extend","own","target","sources","slice","call","arguments","property","source","i","length","hasOwnProperty","create","prototype","properties","result","Object","Constructor","Oopsy","Array","constructor","statics","superConstructor","this","apply","__super"],"mappings":";wLA2DA,SAASA,GAAOC,EAAKC,EAAQC,GAC3B,GAAc,MAAVD,EAAJ,CAIAC,EAAUC,EAAMC,KAAKC,UAAW,EAKhC,KAAK,GAHDC,GACAC,EAEKC,EAAI,EAAGC,EAASP,EAAQO,OAAQD,EAAIC,EAAQD,IAAK,CACxDD,EAASL,EAAQM,EAEjB,KAAKF,IAAYC,GACVP,IAAOU,EAAeN,KAAKG,EAAQD,KACtCL,EAAOK,GAAYC,EAAOD,MAgBlC,QAASK,GAAOC,EAAWC,GACzB,GAAIC,EAaJ,OAZ6B,kBAAlBC,QAAOJ,OAChBG,EAASC,OAAOJ,OAAOC,IAEvBI,EAAYJ,UAAYA,EACxBE,EAAS,GAAIE,GACbA,EAAYJ,UAAY,MAGtBC,GACFd,GAAO,EAAMe,EAAQD,GAGhBC,EAST,QAASG,SAnFLD,GAAc,aAOdN,EAAiBK,OAAOH,UAAUF,eAOlCP,EAAQe,MAAMN,UAAUT,KAuF5Bc,GAAMlB,OAAS,SAASoB,EAAaP,EAAWQ,GAC9C,GAAIC,GAAmBC,IAiBvB,OAf2B,kBAAhBH,KACTC,EAAUR,EACVA,EAAYO,EACZA,EAAc,WACZ,MAAOE,GAAiBE,MAAMD,KAAMjB,aAIxCN,GAAO,EAAOoB,EAAaE,EAAkBD,GAE7CD,EAAYP,UAAYD,EAAOU,EAAiBT,UAAWA,GAC3DO,EAAYP,UAAUO,YAAcA,EAEpCA,EAAYK,QAAUH,EAEfF,SAGQF"} \ No newline at end of file diff --git a/lib/oopsy.js b/lib/oopsy.js index 2099608..a837fad 100644 --- a/lib/oopsy.js +++ b/lib/oopsy.js @@ -26,7 +26,7 @@ * A bare-bones constructor for surrogate prototype swapping. * * @private - * @class Constructor + * @constructor Constructor */ var Constructor = function() {} /** @@ -109,7 +109,7 @@ function create(prototype, properties) { * The base constructor from which all others should extend. * * @public - * @class Oopsy + * @constructor Oopsy */ function Oopsy() {} From 4dd2936d2f0fdc6b5128344f8ca2a2711a00ac4a Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 09:23:49 +0100 Subject: [PATCH 05/17] renamed __super to super_ to provide compatibility with util.inherits --- dist/oopsy.js | 4 ++-- dist/oopsy.js.map | 2 +- dist/oopsy.min.js | 2 +- dist/oopsy.min.js.map | 2 +- lib/oopsy.js | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dist/oopsy.js b/dist/oopsy.js index 5cb0eb3..98b4712 100644 --- a/dist/oopsy.js +++ b/dist/oopsy.js @@ -124,7 +124,7 @@ * If constructor is provided, it will be used as the constructor for the child, otherwise a simple * constructor which only calls the super constructor will be used instead. * - * The super constructor can be accessed via a special __super property on the child constructor. + * The super constructor can be accessed via a special super_ property on the child constructor. * * @param {Function} [constructor] - the constructor for the child * @param {Object} [prototype] - the prototype properties to be defined for the child @@ -149,7 +149,7 @@ constructor.prototype = create(superConstructor.prototype, prototype) constructor.prototype.constructor = constructor - constructor.__super = superConstructor + constructor.super_ = superConstructor return constructor } diff --git a/dist/oopsy.js.map b/dist/oopsy.js.map index cafc0e9..72212ed 100644 --- a/dist/oopsy.js.map +++ b/dist/oopsy.js.map @@ -1 +1 @@ -{"version":3,"file":null,"sources":["../lib/oopsy.js"],"sourcesContent":["/*\n * Copyright (C) 2016 Alasdair Mercer, Skelp\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n'use strict'\n\n/**\n * A bare-bones constructor for surrogate prototype swapping.\n *\n * @private\n * @constructor Constructor\n */\nvar Constructor = function() {}\n/**\n * A reference to Object.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @constructor Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super constructor can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor\n\n return constructor\n}\n\nmodule.exports = Oopsy\n"],"names":[],"mappings":";;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;;;AAQA,MAAI,WAAW,GAAG,WAAW,EAAE;;;;;;;AAO/B,MAAI,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc;;;;;;;AAOpD,MAAI,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK;;;;;;;;;;;;;;;AAejC,EAAA,SAAS,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE;IACpC,IAAI,MAAM,IAAI,IAAI,EAAE;MAClB,MAAM;KACP;;IAED,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;;IAElC,IAAI,QAAQ;IACZ,IAAI,MAAM;;IAEV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;MACxD,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;;MAEnB,KAA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IAEtC,OAAO,WAAW;GACnB;;AAED,cAAiB,KAAK;;;;"} \ No newline at end of file +{"version":3,"file":null,"sources":["../lib/oopsy.js"],"sourcesContent":["/*\n * Copyright (C) 2016 Alasdair Mercer, Skelp\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n'use strict'\n\n/**\n * A bare-bones constructor for surrogate prototype swapping.\n *\n * @private\n * @constructor Constructor\n */\nvar Constructor = function() {}\n/**\n * A reference to Object.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @constructor Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super constructor can be accessed via a special super_ property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.super_ = superConstructor\n\n return constructor\n}\n\nmodule.exports = Oopsy\n"],"names":[],"mappings":";;;;;;EAAA;;;;;;;;;;;;;;;;;;;;;;AAsBA;;;;;;AAQA,MAAI,WAAW,GAAG,WAAW,EAAE;;;;;;;AAO/B,MAAI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AC,MAAM,GAAG,SAAS,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE;IACvD,IAAI,gBAAgB,GAAG,IAAI;;IAE3B,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE;MACrC,OAAO,GAAG,SAAS;MACnB,SAAS,GAAG,WAAW;MACvB,WAAW,GAAG,WAAW;QACvB,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC;OAC/C;KACF;;IAED,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,CAAC;;IAErD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC;IACrE,WAAW,CAAC,SAAS,CAAC,WAAW,GAAG,WAAW;;IAE/C,WAAW,CAAC,MAAM,GAAG,gBAAgB;;IAErC,OAAO,WAAW;GACnB;;AAED,cAAiB,KAAK;;;;"} \ No newline at end of file diff --git a/dist/oopsy.min.js b/dist/oopsy.min.js index 5a41830..c17abbe 100644 --- a/dist/oopsy.min.js +++ b/dist/oopsy.min.js @@ -1,4 +1,4 @@ /*! Oopsy v0.1.0alpha | (C) 2016 Alasdair Mercer | MIT License */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define("oopsy",e):t.Oopsy=e()}(this,function(){"use strict";function t(t,e,o){if(null!=e){o=p.call(arguments,2);for(var n,c,f=0,u=o.length;fObject.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @constructor Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super constructor can be accessed via a special __super property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.__super = superConstructor\n\n return constructor\n}\n\nmodule.exports = Oopsy\n"],"names":["extend","own","target","sources","slice","call","arguments","property","source","i","length","hasOwnProperty","create","prototype","properties","result","Object","Constructor","Oopsy","Array","constructor","statics","superConstructor","this","apply","__super"],"mappings":";wLA2DA,SAASA,GAAOC,EAAKC,EAAQC,GAC3B,GAAc,MAAVD,EAAJ,CAIAC,EAAUC,EAAMC,KAAKC,UAAW,EAKhC,KAAK,GAHDC,GACAC,EAEKC,EAAI,EAAGC,EAASP,EAAQO,OAAQD,EAAIC,EAAQD,IAAK,CACxDD,EAASL,EAAQM,EAEjB,KAAKF,IAAYC,GACVP,IAAOU,EAAeN,KAAKG,EAAQD,KACtCL,EAAOK,GAAYC,EAAOD,MAgBlC,QAASK,GAAOC,EAAWC,GACzB,GAAIC,EAaJ,OAZ6B,kBAAlBC,QAAOJ,OAChBG,EAASC,OAAOJ,OAAOC,IAEvBI,EAAYJ,UAAYA,EACxBE,EAAS,GAAIE,GACbA,EAAYJ,UAAY,MAGtBC,GACFd,GAAO,EAAMe,EAAQD,GAGhBC,EAST,QAASG,SAnFLD,GAAc,aAOdN,EAAiBK,OAAOH,UAAUF,eAOlCP,EAAQe,MAAMN,UAAUT,KAuF5Bc,GAAMlB,OAAS,SAASoB,EAAaP,EAAWQ,GAC9C,GAAIC,GAAmBC,IAiBvB,OAf2B,kBAAhBH,KACTC,EAAUR,EACVA,EAAYO,EACZA,EAAc,WACZ,MAAOE,GAAiBE,MAAMD,KAAMjB,aAIxCN,GAAO,EAAOoB,EAAaE,EAAkBD,GAE7CD,EAAYP,UAAYD,EAAOU,EAAiBT,UAAWA,GAC3DO,EAAYP,UAAUO,YAAcA,EAEpCA,EAAYK,QAAUH,EAEfF,SAGQF"} \ No newline at end of file +{"version":3,"file":null,"sources":["../lib/oopsy.js"],"sourcesContent":["/*\n * Copyright (C) 2016 Alasdair Mercer, Skelp\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\n'use strict'\n\n/**\n * A bare-bones constructor for surrogate prototype swapping.\n *\n * @private\n * @constructor Constructor\n */\nvar Constructor = function() {}\n/**\n * A reference to Object.prototype.hasOwnProperty.\n *\n * @private\n * @type {Function}\n */\nvar hasOwnProperty = Object.prototype.hasOwnProperty\n/**\n * A reference to Array.prototype.slice.\n *\n * @private\n * @type {Function}\n */\nvar slice = Array.prototype.slice\n\n/**\n * Extends the specified target object with the properties in each of the sources provided.\n *\n * Nothing happens if target is null and if any source is null it will be\n * ignored.\n *\n * @param {boolean} own - true to only copy own properties from sources onto\n * target; otherwise false\n * @param {Object} [target] - the target object which should be extended\n * @param {...Object} [sources] - the source objects whose properties are to be copied onto target\n * @return {void}\n * @private\n */\nfunction extend(own, target, sources) {\n if (target == null) {\n return\n }\n\n sources = slice.call(arguments, 2)\n\n var property\n var source\n\n for (var i = 0, length = sources.length; i < length; i++) {\n source = sources[i]\n\n for (property in source) {\n if (!own || hasOwnProperty.call(source, property)) {\n target[property] = source[property]\n }\n }\n }\n}\n\n/**\n * Creates an object which inherits the given prototype.\n *\n * Optionally, the created object can be extended further with the specified properties.\n *\n * @param {Object} prototype - the prototype to be inherited by the created object\n * @param {Object} [properties] - the optional properties to be extended by the created object\n * @return {Object} The newly created object.\n * @private\n */\nfunction create(prototype, properties) {\n var result\n if (typeof Object.create === 'function') {\n result = Object.create(prototype)\n } else {\n Constructor.prototype = prototype\n result = new Constructor()\n Constructor.prototype = null\n }\n\n if (properties) {\n extend(true, result, properties)\n }\n\n return result\n}\n\n/**\n * The base constructor from which all others should extend.\n *\n * @public\n * @constructor Oopsy\n */\nfunction Oopsy() {}\n\n/**\n * Extends the constructor to which this method is associated with the prototype and/or\n * statics provided.\n *\n * If constructor is provided, it will be used as the constructor for the child, otherwise a simple\n * constructor which only calls the super constructor will be used instead.\n *\n * The super constructor can be accessed via a special super_ property on the child constructor.\n *\n * @param {Function} [constructor] - the constructor for the child\n * @param {Object} [prototype] - the prototype properties to be defined for the child\n * @param {Object} [statics] - the static properties to be defined for the child\n * @return {Function} The child constructor provided or the one created if none was given.\n * @public\n * @static\n */\nOopsy.extend = function(constructor, prototype, statics) {\n var superConstructor = this\n\n if (typeof constructor !== 'function') {\n statics = prototype\n prototype = constructor\n constructor = function() {\n return superConstructor.apply(this, arguments)\n }\n }\n\n extend(false, constructor, superConstructor, statics)\n\n constructor.prototype = create(superConstructor.prototype, prototype)\n constructor.prototype.constructor = constructor\n\n constructor.super_ = superConstructor\n\n return constructor\n}\n\nmodule.exports = Oopsy\n"],"names":["extend","own","target","sources","slice","call","arguments","property","source","i","length","hasOwnProperty","create","prototype","properties","result","Object","Constructor","Oopsy","Array","constructor","statics","superConstructor","this","apply","super_"],"mappings":";wLA2DA,SAASA,GAAOC,EAAKC,EAAQC,GAC3B,GAAc,MAAVD,EAAJ,CAIAC,EAAUC,EAAMC,KAAKC,UAAW,EAKhC,KAAK,GAHDC,GACAC,EAEKC,EAAI,EAAGC,EAASP,EAAQO,OAAQD,EAAIC,EAAQD,IAAK,CACxDD,EAASL,EAAQM,EAEjB,KAAKF,IAAYC,GACVP,IAAOU,EAAeN,KAAKG,EAAQD,KACtCL,EAAOK,GAAYC,EAAOD,MAgBlC,QAASK,GAAOC,EAAWC,GACzB,GAAIC,EAaJ,OAZ6B,kBAAlBC,QAAOJ,OAChBG,EAASC,OAAOJ,OAAOC,IAEvBI,EAAYJ,UAAYA,EACxBE,EAAS,GAAIE,GACbA,EAAYJ,UAAY,MAGtBC,GACFd,GAAO,EAAMe,EAAQD,GAGhBC,EAST,QAASG,SAnFLD,GAAc,aAOdN,EAAiBK,OAAOH,UAAUF,eAOlCP,EAAQe,MAAMN,UAAUT,KAuF5Bc,GAAMlB,OAAS,SAASoB,EAAaP,EAAWQ,GAC9C,GAAIC,GAAmBC,IAiBvB,OAf2B,kBAAhBH,KACTC,EAAUR,EACVA,EAAYO,EACZA,EAAc,WACZ,MAAOE,GAAiBE,MAAMD,KAAMjB,aAIxCN,GAAO,EAAOoB,EAAaE,EAAkBD,GAE7CD,EAAYP,UAAYD,EAAOU,EAAiBT,UAAWA,GAC3DO,EAAYP,UAAUO,YAAcA,EAEpCA,EAAYK,OAASH,EAEdF,SAGQF"} \ No newline at end of file diff --git a/lib/oopsy.js b/lib/oopsy.js index a837fad..068c40c 100644 --- a/lib/oopsy.js +++ b/lib/oopsy.js @@ -120,7 +120,7 @@ function Oopsy() {} * If constructor is provided, it will be used as the constructor for the child, otherwise a simple * constructor which only calls the super constructor will be used instead. * - * The super constructor can be accessed via a special __super property on the child constructor. + * The super constructor can be accessed via a special super_ property on the child constructor. * * @param {Function} [constructor] - the constructor for the child * @param {Object} [prototype] - the prototype properties to be defined for the child @@ -145,7 +145,7 @@ Oopsy.extend = function(constructor, prototype, statics) { constructor.prototype = create(superConstructor.prototype, prototype) constructor.prototype.constructor = constructor - constructor.__super = superConstructor + constructor.super_ = superConstructor return constructor } From efe1ed3f62179e0b779856723425e86e28b5dbaa Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 09:31:52 +0100 Subject: [PATCH 06/17] added unit tests --- test/.eslintrc.json | 4 ++ test/oopsy.spec.js | 111 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) diff --git a/test/.eslintrc.json b/test/.eslintrc.json index ba3ed6c..3108303 100644 --- a/test/.eslintrc.json +++ b/test/.eslintrc.json @@ -2,5 +2,9 @@ "extends": "../.eslintrc.json", "env": { "mocha": true + }, + "rules": { + "no-prototype-builtins": "off", + "no-unused-expressions": "off" } } diff --git a/test/oopsy.spec.js b/test/oopsy.spec.js index 492063a..348794d 100644 --- a/test/oopsy.spec.js +++ b/test/oopsy.spec.js @@ -31,4 +31,115 @@ describe('Oopsy', function() { expect(Oopsy).to.be.a('function') expect(new Oopsy()).to.be.an('object') }) + + describe('.extend', function() { + var Base = Oopsy.extend(function(name) { + this.name = name + }, { + greet: function(name) { + return 'Hello ' + name + ', my name is ' + this.name + } + }, { + foo: function() { + return 'bar' + } + }) + + it('should extend the prototype and static properties', function() { + function ChildConstructor() { + ChildConstructor.super_.apply(this, arguments) + + this.id = 123 + } + + var Child = Base.extend(ChildConstructor, { + farewell: function(name) { + return 'Goodbye ' + name + } + }, { + fizz: function() { + return 'buzz' + } + }) + var child = new Child('Foo') + + expect(Child).to.equal(ChildConstructor) + expect(child.hasOwnProperty('name')).to.be.true + expect(child.name).to.equal('Foo') + expect(child.id).to.equal(123) + expect(child.greet('Bar')).to.equal('Hello Bar, my name is Foo') + expect(child.farewell('Bar')).to.equal('Goodbye Bar') + expect(Child.foo()).to.equal('bar') + expect(Child.fizz()).to.equal('buzz') + }) + + it('should return constructor with correct inheritance', function() { + var SubBase = Base.extend(function() { + SubBase.super_.apply(this, arguments) + }) + var Child = SubBase.extend(function() { + Child.super_.apply(this, arguments) + }) + var child = new Child('Foo') + + expect(child).to.be.an.instanceof(Oopsy) + expect(child).to.be.an.instanceof(Base) + expect(child).to.be.an.instanceof(SubBase) + expect(child).to.be.an.instanceof(Child) + }) + + it('should give constructor reference to super constructor', function() { + var SubBase = Base.extend(function() { + SubBase.super_.apply(this, arguments) + }) + var Child = SubBase.extend(function() { + Child.super_.apply(this, arguments) + }) + + expect(Child.super_).to.equal(SubBase) + expect(SubBase.super_).to.equal(Base) + expect(Base.super_).to.equal(Oopsy) + }) + + context('when no constructor is passed', function() { + it('should extend the prototype and static properties', function() { + var Child = Base.extend({ + farewell: function(name) { + return 'Goodbye ' + name + } + }, { + fizz: function() { + return 'buzz' + } + }) + var child = new Child('Foo') + + expect(child.name).to.equal('Foo') + expect(child.greet('Bar')).to.equal('Hello Bar, my name is Foo') + expect(child.farewell('Bar')).to.equal('Goodbye Bar') + expect(Child.foo()).to.equal('bar') + expect(Child.fizz()).to.equal('buzz') + }) + + it('should return a constructor with correct inheritance', function() { + var SubBase = Base.extend() + var Child = SubBase.extend() + var child = new Child('Foo') + + expect(child).to.be.an.instanceof(Oopsy) + expect(child).to.be.an.instanceof(Base) + expect(child).to.be.an.instanceof(SubBase) + expect(child).to.be.an.instanceof(Child) + }) + + it('should return a constructor with reference to super constructor', function() { + var SubBase = Base.extend() + var Child = SubBase.extend() + + expect(Child.super_).to.equal(SubBase) + expect(SubBase.super_).to.equal(Base) + expect(Base.super_).to.equal(Oopsy) + }) + }) + }) }) From 808dd39ff736c1e4b3c7a8bae4294393260d62d9 Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 09:51:41 +0100 Subject: [PATCH 07/17] added test for semi-inheritance of existing classes --- test/oopsy.spec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/oopsy.spec.js b/test/oopsy.spec.js index 348794d..31116cb 100644 --- a/test/oopsy.spec.js +++ b/test/oopsy.spec.js @@ -22,6 +22,7 @@ 'use strict' +var EventEmitter = require('events').EventEmitter var expect = require('chai').expect var Oopsy = require('../lib/oopsy') @@ -101,6 +102,23 @@ describe('Oopsy', function() { expect(Base.super_).to.equal(Oopsy) }) + it('should allow semi-inheritance of existing classes', function() { + var Child = Base.extend(function() { + Child.super_.apply(this, arguments) + + EventEmitter.call(this) + }, EventEmitter.prototype, EventEmitter) + var child = new Child('Foo') + + expect(Child.super_).to.equal(Base) + expect(child).to.be.an.instanceof(Oopsy) + expect(child).to.be.an.instanceof(Base) + expect(child).to.be.an.instanceof(Child) + expect(child).not.to.be.an.instanceof(EventEmitter) + expect(child.name).to.equal('Foo') + expect(child.listenerCount()).to.equal(0) + }) + context('when no constructor is passed', function() { it('should extend the prototype and static properties', function() { var Child = Base.extend({ From 894885e0ffe99192d4673ac6a1c432ef9223140d Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 10:20:05 +0100 Subject: [PATCH 08/17] document API in README.md --- README.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 46c8b69..bce1995 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,58 @@ If you want to simply download the file to be used in the browser you can find t ## API -TODO: Document +The API is extremely simple and is designed to make it as easy as possible to implement traditional inheritance. + +``` javascript +Oopsy.extend([constructor][, prototype][, statics]) +``` + +It is very flexible and can be used to extend *classes*: + +``` javascript +var BaseObject = Oopsy.extend(function(options) { + this.options = options || {} +}) + +var ChildObject = BaseObject.extend({ + getOption: function(name) { + return this.options[name] + }, + setOption: function(name, value) { + this.options[name] = value + } +}) + +var Person = ChildObject.extend(function(name, options) { + Person.super_.call(this, options) + + this.name = name + + Person.people.push(this) +}, { + greet: function(name) { + return 'Hello ' + name + ', my name is ' + this.name + } +}, { + people: [] +}) +``` + +All constructors extended by Oopsy are given a static `super_` property which references the super constructor. + +Also, this can be used to extend existing *classes* such as `EventEmitter`: + +``` javascript +var EventEmitter = require('events').EventEmitter +var Oopsy = require('oopsy') + +var BaseObject = Oopsy.extend(function() { + EventEmitter.call(this) +}, EventEmitter.prototype, EventEmitter) +``` + +However, this last approach has the caveats of `instanceof` not identifying this kind of inheritance and `super_` will +only reference the constructor that is extended. ## Bugs From 2a4b9471abdac961ee6251c4690ed76b29571ab0 Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 10:22:54 +0100 Subject: [PATCH 09/17] roll 0.1.0 --- bower.json | 2 +- dist/oopsy.min.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index c528dc0..c2730a0 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "oopsy", - "version": "0.1.0alpha", + "version": "0.1.0", "description": "Simple OOP for JavaScript", "homepage": "https://github.com/Skelp/oopsy", "authors": [ diff --git a/dist/oopsy.min.js b/dist/oopsy.min.js index c17abbe..9978d7c 100644 --- a/dist/oopsy.min.js +++ b/dist/oopsy.min.js @@ -1,4 +1,4 @@ -/*! Oopsy v0.1.0alpha | (C) 2016 Alasdair Mercer | MIT License */ +/*! Oopsy v0.1.0 | (C) 2016 Alasdair Mercer | MIT License */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define("oopsy",e):t.Oopsy=e()}(this,function(){"use strict";function t(t,e,o){if(null!=e){o=p.call(arguments,2);for(var n,c,f=0,u=o.length;f Date: Wed, 21 Sep 2016 10:32:44 +0100 Subject: [PATCH 10/17] dropping CI support for Node.js <0.12 to avoid workarounds for rollup --- .travis.yml | 1 - Gruntfile.js | 9 +-------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index e8cbb2b..a9e5de2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: node_js node_js: - - "0.10" - "0.12" - "4.0" - "6.0" diff --git a/Gruntfile.js b/Gruntfile.js index 2561076..270e44b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -102,15 +102,8 @@ module.exports = function(grunt) { require('load-grunt-tasks')(grunt) var buildTasks = [ 'compile' ] - var compileTasks = [] var testTasks = [ 'compile', 'mochaTest' ] - if (semver.satisfies(process.version, '>=0.12')) { - compileTasks.push('clean', 'rollup') - } else { - grunt.log.writeln('"compile" task is disabled because Node.js version is <0.12! Please consider upgrading Node.js...') - } - if (semver.satisfies(process.version, '>=4')) { buildTasks.unshift('eslint') testTasks.unshift('eslint') @@ -120,6 +113,6 @@ module.exports = function(grunt) { grunt.registerTask('default', [ 'build' ]) grunt.registerTask('build', buildTasks) - grunt.registerTask('compile', compileTasks) + grunt.registerTask('compile', [ 'clean', 'rollup' ]) grunt.registerTask('test', testTasks) } From 2572502f0a9d8fd8c2c2517270be4f5f29384ba2 Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 10:57:37 +0100 Subject: [PATCH 11/17] fixed test failing on Node.js <0.12 --- test/oopsy.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/oopsy.spec.js b/test/oopsy.spec.js index 31116cb..784f209 100644 --- a/test/oopsy.spec.js +++ b/test/oopsy.spec.js @@ -116,7 +116,7 @@ describe('Oopsy', function() { expect(child).to.be.an.instanceof(Child) expect(child).not.to.be.an.instanceof(EventEmitter) expect(child.name).to.equal('Foo') - expect(child.listenerCount()).to.equal(0) + expect(child.listeners()).to.eql([]) }) context('when no constructor is passed', function() { From 88487d59427ea310998cfb6b18d3266e1799c267 Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 11:22:03 +0100 Subject: [PATCH 12/17] build now runs on Node.js 0.10 but skips linting and compilation --- .travis.yml | 7 +-- CONTRIBUTING.md | 8 +++ Gruntfile.js | 134 +++++++++++++++++++++++++++--------------------- package.json | 1 - 4 files changed, 88 insertions(+), 62 deletions(-) diff --git a/.travis.yml b/.travis.yml index a9e5de2..dc885e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,8 @@ language: node_js node_js: - - "0.12" - - "4.0" - - "6.0" + - "0.10.x" + - "0.12.x" + - "4" + - "6" script: - npm test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f7bd1bb..4435531 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,6 +16,14 @@ $ npm install $ npm test ``` +If you're using a version of [Node.js](https://nodejs.org) that is older than 0.12, then linting is not performed by +this step. Please consider upgrading to at least 0.12 or your pull request may fail on the CI build. + +Likewise, [Node.js](https://nodejs.org) versions older than 0.10 will also not be able to compile the source code using +[Rollup](http://rollupjs.org) so the test suite will not be executed against any changes you've made to `lib/oopsy.js`. +For this reason, 0.10 is not supported from a development perspective, but our CI builds do run the test suite against +the pre-compiled code for this version to ensure that it works. + All pull requests should be made to the `develop` branch. Don't forget to add your details to the list of diff --git a/Gruntfile.js b/Gruntfile.js index 270e44b..2c58e05 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -21,21 +21,13 @@ */ module.exports = function(grunt) { - var commonjs = require('rollup-plugin-commonjs') + var commonjs var semver = require('semver') - var uglify = require('rollup-plugin-uglify') + var uglify grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), - clean: { - build: [ 'dist/**' ] - }, - - eslint: { - target: [ 'lib/**/*.js', 'test/**/*.js' ] - }, - mochaTest: { test: { options: { @@ -46,51 +38,6 @@ module.exports = function(grunt) { } }, - rollup: { - umdDevelopment: { - options: { - format: 'umd', - moduleId: 'oopsy', - moduleName: 'Oopsy', - sourceMap: true, - sourceMapRelativePaths: true, - plugins: function() { - return [ - commonjs() - ] - } - }, - files: { - 'dist/oopsy.js': 'lib/oopsy.js' - } - }, - umdProduction: { - options: { - format: 'umd', - moduleId: 'oopsy', - moduleName: 'Oopsy', - sourceMap: true, - sourceMapRelativePaths: true, - banner: '/*! Oopsy v<%= pkg.version %> | (C) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | MIT License */', - plugins: function() { - return [ - commonjs(), - uglify({ - output: { - comments: function(node, comment) { - return comment.type === 'comment2' && /^\!/.test(comment.value) - } - } - }) - ] - } - }, - files: { - 'dist/oopsy.min.js': 'lib/oopsy.js' - } - } - }, - watch: { all: { files: [ 'lib/**/*.js', 'test/**/*.js' ], @@ -99,20 +46,91 @@ module.exports = function(grunt) { } }) - require('load-grunt-tasks')(grunt) - var buildTasks = [ 'compile' ] + var compileTasks = [] var testTasks = [ 'compile', 'mochaTest' ] + if (semver.satisfies(process.version, '>=0.12')) { + commonjs = require('rollup-plugin-commonjs') + uglify = require('rollup-plugin-uglify') + + compileTasks.push('clean', 'rollup') + + grunt.config.merge({ + clean: { + build: [ 'dist/**' ] + }, + + rollup: { + umdDevelopment: { + options: { + format: 'umd', + moduleId: 'oopsy', + moduleName: 'Oopsy', + sourceMap: true, + sourceMapRelativePaths: true, + plugins: function() { + return [ + commonjs() + ] + } + }, + files: { + 'dist/oopsy.js': 'lib/oopsy.js' + } + }, + umdProduction: { + options: { + format: 'umd', + moduleId: 'oopsy', + moduleName: 'Oopsy', + sourceMap: true, + sourceMapRelativePaths: true, + banner: '/*! Oopsy v<%= pkg.version %> | (C) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | MIT License */', + plugins: function() { + return [ + commonjs(), + uglify({ + output: { + comments: function(node, comment) { + return comment.type === 'comment2' && /^\!/.test(comment.value) + } + } + }) + ] + } + }, + files: { + 'dist/oopsy.min.js': 'lib/oopsy.js' + } + } + } + }) + + grunt.loadNpmTasks('grunt-contrib-clean') + grunt.loadNpmTasks('grunt-rollup') + } else { + grunt.log.writeln('"clean" and "rollup" tasks are disabled because Node.js version is <0.12! Please consider upgrading Node.js...') + } + if (semver.satisfies(process.version, '>=4')) { buildTasks.unshift('eslint') testTasks.unshift('eslint') + + grunt.config.set('eslint', { + target: [ 'lib/**/*.js', 'test/**/*.js' ] + }) + + grunt.loadNpmTasks('grunt-eslint') } else { grunt.log.writeln('"eslint" task is disabled because Node.js version is <4! Please consider upgrading Node.js...') } + grunt.loadNpmTasks('grunt-contrib-watch') + grunt.loadNpmTasks('grunt-mocha-test') + grunt.registerTask('default', [ 'build' ]) grunt.registerTask('build', buildTasks) - grunt.registerTask('compile', [ 'clean', 'rollup' ]) + grunt.registerTask('compile', compileTasks) grunt.registerTask('test', testTasks) } diff --git a/package.json b/package.json index 49f9592..b6bcaaf 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "grunt-eslint": "^18.1.0", "grunt-mocha-test": "^0.13.2", "grunt-rollup": "^0.8.0", - "load-grunt-tasks": "^3.5.0", "mocha": "^3.0.2", "rollup-plugin-commonjs": "^5.0.4", "rollup-plugin-uglify": "^1.0.1", From e28adc667657a38ae37c9fa7f7e0519cb375cd7c Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 11:24:43 +0100 Subject: [PATCH 13/17] fixed Node.js versions for CI builds --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dc885e5..ba153ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: - - "0.10.x" - - "0.12.x" + - "0.10" + - "0.12" - "4" - "6" script: From 214fe09a71056a279c89ab4b9abc3ccb6420e54d Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 12:20:51 +0100 Subject: [PATCH 14/17] changed bower package name to skelp-oopsy to avoid conflict with existing package --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bce1995..ad8063d 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Install using the package manager for your desired environment(s): ``` bash $ npm install --save oopsy # OR: -$ bower install --save oopsy +$ bower install --save skelp-oopsy ``` You'll need to have at least [Node.js](https://nodejs.org) installed and you'll only need [Bower](https://bower.io) if diff --git a/package.json b/package.json index b6bcaaf..790722c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "oopsy", + "name": "skelp-oopsy", "version": "0.1.0", "description": "Simple OOP for JavaScript", "homepage": "https://github.com/Skelp/oopsy", From e432cbadbff7bfca0532f1a465a39b3ef76e54cd Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 12:23:44 +0100 Subject: [PATCH 15/17] added change log --- CHANGES.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 CHANGES.md diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..3159105 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,7 @@ +## Version 0.1.1, 2016.09.21 + +* Change [Bower](https://bower.io) package name to `skelp-oopsy` to avoid conflict with existing package + +## Version 0.1.0, 2016.09.21 + +* Initial release From 825108927b1ca1b715cd4d616cfbd11e679acd78 Mon Sep 17 00:00:00 2001 From: Alasdair Mercer Date: Wed, 21 Sep 2016 12:24:27 +0100 Subject: [PATCH 16/17] roll 0.1.1 --- bower.json | 2 +- dist/oopsy.min.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index c2730a0..5dfd6c9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "oopsy", - "version": "0.1.0", + "version": "0.1.1", "description": "Simple OOP for JavaScript", "homepage": "https://github.com/Skelp/oopsy", "authors": [ diff --git a/dist/oopsy.min.js b/dist/oopsy.min.js index 9978d7c..918bb64 100644 --- a/dist/oopsy.min.js +++ b/dist/oopsy.min.js @@ -1,4 +1,4 @@ -/*! Oopsy v0.1.0 | (C) 2016 Alasdair Mercer | MIT License */ +/*! Oopsy v0.1.1 | (C) 2016 Alasdair Mercer | MIT License */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define("oopsy",e):t.Oopsy=e()}(this,function(){"use strict";function t(t,e,o){if(null!=e){o=p.call(arguments,2);for(var n,c,f=0,u=o.length;f Date: Wed, 21 Sep 2016 12:48:32 +0100 Subject: [PATCH 17/17] reroll 0.1.1 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 5dfd6c9..a33a2a5 100644 --- a/bower.json +++ b/bower.json @@ -1,5 +1,5 @@ { - "name": "oopsy", + "name": "skelp-oopsy", "version": "0.1.1", "description": "Simple OOP for JavaScript", "homepage": "https://github.com/Skelp/oopsy", diff --git a/package.json b/package.json index 61da0ee..1259c5f 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "skelp-oopsy", + "name": "oopsy", "version": "0.1.1", "description": "Simple OOP for JavaScript", "homepage": "https://github.com/Skelp/oopsy",