-
Notifications
You must be signed in to change notification settings - Fork 0
/
protomatter.min.js
7 lines (7 loc) · 3.1 KB
/
protomatter.min.js
1
2
3
4
5
6
7
/*!
* Protomatter.js 0.2.1
* https://github.com/whastings/protomatter.js
* (c) 2015 Will Hastings
* Protomatter.js may be freely distributed under the MIT license.
*/
!function(t){"use strict";function r(t,r){for(;r&&r!==v;)a(r._copyPrivate)&&r._copyPrivate(t,!0),r=Object.getPrototypeOf(r)}function e(t,r,e){var n,o;for(o in t)n=t[o],a(n)&&n!==v[o]&&(r[o]=function(n){return function(){var o,i;return o=this===r||this===w||void 0===this,i=o?e:this,t[n].apply(i,arguments)}}(o))}function n(t){return function(){for(var r=0,e=t.length;e>r;r++)t[r].apply(this,arguments)}}function o(t){return function(r){var e,n,o,i;if(i=u(t,function(t){return t.hasOwnProperty(r)&&a(t[r])}),!i)throw new Error("Method "+r+" is not defined.");return e=y.call(arguments,1),n=this.callSuper,this.callSuper=i.callSuper,o=i[r].apply(this,e),this.callSuper=n,o}}function i(t,r){return r=r||{},r.superProto=this,h.create(t,r)}function u(t,r){for(;t;){if(r(t))return t;t=Object.getPrototypeOf(t)}return null}function a(t){return"function"==typeof t}function c(t){var r=typeof t;return"object"===r||"function"===r}function s(t){var r;if(!this.allowMixins)throw new Error(m);if(!c(t))throw new Error(P);r="object"==typeof this.public?this.public:this,f(t,function(t,e){a(t)&&(t=t.bind(this)),r[e]=t}.bind(this))}function p(t,r){if(!c(r))throw new Error(x);f(r,function(r,e){"initialize"!==e&&(t[e]=r)}),a(r._copyPrivate)&&r._copyPrivate(t.private)}function f(t,r){for(var e in t)t.hasOwnProperty(e)&&r(t[e],e)}function l(t,n){var o=Object.create(t);return o.public=t,r(o,n),e(n,t,o),o}var h={},y=Array.prototype.slice,v=Object.prototype,w="undefined"==typeof global?window:global,d="Pass two or more prototypes to compose them.",b="Constructor passed is not a function.",m="This object type does not accept mixins.",P="Mixin passed is not an object",g="Private methods passed must be in an object.",x="Prototype passed is not an object.",j="Given superProto is not an object.";h.create=function(t,r){var e,n,u;if(r=r||{},r.allowMixins=void 0===r.allowMixins?!0:r.allowMixins,u=r.superProto,t=t||{},a(t)&&(t=t()),u){if(!c(u))throw new Error(j);n=Object.create(u),n.callSuper=o(u)}else n={};if(f(t,function(t,r){"private"!==r&&(n[r]=t)}),e=t.private){if(!c(e))throw new Error(g);n._copyPrivate=function(t,r){f(e,function(e,n){t[n]=r?function(){var r=this===w||void 0===this?t:this;return e.apply(r,arguments)}:e})}}return n.create=function(){var t,e=Object.create(n),o=l(e,n);return o.allowMixins=!!r.allowMixins,a(n.init)&&(n.hasOwnProperty("init")?n.init.apply(o,arguments):(t=y.call(arguments),t.unshift("init"),n.callSuper.apply(o,t))),e},n.extend=i,n.mixIn=s,n},h.compose=function(){var t,r,e=arguments,o=e.length,i={"private":{}},u=[];if(2>o)throw new Error(d);for(r=0;o>r;r++)t=e[r],p(i,t),a(t.init)&&u.push(t.init);return u.length>0&&(i.init=n(u)),this.create(i)},h.convert=function(t,r){var e;if(r=r||{},!a(t))throw new Error(b);return t.prototype!==v&&(r.superProto=Object.getPrototypeOf(t.prototype)),e=h.create(t.prototype,r),e.init=t,e},"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=h),exports.Protomatter=h):t.Protomatter=h}(this);