inital upload
This commit is contained in:
51
node_modules/ts-invariant/lib/invariant.js
generated
vendored
Normal file
51
node_modules/ts-invariant/lib/invariant.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
import { __extends } from "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) {
|
||||
__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));
|
||||
export { InvariantError };
|
||||
export 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 = {}));
|
||||
export function setVerbosity(level) {
|
||||
var old = verbosityLevels[verbosityLevel];
|
||||
verbosityLevel = Math.max(0, verbosityLevels.indexOf(level));
|
||||
return old;
|
||||
}
|
||||
export default invariant;
|
||||
//# sourceMappingURL=invariant.js.map
|
||||
Reference in New Issue
Block a user