Skip to content

Commit

Permalink
simply function and add type for parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
koddsson committed Jan 6, 2024
1 parent 8e2bb74 commit 17dc89d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions src/function.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { truncate } from './helpers.js'
import type { Options } from './types.js'

export default function inspectFunction(func: Function, options: Options) {
let functionType = 'Function'
// @ts-ignore
const stringTag = func[Symbol.toStringTag];
if (typeof stringTag === 'string') {
functionType = stringTag;
}
type ToStringable = Function & {[Symbol.toStringTag]: string};

export default function inspectFunction(func: ToStringable, options: Options) {
const functionType = func[Symbol.toStringTag] || 'Function'

const name = func.name
if (!name) {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export function inspect(value: unknown, opts: Partial<Options> = {}): string {
if (type === 'object') {
type = toString.call(value).slice(8, -1)
}

// If it is a base value that we already support, then use Loupe's inspector
if (type in baseTypesMap) {
return (baseTypesMap[type as keyof typeof baseTypesMap] as Inspect)(value, options)
Expand Down

0 comments on commit 17dc89d

Please sign in to comment.