Skip to content

Commit

Permalink
Adjust check for the function-like type
Browse files Browse the repository at this point in the history
  • Loading branch information
yurkimus committed Jul 28, 2024
1 parent 7c0baf0 commit a1b197f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@yurkimus/types",
"version": "0.2.8",
"version": "0.2.9",
"exports": "./source/index.js"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "module",
"name": "@yurkimus/types",
"version": "0.2.8",
"version": "0.2.9",
"exports": "./source/index.js"
}
9 changes: 2 additions & 7 deletions source/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export var is = (string, value) => type(value) == string
export var isLike = (string, value) => {
switch (string) {
case 'Promise':
return value && 'then' in value && isLike('Function', value.then)
return value && 'then' in value && typeof value.then == 'function'

case 'Array':
return value && 'length' in value
Expand All @@ -80,12 +80,7 @@ export var isLike = (string, value) => {
return URL.canParse(value)

case 'Function':
return (
value &&
'call' in value &&
typeof value.call == 'function' &&
'length' in value
)
return typeof value == 'function'

default:
throw new TypeError(`Check for ${string} is not implemented`)
Expand Down

0 comments on commit a1b197f

Please sign in to comment.