Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

type-name

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

type-name

Just a reasonable typeof

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
210K
decreased by-11.49%
Maintainers
1
Weekly downloads
 
Created

What is type-name?

The type-name npm package is used to get the name of a JavaScript value's type. It is particularly useful for debugging and logging purposes, where knowing the exact type of a value can be crucial.

What are type-name's main functionalities?

Basic Type Identification

This feature allows you to identify the basic types of JavaScript values such as numbers, strings, and booleans.

const typeName = require('type-name');
console.log(typeName(123)); // 'Number'
console.log(typeName('hello')); // 'String'
console.log(typeName(true)); // 'Boolean'

Object Type Identification

This feature helps in identifying the types of more complex objects like arrays, dates, and plain objects.

const typeName = require('type-name');
console.log(typeName({})); // 'Object'
console.log(typeName([])); // 'Array'
console.log(typeName(new Date())); // 'Date'

Custom Class Type Identification

This feature allows you to identify instances of custom classes, which can be particularly useful in larger codebases with many custom types.

const typeName = require('type-name');
class MyClass {}
console.log(typeName(new MyClass())); // 'MyClass'

Other packages similar to type-name

Keywords

FAQs

Package last updated on 27 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc