MCPcopy
hub / github.com/RaspberryPiFoundation/blockly / mixin

Method mixin

packages/blockly/core/block.ts:1916–1937  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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.

Callers 6

registerMixinFunction · 0.80
registerMutatorFunction · 0.80
text.tsFile · 0.80
QUOTES_EXTENSIONFunction · 0.80
JOIN_EXTENSIONFunction · 0.80
LOGIC_COMPARE_EXTENSIONFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected