# which-builtin-type

> What is the type of this builtin JS value?

Latest version **1.2.1** (published 2024-12-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install which-builtin-type
pnpm add which-builtin-type
yarn add which-builtin-type
bun add which-builtin-type
```

## Health

**Score 50/100 (C)** — status: stable.

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

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2024-12-13 |
| First published | 2020-01-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 0.4 |
| Dependencies | 13 |
| Unpacked size | 29.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Jordan Harband |
| Maintainers | ljharb |
| Keywords | type, builtin, ecmascript |

## Links

- npm: https://www.npmjs.com/package/which-builtin-type
- Repository: https://github.com/inspect-js/which-builtin-type
- Homepage: https://github.com/inspect-js/which-builtin-type#readme
- Issues: https://github.com/inspect-js/which-builtin-type/issues
- Funding: https://github.com/sponsors/ljharb
- npm.io page: https://npm.io/package/which-builtin-type

## Dependencies (13)

- [isarray](https://npm.io/package/isarray.md) ^2.0.5
- [is-regex](https://npm.io/package/is-regex.md) ^1.2.1
- [call-bound](https://npm.io/package/call-bound.md) ^1.0.2
- [is-weakref](https://npm.io/package/is-weakref.md) ^1.0.2
- [is-date-object](https://npm.io/package/is-date-object.md) ^1.1.0
- [has-tostringtag](https://npm.io/package/has-tostringtag.md) ^1.0.2
- [which-collection](https://npm.io/package/which-collection.md) ^1.0.2
- [is-async-function](https://npm.io/package/is-async-function.md) ^2.0.0
- [which-typed-array](https://npm.io/package/which-typed-array.md) ^1.1.16
- [is-generator-function](https://npm.io/package/is-generator-function.md) ^1.0.10
- [which-boxed-primitive](https://npm.io/package/which-boxed-primitive.md) ^1.1.0
- [function.prototype.name](https://npm.io/package/function.prototype.name.md) ^1.1.6
- [is-finalizationregistry](https://npm.io/package/is-finalizationregistry.md) ^1.1.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2024-12-13
- 1.2.0 — 2024-11-23
- 1.1.4 — 2024-07-29
- 1.1.3 — 2022-11-02
- 1.1.2 — 2022-04-12
- 1.1.1 — 2021-08-06
- 1.1.0 — 2021-04-18
- 1.0.1 — 2020-12-15
- 1.0.0 — 2020-01-25

## README

# which-builtin-type <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

[![npm badge][npm-badge-png]][package-url]

What is the type of this builtin JavaScript value? Works cross-realm, without `instanceof`, and can not be fooled by a `constructor` property.

## Example

```js
var whichBuiltinType = require('which-builtin-type');
var assert = require('assert');

assert.equal(undefined, whichBuiltinType(undefined));
assert.equal(null, whichBuiltinType(null));
assert.equal('Boolean', whichBuiltinType(false));
assert.equal('Boolean', whichBuiltinType(true));
assert.equal('Array', whichBuiltinType([]));
assert.equal('Object', whichBuiltinType({}));
assert.equal('RegExp', whichBuiltinType(/a/g));
assert.equal('RegExp', whichBuiltinType(new RegExp('a', 'g')));
assert.equal('Date', whichBuiltinType(new Date()));
assert.equal('Number', whichBuiltinType(42));
assert.equal('Number', whichBuiltinType(NaN));
assert.equal('Number', whichBuiltinType(Infinity));
assert.equal('Number', whichBuiltinType(new Number(42)));
assert.equal('String', whichBuiltinType('foo'));
assert.equal('String', whichBuiltinType(Object('foo')));
assert.equal('Function', whichBuiltinType(function () {}));
assert.equal('GeneratorFunction', whichBuiltinType(function* () {}));
assert.equal('Function', whichBuiltinType(x => x * x));
assert.equal('Array', whichBuiltinType([]));
assert.equal('Int8Array', whichBuiltinType(new Int8Array()));
assert.equal('Uint8Array', whichBuiltinType(new Uint8Array()));
assert.equal('Uint8ClampedArray', whichBuiltinType(new Uint8ClampedArray()));
assert.equal('Int16Array', whichBuiltinType(new Int16Array()));
assert.equal('Uint16Array', whichBuiltinType(new Uint16Array()));
assert.equal('Int32Array', whichBuiltinType(new Int32Array()));
assert.equal('Uint32Array', whichBuiltinType(new Uint32Array()));
assert.equal('Float32Array', whichBuiltinType(new Float32Array()));
assert.equal('Float64Array', whichBuiltinType(new Float64Array()));
assert.equal('BigInt64Array', whichBuiltinType(new BigInt64Array()));
assert.equal('BigUint64Array', whichBuiltinType(new BigUint64Array()));
```

## Tests
Simply clone the repo, `npm install`, and run `npm test`

[package-url]: https://npmjs.org/package/which-builtin-type
[npm-version-svg]: https://versionbadg.es/inspect-js/which-builtin-type.svg
[deps-svg]: https://david-dm.org/inspect-js/which-builtin-type.svg
[deps-url]: https://david-dm.org/inspect-js/which-builtin-type
[dev-deps-svg]: https://david-dm.org/inspect-js/which-builtin-type/dev-status.svg
[dev-deps-url]: https://david-dm.org/inspect-js/which-builtin-type#info=devDependencies
[npm-badge-png]: https://which-builtin-type/which-builtin-type.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/which-builtin-type.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/which-builtin-type.svg
[downloads-url]: https://npm-stat.com/charts.html?package=which-builtin-type
[codecov-image]: https://codecov.io/gh/inspect-js/which-builtin-type/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/inspect-js/which-builtin-type/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/inspect-js/which-builtin-type
[actions-url]: https://github.com/inspect-js/which-builtin-type/actions

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