Skip to content

Commit

Permalink
Merge pull request #55 from jeremybalog/deprecate-falsey
Browse files Browse the repository at this point in the history
Deprecate Falsey
  • Loading branch information
jaredwray authored Jul 5, 2024
2 parents de9a918 + 51138fa commit cd81b31
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
43 changes: 42 additions & 1 deletion lib/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,48 @@ require('kind-of', 'typeOf');
// matching utils
require('is-glob');
require('micromatch', 'mm');
require('falsey');
utils.falsey = function falsey(val, keywords) {
if (!val) {
return true;
}

let words = keywords || [
"0",
"false",
"nada",
"nil",
"nay",
"nah",
"negative",
"no",
"none",
"nope",
"nul",
"null",
"nix",
"nyet",
"uh-uh",
"veto",
"zero",
];

if (!Array.isArray(words)) {
words = [words];
}

const lower = typeof val === "string" ? val.toLowerCase() : null;

for (const word of words) {
if (word === val) {
return true;
}
if (word === lower) {
return true;
}
}

return false;
};

// Number utils
require('is-even');
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@
"define-property": "^2.0.2",
"ent": "^2.2.1",
"extend-shallow": "^3.0.2",
"falsey": "^1.0.0",
"for-in": "^1.0.2",
"for-own": "^1.0.0",
"fs-exists-sync": "^0.1.0",
Expand Down

0 comments on commit cd81b31

Please sign in to comment.