ts-invariant
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -9,3 +9,4 @@ export declare class InvariantError extends Error { | ||
function warn(...args: any[]): void; | ||
function error(...args: any[]): void; | ||
} | ||
export default invariant; |
@@ -34,2 +34,10 @@ import { __extends } from 'tslib'; | ||
invariant.warn = warn; | ||
function error() { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
return console.error.apply(console, args); | ||
} | ||
invariant.error = error; | ||
})(invariant || (invariant = {})); | ||
@@ -36,0 +44,0 @@ var invariant$1 = invariant; |
@@ -38,2 +38,10 @@ 'use strict'; | ||
invariant.warn = warn; | ||
function error() { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
return console.error.apply(console, args); | ||
} | ||
invariant.error = error; | ||
})(invariant || (invariant = {})); | ||
@@ -40,0 +48,0 @@ var invariant$1 = invariant; |
@@ -84,2 +84,27 @@ "use strict"; | ||
}); | ||
it("invariant.error", function () { | ||
var argsReceived = []; | ||
var error = console.error; | ||
console.error = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
argsReceived.push(args); | ||
}; | ||
try { | ||
invariant_1.invariant.error("named", "export"); | ||
assert_1.default.deepEqual(argsReceived, [ | ||
["named", "export"], | ||
]); | ||
invariant_1.default.error("default", "export"); | ||
assert_1.default.deepEqual(argsReceived, [ | ||
["named", "export"], | ||
["default", "export"], | ||
]); | ||
} | ||
finally { | ||
console.error = error; | ||
} | ||
}); | ||
}); |
{ | ||
"name": "ts-invariant", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "Ben Newman <ben@apollographql.com>", | ||
@@ -40,3 +40,3 @@ "description": "TypeScript implementation of invariant(condition, message)", | ||
}, | ||
"gitHead": "20020a92c8a46e6d4839ec17baefa51a29b713d2" | ||
"gitHead": "9298ee0391e85354cfdf932bdb116c6dc9fe8445" | ||
} |
@@ -28,4 +28,8 @@ const genericMessage = "Invariant Violation"; | ||
} | ||
export function error(...args: any[]) { | ||
return console.error(...args); | ||
} | ||
} | ||
export default invariant; |
@@ -77,2 +77,23 @@ import assert from "assert"; | ||
}); | ||
it("invariant.error", function () { | ||
const argsReceived: any[][] = []; | ||
const { error } = console; | ||
console.error = (...args) => { | ||
argsReceived.push(args); | ||
}; | ||
try { | ||
invariant.error("named", "export"); | ||
assert.deepEqual(argsReceived, [ | ||
["named", "export"], | ||
]); | ||
defaultExport.error("default", "export"); | ||
assert.deepEqual(argsReceived, [ | ||
["named", "export"], | ||
["default", "export"], | ||
]); | ||
} finally { | ||
console.error = error; | ||
} | ||
}); | ||
}); |
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
13893
383