-
Notifications
You must be signed in to change notification settings - Fork 7
factor out isMergeable #83
Copy link
Copy link
Open
Description
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 ) );
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels