@react-dnd/invariant
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -11,2 +11,2 @@ /** | ||
*/ | ||
export default function invariant(condition: any, format: string, a?: any, b?: any, c?: any, d?: any, e?: any, f?: any): void; | ||
export default function invariant(condition: any, format: string, ...args: any[]): void; |
@@ -13,3 +13,7 @@ 'use strict'; | ||
*/ | ||
function invariant(condition, format, a, b, c, d, e, f) { | ||
function invariant(condition, format) { | ||
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
{ | ||
@@ -27,3 +31,2 @@ if (format === undefined) { | ||
} else { | ||
var args = [a, b, c, d, e, f]; | ||
var argIndex = 0; | ||
@@ -30,0 +33,0 @@ error = new Error(format.replace(/%s/g, function () { |
@@ -1,2 +0,2 @@ | ||
"use strict";exports.default=function(e,r,n,i,o,t,a,f){if(!e){var s;if(void 0===r)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var d=[n,i,o,t,a,f],l=0;(s=new Error(r.replace(/%s/g,(function(){return d[l++]})))).name="Invariant Violation"}throw s.framesToPop=1,s}}; | ||
"use strict";exports.default=function(e,r){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];if(!e){var a;if(void 0===r)a=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var t=0;(a=new Error(r.replace(/%s/g,(function(){return i[t++]})))).name="Invariant Violation"}throw a.framesToPop=1,a}}; | ||
//# sourceMappingURL=invariant.cjs.production.min.js.map |
@@ -11,3 +11,7 @@ /** | ||
*/ | ||
function invariant(condition, format, a, b, c, d, e, f) { | ||
function invariant(condition, format) { | ||
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
if (process.env.NODE_ENV !== 'production') { | ||
@@ -25,3 +29,2 @@ if (format === undefined) { | ||
} else { | ||
var args = [a, b, c, d, e, f]; | ||
var argIndex = 0; | ||
@@ -28,0 +31,0 @@ error = new Error(format.replace(/%s/g, function () { |
{ | ||
"name": "@react-dnd/invariant", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"private": false, | ||
@@ -14,10 +14,25 @@ "description": "invariantx", | ||
"scripts": { | ||
"start": "tsdx watch", | ||
"build": "tsdx build", | ||
"test": "tsdx test", | ||
"watch": "tsdx watch", | ||
"lint": "tsdx lint" | ||
}, | ||
"peerDependencies": {}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "tsdx lint" | ||
} | ||
}, | ||
"prettier": { | ||
"printWidth": 80, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^24.0.23", | ||
"tsdx": "^0.11.0" | ||
"husky": "^3.1.0", | ||
"tsdx": "^0.11.0", | ||
"tslib": "^1.10.0", | ||
"typescript": "^3.7.2" | ||
}, | ||
@@ -24,0 +39,0 @@ "main": "dist/index.js", |
# invariant | ||
[![Build Status](https://travis-ci.org/zertosh/invariant.svg?branch=master)](https://travis-ci.org/zertosh/invariant) | ||
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Freact-dnd%2Finvariant%2Fbadge&style=flat)](https://actions-badge.atrox.dev/react-dnd/invariant/goto) | ||
@@ -9,2 +9,4 @@ A mirror of Facebook's `invariant` (e.g. [React](https://github.com/facebook/react/blob/v0.13.3/src/vendor/core/invariant.js), [flux](https://github.com/facebook/flux/blob/2.0.2/src/invariant.js)). | ||
## Note: This has been forked by react-dnd for ESM and TypeScript support | ||
## Install | ||
@@ -11,0 +13,0 @@ |
@@ -12,3 +12,7 @@ /** | ||
export default function invariant(condition: any, format: string, a?: any, b?: any, c?: any, d?: any, e?: any, f?: any) { | ||
export default function invariant( | ||
condition: any, | ||
format: string, | ||
...args: any[] | ||
) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
@@ -21,13 +25,14 @@ if (format === undefined) { | ||
if (!condition) { | ||
var error; | ||
let error; | ||
if (format === undefined) { | ||
error = new Error( | ||
'Minified exception occurred; use the non-minified dev environment ' + | ||
'for the full error message and additional helpful warnings.' | ||
'for the full error message and additional helpful warnings.' | ||
); | ||
} else { | ||
var args = [a, b, c, d, e, f]; | ||
var argIndex = 0; | ||
let argIndex = 0; | ||
error = new Error( | ||
format.replace(/%s/g, function() { return args[argIndex++]; }) | ||
format.replace(/%s/g, function() { | ||
return args[argIndex++]; | ||
}) | ||
); | ||
@@ -37,5 +42,5 @@ error.name = 'Invariant Violation'; | ||
error.framesToPop = 1; // we don't care about invariant's own frame | ||
(error as any).framesToPop = 1; // we don't care about invariant's own frame | ||
throw error; | ||
} | ||
}; | ||
} |
@@ -1,8 +0,8 @@ | ||
import invariant from '../src' | ||
import invariant from '../src'; | ||
describe("development mode", () => { | ||
describe('development mode', () => { | ||
const OLD_ENV = process.env; | ||
beforeEach(() => { | ||
jest.resetModules() // this is important - it clears the cache | ||
jest.resetModules(); // this is important - it clears the cache | ||
process.env = { ...OLD_ENV }; | ||
@@ -16,12 +16,12 @@ delete process.env.NODE_ENV; | ||
it("works", () => { | ||
process.env.NODE_ENV = 'development' | ||
it('works', () => { | ||
process.env.NODE_ENV = 'development'; | ||
expect(function() { | ||
invariant(true, "invariant message"); | ||
invariant(true, 'invariant message'); | ||
}).not.toThrow(); | ||
expect(function() { | ||
invariant(false, "invariant message"); | ||
}).toThrow( /invariant message/); | ||
invariant(false, 'invariant message'); | ||
}).toThrow(/invariant message/); | ||
@@ -28,0 +28,0 @@ expect(function() { |
@@ -1,8 +0,8 @@ | ||
import invariant from '../src' | ||
import invariant from '../src'; | ||
describe("production mode", () => { | ||
describe('production mode', () => { | ||
const OLD_ENV = process.env; | ||
beforeEach(() => { | ||
jest.resetModules() // this is important - it clears the cache | ||
jest.resetModules(); // this is important - it clears the cache | ||
process.env = { ...OLD_ENV }; | ||
@@ -16,11 +16,11 @@ delete process.env.NODE_ENV; | ||
it("works", () => { | ||
process.env.NODE_ENV = 'production' | ||
it('works', () => { | ||
process.env.NODE_ENV = 'production'; | ||
expect(function() { | ||
invariant(true, "invariant message"); | ||
invariant(true, 'invariant message'); | ||
}).not.toThrow(); | ||
expect(function() { | ||
invariant(false, "invariant message"); | ||
invariant(false, 'invariant message'); | ||
}).toThrow(/invariant message/); | ||
@@ -27,0 +27,0 @@ |
Sorry, the diff of this file is not supported yet
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
18349
19
219
40
5