merge.js has private function validateMergeableObject that contains this nice validation:
assert && assert( object === null ||
( object && typeof object === 'object' &&
Object.getPrototypeOf( object ) === Object.prototype ),
'Object should be null or a truthy object that cannot have an extra prototype' );
A similar test seems to be duplicated many times throughout the PhET code base. Search for getPrototypeOf shows 62 occurrences, and it looks like most of these are doing the same thing as validateMergeableObject -- type validation of options arg.
Would anyone object to factoring out isMergeable?
function isMergeable( object ) {
return ( object === null ||
( object && typeof object === 'object' && Object.getPrototypeOf( object ) === Object.prototype ) );
}
merge.js has private function
validateMergeableObjectthat contains this nice validation:A similar test seems to be duplicated many times throughout the PhET code base. Search for getPrototypeOf shows 62 occurrences, and it looks like most of these are doing the same thing as
validateMergeableObject-- type validation ofoptionsarg.Would anyone object to factoring out
isMergeable?