Skip to content

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

@TuckerWhitehouse

Description

@TuckerWhitehouse

The knex library uses isEmpty(transaction) where transaction is a function with methods attached to it.
https://github.com/knex/knex/blob/master/lib/builder-interface-augmenter.js#L80

In es-toolkit, isEmpty returns true because typeof transaction === 'object' returns false, so it skips checking object properties, whereas lodash always iterates properties.
https://github.com/lodash/lodash/blob/main/lodash.js#L11590-L11612

For parity, it seems es-toolkit would need to move the Object.keys check outside of the typeof check.
https://github.com/toss/es-toolkit/blob/main/src/compat/predicate/isEmpty.ts#L77

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions