UNPKG

web-audio-test-api

Version:
40 lines (33 loc) 1.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = contract; function contract(_ref) { var precondition = _ref.precondition; var postcondition = _ref.postcondition; return function (target, name, descriptor) { var func = descriptor.value; descriptor.value = function contract() { if (typeof precondition === "function") { try { precondition.call.apply(precondition, [this].concat(Array.prototype.slice.call(arguments))); } catch (e) { e.message = this.constructor.name + "#" + name + "; " + e.message; throw e; } } var res = func.call.apply(func, [this].concat(Array.prototype.slice.call(arguments))); if (typeof postcondition === "function") { try { postcondition.call(this, res); } catch (e) { e.message = this.constructor.name + "#" + name + "; " + e.message; throw e; } } return res; }; return descriptor; }; }