Skip to main content

Function: assertIsMobjectMethod()

assertIsMobjectMethod(mob, methodName): void

Defined in: src/animation/Always.ts:121

Assert that (mob, methodName) names a method of a Mobject (CE assert_is_mobject_method).

CE takes one bound method and recovers the receiver from method.__self__. A JavaScript method reference loses its this, so this repo validates the (mobject, methodName) pair that always / fAlways already accept. The check throws a clear Error when mob is not a Mobject, or when mob[methodName] is not a function.

Parameters​

mob​

unknown

The value that must be a Mobject.

methodName​

string

The name that must resolve to a method on mob.

Returns​

void

Throws​

Error when mob is not a Mobject or methodName is not a method.

Example​

assertIsMobjectMethod(dot, 'setX'); // ok
assertIsMobjectMethod(dot, 'nope'); // throws