New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

get-dtype-of

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-dtype-of

Returns the datatype of the arg.

latest
Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

get-dtype-of

NPM version NPM downloads Known Vulnerabilities

Description

This package returns the type of input. By default, the returned data type can be a string | number | boolean | array | object | null | undefined | function. Setting refineObject to true returns the refined type of object (e.g., Date, Map, Set, Buffer, EventEmitter).

Installation

  npm i get-dtype-of

Usage

getTypeOf(input, refineObject)

  • input | any
  • refineObject | boolean | default: false

Examples


  const getTypeOf = require('get-dtype-of');

Without OptionReturnsWith Option (refineObject: true)Returns
getTypeOf("Hello")stringgetTypeOf("Hello", true)string
getTypeOf(412)numbergetTypeOf(412, true)number
getTypeOf(true)booleangetTypeOf(true, true)boolean
getTypeOf(undefined)undefinedgetTypeOf(undefined, true)undefined
getTypeOf(["a", "b"])arraygetTypeOf(["a", "b"], true)array
getTypeOf(null)nullgetTypeOf(null, true)null
getTypeOf(stream)functiongetTypeOf(stream, true)function
getTypeOf({ name: "John" })objectgetTypeOf({ name: "John" }, true)object
getTypeOf(/[a-z]/)objectgetTypeOf(/[a-z]/, true)RegExp
getTypeOf(new Date())objectgetTypeOf(new Date(), true)Date
getTypeOf(new Set())objectgetTypeOf(new Set(), true)Set

Keywords

typeof

FAQs

Package last updated on 08 Jan 2023

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