{"size": 621, "ext": "js", "max_stars_repo_path": "src/setPrototypeOf.js", "max_stars_repo_name": "adeira/fetch", "max_stars_repo_stars_event_min_datetime": "2019-06-07T08:18:33.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-07T09:01:54.000Z", "max_issues_repo_path": "src/setPrototypeOf.js", "max_issues_repo_name": "adeira/fetch", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/setPrototypeOf.js", "max_forks_repo_name": "adeira/fetch", "max_forks_repo_forks_event_min_datetime": "2019-05-24T23:33:59.000Z", "max_forks_repo_forks_event_max_datetime": "2019-05-24T23:33:59.000Z"}
{"max_stars_count": 12, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 25.875, "max_line_length": 120, "alphanum_fraction": 0.7149758454}
// @flow

type AnyObject = { [string]: any, ... };

type AnyProtoObject = {
  -__proto__: typeof Error,
  +[string]: any,
  ...
};

/**
 * Necessary for Android version of React Native which doesn't support 'Object.setPrototypeOf'.
 *
 * @see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf#Polyfill
 */
export default function setPrototypeOf(obj: AnyObject, prototype: typeof Error): AnyProtoObject {
  if (Object.setPrototypeOf) {
    return Object.setPrototypeOf(obj, prototype);
  }

  obj.__proto__ = prototype; // eslint-disable-line no-proto
  return obj;
}
