UNPKG

graphql

Version:

A Query Language and Runtime which can target any service.

49 lines (40 loc) 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = inspect; function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } /** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * strict */ /** * Used to print values in error messages. */ function inspect(value) { switch (_typeof(value)) { case 'string': return JSON.stringify(value); case 'function': return value.name ? "[function ".concat(value.name, "]") : '[function]'; case 'object': if (value) { if (typeof value.inspect === 'function') { return value.inspect(); } else if (Array.isArray(value)) { return '[' + value.map(inspect).join(', ') + ']'; } var properties = Object.keys(value).map(function (k) { return "".concat(k, ": ").concat(inspect(value[k])); }).join(', '); return properties ? '{ ' + properties + ' }' : '{}'; } return String(value); default: return String(value); } }