* Add key/values from mixinObj to this block object. By default, this method * will check that the keys in mixinObj will not overwrite existing values in * the block, including prototype values. This provides some insurance against * mixin / extension incompatibilities with future block fea
(mixinObj: AnyDuringMigration, opt_disableCheck?: boolean)
| 1914 | * @param opt_disableCheck Option flag to disable overwrite checks. |
| 1915 | */ |
| 1916 | mixin(mixinObj: AnyDuringMigration, opt_disableCheck?: boolean) { |
| 1917 | if ( |
| 1918 | opt_disableCheck !== undefined && |
| 1919 | typeof opt_disableCheck !== 'boolean' |
| 1920 | ) { |
| 1921 | throw Error('opt_disableCheck must be a boolean if provided'); |
| 1922 | } |
| 1923 | if (!opt_disableCheck) { |
| 1924 | const overwrites = []; |
| 1925 | for (const key in mixinObj) { |
| 1926 | if ((this as AnyDuringMigration)[key] !== undefined) { |
| 1927 | overwrites.push(key); |
| 1928 | } |
| 1929 | } |
| 1930 | if (overwrites.length) { |
| 1931 | throw Error( |
| 1932 | 'Mixin will overwrite block members: ' + JSON.stringify(overwrites), |
| 1933 | ); |
| 1934 | } |
| 1935 | } |
| 1936 | Object.assign(this, mixinObj); |
| 1937 | } |
| 1938 | |
| 1939 | /** |
| 1940 | * Interpolate a message description onto the block. |
no outgoing calls
no test coverage detected