1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 | /**
|
8 | * Removes event handlers from the given object.
|
9 | * A field is considered an event handler if it is a function with a name beginning with `on`.
|
10 | *
|
11 | * @param object Object to remove event handlers from.
|
12 | * @returns Object with event handlers removed.
|
13 | */
|
14 | function omitEventHandlers(object) {
|
15 | if (object === undefined) {
|
16 | return {};
|
17 | }
|
18 | const result = {};
|
19 | Object.keys(object).filter(prop => !(prop.match(/^on[A-Z]/) && typeof object[prop] === 'function')).forEach(prop => {
|
20 | result[prop] = object[prop];
|
21 | });
|
22 | return result;
|
23 | }
|
24 | var _default = exports.default = omitEventHandlers; |
\ | No newline at end of file |