Skip to content

Commit

Permalink
Move boolean array definitions outside of function
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Brophy committed May 25, 2021
1 parent ba00c97 commit 99cfd90
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/lib/isBoolean.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import assertString from './util/assertString';

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

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

const strictBooleans = ['true', 'false', '1', '0'];
const looseBooleans = [...strictBooleans, 'yes', 'no'];

if (options.loose) {
return (looseBooleans.indexOf(str.toLowerCase()) >= 0);
return looseBooleans.includes(str.toLowerCase());
}

return (strictBooleans.indexOf(str) >= 0);
return strictBooleans.includes(str);
}

0 comments on commit 99cfd90

Please sign in to comment.