Skip to content

feat: add isTruthy, isFalsy, and isEmpty utils#76

Merged
teneplaysofficial merged 2 commits into
mainfrom
dev
Jan 16, 2026
Merged

feat: add isTruthy, isFalsy, and isEmpty utils#76
teneplaysofficial merged 2 commits into
mainfrom
dev

Conversation

@teneplaysofficial

@teneplaysofficial teneplaysofficial commented Jan 16, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added three validation utilities: isTruthy(), isFalsy(), and isEmpty() for consistent truthiness and emptiness checks across primitives, collections, and objects.
  • Tests

    • Added comprehensive test suites covering edge cases and varied input types for each new utility.
  • Chores

    • Prepared a minor version bump for the valid package.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot

changeset-bot Bot commented Jan 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 22dfb28

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@js-utils-kit/valid Minor
@js-utils-kit/core Patch
js-utils-kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jan 16, 2026

Copy link
Copy Markdown

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

Adds three new exported utilities to @js-utils-kit/validisTruthy, isFalsy, and isEmpty — with implementations, JSDoc, tests, and a changeset bumping the package version.

Changes

Cohort / File(s) Summary
Changeset
.changeset/fruity-feet-taste.md
Adds changeset documenting a minor version bump for @js-utils-kit/valid and the three new exports
Public exports
packages/valid/src/index.ts
Re-exports: isTruthy, isFalsy, isEmpty
Implementations
packages/valid/src/isTruthy.ts, packages/valid/src/isFalsy.ts, packages/valid/src/isEmpty.ts
New utility functions: isTruthy<T>(value): boolean, isFalsy<T>(value): boolean, isEmpty<T>(value): boolean (handles strings, arrays, objects, Map/Set, null/undefined)
Tests
packages/valid/test/isTruthy.test.ts, packages/valid/test/isFalsy.test.ts, packages/valid/test/isEmpty.test.ts
Adds Vitest suites covering falsy/truthy values, NaN behavior, collections, objects, and edge cases

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through code with careful peeks,
I found three helpers for truth and leaks.
isTruthy, isFalsy, isEmpty — hooray!
Tests bound them safe, set out to play.
sniffs the changeset and twitches whiskers

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add isTruthy, isFalsy, and isEmpty utils' accurately and specifically describes the main changes in the pull request, which add three new utility functions to the @js-utils-kit/valid package.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed49d8d and 22dfb28.

📒 Files selected for processing (6)
  • packages/valid/src/isEmpty.ts
  • packages/valid/src/isFalsy.ts
  • packages/valid/src/isTruthy.ts
  • packages/valid/test/isEmpty.test.ts
  • packages/valid/test/isFalsy.test.ts
  • packages/valid/test/isTruthy.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/valid/test/isFalsy.test.ts
  • packages/valid/src/isFalsy.ts
  • packages/valid/test/isEmpty.test.ts
🧰 Additional context used
🧬 Code graph analysis (1)
packages/valid/test/isTruthy.test.ts (1)
packages/valid/src/isTruthy.ts (1)
  • isTruthy (31-38)
🔇 Additional comments (3)
packages/valid/src/isEmpty.ts (1)

30-54: Clean and robust emptiness checks.

Covers null/undefined, strings, arrays, Map/Set, and plain objects in a predictable way.

packages/valid/src/isTruthy.ts (1)

31-37: Minimal, correct truthiness check.

Boolean(value) is the right, idiomatic implementation here.

packages/valid/test/isTruthy.test.ts (1)

4-55: Comprehensive test coverage.

Nice spread across falsy primitives (including 0n), NaN, and truthy exotic objects.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @teneplaysofficial, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the @js-utils-kit/valid package by introducing a set of new, robust utility functions designed to streamline common validation tasks. These additions provide developers with reliable methods to determine the truthiness, falsiness, or emptiness of different JavaScript values, improving code clarity and reducing potential bugs related to type coercion and value checks.

Highlights

  • New Utility Functions: Introduced three new utility functions: isTruthy, isFalsy, and isEmpty to the @js-utils-kit/valid package.
  • isTruthy Function: Added isTruthy which checks if a value is truthy, with explicit handling to correctly identify NaN as falsy.
  • isFalsy Function: Added isFalsy which checks if a value is falsy, including NaN in its definition of falsy values.
  • isEmpty Function: Added isEmpty which provides a comprehensive check for empty values across various data types, including null, undefined, empty strings (including whitespace), empty arrays, objects, Maps, and Sets.
  • Comprehensive Testing: Each new utility function comes with a dedicated suite of unit tests to ensure correctness and cover various edge cases.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces three new utility functions: isTruthy, isFalsy, and isEmpty, along with their corresponding tests. The implementations for isTruthy and isFalsy are functionally correct but can be simplified by removing redundant checks. The isEmpty function has a potential issue where it incorrectly identifies complex objects like Date as empty; I've suggested a more precise check for plain objects. The test suites are well-written, but I've recommended adding test cases for BigInt (0n) to improve coverage for isTruthy and isFalsy, and correcting the test for isEmpty with Date objects to reflect more intuitive behavior.

Comment thread packages/valid/src/isEmpty.ts Outdated
Comment thread packages/valid/test/isEmpty.test.ts Outdated
Comment thread packages/valid/src/isFalsy.ts Outdated
Comment thread packages/valid/src/isTruthy.ts Outdated
Comment thread packages/valid/test/isFalsy.test.ts
Comment thread packages/valid/test/isTruthy.test.ts
@codecov

codecov Bot commented Jan 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@teneplaysofficial teneplaysofficial merged commit 24d542d into main Jan 16, 2026
13 checks passed
@teneplaysofficial teneplaysofficial deleted the dev branch January 16, 2026 11:12
@github-actions github-actions Bot mentioned this pull request Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant