npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@lopatnov/get-internal-type

v2.2.1

Published

Determine the internal JavaScript [[Class]] of an object. A lightweight, cross-platform TypeScript library for reliable runtime type detection.

Readme

@lopatnov/get-internal-type

Determine the internal JavaScript [[Class]] of an object. A lightweight, cross-platform TypeScript library for reliable runtime type detection.

npm downloads npm version License GitHub issues GitHub stars


Table of Contents


Supported Types

Primitives

| Object Value | Result | Since | | :------------------------- | :------------ | :---- | | undefined | "undefined" | 1.0.0 | | null | "null" | 1.0.0 | | false | "boolean" | 1.0.0 | | 123 | "number" | 1.0.0 | | BigInt(9007199254740991) | "bigint" | 1.0.0 | | "hello" | "string" | 1.0.0 | | Symbol("123") | "symbol" | 1.0.0 |

Functions

| Object Value | Result | Since | | :---------------------- | :-------------------- | :---- | | function(){} | "function" | 1.0.0 | | () => {} | "function" | 1.0.0 | | class Simple {} | "function" | 1.0.0 | | async function(){} | "function" | 2.0.0 | | function* () {} | "generatorfunction" | 1.4.1 | | async function* () {} | "generatorfunction" | 2.0.0 |

Objects

| Object Value | Result | Since | | :------------------------------- | :---------- | :---- | | {} | "object" | 1.0.0 | | new (class SomeCustomClass {}) | "object" | 1.0.0 | | [1,2,3] | "array" | 1.0.0 | | /s+/gi | "regexp" | 1.0.0 | | new Date() | "date" | 1.0.0 | | new Error("A mistake") | "error" | 1.0.0 | | Promise.resolve('any') | "promise" | 1.4.0 |

Collections

| Object Value | Result | Since | | :-------------- | :------ | :---- | | new Map() | "map" | 1.2.0 | | new WeakMap() | "map" | 1.3.1 | | new Set() | "set" | 1.2.0 | | new WeakSet() | "set" | 1.3.1 |

Generators

| Object Value | Result | Since | | :-------------------------- | :------------ | :---- | | (function* () {})() | "generator" | 1.4.1 | | (async function* () {})() | "generator" | 2.0.0 |

Typed Arrays

All typed arrays return "typedarray" (since 1.3.0):

Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, BigInt64Array, BigUint64Array

Structured Data

| Object Value | Result | Since | | :------------------------- | :-------------- | :---- | | new ArrayBuffer(8) | "arraybuffer" | 1.5.0 | | new SharedArrayBuffer(8) | "arraybuffer" | 2.0.0 | | new DataView(buffer) | "dataview" | 1.5.0 |

Weak References

| Object Value | Result | Since | | :----------------------------- | :----------------------- | :---- | | new WeakRef(obj) | "weakref" | 2.0.0 | | new FinalizationRegistry(cb) | "finalizationregistry" | 2.0.0 |


Installation

npm install @lopatnov/get-internal-type

Browser:

<script src="https://lopatnov.github.io/get-internal-type/dist/get-internal-type.umd.min.js"></script>

Usage

ES Modules

import getInternalType from "@lopatnov/get-internal-type";
// or named import:
// import { getInternalType } from "@lopatnov/get-internal-type";

getInternalType(42); // "number"
getInternalType("hello"); // "string"
getInternalType([1, 2, 3]); // "array"
getInternalType(new Map()); // "map"
getInternalType(new Set()); // "set"
getInternalType(Promise.resolve()); // "promise"
getInternalType(null); // "null"
getInternalType(undefined); // "undefined"

CommonJS

const getInternalType = require("@lopatnov/get-internal-type");

getInternalType({}); // "object"
getInternalType(new Date()); // "date"
getInternalType(/regex/); // "regexp"
getInternalType(new Error()); // "error"

Browser (UMD)

<script src="https://lopatnov.github.io/get-internal-type/dist/get-internal-type.umd.min.js"></script>
<script>
  console.log(getInternalType([1, 2, 3])); // "array"
</script>

API

getInternalType(obj: any): string

Returns a lowercase string representing the internal [[Class]] of the given object.

| Parameter | Type | Description | | :-------- | :---- | :--------------------------------- | | obj | any | The value to determine the type of |

Returns: string — a lowercase type identifier.

// Primitives
getInternalType(undefined); // "undefined"
getInternalType(null); // "null"
getInternalType(false); // "boolean"
getInternalType(Symbol("123")); // "symbol"
getInternalType(123); // "number"
getInternalType(BigInt(9007199254740991)); // "bigint"
getInternalType("hello"); // "string"

// Objects
getInternalType({}); // "object"
getInternalType([1, 2, 3]); // "array"
getInternalType(/s+/gi); // "regexp"
getInternalType(new Date()); // "date"
getInternalType(new Error("oops")); // "error"

// Collections
getInternalType(new Map()); // "map"
getInternalType(new WeakMap()); // "map"
getInternalType(new Set()); // "set"
getInternalType(new WeakSet()); // "set"

// Functions & Generators
getInternalType(() => {}); // "function"
getInternalType(async () => {}); // "function"
getInternalType(function* () {}); // "generatorfunction"
getInternalType(async function* () {}); // "generatorfunction"
getInternalType((function* () {})()); // "generator"

// Structured Data
getInternalType(Promise.resolve("any")); // "promise"
getInternalType(new ArrayBuffer(16)); // "arraybuffer"
getInternalType(new DataView(new ArrayBuffer(16))); // "dataview"
getInternalType(new Int8Array(8)); // "typedarray"

// Weak References
getInternalType(new WeakRef({})); // "weakref"
getInternalType(new FinalizationRegistry(() => {})); // "finalizationregistry"

Demo


Contributing

Contributions are welcome! Please read CONTRIBUTING.md before opening a pull request.


Built With


License

Apache-2.0 © 2019–2026 Oleksandr Lopatnov · LinkedIn