defineInspect.mjs 575 B

123456789101112131415
  1. import invariant from "./invariant.mjs";
  2. import nodejsCustomInspectSymbol from "./nodejsCustomInspectSymbol.mjs";
  3. /**
  4. * The `defineInspect()` function defines `inspect()` prototype method as alias of `toJSON`
  5. */
  6. export default function defineInspect(classObject) {
  7. var fn = classObject.prototype.toJSON;
  8. typeof fn === 'function' || invariant(0);
  9. classObject.prototype.inspect = fn; // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317')
  10. if (nodejsCustomInspectSymbol) {
  11. classObject.prototype[nodejsCustomInspectSymbol] = fn;
  12. }
  13. }