Skip to content

Commit 99cfd90

Browse files
author
Bryan Brophy
committed
Move boolean array definitions outside of function
1 parent ba00c97 commit 99cfd90

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/lib/isBoolean.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import assertString from './util/assertString';
22

33
const defaultOptions = { loose: false };
4+
const strictBooleans = ['true', 'false', '1', '0'];
5+
const looseBooleans = [...strictBooleans, 'yes', 'no'];
46

57
export default function isBoolean(str, options = defaultOptions) {
68
assertString(str);
79

8-
const strictBooleans = ['true', 'false', '1', '0'];
9-
const looseBooleans = [...strictBooleans, 'yes', 'no'];
10-
1110
if (options.loose) {
12-
return (looseBooleans.indexOf(str.toLowerCase()) >= 0);
11+
return looseBooleans.includes(str.toLowerCase());
1312
}
1413

15-
return (strictBooleans.indexOf(str) >= 0);
14+
return strictBooleans.includes(str);
1615
}

0 commit comments

Comments
 (0)