Skip to content

Commit 007c7a4

Browse files
committed
refactor(isPlainObject): use type predicate
refactor: the only use of isPlainObject to not explicitly set the type when it is inferred by predicate
1 parent be6fec1 commit 007c7a4

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

packages/bootstrap-vue-3/src/utils/inspect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ export const isNumeric = (value: unknown): boolean => /^[0-9]*\.?[0-9]+$/.test(S
1616
* @param obj
1717
* @returns
1818
*/
19-
export const isPlainObject = (obj: unknown): boolean =>
19+
export const isPlainObject = (obj: unknown): obj is Record<PropertyKey, unknown> =>
2020
Object.prototype.toString.call(obj) === '[object Object]'

packages/bootstrap-vue-3/src/utils/stringUtils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ export const toString = (val: unknown, spaces = 2): string =>
1818
? val
1919
: val === undefined || val === null
2020
? ''
21-
: Array.isArray(val) ||
22-
(isPlainObject(val) &&
23-
(val as Record<string, unknown>).toString === Object.prototype.toString)
21+
: Array.isArray(val) || (isPlainObject(val) && val.toString === Object.prototype.toString)
2422
? JSON.stringify(val, null, spaces)
2523
: String(val)
2624

0 commit comments

Comments
 (0)