@10xly/is-instance-of
v1.0.0
Published
Check if something's an instance of something.
Readme
@10xly/is-instance-of
check if somethings an instance of something else. p]
Instawation
npm install @10xly/is-instance-ofUsage
const isInstanceOf = require("@10xly/is-instance-of")
class Animal {}
class Dog extends Animal {}
const pet = new Dog()
// Check by Constructor
isInstanceOf(pet, Dog) // true
isInstanceOf(pet, Animal) // true
// Check by Name (String)
isInstanceOf(pet, "Dog") // true
// Multiple options
isInstanceOf(pet, ["Cat", "Dog"]) // trueWhy you might use this seriously
This is a version of is-instance-of by lamansky that resolves a vulnerability in lodash.set. However, it is a little overengineered, but this actually has a practical purpose. see the readme of is-instance-of for more info
