warriorjs-engine
Version:
The bowels of WarriorJS
33 lines (25 loc) • 780 B
JavaScript
;
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.playerObject = playerObject;
var originalObject = Symbol();
exports.originalObject = originalObject;
function playerObject() {
var allowedProperties = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];
return function (target) {
Object.defineProperty(target.prototype, 'toPlayerObject', {
value: function value() {
var _this = this;
var result = {};
allowedProperties.filter(function (id) {
return typeof _this[id] === 'function';
}).forEach(function (id) {
return result[id] = _this[id].bind(_this);
});
result[originalObject] = this;
return result;
}
});
};
}