UNPKG
@uxland/functional
Version:
alpha (1.0.0-alpha.1)
latest (1.0.0-alpha.3)
1.0.0-alpha.3
1.0.0-alpha.2
1.0.0-alpha.1
1.0.0-alpha.0
Functional
github.com/uxland/uxland/tree/master/packages/functional
uxland/uxland
@uxland/functional
/
src
/
invariant.ts
7 lines
(6 loc)
•
254 B
text/typescript
View Raw
1
2
3
4
5
6
7
export
type
ConditionFactory
=
() =>
any
;
export
const
invariant
= (
condition
:
any
|
ConditionFactory
,
message
?:
string
) =>{ condition =
typeof
condition ===
'function'
?
condition
() : condition;
if
(!condition)
throw
new
Error
(message); };