UNPKG
@kitmi/utils
Version:
latest (1.3.1)
1.3.1
1.3.0
1.2.3
1.2.2
1.2.1
1.2.0
1.1.3
1.1.2
1.1.1
1.1.0
1.0.0
A JavaScript utility library for both server and browser
github.com/kitmi/jacaranda
kitmi/jacaranda
@kitmi/utils
/
src
/
toBoolean.js
16 lines
(11 loc)
•
274 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function
toBoolean
(
any
) {
const
type
=
typeof
any
;
if
(
type
===
'boolean'
) {
return
any
; }
if
(
type
===
'number'
) {
return
any
===
1
; }
return
type
===
'string'
&& (
any
===
'1'
||
/^true$/i
.
test
(
any
)); }
export
default
toBoolean;