ts-invariant
Advanced tools
Comparing version 0.8.2 to 0.9.0
@@ -7,5 +7,10 @@ export declare class InvariantError extends Error { | ||
export declare function invariant(condition: any, message?: string | number): asserts condition; | ||
declare const verbosityLevels: readonly ["log", "warn", "error", "silent"]; | ||
declare type VerbosityLevel = (typeof verbosityLevels)[number]; | ||
declare const verbosityLevels: readonly ["debug", "log", "warn", "error", "silent"]; | ||
export declare type VerbosityLevel = (typeof verbosityLevels)[number]; | ||
export declare type ConsoleMethodName = Exclude<VerbosityLevel, "silent">; | ||
export declare namespace invariant { | ||
const debug: { | ||
(...data: any[]): void; | ||
(message?: any, ...optionalParams: any[]): void; | ||
}; | ||
const log: { | ||
@@ -12,0 +17,0 @@ (...data: any[]): void; |
@@ -27,8 +27,11 @@ import { __extends } from 'tslib'; | ||
} | ||
var verbosityLevels = ["log", "warn", "error", "silent"]; | ||
var verbosityLevels = ["debug", "log", "warn", "error", "silent"]; | ||
var verbosityLevel = verbosityLevels.indexOf("log"); | ||
function wrapConsoleMethod(method) { | ||
function wrapConsoleMethod(name) { | ||
return function () { | ||
if (verbosityLevels.indexOf(method) >= verbosityLevel) { | ||
return console[method].apply(console, arguments); | ||
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); | ||
} | ||
@@ -38,2 +41,3 @@ }; | ||
(function (invariant) { | ||
invariant.debug = wrapConsoleMethod("debug"); | ||
invariant.log = wrapConsoleMethod("log"); | ||
@@ -40,0 +44,0 @@ invariant.warn = wrapConsoleMethod("warn"); |
@@ -31,8 +31,11 @@ 'use strict'; | ||
} | ||
var verbosityLevels = ["log", "warn", "error", "silent"]; | ||
var verbosityLevels = ["debug", "log", "warn", "error", "silent"]; | ||
var verbosityLevel = verbosityLevels.indexOf("log"); | ||
function wrapConsoleMethod(method) { | ||
function wrapConsoleMethod(name) { | ||
return function () { | ||
if (verbosityLevels.indexOf(method) >= verbosityLevel) { | ||
return console[method].apply(console, arguments); | ||
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); | ||
} | ||
@@ -42,2 +45,3 @@ }; | ||
(function (invariant) { | ||
invariant.debug = wrapConsoleMethod("debug"); | ||
invariant.log = wrapConsoleMethod("log"); | ||
@@ -44,0 +48,0 @@ invariant.warn = wrapConsoleMethod("warn"); |
{ | ||
"name": "ts-invariant", | ||
"version": "0.8.2", | ||
"version": "0.9.0", | ||
"author": "Ben Newman <ben@apollographql.com>", | ||
@@ -45,3 +45,3 @@ "description": "TypeScript implementation of invariant(condition, message)", | ||
}, | ||
"gitHead": "825772145ce8c1e6a29b81d8451fc984596cbab3" | ||
"gitHead": "31f1ac3f8463356c216f110465f937c8442bffea" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22464
16
292