Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-invariant

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-invariant - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

1

lib/invariant.d.ts

@@ -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;
}
});
});

4

package.json
{
"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;
}
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc