inspect-js / inspect-js/is-string
Slow on the try/catch case
- Dominant language
- JavaScript
- Stars
- 22
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
While profiling an application, I found `is-string` (and a few related libraries) pretty much topping the charts across the entire codebase:

It appears that the try/catch check in `tryStringObject` does not get optimized (due to being a try/catch, I assume) and this makes the type checks very slow, comparatively speaking. It's on a hot path for me due to being used in argument validation code.
The same problem manifests in `is-number-object` and `is-date-object` (and presumably others that happen to not be used in this particular project).
Perhaps this check could be replaced with a faster one in some way, or if not, only applied if the value hits a (faster) test that suggests this check should be applied?
Contributor guide
Assessment
This issue has not been assessed yet.