| Current Path : /home/emeraadmin/public_html/4d695/ |
| Current File : /home/emeraadmin/public_html/4d695/invariant.tar |
src/index.ts 0000644 00000002224 15170141634 0007014 0 ustar 00 /**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/
export function invariant(condition: any, format: string, ...args: any[]) {
if (process.env.NODE_ENV !== 'production') {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
}
if (!condition) {
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.'
);
} else {
let argIndex = 0;
error = new Error(
format.replace(/%s/g, function() {
return args[argIndex++];
})
);
error.name = 'Invariant Violation';
}
(error as any).framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
}
package.json 0000644 00000003727 15170141634 0007045 0 ustar 00 {
"_from": "@react-dnd/invariant@^2.0.0",
"_id": "@react-dnd/invariant@2.0.0",
"_inBundle": false,
"_integrity": "sha512-xL4RCQBCBDJ+GRwKTFhGUW8GXa4yoDfJrPbLblc3U09ciS+9ZJXJ3Qrcs/x2IODOdIE5kQxvMmE2UKyqUictUw==",
"_location": "/@react-dnd/invariant",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "@react-dnd/invariant@^2.0.0",
"name": "@react-dnd/invariant",
"escapedName": "@react-dnd%2finvariant",
"scope": "@react-dnd",
"rawSpec": "^2.0.0",
"saveSpec": null,
"fetchSpec": "^2.0.0"
},
"_requiredBy": [
"/dnd-core"
],
"_resolved": "https://registry.npmjs.org/@react-dnd/invariant/-/invariant-2.0.0.tgz",
"_shasum": "09d2e81cd39e0e767d7da62df9325860f24e517e",
"_spec": "@react-dnd/invariant@^2.0.0",
"_where": "C:\\xampp\\htdocs\\emeraltd\\node_modules\\dnd-core",
"author": {
"name": "Andres Suarez",
"email": "zertosh@gmail.com"
},
"bugs": {
"url": "https://github.com/react-dnd/invariant/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "invariantx",
"devDependencies": {
"@types/jest": "^24.0.23",
"husky": "^3.1.0",
"tsdx": "^0.11.0",
"tslib": "^1.10.0",
"typescript": "^3.7.2"
},
"homepage": "https://github.com/react-dnd/invariant#readme",
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
}
},
"keywords": [
"test",
"invariant"
],
"license": "MIT",
"main": "dist/index.js",
"module": "dist/invariant.esm.js",
"name": "@react-dnd/invariant",
"peerDependencies": {},
"prettier": {
"printWidth": 80,
"semi": true,
"singleQuote": true,
"trailingComma": "es5"
},
"private": false,
"repository": {
"type": "git",
"url": "git+https://github.com/react-dnd/invariant.git"
},
"scripts": {
"build": "tsdx build",
"lint": "tsdx lint",
"start": "tsdx watch",
"test": "tsdx test"
},
"typings": "dist/index.d.ts",
"version": "2.0.0"
}
test/production.spec.ts 0000644 00000001406 15170141634 0011215 0 ustar 00 import invariant from '../src';
describe('production mode', () => {
const OLD_ENV = process.env;
beforeEach(() => {
jest.resetModules(); // this is important - it clears the cache
process.env = { ...OLD_ENV };
delete process.env.NODE_ENV;
});
afterEach(() => {
process.env = OLD_ENV;
});
it('works', () => {
process.env.NODE_ENV = 'production';
expect(function() {
invariant(true, 'invariant message');
}).not.toThrow();
expect(function() {
invariant(false, 'invariant message');
}).toThrow(/invariant message/);
expect(function() {
(invariant as any)(true);
}).not.toThrow();
expect(function() {
(invariant as any)(false);
}).toThrow(/minified exception occurred/i);
});
});
test/development.spec.ts 0000644 00000001416 15170141634 0011352 0 ustar 00 import invariant from '../src';
describe('development mode', () => {
const OLD_ENV = process.env;
beforeEach(() => {
jest.resetModules(); // this is important - it clears the cache
process.env = { ...OLD_ENV };
delete process.env.NODE_ENV;
});
afterEach(() => {
process.env = OLD_ENV;
});
it('works', () => {
process.env.NODE_ENV = 'development';
expect(function() {
invariant(true, 'invariant message');
}).not.toThrow();
expect(function() {
invariant(false, 'invariant message');
}).toThrow(/invariant message/);
expect(function() {
(invariant as any)(true);
}).toThrow(/requires an error/i);
expect(function() {
(invariant as any)(false);
}).toThrow(/requires an error/i);
});
});
LICENSE 0000644 00000002070 15170141634 0005552 0 ustar 00 MIT License
Copyright (c) 2013-present, Facebook, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
dist/invariant.esm.js 0000644 00000002440 15170141634 0010625 0 ustar 00 /**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/
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') {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
}
if (!condition) {
var 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.');
} else {
var argIndex = 0;
error = new Error(format.replace(/%s/g, function () {
return args[argIndex++];
}));
error.name = 'Invariant Violation';
}
error.framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
}
export { invariant };
//# sourceMappingURL=invariant.esm.js.map
dist/invariant.esm.js.map 0000644 00000003677 15170141634 0011416 0 ustar 00 {"version":3,"file":"invariant.esm.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Use invariant() to assert state which your program assumes to be true.\n *\n * Provide sprintf-style format (only %s is supported) and arguments\n * to provide information about what broke and what you were\n * expecting.\n *\n * The invariant message will be stripped in production, but the invariant\n * will remain to ensure logic does not differ in production.\n */\n\nexport function invariant(condition: any, format: string, ...args: any[]) {\n if (process.env.NODE_ENV !== 'production') {\n if (format === undefined) {\n throw new Error('invariant requires an error message argument');\n }\n }\n\n if (!condition) {\n let error;\n if (format === undefined) {\n error = new Error(\n 'Minified exception occurred; use the non-minified dev environment ' +\n 'for the full error message and additional helpful warnings.'\n );\n } else {\n let argIndex = 0;\n error = new Error(\n format.replace(/%s/g, function() {\n return args[argIndex++];\n })\n );\n error.name = 'Invariant Violation';\n }\n\n (error as any).framesToPop = 1; // we don't care about invariant's own frame\n throw error;\n }\n}\n"],"names":["invariant","condition","format","args","process","env","NODE_ENV","undefined","Error","error","argIndex","replace","name","framesToPop"],"mappings":"AAAA;;;;;;;;;;AAWA,SAAgBA,UAAUC,WAAgBC;oCAAmBC;IAAAA;;;MACvDC,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;QACrCJ,MAAM,KAAKK,SAAf,EAA0B;YAClB,IAAIC,KAAJ,CAAU,8CAAV,CAAN;;;;MAIA,CAACP,SAAL,EAAgB;QACVQ,KAAJ;;QACIP,MAAM,KAAKK,SAAf,EAA0B;MACxBE,KAAK,GAAG,IAAID,KAAJ,CACN,uEACE,6DAFI,CAAR;KADF,MAKO;UACDE,QAAQ,GAAG,CAAf;MACAD,KAAK,GAAG,IAAID,KAAJ,CACNN,MAAM,CAACS,OAAP,CAAe,KAAf,EAAsB;eACbR,IAAI,CAACO,QAAQ,EAAT,CAAX;OADF,CADM,CAAR;MAKAD,KAAK,CAACG,IAAN,GAAa,qBAAb;;;IAGDH,KAAa,CAACI,WAAd,GAA4B,CAA5B,CAjBa;;UAkBRJ,KAAN;;;;;;"} dist/invariant.cjs.production.min.js.map 0000644 00000003132 15170141634 0014342 0 ustar 00 {"version":3,"file":"invariant.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Use invariant() to assert state which your program assumes to be true.\n *\n * Provide sprintf-style format (only %s is supported) and arguments\n * to provide information about what broke and what you were\n * expecting.\n *\n * The invariant message will be stripped in production, but the invariant\n * will remain to ensure logic does not differ in production.\n */\n\nexport function invariant(condition: any, format: string, ...args: any[]) {\n if (process.env.NODE_ENV !== 'production') {\n if (format === undefined) {\n throw new Error('invariant requires an error message argument');\n }\n }\n\n if (!condition) {\n let error;\n if (format === undefined) {\n error = new Error(\n 'Minified exception occurred; use the non-minified dev environment ' +\n 'for the full error message and additional helpful warnings.'\n );\n } else {\n let argIndex = 0;\n error = new Error(\n format.replace(/%s/g, function() {\n return args[argIndex++];\n })\n );\n error.name = 'Invariant Violation';\n }\n\n (error as any).framesToPop = 1; // we don't care about invariant's own frame\n throw error;\n }\n}\n"],"names":["condition","format","args","error","undefined","Error","argIndex","replace","name","framesToPop"],"mappings":"wCAW0BA,EAAgBC,8BAAmBC,mCAAAA,wBAOtDF,EAAW,KACVG,UACWC,IAAXH,EACFE,EAAQ,IAAIE,MACV,qIAGG,KACDC,EAAW,GACfH,EAAQ,IAAIE,MACVJ,EAAOM,QAAQ,OAAO,kBACbL,EAAKI,UAGVE,KAAO,4BAGdL,EAAcM,YAAc,EACvBN"} dist/invariant.cjs.production.min.js 0000644 00000000737 15170141634 0013576 0 ustar 00 "use strict";exports.invariant=function(r,e){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];if(!r){var a;if(void 0===e)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(e.replace(/%s/g,(function(){return i[t++]})))).name="Invariant Violation"}throw a.framesToPop=1,a}};
//# sourceMappingURL=invariant.cjs.production.min.js.map
dist/test/production.spec.d.ts 0000644 00000000014 15170141634 0012374 0 ustar 00 export {};
dist/test/development.spec.d.ts 0000644 00000000014 15170141634 0012530 0 ustar 00 export {};
dist/index.js 0000644 00000000304 15170141634 0007153 0 ustar 00
'use strict'
if (process.env.NODE_ENV === 'production') {
module.exports = require('./invariant.cjs.production.min.js')
} else {
module.exports = require('./invariant.cjs.development.js')
}
dist/invariant.cjs.development.js.map 0000644 00000003604 15170141634 0013720 0 ustar 00 {"version":3,"file":"invariant.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * Use invariant() to assert state which your program assumes to be true.\n *\n * Provide sprintf-style format (only %s is supported) and arguments\n * to provide information about what broke and what you were\n * expecting.\n *\n * The invariant message will be stripped in production, but the invariant\n * will remain to ensure logic does not differ in production.\n */\n\nexport function invariant(condition: any, format: string, ...args: any[]) {\n if (process.env.NODE_ENV !== 'production') {\n if (format === undefined) {\n throw new Error('invariant requires an error message argument');\n }\n }\n\n if (!condition) {\n let error;\n if (format === undefined) {\n error = new Error(\n 'Minified exception occurred; use the non-minified dev environment ' +\n 'for the full error message and additional helpful warnings.'\n );\n } else {\n let argIndex = 0;\n error = new Error(\n format.replace(/%s/g, function() {\n return args[argIndex++];\n })\n );\n error.name = 'Invariant Violation';\n }\n\n (error as any).framesToPop = 1; // we don't care about invariant's own frame\n throw error;\n }\n}\n"],"names":["invariant","condition","format","args","undefined","Error","error","argIndex","replace","name","framesToPop"],"mappings":";;AAAA;;;;;;;;;;AAWA,SAAgBA,UAAUC,WAAgBC;oCAAmBC;IAAAA;;;EAChB;QACrCD,MAAM,KAAKE,SAAf,EAA0B;YAClB,IAAIC,KAAJ,CAAU,8CAAV,CAAN;;;;MAIA,CAACJ,SAAL,EAAgB;QACVK,KAAJ;;QACIJ,MAAM,KAAKE,SAAf,EAA0B;MACxBE,KAAK,GAAG,IAAID,KAAJ,CACN,uEACE,6DAFI,CAAR;KADF,MAKO;UACDE,QAAQ,GAAG,CAAf;MACAD,KAAK,GAAG,IAAID,KAAJ,CACNH,MAAM,CAACM,OAAP,CAAe,KAAf,EAAsB;eACbL,IAAI,CAACI,QAAQ,EAAT,CAAX;OADF,CADM,CAAR;MAKAD,KAAK,CAACG,IAAN,GAAa,qBAAb;;;IAGDH,KAAa,CAACI,WAAd,GAA4B,CAA5B,CAjBa;;UAkBRJ,KAAN;;;;;;"} dist/index.d.ts 0000644 00000000725 15170141634 0007416 0 ustar 00 /**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/
export declare function invariant(condition: any, format: string, ...args: any[]): void;
dist/invariant.cjs.development.js 0000644 00000002431 15170141634 0013141 0 ustar 00 'use strict';
/**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/
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 (format === undefined) {
throw new Error('invariant requires an error message argument');
}
}
if (!condition) {
var 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.');
} else {
var argIndex = 0;
error = new Error(format.replace(/%s/g, function () {
return args[argIndex++];
}));
error.name = 'Invariant Violation';
}
error.framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
}
exports.invariant = invariant;
//# sourceMappingURL=invariant.cjs.development.js.map
README.md 0000644 00000003351 15170141634 0006027 0 ustar 00 # invariant
[](https://actions-badge.atrox.dev/react-dnd/invariant/goto)
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)).
A way to provide descriptive errors in development but generic errors in production.
## Note: This has been forked by react-dnd for ESM and TypeScript support
## Install
With [npm](http://npmjs.org) do:
```sh
npm install invariant
```
## `invariant(condition, message)`
```js
var invariant = require('invariant');
invariant(someTruthyVal, 'This will not throw');
// No errors
invariant(someFalseyVal, 'This will throw an error with this message');
// Error: Invariant Violation: This will throw an error with this message
```
**Note:** When `process.env.NODE_ENV` is not `production`, the message is required. If omitted, `invariant` will throw regardless of the truthiness of the condition. When `process.env.NODE_ENV` is `production`, the message is optional – so they can be minified away.
### Browser
When used with [browserify](https://github.com/substack/node-browserify), it'll use `browser.js` (instead of `invariant.js`) and the [envify](https://github.com/hughsk/envify) transform will inline the value of `process.env.NODE_ENV`.
### Node
The node version is optimized around the performance implications of accessing `process.env`. The value of `process.env.NODE_ENV` is cached, and repeatedly used instead of reading `process.env`. See [Server rendering is slower with npm react #812](https://github.com/facebook/react/issues/812)
tsconfig.json 0000644 00000001344 15170141634 0007257 0 ustar 00 {
"include": ["src", "types", "test"],
"compilerOptions": {
"target": "es5",
"module": "esnext",
"lib": ["dom", "esnext"],
"importHelpers": true,
"declaration": true,
"sourceMap": true,
"rootDir": "./",
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"baseUrl": "./",
"paths": {
"*": ["src/*", "node_modules/*"]
},
"jsx": "react",
"esModuleInterop": true
}
}
CHANGELOG.md 0000644 00000002413 15170141634 0006357 0 ustar 00 2.2.4 / 2018-03-13
==================
* Use flow strict mode (i.e. `@flow strict`).
2.2.3 / 2018-02-19
==================
* Change license from BSD+Patents to MIT.
2.2.2 / 2016-11-15
==================
* Add LICENSE file.
* Misc housekeeping.
2.2.1 / 2016-03-09
==================
* Use `NODE_ENV` variable instead of `__DEV__` to cache `process.env.NODE_ENV`.
2.2.0 / 2015-11-17
==================
* Use `error.name` instead of `Invariant Violation`.
2.1.3 / 2015-11-17
==================
* Remove `@provideModule` pragma.
2.1.2 / 2015-10-27
==================
* Fix license.
2.1.1 / 2015-09-20
==================
* Use correct SPDX license.
* Test "browser.js" using browserify.
* Switch from "envify" to "loose-envify".
2.1.0 / 2015-06-03
==================
* Add "envify" as a dependency.
* Fixed license field in "package.json".
2.0.0 / 2015-02-21
==================
* Switch to using the "browser" field. There are now browser and server versions that respect the "format" in production.
1.0.2 / 2014-09-24
==================
* Added tests, npmignore and gitignore.
* Clarifications in README.
1.0.1 / 2014-09-24
==================
* Actually include 'invariant.js'.
1.0.0 / 2014-09-24
==================
* Initial release.
.github/workflows/nodejs.yml 0000644 00000000743 15170141634 0012154 0 ustar 00 name: Node CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [8.x, 10.x, 12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
yarn install
yarn build
yarn test
env:
CI: true