From 51138faf39ee026b79b8a69238c576becf9ed15c Mon Sep 17 00:00:00 2001 From: Jeremy Balog Date: Fri, 5 Jul 2024 19:57:48 +0000 Subject: [PATCH] Deprecate Falsey --- lib/utils/utils.js | 43 ++++++++++++++++++++++++++++++++++++++++++- package.json | 1 - 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/lib/utils/utils.js b/lib/utils/utils.js index 4f9eb18..7daa318 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -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'); diff --git a/package.json b/package.json index e4d5953..9623edd 100644 --- a/package.json +++ b/package.json @@ -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",