defineInspect.js 858 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = defineInspect;
  6. var _invariant = _interopRequireDefault(require("./invariant.js"));
  7. var _nodejsCustomInspectSymbol = _interopRequireDefault(require("./nodejsCustomInspectSymbol.js"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. /**
  10. * The `defineInspect()` function defines `inspect()` prototype method as alias of `toJSON`
  11. */
  12. function defineInspect(classObject) {
  13. var fn = classObject.prototype.toJSON;
  14. typeof fn === 'function' || (0, _invariant.default)(0);
  15. classObject.prototype.inspect = fn; // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317')
  16. if (_nodejsCustomInspectSymbol.default) {
  17. classObject.prototype[_nodejsCustomInspectSymbol.default] = fn;
  18. }
  19. }