@magicbell/core
Version:
Official MagicBell API wrapper
19 lines • 645 B
JavaScript
import get from 'lodash/get.js';
/**
* Decorator factory to unwrap the arguments of the method decorated with this.
*
* @example
* @unwrap('notification')
* set(json = {}) { Object.assign(this, json) }
*/
export default function unwrap(wrapKey) {
return function (target, propertyKey, descriptor) {
const originalMethod = descriptor.value;
descriptor.value = function (...args) {
const [json, ...otherArgs] = args;
const unwrappedJson = get(json, wrapKey, json);
return originalMethod.apply(this, [unwrappedJson, ...otherArgs]);
};
};
}
//# sourceMappingURL=unwrap.js.map