@guanghechen/invariant 4.7.4 → 5.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/cjs/index.cjs +0 -1
- package/lib/esm/index.mjs +0 -1
- package/package.json +5 -5
- package/lib/cjs/index.cjs.map +0 -1
- package/lib/esm/index.mjs.map +0 -1
- package/src/index.ts +0 -27
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<header>
|
|
2
2
|
<h1 align="center">
|
|
3
|
-
<a href="https://github.com/guanghechen/node-scaffolds/tree/release-
|
|
3
|
+
<a href="https://github.com/guanghechen/node-scaffolds/tree/release-5.x.x/packages/invariant#readme">@guanghechen/invariant</a>
|
|
4
4
|
</h1>
|
|
5
5
|
<div align="center">
|
|
6
6
|
<a href="https://www.npmjs.com/package/@guanghechen/invariant">
|
|
@@ -84,5 +84,5 @@ and throw an error when the given condition fails.
|
|
|
84
84
|
|
|
85
85
|
## Related
|
|
86
86
|
|
|
87
|
-
[homepage]: https://github.com/guanghechen/node-scaffolds/tree/release-
|
|
87
|
+
[homepage]: https://github.com/guanghechen/node-scaffolds/tree/release-5.x.x/packages/invariant#readme
|
|
88
88
|
[tiny-invariant]: https://github.com/alexreardon/tiny-invariant
|
package/lib/cjs/index.cjs
CHANGED
package/lib/esm/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guanghechen/invariant",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-alpha.1",
|
|
4
4
|
"description": "Invariant function",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "guanghechen",
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/guanghechen/node-scaffolds/tree/release-
|
|
11
|
+
"url": "https://github.com/guanghechen/node-scaffolds/tree/release-5.x.x",
|
|
12
12
|
"directory": "packages/invariant"
|
|
13
13
|
},
|
|
14
|
-
"homepage": "https://github.com/guanghechen/node-scaffolds/tree/release-
|
|
14
|
+
"homepage": "https://github.com/guanghechen/node-scaffolds/tree/release-5.x.x/packages/invariant#readme",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"main": "./lib/cjs/index.cjs",
|
|
17
17
|
"module": "./lib/esm/index.mjs",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"lib/",
|
|
30
|
-
"
|
|
30
|
+
"!lib/**/*.map",
|
|
31
31
|
"package.json",
|
|
32
32
|
"CHANGELOG.md",
|
|
33
33
|
"LICENSE",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"rimraf": "^4.4.1",
|
|
45
45
|
"rollup": "^3.20.2"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "45d61b7ac2bd92cd6fbbfb5c310bd6bbb95f49f8"
|
|
48
48
|
}
|
package/lib/cjs/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA,MAAM,YAAY,GAAY,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAA;AACnE,MAAM,MAAM,GAAG,kBAAkB,CAAA;AASjB,SAAA,SAAS,CACvB,SAAkB,EAClB,OAAwC,EAAA;AAExC,IAAA,IAAI,SAAS;QAAE,OAAM;AAIrB,IAAA,IAAI,YAAY;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAA;IAGzC,IAAI,OAAO,IAAI,IAAI;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAEnD,MAAM,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI,IAAI,OAAO,YAAY,QAAQ,GAAG,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAA;AACtF;;;;;"}
|
package/lib/esm/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAY,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAA;AACnE,MAAM,MAAM,GAAG,kBAAkB,CAAA;AASjB,SAAA,SAAS,CACvB,SAAkB,EAClB,OAAwC,EAAA;AAExC,IAAA,IAAI,SAAS;QAAE,OAAM;AAIrB,IAAA,IAAI,YAAY;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAA;IAGzC,IAAI,OAAO,IAAI,IAAI;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAEnD,MAAM,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI,IAAI,OAAO,YAAY,QAAQ,GAAG,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC,CAAA;AACtF;;;;"}
|
package/src/index.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const isProduction: boolean = process.env.NODE_ENV === 'production'
|
|
2
|
-
const prefix = 'Invariant failed'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Assert the condition is true
|
|
6
|
-
*
|
|
7
|
-
* @param condition
|
|
8
|
-
* @param message
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
export function invariant(
|
|
12
|
-
condition: boolean,
|
|
13
|
-
message?: (() => string) | string | null,
|
|
14
|
-
): asserts condition {
|
|
15
|
-
if (condition) return
|
|
16
|
-
|
|
17
|
-
// Strip out errors messages in production environment.
|
|
18
|
-
/* c8 ignore next */
|
|
19
|
-
if (isProduction) throw new Error(prefix)
|
|
20
|
-
|
|
21
|
-
// Throw an error when the condition fails.
|
|
22
|
-
if (message == null) throw new Error(prefix + ': ')
|
|
23
|
-
|
|
24
|
-
throw new Error(prefix + ': ' + (message instanceof Function ? message() : message))
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default invariant
|