diff --git a/src/compat/predicate/isEmpty.spec.ts b/src/compat/predicate/isEmpty.spec.ts index bccc3448d..51b8086e9 100644 --- a/src/compat/predicate/isEmpty.spec.ts +++ b/src/compat/predicate/isEmpty.spec.ts @@ -33,6 +33,13 @@ describe('isEmpty', () => { expect(isEmpty('a')).toBe(false); }); + it('should return `false` for functions with own enumerable properties', () => { + function transaction() {} + transaction.commit = () => {}; + + expect(isEmpty(transaction)).toBe(false); + }); + it('should work with an object that has a `length` property', () => { expect(isEmpty({ length: 0 })).toBe(false); }); diff --git a/src/compat/predicate/isEmpty.ts b/src/compat/predicate/isEmpty.ts index 628c8c3c3..47c65a6be 100644 --- a/src/compat/predicate/isEmpty.ts +++ b/src/compat/predicate/isEmpty.ts @@ -63,7 +63,7 @@ export function isEmpty(value?: unknown): boolean { return value.length === 0; } - if (typeof value === 'object') { + if (typeof value === 'object' || typeof value === 'function') { if (value instanceof Map || value instanceof Set) { return value.size === 0; }