Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 @@
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 All @@ -52,7 +59,7 @@
});

it('should work with jQuery/MooTools DOM query collections', () => {
function Foo(this: any, elements: any) {

Check warning on line 62 in src/compat/predicate/isEmpty.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 62 in src/compat/predicate/isEmpty.spec.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
Array.prototype.push.apply(this, elements);
}
Foo.prototype = { length: 0, splice: Array.prototype.splice };
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 @@ -6,16 +6,16 @@

declare let Buffer:
| {
isBuffer: (a: any) => boolean;

Check warning on line 9 in src/compat/predicate/isEmpty.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
}
| undefined;

export function isEmpty<T extends { __trapAny: any }>(value?: T): boolean;

Check warning on line 13 in src/compat/predicate/isEmpty.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
export function isEmpty(value: string): value is '';
export function isEmpty(value: Map<any, any> | Set<any> | ArrayLike<any> | null | undefined): boolean;

Check warning on line 15 in src/compat/predicate/isEmpty.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 15 in src/compat/predicate/isEmpty.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 15 in src/compat/predicate/isEmpty.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 15 in src/compat/predicate/isEmpty.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
export function isEmpty(value: object): boolean;
export function isEmpty<T extends object>(value: T | null | undefined): value is EmptyObjectOf<T> | null | undefined;
export function isEmpty(value?: any): boolean;

Check warning on line 18 in src/compat/predicate/isEmpty.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

/**
* Checks if a given value is empty.
Expand Down Expand Up @@ -51,7 +51,7 @@
// Objects like { "length": 0 } are not empty in lodash
if (isArrayLike(value)) {
if (
typeof (value as any).splice !== 'function' &&

Check warning on line 54 in src/compat/predicate/isEmpty.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
typeof value !== 'string' &&
(typeof Buffer === 'undefined' || !Buffer.isBuffer(value)) &&
!isTypedArray(value) &&
Expand All @@ -63,7 +63,7 @@
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