Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/compat/predicate/isEmpty.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 1 addition & 1 deletion src/compat/predicate/isEmpty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading