# is-subclass-of

> Returns true if A is a subclass of B.

Latest version **1.0.1** (published 2018-04-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-subclass-of
pnpm add is-subclass-of
yarn add is-subclass-of
bun add is-subclass-of
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-04-10 |
| First published | 2018-04-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 2 |
| Unpacked size | 3.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | John Lamansky |
| Maintainers | lamansky |
| Keywords | class, subclass |

## Links

- npm: https://www.npmjs.com/package/is-subclass-of
- Repository: https://github.com/lamansky/is-subclass-of
- Issues: https://github.com/lamansky/is-subclass-of/issues
- npm.io page: https://npm.io/package/is-subclass-of

## Dependencies (2)

- [sbo](https://npm.io/package/sbo.md) ^1.0.0
- [class-ancestors](https://npm.io/package/class-ancestors.md) ^1.0.0

## Recent versions

- 1.0.1 (latest) — 2018-04-10

## README

# is-subclass-of

Returns true if A is a subclass of B.

## Installation

Requires [Node.js](https://nodejs.org/) 6.0.0 or above.

```bash
npm i is-subclass-of
```

## API

The module exports a single function.

### Parameters

1. Bindable: `A` (function): What may or may not be a subclass of B.
2. `B` (function or string): What may or may not be an ancestor of A. You can either provide the class itself or its string name.

### Return Value

* Returns `true` if `A` is a subclass of `B`.
* Otherwise `false`.

## Example

```javascript
const isSubclassOf = require('is-subclass-of')

isSubclassOf(Date, Error) // false
isSubclassOf(Error, Error) // false

isSubclassOf(TypeError, Error) // true
isSubclassOf(RangeError, Error) // true
isSubclassOf(RangeError, 'Error') // true

class A {}
class B extends A {}
isSubclassOf(A, A) // false
isSubclassOf(B, A) // true
isSubclassOf(B, 'A') // true

// Supports the bind operator
TypeError::isSubclassOf(Error) // true
TypeError::isSubclassOf('Error') // true
B::isSubclassOf(A) // true
```

## Related

* [is-class-of](https://github.com/lamansky/is-class-of): Returns true if A is a subclass of B or the same class as B.
* [is-instance-of](https://github.com/lamansky/is-instance-of): Like `instanceof`, but uses class name strings.

---
_Source: https://npm.io/package/is-subclass-of · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
