mesqueeb / is-what

JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.
https://mesqueeb.github.io/is-what/
MIT License
170 stars 18 forks source link

Add isCallable() and isConstructable() #52

Open jcbhmr opened 1 year ago

jcbhmr commented 1 year ago

https://github.com/caitp/TC39-Proposals/blob/trunk/tc39-reflect-isconstructor-iscallable.md

☝ Basically that.

Use case:

if (isConstructable(thing)) {
  return new thing()
} else if (isCallable(thing)) {
  return thing()
} else {
  return thing
}
mesqueeb commented 1 year ago

Seems good to me! PR welcome