UNPKG

monopoly-shared-model

Version:

Shared model for Monopoly

32 lines 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function consoleLogMethod(target, key, descriptor) { // save a reference to the original method this way we keep the values currently in the // descriptor and don't overwrite what another decorator might have done to the descriptor. if (descriptor === undefined) { descriptor = Object.getOwnPropertyDescriptor(target, key); } const originalMethod = descriptor.value; // Editing the descriptor/value parameter descriptor.value = function () { const args = []; for (let _i = 0; _i < arguments.length; _i++) { args[_i - 0] = arguments[_i]; } const allArgs = args .map((arg) => { return JSON.stringify(arg); }) .join(); // note usage of originalMethod here console.log('Calling method: ' + key + '(' + allArgs + ')'); const result = originalMethod.apply(this, args); const r = JSON.stringify(result); console.log('Calling method: ' + key + '(' + allArgs + ') => ' + r); return result; }; // return edited descriptor as opposed to overwriting the descriptor return descriptor; } exports.consoleLogMethod = consoleLogMethod; //# sourceMappingURL=LogUtils.js.map