UNPKG

web-ui-pack

Version:
13 lines (12 loc) 326 B
export default function onSpy(obj, method, callback) { const orig = obj[method]; const n = { [method]() { const r = orig.apply(obj, arguments); callback.apply(obj, arguments); return r; }, }; obj[method] = n[method]; return () => (obj[method] = orig); }