# typechecker

> Utilities to get and check variable types (isString, isPlainObject, isRegExp, etc)

Latest version **9.3.0** (published 2023-12-27) · Artistic-2.0 license · 0 weekly downloads

## Install

```sh
npm install typechecker
pnpm add typechecker
yarn add typechecker
bun add typechecker
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 9.3.0 |
| Published | 2023-12-27 |
| First published | 2013-03-27 |
| Weekly downloads | 0 |
| License | Artistic-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=4 |
| Dependencies | 1 |
| Unpacked size | 103.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 49 |
| Author | Benjamin Lupton |
| Maintainers | bevryme |
| Keywords | array, assert, assertion, async, async function, async-function, asyncFunction, bool, boolean, browser, check, check-type, checking, class, class-identifier, class-instance, compare, conventional class, conventional-class, conventionalClass, date, define-type, deno, deno-edition, deno-entry, denoland, empty, empty array, empty keys, empty map, empty plain object, empty-array, empty-keys, empty-map, empty-plain-object, emptyArray, emptyKeys, emptyMap, emptyPlainObject, error, es2022, es5, function, get object type, get type, get-object-type, get-type, getObjectType, getType, instanceof, is, is arguments, is array, is async, is async function, is bool, is boolean, is class, is conventional class, is date, is empty array, is empty keys, is empty map, is empty plain object, is empty weak map, is error, is function, is map, is native class, is null, is nullish, is number, is object, is plain object, is regexp, is string, is sync, is sync function, is undefined, is weak map, is-arguments, is-array, is-async, is-async-function, is-bool, is-boolean, is-class, is-conventional-class, is-date, is-empty-array, is-empty-keys, is-empty-map, is-empty-plain-object, is-empty-weak-map, is-error, is-function, is-map, is-native-class, is-null, is-nullish, is-number, is-object, is-plain-obj, is-plain-object, is-regexp, is-string, is-sync, is-sync-function, is-undefined, is-weak-map, isArguments, isArray, isAsyncFunction, isBool, isBoolean, isClass, isConventionalClass, isDate, isEmptyArray, isEmptyKeys, isEmptyMap, isEmptyPlainObject, isEmptyWeakMap, isError, isFunction, isMap, isNativeClass, isNull, isNullish, isNumber, isObject, isRegExp, isString, isSync, isSyncFunction, isUndefined, isWeakMap, javascript, javascript-type, keys, kind, map, module, native, native class, native-class, nativeClass, node, null, number, object, plain, plain object, plain objects, plain-object, plain-objects, plainObject, primitive, primitive-types, pure, regex, regexp, regular expression, simple, string, sync, syncFunction, test, type, type-check, type-checker, type-checking, typechecker, typed, typeguards, typeof, types, typescript, undefined, util, utility, validate, validation, vanilla, verify, weak map, weak-map, weakMap, what-type |

## Links

- npm: https://www.npmjs.com/package/typechecker
- Repository: https://github.com/bevry/typechecker
- Issues: https://github.com/bevry/typechecker/issues
- Funding: https://bevry.me/fund
- npm.io page: https://npm.io/package/typechecker

## Dependencies (1)

- [editions](https://npm.io/package/editions.md) ^6.20.0

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 9.3.0 (latest) — 2023-12-27
- 9.4.0-next.1703778254.acb9c34358ef897fb27cdc9a030bda131e6cab12 (next) — 2023-12-28
- 9.3.0-next.1703661934.019a3b2a8a58380adcb4e4f20e2577844d4303b8 — 2023-12-27
- 9.2.0 — 2023-12-05
- 9.2.0-next.1701791666.f2739c783e11bef5ea964fc3168dd3ea22dbc887 — 2023-12-05
- 9.1.0 — 2023-12-05
- 9.1.0-next.1701778342.3c54fdb00d29abd42b4eba755877d337057114dc — 2023-12-05
- 9.0.0-next.1700891286.6cec1fd7e7995369a77db32de2040bf81f9fd96a — 2023-11-25
- 9.0.0 — 2023-11-25
- 9.0.0-next.1700890914.3ea794d71d08da87fe1962ec8557106fb87d0027 — 2023-11-25
- 8.6.0 — 2023-11-24
- 8.6.0-next.1700864529.8124fd71a842d73944daad9f44000d1b69f9f9ab — 2023-11-24
- 8.5.0-next.1700541462.9f830ef7d36125aeda08349b457920cc136d8834 — 2023-11-21
- 8.5.0 — 2023-11-21
- 8.4.0 — 2023-11-21
- … 120 more at https://npm.io/package/typechecker/versions

## README

<!-- TITLE/ -->

# TypeChecker

<!-- /TITLE -->

<!-- BADGES/ -->

<span class="badge-githubworkflow"><a href="https://github.com/bevry/typechecker/actions?query=workflow%3Abevry" title="View the status of this project's GitHub Workflow: bevry"><img src="https://github.com/bevry/typechecker/workflows/bevry/badge.svg" alt="Status of the GitHub Workflow: bevry" /></a></span>
<span class="badge-npmversion"><a href="https://npmjs.org/package/typechecker" title="View this project on NPM"><img src="https://img.shields.io/npm/v/typechecker.svg" alt="NPM version" /></a></span>
<span class="badge-npmdownloads"><a href="https://npmjs.org/package/typechecker" title="View this project on NPM"><img src="https://img.shields.io/npm/dm/typechecker.svg" alt="NPM downloads" /></a></span>
<br class="badge-separator" />
<span class="badge-githubsponsors"><a href="https://github.com/sponsors/balupton" title="Donate to this project using GitHub Sponsors"><img src="https://img.shields.io/badge/github-donate-yellow.svg" alt="GitHub Sponsors donate button" /></a></span>
<span class="badge-thanksdev"><a href="https://thanks.dev/u/gh/bevry" title="Donate to this project using ThanksDev"><img src="https://img.shields.io/badge/thanksdev-donate-yellow.svg" alt="ThanksDev donate button" /></a></span>
<span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
<span class="badge-liberapay"><a href="https://liberapay.com/bevry" title="Donate to this project using Liberapay"><img src="https://img.shields.io/badge/liberapay-donate-yellow.svg" alt="Liberapay donate button" /></a></span>
<span class="badge-buymeacoffee"><a href="https://buymeacoffee.com/balupton" title="Donate to this project using Buy Me A Coffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg" alt="Buy Me A Coffee donate button" /></a></span>
<span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span>
<span class="badge-crypto"><a href="https://bevry.me/crypto" title="Donate to this project using Cryptocurrency"><img src="https://img.shields.io/badge/crypto-donate-yellow.svg" alt="crypto donate button" /></a></span>
<span class="badge-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span>
<br class="badge-separator" />
<span class="badge-discord"><a href="https://discord.gg/nQuXddV7VP" title="Join this project's community on Discord"><img src="https://img.shields.io/discord/1147436445783560193?logo=discord&amp;label=discord" alt="Discord server badge" /></a></span>
<span class="badge-twitch"><a href="https://www.twitch.tv/balupton" title="Join this project's community on Twitch"><img src="https://img.shields.io/twitch/status/balupton?logo=twitch" alt="Twitch community badge" /></a></span>

<!-- /BADGES -->

<!-- DESCRIPTION/ -->

Utilities to get and check variable types (isString, isPlainObject, isRegExp, etc)

<!-- /DESCRIPTION -->


## Why?

Why should I use this instead of say `instanceof`?

Under certain circumstances `instanceof` may not return the correct results. This occurs with [node's vm module](http://nodejs.org/api/vm.html#vm_globals) especially, and circumstances where an object's prototype has been dereferenced from the original. As such, for basic `==` and `===` checks (like `a === null`), you're fine not using this, but for checks when you would have done `instanceof` (like `err instanceof Error`), you should try to use this instead. Plus things like `isPlainObject` are darn useful!

## Usage

[Complete API Documentation.](http://master.typechecker.bevry.surge.sh/docs/)

<!-- INSTALL/ -->

## Install

### [npm](https://npmjs.com "npm is a package manager for javascript")

-   Install: `npm install --save typechecker`
-   Import: `import * as pkg from ('typechecker')`
-   Require: `const pkg = require('typechecker')`

### [Deno](https://deno.land "Deno is a secure runtime for JavaScript and TypeScript, it is an alternative for Node.js")

``` typescript
import * as pkg from 'https://unpkg.com/typechecker@^9.3.0/edition-deno/index.ts'
```
### [Skypack](https://www.skypack.dev "Skypack is a JavaScript Delivery Network for modern web apps")

``` html
<script type="module">
    import * as pkg from '//cdn.skypack.dev/typechecker@^9.3.0'
