New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lopatnov/get-internal-type

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lopatnov/get-internal-type

Determine the internal JavaScript [[Class]] of an object.

  • 1.5.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-55.56%
Maintainers
1
Weekly downloads
 
Created
Source

get-internal-type Twitter

npm NPM version License GitHub issues GitHub forks GitHub stars Build Status

Patreon sobe.ru LinkedIn

Determine the JavaScript [[Class]] of an object, where:

Object Value[[Class]]Version
undefinedundefined1.0.0
nullnull1.0.0
falseboolean1.0.0
Symbol("123")symbol1.0.0
123number1.0.0
BigInt(9007199254740991)bigint1.0.0
"hello"string1.0.0
/s+/giregexp1.0.0
new Date()date1.0.0
new Error("A mistake")error1.0.0
{}object1.0.0
new (class SomeCustomClass {})object1.0.0
() => {}function1.0.0
function(){}function1.0.0
class Simple {}function1.0.0
[1,2,3]array1.0.0
new Set()set1.2.0
new WeakSet()set1.3.1
new Map()map1.2.0
new WeakMap()map1.3.1
new Int8Array(8)typedarray1.3.0
new Uint8Array()typedarray1.3.0
new Uint8ClampedArray()typedarray1.3.0
new Int16Array()typedarray1.3.0
new Uint16Array()typedarray1.3.0
new Int32Array()typedarray1.3.0
new Uint32Array()typedarray1.3.0
new Float32Array()typedarray1.3.0
new Float64Array()typedarray1.3.0
new BigInt64Array()typedarray1.3.0
new BigUint64Array()typedarray1.3.0
Promise.resolve('any')promise1.4.0
function* () {}generatorfunction1.4.1
(function* () {})()generator1.4.1
new ArrayBuffer(8)arraybuffer1.5.0
new DataView(buffer)dataview1.5.0

Install

https://nodei.co/npm/@lopatnov/get-internal-type.png?downloads=true&downloadRank=true&stars=true

npm install @lopatnov/get-internal-type

Browser

<script src="//lopatnov.github.io/get-internal-type/dist/polyfills/array.forEach.min.js"></script>
<script src="//lopatnov.github.io/get-internal-type/dist/get-internal-type.min.js"></script>

Browser support: Cross-browser

Import package to the project

TypeScript

import getInternalType from 'get-internal-type';

JavaScript

var getInternalType = require("get-internal-type");

Gets object type

getInternalType(obj: any) => string

console.log(getInternalType(undefined)) // expected "undefined"
console.log(getInternalType(null)) // expected "null"
console.log(getInternalType(false)) // expected "boolean"
console.log(getInternalType(Symbol("123"))) // expected "symbol"
console.log(getInternalType(123)) // expected "number"
console.log(getInternalType(BigInt(9007199254740991))) // expected "bigint"
console.log(getInternalType("hello")) // expected "string"
console.log(getInternalType(/s+/gi)) // expected "regexp"
console.log(getInternalType(new Date())) // expected "date"
console.log(getInternalType(new Error("A mistake"))) // expected "error"
console.log(getInternalType({})) // expected "object"
console.log(getInternalType(new (class SomeCustomClass {}))) // expected "object"
console.log(getInternalType(() => {})) // expected "function"
console.log(getInternalType(function(){})) // expected "function"
console.log(getInternalType(class Simple {})) // expected "function"
console.log(getInternalType([1,2,3])) // expected "array"

console.log(getInternalType(new Set())) // expected "set"
console.log(getInternalType(new WeakSet())) // expected "set"
console.log(getInternalType(new Map())) // expected "map"
console.log(getInternalType(new WeakMap())) // expected "map"

console.log(getInternalType(new Int8Array(8))) // expected "typedarray"
console.log(getInternalType(new Uint8Array())) // expected "typedarray"
console.log(getInternalType(new Uint8ClampedArray())) // expected "typedarray"
console.log(getInternalType(new Int16Array())) // expected "typedarray"
console.log(getInternalType(new Uint16Array())) // expected "typedarray"
console.log(getInternalType(new Int32Array())) // expected "typedarray"
console.log(getInternalType(new Uint32Array())) // expected "typedarray"
console.log(getInternalType(new Float32Array())) // expected "typedarray"
console.log(getInternalType(new Float64Array())) // expected "typedarray"
console.log(getInternalType(new BigInt64Array())) // expected "typedarray"
console.log(getInternalType(new BigUint64Array())) // expected "typedarray"

console.log(getInternalType(Promise.resolve('any'))) // expected "promise"
console.log(getInternalType(function* () {})) // expected "generatorfunction" (ES6)
console.log(getInternalType((function* () {})())) // expected "generator"

console.log(getInternalType(new ArrayBuffer(16))) // expected "arraybuffer"
console.log(getInternalType(new DataView(new ArrayBuffer(16)))) // expected "dataview"

Demo

See, how it's working: https://runkit.com/lopatnov/get-internal-type-demo

Test it with a runkit: https://npm.runkit.com/%40lopatnov%2Fget-internal-type

Rights and Agreements

License Apache-2.0

Copyright 2019-2021 Oleksandr Lopatnov

Keywords

FAQs

Package last updated on 04 Jul 2021

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