Created
March 3, 2018 19:33
-
-
Save jbaxleyiii/4c9bd421d87ab6783381a45e34af0746 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
the extends function takes a base class and returns a function | |
that can be extended into a new class given methods | |
the methods must be in the form of [ | |
{ key: "methodName": value: function } | |
] | |
this is pulled from babel => es5 of a class extend | |
*/ | |
let extends = [%raw | |
{| | |
var extender = function(baseClass) { | |
var _createClass = (function() { | |
function defineProperties(target, props) { | |
for (var i = 0; i < props.length; i++) { | |
var descriptor = props[i]; | |
descriptor.enumerable = descriptor.enumerable || false; | |
descriptor.configurable = true; | |
if ("value" in descriptor) descriptor.writable = true; | |
Object.defineProperty(target, descriptor.key, descriptor); | |
} | |
} | |
return function(Constructor, protoProps, staticProps) { | |
if (protoProps) defineProperties(Constructor.prototype, protoProps); | |
if (staticProps) defineProperties(Constructor, staticProps); | |
return Constructor; | |
}; | |
})(); | |
function _possibleConstructorReturn(self, call) { | |
if (!self) { | |
throw new ReferenceError( | |
"this hasn't been initialised - super() hasn't been called" | |
); | |
} | |
return call && (typeof call === "object" || typeof call === "function") | |
? call | |
: self; | |
} | |
function _inherits(subClass, superClass) { | |
if (typeof superClass !== "function" && superClass !== null) { | |
throw new TypeError( | |
"Super expression must either be null or a function, not " + | |
typeof superClass | |
); | |
} | |
subClass.prototype = Object.create(superClass && superClass.prototype, { | |
constructor: { | |
value: subClass, | |
enumerable: false, | |
writable: true, | |
configurable: true | |
} | |
}); | |
if (superClass) | |
Object.setPrototypeOf | |
? Object.setPrototypeOf(subClass, superClass) | |
: (subClass.__proto__ = superClass); | |
} | |
return function(methods) { | |
var CustomDirective = (function(_SchemaDirectiveVisit) { | |
_inherits(CustomDirective, _SchemaDirectiveVisit); | |
function CustomDirective() { | |
return _possibleConstructorReturn( | |
this, | |
( | |
CustomDirective.__proto__ || | |
Object.getPrototypeOf(UniqueIdDirective) | |
).apply(this, arguments) | |
); | |
} | |
var convert = function convert(methods) { | |
return Object.keys(methods).map(function (key) { | |
return { | |
key: key, | |
value: methods[key] | |
}; | |
}); | |
}; | |
_createClass(CustomDirective, convert(methods)); | |
return CustomDirective; | |
})(baseClass); | |
}; | |
}; | |
|} | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment