forked from daffl/uberproto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proto.min.js
3 lines (3 loc) · 1.14 KB
/
proto.min.js
1
2
3
(function(){"undefined"==typeof define&&(define=function(a){a=a();"undefined"==typeof exports?Proto=a:module.exports=a});Object.create||(Object.create=function(a){function b(){}if(1<arguments.length)throw Error("Object.create implementation only accepts the first parameter.");b.prototype=a;return new b});Object.getPrototypeOf||(Object.getPrototypeOf=function(a){return a.proto||a.constructor.prototype});define(function(){return{create:function(){var a=Object.create(this),b=typeof a.__init==="string"?
a.__init:"init";typeof a[b]=="function"&&a[b].apply(a,arguments);return a},mixin:function(a,b){var d=b||this,g=/xyz/.test(function(){xyz})?/\b_super\b/:/.*/,f=Object.getPrototypeOf(d)||d.prototype,e,c;for(c in a){e=d[c];d[c]=typeof a[c]=="function"&&typeof f[c]=="function"&&g.test(a[c])||typeof e=="function"&&typeof a[c]=="function"?function(a,b,c){return function(){var d=this._super;this._super=typeof a=="function"?a:f[b];var e=c.apply(this,arguments);this._super=d;return e}}(e,c,a[c]):a[c]}return d},
extend:function(a,b){return this.mixin(a,Object.create(b||this))},proxy:function(a,b){var d=b||this;return function(){return d[a].apply(d,arguments)}}}})})();