1 | define(["require", "exports"], function (require, exports) {
|
2 | "use strict";
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | var REACT_LIFECYCLE_EXCLUSIONS = [
|
5 | 'setState',
|
6 | 'render',
|
7 | 'componentWillMount',
|
8 | 'UNSAFE_componentWillMount',
|
9 | 'componentDidMount',
|
10 | 'componentWillReceiveProps',
|
11 | 'UNSAFE_componentWillReceiveProps',
|
12 | 'shouldComponentUpdate',
|
13 | 'componentWillUpdate',
|
14 | 'getSnapshotBeforeUpdate',
|
15 | 'UNSAFE_componentWillUpdate',
|
16 | 'componentDidUpdate',
|
17 | 'componentWillUnmount',
|
18 | ];
|
19 | |
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | function hoistMethods(
|
29 | // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
30 | destination,
|
31 |
|
32 | source, exclusions) {
|
33 | if (exclusions === void 0) { exclusions = REACT_LIFECYCLE_EXCLUSIONS; }
|
34 | var hoisted = [];
|
35 | var _loop_1 = function (methodName) {
|
36 | if (typeof source[methodName] === 'function' &&
|
37 | destination[methodName] === undefined &&
|
38 | (!exclusions || exclusions.indexOf(methodName) === -1)) {
|
39 | hoisted.push(methodName);
|
40 |
|
41 | destination[methodName] = function () {
|
42 | var args = [];
|
43 | for (var _i = 0; _i < arguments.length; _i++) {
|
44 | args[_i] = arguments[_i];
|
45 | }
|
46 | source[methodName].apply(source, args);
|
47 | };
|
48 | }
|
49 | };
|
50 | for (var methodName in source) {
|
51 | _loop_1(methodName);
|
52 | }
|
53 | return hoisted;
|
54 | }
|
55 | exports.hoistMethods = hoistMethods;
|
56 | |
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 | function unhoistMethods(source, methodNames) {
|
65 | methodNames.forEach(function (methodName) { return delete source[methodName]; });
|
66 | }
|
67 | exports.unhoistMethods = unhoistMethods;
|
68 | });
|
69 |
|
\ | No newline at end of file |