@magicbell/core
Version:
Official MagicBell API wrapper
23 lines • 820 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = unwrap;
const tslib_1 = require("tslib");
const get_js_1 = tslib_1.__importDefault(require("lodash/get.js"));
/**
* Decorator factory to unwrap the arguments of the method decorated with this.
*
* @example
* @unwrap('notification')
* set(json = {}) { Object.assign(this, json) }
*/
function unwrap(wrapKey) {
return function (target, propertyKey, descriptor) {
const originalMethod = descriptor.value;
descriptor.value = function (...args) {
const [json, ...otherArgs] = args;
const unwrappedJson = (0, get_js_1.default)(json, wrapKey, json);
return originalMethod.apply(this, [unwrappedJson, ...otherArgs]);
};
};
}
//# sourceMappingURL=unwrap.js.map