uncouple
Version:
Uncouple constructors and classes methods into functions.
8 lines (7 loc) • 1.43 kB
JavaScript
/*!
* uncouple v0.6.0
* (c) Vitor Luiz Cavalcanti <vitorluizc@outlook.com> (https://vitorluizc.github.io)
* Released under the MIT License.
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).uncouple={})}(this,function(t){"use strict";var e=Object.getOwnPropertyNames,n=function(t){return function(e){return"constructor"!==e&&"function"==typeof t[e]}},r=function(t,e){return t+(e?e[0].toUpperCase()+e.substr(1):"")};t.uncoupleGetters=function(t){var n=t.prototype||t,o=Object.create(null);return e(n).forEach(function(t){var e=Object.getOwnPropertyDescriptor(n,t)||{};"function"==typeof e.get&&(o[r("get",t)]=Function.call.bind(e.get))}),o},t.uncoupleMethods=function(t){var r=t.prototype||t,o=Object.create(null);return e(r).filter(n(r)).forEach(function(t){o[t]=Function.call.bind(r[t])}),o},t.uncoupleMethodsAsCurries=function(t){var r=t.prototype||t,o=Object.create(null);return e(r).filter(n(r)).forEach(function(t){o[t]=function(){var e=arguments;return function(n){return r[t].apply(n,e)}}}),o},t.uncoupleSetters=function(t){var n=t.prototype||t,o=Object.create(null);return e(n).forEach(function(t){var e=Object.getOwnPropertyDescriptor(n,t)||{};"function"==typeof e.set&&(o[r("set",t)]=Function.call.bind(e.set))}),o},Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=index.umd.min.js.map