Check for obj.prototype before reading or assigning

When using the ['lodash-amd'](https://npmjs.org/package/lodash-amd) package, `setModuleId` fails, since the functions defined by LoDash aren't the type that have a `.prototype` property.

This just checks that `obj.prototype` exists before assigning or reading it.