Skip to content

fix(compat/isEmpty): handle functions with own enumerable properties#1645

Open
D-Sketon wants to merge 2 commits intotoss:mainfrom
D-Sketon:fix/isEmpty
Open

fix(compat/isEmpty): handle functions with own enumerable properties#1645
D-Sketon wants to merge 2 commits intotoss:mainfrom
D-Sketon:fix/isEmpty

Conversation

@D-Sketon
Copy link
Copy Markdown
Contributor

fix #1638

Copilot AI review requested due to automatic review settings March 15, 2026 12:29
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
es-toolkit Ready Ready Preview, Comment Apr 18, 2026 9:26am

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes compat/predicate/isEmpty behavior to match lodash when the input is a function that has own enumerable properties (e.g., knex transactions), addressing issue #1638.

Changes:

  • Treat typeof value === 'function' similarly to objects so Object.keys is checked.
  • Add a regression test ensuring functions with attached enumerable properties are not considered empty.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/compat/predicate/isEmpty.ts Extends the “object” handling branch to include functions so enumerable properties are detected.
src/compat/predicate/isEmpty.spec.ts Adds a regression test for functions with attached enumerable properties.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

});

it('should return `false` for functions with own enumerable properties', () => {
function transaction() {}
@D-Sketon D-Sketon changed the title fix(isEmpty): handle functions with own enumerable properties fix(compat/isEmpty): handle functions with own enumerable properties Mar 15, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.97%. Comparing base (c8fec98) to head (e1cdc9b).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1645   +/-   ##
=======================================
  Coverage   99.97%   99.97%           
=======================================
  Files         497      497           
  Lines        4660     4660           
  Branches     1348     1348           
=======================================
  Hits         4659     4659           
  Misses          1        1           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

[isEmpty] Incompatible with lodash#isEmpty (different handling of functions with properties attached)

3 participants