</script>
```
### [unpkg](https://unpkg.com "unpkg is a fast, global content delivery network for everything on npm")

``` html
<script type="module">
    import * as pkg from '//unpkg.com/typechecker@^9.3.0'
</script>
```
### [jspm](https://jspm.io "Native ES Modules CDN")

``` html
<script type="module">
    import * as pkg from '//dev.jspm.io/typechecker@9.3.0'
</script>
```
### [Editions](https://editions.bevry.me "Editions are the best way to produce and consume packages you care about.")

This package is published with the following editions:
-   `typechecker` aliases `typechecker/index.cjs` which uses the [Editions Autoloader](https://github.com/bevry/editions "You can use the Editions Autoloader to autoload the appropriate edition for your consumers environment") to automatically select the correct edition for the consumer's environment
-   `typechecker/source/index.ts` is [TypeScript](https://www.typescriptlang.org/ "TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.") source code with [Import](https://babeljs.io/docs/learn-es2015/#modules "ECMAScript Modules") for modules
-   `typechecker/edition-browsers/index.js` is [TypeScript](https://www.typescriptlang.org/ "TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.") compiled against [ES2022](https://en.wikipedia.org/wiki/ES2022 "ECMAScript 2022") for web browsers with [Import](https://babeljs.io/docs/learn-es2015/#modules "ECMAScript Modules") for modules
-   `typechecker/edition-es2022/index.js` is [TypeScript](https://www.typescriptlang.org/ "TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.") compiled against [ES2022](https://en.wikipedia.org/wiki/ES2022 "ECMAScript 2022") for [Node.js](https://nodejs.org "Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine") 6 || 8 || 10 || 12 || 14 || 16 || 18 || 20 || 21 with [Require](https://nodejs.org/dist/latest-v5.x/docs/api/modules.html "Node/CJS Modules") for modules
-   `typechecker/edition-es5/index.js` is [TypeScript](https://www.typescriptlang.org/ "TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.") compiled against ES5 for [Node.js](https://nodejs.org "Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine") 4 || 6 || 8 || 10 || 12 || 14 || 16 || 18 || 20 || 21 with [Require](https://nodejs.org/dist/latest-v5.x/docs/api/modules.html "Node/CJS Modules") for modules
-   `typechecker/edition-es2022-esm/index.js` is [TypeScript](https://www.typescriptlang.org/ "TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.") compiled against [ES2022](https://en.wikipedia.org/wiki/ES2022 "ECMAScript 2022") for [Node.js](https://nodejs.org "Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine") 12 || 14 || 16 || 18 || 20 || 21 with [Import](https://babeljs.io/docs/learn-es2015/#modules "ECMAScript Modules") for modules
-   `typechecker/edition-types/index.d.ts` is [TypeScript](https://www.typescriptlang.org/ "TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.") compiled Types with [Import](https://babeljs.io/docs/learn-es2015/#modules "ECMAScript Modules") for modules
-   `typechecker/edition-deno/index.ts` is [TypeScript](https://www.typescriptlang.org/ "TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.") source code made to be compatible with [Deno](https://deno.land "Deno is a secure runtime for JavaScript and TypeScript, it is an alternative to Node.js")

<!-- /INSTALL -->

<!-- HISTORY/ -->

## History

[Discover the release history by heading on over to the `HISTORY.md` file.](https://github.com/bevry/typechecker/blob/HEAD/HISTORY.md#files)

<!-- /HISTORY -->

<!-- BACKERS/ -->

## Backers

### Code

[Discover how to contribute via the `CONTRIBUTING.md` file.](https://github.com/bevry/typechecker/blob/HEAD/CONTRIBUTING.md#files)

#### Authors

-   [Benjamin Lupton](https://balupton.com) — Accelerating collaborative wisdom.

#### Maintainers

-   [Benjamin Lupton](https://github.com/balupton) — Accelerating collaborative wisdom.

#### Contributors

-   [Benjamin Lupton](https://github.com/balupton) — [view contributions](https://github.com/bevry/typechecker/commits?author=balupton "View the GitHub contributions of Benjamin Lupton on repository bevry/typechecker")
-   [Joe Gesualdo](https://github.com/joegesualdo) — [view contributions](https://github.com/bevry/typechecker/commits?author=joegesualdo "View the GitHub contributions of Joe Gesualdo on repository bevry/typechecker")
-   [Matt Bierner](https://github.com/mjbvz) — [view contributions](https://github.com/bevry/typechecker/commits?author=mjbvz "View the GitHub contributions of Matt Bierner on repository bevry/typechecker")
-   [Sean Fridman](https://github.com/sfrdmn) — [view contributions](https://github.com/bevry/typechecker/commits?author=sfrdmn "View the GitHub contributions of Sean Fridman on repository bevry/typechecker")

### Finances

<span class="badge-githubsponsors"><a href="https://github.com/sponsors/balupton" title="Donate to this project using GitHub Sponsors"><img src="https://img.shields.io/badge/github-donate-yellow.svg" alt="GitHub Sponsors donate button" /></a></span>
<span class="badge-thanksdev"><a href="https://thanks.dev/u/gh/bevry" title="Donate to this project using ThanksDev"><img src="https://img.shields.io/badge/thanksdev-donate-yellow.svg" alt="ThanksDev donate button" /></a></span>
<span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
<span class="badge-liberapay"><a href="https://liberapay.com/bevry" title="Donate to this project using Liberapay"><img src="https://img.shields.io/badge/liberapay-donate-yellow.svg" alt="Liberapay donate button" /></a></span>
<span class="badge-buymeacoffee"><a href="https://buymeacoffee.com/balupton" title="Donate to this project using Buy Me A Coffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg" alt="Buy Me A Coffee donate button" /></a></span>
<span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span>
<span class="badge-crypto"><a href="https://bevry.me/crypto" title="Donate to this project using Cryptocurrency"><img src="https://img.shields.io/badge/crypto-donate-yellow.svg" alt="crypto donate button" /></a></span>
<span class="badge-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span>

#### Sponsors

-   [Andrew Nesbitt](https://nesbitt.io) — Software engineer and researcher
-   [Balsa](https://balsa.com) — We're Balsa, and we're building tools for builders.
-   [Codecov](https://codecov.io/) — Empower developers with tools to improve code quality and testing.
-   [Poonacha Medappa](https://poonachamedappa.com)
-   [Rob Morris](https://github.com/Rob-Morris)
-   [Sentry](https://sentry.io) — Real-time crash reporting for your web apps, mobile apps, and games.
-   [Syntax](https://syntax.fm) — Syntax Podcast

#### Donors

-   [Andrew Nesbitt](https://nesbitt.io)
-   [Balsa](https://balsa.com)
-   [Chad](https://opencollective.com/chad8)
-   [Codecov](https://codecov.io/)
-   [entroniq](https://gitlab.com/entroniq)
-   [Jean-Luc Geering](https://github.com/jlgeering)
-   [Michael Duane Mooring](https://bevry.me)
-   [Mohammed Shah](https://github.com/smashah)
-   [Poonacha Medappa](https://poonachamedappa.com)
-   [Rob Morris](https://github.com/Rob-Morris)
-   [Sentry](https://sentry.io)
-   [ServieJS](https://github.com/serviejs)
-   [Skunk Team](https://skunk.team)
-   [Syntax](https://syntax.fm)

<!-- /BACKERS -->

<!-- LICENSE/ -->

## License

Unless stated otherwise all works are:

-   Copyright &copy; [Benjamin Lupton](https://balupton.com)

and licensed under:

-   [Artistic License 2.0](http://spdx.org/licenses/Artistic-2.0.html)

<!-- /LICENSE -->

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