# prototypeof

> 👌 Simply get the type of an object.

Latest version **1.0.0** (published 2017-05-21) · MIT license · 0 weekly downloads

## Install

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

## 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.0 |
| Published | 2017-05-21 |
| First published | 2017-05-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Etienne Prud’homme |
| Maintainers | notetienne |
| Keywords | typeof, type, prototype, class |

## Links

- npm: https://www.npmjs.com/package/prototypeof
- Repository: https://github.com/notetiene/prototypeof
- Homepage: https://github.com/notetiene/prototypeof#readme
- Issues: https://github.com/notetiene/prototypeof/issues
- npm.io page: https://npm.io/package/prototypeof

## 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.0.0 (latest) — 2017-05-21

## README

# prototypeof [![Build Status](https://travis-ci.org/notetiene/prototypeof.svg?branch=master)](https://travis-ci.org/notetiene/prototypeof)

> 👌 Simply get the type of an object.

**_prototypeof_** is a simple function to get the type of an object by
using `Object.prototype.toString` on any given object. Usually, this
is always the best way to guess the type of an object since `typeof`
may return things not expected (`Array` and `Null` are considered
`object`).

Furthermore, even when using `Object.prototype.toString`, there’s no
easy way to make custom types names. That’s why I created
`prototypeof`.

The name may look misleading (we’re not actually getting the
prototype), but is
_[etymologically](https://en.wikipedia.org/wiki/Etymology)_
correct. Which corresponds to *πρωτο- (prōto-)* (most recent ancestor)
and type.

## Getting Started


```javascript
const prototypeof = require('prototypeof');

class Type {
    constructor() {
    }
}

var type = new Type();
console.log(prototypeof(type)); // "Object"
console.log(prototypeof(Type, 'Type')); // "Type"
console.log(prototypeof(type)); // "Type"
```

## JavaScript API

### prototypeof ( object[, type])
Get the type of an object and optionally set its type. If the object
has a prototype, set the prototypal type. Finally return the type
name.

* `object`: Any objects or primitives.
* `type`: _Optional_. If truthy, set the type name.
* Return: A type name as a `String`.

## License

This module and the whole directory is subject to
the [MIT license](LICENSE.md).

I usually prefer the GPL license, but I don’t think it’s big enough
care for that (and scare people like you).

Copyright (c) 2017 Etienne Prud’homme

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