-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specified more types in generic utilities
- Loading branch information
1 parent
a491a2d
commit 4fce6bd
Showing
5 changed files
with
7 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Thanks 30 seconds of code... | ||
// https://github.com/30-seconds/30-seconds-of-code#flatten | ||
|
||
export default function flatten(arr: any[], depth = 1) { | ||
return arr.reduce((a: any[], v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []); | ||
export default function flatten(arr: unknown[], depth = 1) { | ||
return arr.reduce((a: unknown[], v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
const isEmptyObject = (obj: any) => obj && Object.keys(obj).length === 0; | ||
const isEmptyObject = (obj: object | undefined) => obj && Object.keys(obj).length === 0; | ||
|
||
export { isEmptyObject }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters