You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
2.1 KiB
61 lines
2.1 KiB
4 months ago
|
'use strict';
|
||
|
|
||
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||
|
|
||
|
var tslib = require('tslib');
|
||
|
|
||
|
var genericMessage = "Invariant Violation";
|
||
|
var _a = Object.setPrototypeOf, setPrototypeOf = _a === void 0 ? function (obj, proto) {
|
||
|
obj.__proto__ = proto;
|
||
|
return obj;
|
||
|
} : _a;
|
||
|
var InvariantError = /** @class */ (function (_super) {
|
||
|
tslib.__extends(InvariantError, _super);
|
||
|
function InvariantError(message) {
|
||
|
if (message === void 0) { message = genericMessage; }
|
||
|
var _this = _super.call(this, typeof message === "number"
|
||
|
? genericMessage + ": " + message + " (see https://github.com/apollographql/invariant-packages)"
|
||
|
: message) || this;
|
||
|
_this.framesToPop = 1;
|
||
|
_this.name = genericMessage;
|
||
|
setPrototypeOf(_this, InvariantError.prototype);
|
||
|
return _this;
|
||
|
}
|
||
|
return InvariantError;
|
||
|
}(Error));
|
||
|
function invariant(condition, message) {
|
||
|
if (!condition) {
|
||
|
throw new InvariantError(message);
|
||
|
}
|
||
|
}
|
||
|
var verbosityLevels = ["debug", "log", "warn", "error", "silent"];
|
||
|
var verbosityLevel = verbosityLevels.indexOf("log");
|
||
|
function wrapConsoleMethod(name) {
|
||
|
return function () {
|
||
|
if (verbosityLevels.indexOf(name) >= verbosityLevel) {
|
||
|
// Default to console.log if this host environment happens not to provide
|
||
|
// all the console.* methods we need.
|
||
|
var method = console[name] || console.log;
|
||
|
return method.apply(console, arguments);
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
(function (invariant) {
|
||
|
invariant.debug = wrapConsoleMethod("debug");
|
||
|
invariant.log = wrapConsoleMethod("log");
|
||
|
invariant.warn = wrapConsoleMethod("warn");
|
||
|
invariant.error = wrapConsoleMethod("error");
|
||
|
})(invariant || (invariant = {}));
|
||
|
function setVerbosity(level) {
|
||
|
var old = verbosityLevels[verbosityLevel];
|
||
|
verbosityLevel = Math.max(0, verbosityLevels.indexOf(level));
|
||
|
return old;
|
||
|
}
|
||
|
var invariant$1 = invariant;
|
||
|
|
||
|
exports.InvariantError = InvariantError;
|
||
|
exports["default"] = invariant$1;
|
||
|
exports.invariant = invariant;
|
||
|
exports.setVerbosity = setVerbosity;
|
||
|
//# sourceMappingURL=invariant.cjs.map
|